akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>

struct xyz {
	long long a;
	long long b;
};

int main() {
	int n, m;
	std::cin >> n >> m;
	
	std::vector<xyz> v(n);
	for(int i = 0; i < n; i++) {
		std::cin >> v[i].a >> v[i].b;
	}
	
	std::sort(v.begin(), v.end(), [](const xyz &x, const xyz &y){return x.a < y.a;});
	
	long long ans = 0;
	int cnt = 0;
	for(int i = 0; i < n; i++) {
		if(v[i].b + cnt >= m) {
			ans += v[i].a * (m - cnt);
			break;
		}
		else {
			cnt += v[i].b;
			ans += v[i].a * v[i].b;
		}
	}
	
	std::cout << ans << std::endl;
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;
const double EPS = 1e-8;
const double INF = 1e18;

bool epseq(const double &a, const double &b){
    return abs(a-b) < EPS;
}

vector<double> solve_quadeq(double a, double b, double c){
    vector<double> ret;
    if(abs(a) < EPS){
        if(abs(b) > EPS) ret.push_back(-c/b);
        return ret;
    }
    double d = b*b -4*a*c;
    if(abs(d) < EPS) d = 0;
    if(d < 0) return ret;
    if(d < 0) d = 0;
    ret.push_back((-b +sqrt(d))/(2*a));
    ret.push_back((-b -sqrt(d))/(2*a));
    return ret;
}

int main(){
    int w,h,n;
    cin >> w >> h >> n;
    vector<double> a(n), b(n), c(n);
    for(int i=0; i<n; i++){
        double aa,p,q;
        cin >> aa >> p >> q;
        a[i] = aa;
        b[i] = -2*aa*p;
        c[i] = aa*p*p +q;
    }

    vector<double> cpx;
    cpx.push_back(0);
    cpx.push_back(w);
    for(int i=0; i<n; i++){
        for(int j=i+1; j<n; j++){
            vector<double> ret = solve_quadeq(a[i]-a[j], b[i]-b[j], c[i]-c[j]);
            cpx.insert(cpx.end(), ret.begin(), ret.end());
        }
        vector<double> ret = solve_quadeq(a[i], b[i], c[i]);
        cpx.insert(cpx.end(), ret.begin(), ret.end());
        ret = solve_quadeq(a[i], b[i], c[i] -h);
        cpx.insert(cpx.end(), ret.begin(), ret.end());
    }
    for(int i=cpx.size()-1; i>=0; i--){
        if(cpx[i] < 0 || w < cpx[i]){
            cpx.erase(cpx.begin() +i);
        }
    }
    sort(cpx.begin(), cpx.end());
    cpx.erase(unique(cpx.begin(), cpx.end(), epseq), cpx.end());

    double ans = 0;
    for(int i=0; i<(int)cpx.size()-1; i++){
        int hidx = -1;
        double hval = -INF;
        double x = (cpx[i] +cpx[i+1])/2.0;
        for(int j=0; j<n; j++){
            double val = a[j]*x*x +b[j]*x +c[j];
            if(val > hval){
                hval = val;
                hidx = j;
            }
        }
        if(hval < 0 || h < hval) continue;

        double interval = cpx[i+1] -cpx[i];
        int sepnum = 1;
        while(interval > sepnum*1e-6){
            sepnum *= 2;
        }
        double h = interval /sepnum;
        vector<double> f(sepnum+1);
        for(int j=0; j<=sepnum; j++){
            double dydx = 2*a[hidx]*(cpx[i] +j*h) +b[hidx];
            f[j] = sqrt(1 +dydx*dydx);
        }
        double sum = f[0] +f[sepnum];
        for(int j=1; j<sepnum; j+=2){
            sum += 4*f[j];
        }
        for(int j=2; j<sepnum; j+=2){
            sum += 2*f[j];
        }
        sum *= h/3;
        ans += sum;
    }
    cout << fixed << setprecision(10);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 68224
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define rrep(i,a) for(int i=(int)a-1;i>=0;--i)
#define REP(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RREP(i,a,b) for(int i=(int)a-1;i>=b;--i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n) / gcd(n, m)*abs(m);//gl=xy
}
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
using namespace std;

void solve(){
  vector<bool>v(5000);
  int n;
  cin>>n;
  vector<int>a(n);
  rep(i,n)cin>>a[i];
  rep(bit,(1<<n)){
    int sum=0;
    rep(i,n){
      if(bit&(1<<i))sum+=a[i];
    }
    v[sum]=true;
  }
  int q;
  cin>>q;
  while(q--){
    int m;
    cin>>m;
    if(v[m])cout<<"yes\n";
    else cout<<"no\n";
  }
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
  solve();
	return 0;
}



Measured memory_bytes: 3144
import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")

def no():
    print("No")
    exit()

def main():
    def ok(dir):
        goal = abs(xy[dir])
        over=total[dir]-goal
        if over<0 or over%2:
            return False
        if over==0:
            return True
        over//=2
        dp = [False] * (over + 1)
        dp[0] = True
        for d in dd[dir]:
            for i in range(d, over + 1):
                dp[i] |= dp[i - d]
            if dp[-1]: return True
        return False

    s = input()[:-1]
    xy = list(map(int, input().split()))

    dd = [[], []]
    total=[0,0]
    dir = 0
    cnt = 0
    first = True
    for c in s:
        if c == "F":
            cnt += 1
        if c == "T":
            if first:
                xy[0] -= cnt
                first = False
            else:
                if cnt: dd[dir].append(cnt)
                total[dir]+=cnt
            dir = 1 - dir
            cnt = 0
    if first:
        xy[0] -= cnt
    else:
        if cnt: dd[dir].append(cnt)
        total[dir] += cnt
    #print(xy, dd)

    for dir in range(2):
        if not ok(dir): no()
    print("Yes")

main()


Measured memory_bytes: 3188
var n:longint;
    dist:array[0..100050]of longint;
    q:array[0..5000050]of longint;
    v:array[0..100050]of boolean;
procedure spfa;
var  head,tail:longint;
     i,now,y:longint;
begin
  head:=1;
  tail:=0;
  for i:=1 to n-1 do
  dist[i]:=i;
  dist[0]:=n;
  for i:=0 to n-1 do
  begin
    inc(tail);
    q[tail]:=i;
    v[i]:=true;
  end;
  while head<=tail do
  begin
    now:=q[head];
    for i:=0 to 9 do
    begin
      y:=(now*10+i) mod n;
      if dist[y]>dist[now]+i then
      begin
        dist[y]:=dist[now]+i;
        if not v[y] then
        begin
          v[y]:=true;
          inc(tail);
          q[tail]:=y;
        end;
      end;
    end;
    inc(head);
    v[now]:=false;
  end;
end;
begin
  read(n);
  spfa;
  writeln(dist[0]);
end.

Measured memory_bytes: 6144
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N,M;
  cin>>N>>M;
  vector<vector<int>> vec(N,vector<int>(M,0));
  vector<int> count(N);
  for(int i=0;i<N;i++){
  	for(int j=0;j<M;j++){
    cin >> vec.at(i).at(j);
      //cout<<vec.at(i).at(j);
      for(int k=0;k<N;k++){
      	if(vec.at(i).at(j)==k+1){
      	  
          count.at(k)+=1;
        }
      }
    }
  }
  for(int i=0;i<N;i++){
    cout<<count.at(i)<<endl;
  }

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <unordered_map>

using namespace std;

#define FOR(i, a, n) for(ll i = ((ll) a); i < ((ll) n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define DMP(x) cerr << #x << " = " << (x) << endl;
#define DBG(x) cerr << #x << " = " << (x) << " (L" << __ LINE__ << ") " << " " << __FILE__ << endl;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

inline bool is_in(const ll y, const pll p) {
    return p.first <= y && y <= p.second;
}

int main() {
    while(true) {
        int n, q;
        cin >> n >> q;
        if(n == 0 && q == 0) break;
        unordered_map<string, pll> hs;
        REP(i, n) {
            string en;
            ll ey, wy;
            cin >> en >> ey >> wy;
            hs[en] = make_pair(wy - ey + 1, wy);
        }
        REP(i, q) {
            ll qy;
            cin >> qy;
            bool find_flg = false;
            for(auto v : hs) {
                if(is_in(qy, v.second)) {
                    cout << v.first << " " << qy - v.second.first + 1 << endl;
                    find_flg = true;
                    break;
                }
            }
            if(!find_flg) cout << "Unknown" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3116
#include<bits/stdc++.h>

using namespace std;

int main()
{
        int x,a,b;
        cin>>x>>a>>b;

        if(a>=b)
                cout<<"delicious"<<endl;
        else
        {
                if(b-a>x)
                        cout<<"dangerous"<<endl;
                else
                        cout<<"safe"<<endl;
        }
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <stack>
//#define LOCAL
using namespace std;
typedef long long ll;
const int mx=1e3+10;
stack<ll>sta[mx];

int main() {
#ifdef LOCAL
ifstream fin("1.txt");
streambuf*p;
p=cin.rdbuf(fin.rdbuf());
#endif // LOCAL

ll n, q;
cin>>n>>q;
for(ll i=1;i<=q;i++){
    ll q, sub, value;
    cin>>q;
    switch(q){
        case 0: cin>>sub>>value;
                sta[sub].push(value);
                break;
        case 1: cin>>sub;
                if(sta[sub].size()>0) cout<<sta[sub].top()<<endl;;
                break;
        case 2: cin>>sub;
                if(sta[sub].size()>0)sta[sub].pop();
                break;
    }

}

#ifdef LOCAL
fin.close();
#endif // LOCAL
}




Measured memory_bytes: 5252
#include<iostream>
using namespace std;

int main(){
    int h,w;
    
    while(1){
        cin >> h >> w;
        
        if (h == 0 && w == 0) { break; }
        
        for (int i = 0; i < h; i++){
            for (int j = 0; j < w; j++){
                if (i == 0 || i == (h - 1) || j == 0 || j == (w - 1)){
                    cout << "#";
                } else {
                    cout << ".";
                }
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1152
function main(input){
	const args=input.split(" ");
	const a=parseInt(args[0],10);
	const b=parseInt(args[1],10);
	
	if((a*b)%2===0){
		console.log('Even');
	}else{
		console.log('Odd');
	}
		
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29664
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;
int num[105];

int main()
{
    int n,x,mx=0,ans=0;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> x;
        if(x>=mx){
            mx=x;
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
// -*- mode:c++; coding:utf-8; indent-tabs-mode:nil; -*-
// ALDS1_2-D

#include <algorithm>
#include <iostream>

static void print_ints(const int as[], const unsigned int n,
                       const char* sep = " ") {
  const char* out_sep = "";
  for (unsigned int i = 0; i < n; ++i) {
    std::cout << out_sep << as[i];
    out_sep = sep;
  }
  std::cout << std::endl;
}

static void print_int(const unsigned int n) {
  std::cout << n << std::endl;
}

static unsigned int cnt = 0;

inline
static void insert(int as[], const unsigned int i, const unsigned int d) {
  const int asi = as[i];
  unsigned int j = i;
  while (j >= d && asi < as[j-d]) {
    as[j] = as[j-d];
    j -= d;
    ++cnt;
  }
  as[j] = asi;
}

void insertion_sort(int as[], const unsigned int n, const unsigned int d) {
  for (unsigned int i = d; i < n; ++i) {
    insert(as, i, d);
  }
}

inline
unsigned int next_g(const unsigned int g) { return 3*g + 1; }

unsigned int gen_m(const unsigned int n) {
  if (n < 2) {
    return 1;
  }
  unsigned int m = 1;
  for (unsigned int g = 1; g < n; g = next_g(g)) {
    ++m;
  }
  return m-1; // over 1 time
}

void shell_sort(int as[], const unsigned int n) {
  cnt = 0;

  unsigned int m = gen_m(n);
  int gs[m];
  for (unsigned int g = 1, i = 0; i < m; ++i) {
    gs[m-1-i] = g;
    g = next_g(g);
  }
  print_int(m);
  print_ints(gs, m);

  for(unsigned int i = 0; i < m; ++i) {
    insertion_sort(as, n, gs[i]);
  }
  
  print_int(cnt);
}

int main(void) {
  unsigned int n;
  std::cin >> n;
  int as[n];
  for (unsigned int i = 0; i < n; ++i) {
    std::cin >> as[i];
  }

  shell_sort(as, n);
  print_ints(as, n, "\n");

  return 0;
}
// end

Measured memory_bytes: 5076
#include<bits/stdc++.h>
using namespace std;

//#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define LL long long
#define F first
#define S second
#define MP make_pair
#define PB push_back

LL n;

vector< pair<int,int> > factorize(LL n)
{
        vector< pair<int,int> > res;
        if(n == 1)
        {
                res.PB(MP(1,1));
                return res;
        }
        for(LL i = 2; i * i <= n; i++)
        {
                if(n % i == 0)
                {
                        int cnt = 0;
                        while(n % i == 0)
                        {
                                n /= i;
                                cnt++;
                        }
                        res.PB(MP(i,cnt));
                }
        }
        if (n != 1)
        {
                res.PB(MP(n,1));
        }
        return res;
}

int main() {
	cin >> n;
	if(n == 1) {
		cout << 0 << endl;
		return 0;
	}

	int ans = 0;
	vector<pair<int,int> > temp = factorize(n);
	for(int i=0;i<temp.size();i++) {
		int p = temp[i].S;
		int st = 1;
		while(p - st >= 0) {
			ans++;
			p = p - st;
			st++;
		}
	}


	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3628
package main
 
import (
	"fmt"
	"math"
)
 
func main() {
	var n int
	var t, a float64
	fmt.Scan(&n, &t, &a)
	hs := make([]float64, n)
	for i, _ := range hs {
		fmt.Scan(&hs[i])
	}
 
	min := float64(10000)
	ans := 0
	for i, h := range hs {
		diff := math.Abs(a - (t - h*0.006))
		if min > diff {
			min = diff
			ans = i
		}
	}
	fmt.Println(ans + 1)
}

Measured memory_bytes: 512
using System;
class Program{
	static int[,] table = new int[10,10];
	static void Main(){
		String s;
		while((s = Console.ReadLine()) != null){
			int[] a = Array.ConvertAll(s.Split(','), int.Parse);
			switch(a[2]) {
			case 1:
				inkS(a[0], a[1]);
				break;
			case 2:
				inkM(a[0], a[1]);
				break;
			case 3:
				inkL(a[0], a[1]);
				break;
			}
		}
		int max = 0;
		int zeros = 0;
		foreach(int n in table) {
			if(n == 0)
				zeros++;
			if(n > max)
				max = n;
		}
		Console.WriteLine(zeros);
		Console.WriteLine(max);
	}
	
	static void ink(int x, int y) {
		if(0 <= x && x < 10 && 0 <= y && y < 10)
			table[x,y]++;
	}
	
	static void inkS(int x, int y) {
		ink(x,y);
		ink(x+1,y);
		ink(x-1,y);
		ink(x,y+1);
		ink(x,y-1);
	}
	
	static void inkM(int x, int y) {
		inkS(x,y);
		ink(x+1,y+1);
		ink(x+1,y-1);
		ink(x-1,y+1);
		ink(x-1,y-1);
	}
	
	static void inkL(int x, int y) {
		inkM(x,y);
		ink(x+2,y);
		ink(x-2,y);
		ink(x,y+2);
		ink(x,y-2);
	}
}

Measured memory_bytes: 9040
//2736 問四 渡辺彩子
import java.util.Scanner;

public class Main{
	
	public void solve(){
		Scanner sc=new Scanner(System.in);
		int ijyo,i,n,k;
		ijyo=1;
		i=0;
		
		n=sc.nextInt();
		while(n!=0){
			for(int h=0;h<n;h++){
				k=sc.nextInt();
				
				if(k>=2){
					ijyo++;
				}else{
				}
				if(k==1){
					i++;
				}
			}
			
			if(ijyo>=2){
				System.out.println(ijyo+i);
			}else{
				System.out.println("NA");
			}
			
			ijyo=1;
			i=0;
			n=sc.nextInt();
		}
	}
	
	public static void main(String[]args){
	      Main obj=new Main();
		  obj.solve();
	}
}

Measured memory_bytes: 158556
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<string, string>

using namespace std;

int N;
string s;
map<P, long> mp;

int main() {
  cin >> N;
  cin >> s;

  for (int i=0; i<(1<<N); i++) {
    string red, blue;
    for (int b=0; b<N; b++) {
      if ((i>>b)&1) {
        red.push_back(s.at(b));
      } else {
        blue.push_back(s.at(b));
      }
    }
    mp[P(red, blue)]++;
  }

  reverse(s.begin(), s.end());

  long ans = 0;
  for (int i=0; i<(1<<N); i++) {
    string red, blue;
    for (int b = 0; b < N; b++) {
      if ((i >> b) & 1) {
        red.push_back(s.at(b));
      } else {
        blue.push_back(s.at(b));
      }
    }
    ans += mp[P(red, blue)];
  }
  cout << ans << endl;
}


Measured memory_bytes: 91904
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i <= (ll)(n); ++i)
#define MAX 500010
#define MOD 1000000007
typedef long long  ll;

using namespace std;

ll ans;


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	ll N;
	cin >> N;

	vector<ll> A(N);
	map<ll,vector<ll>> R,L;
	rep(i,N){
		cin >> A[i];
		R[- A[i] + i + 1].push_back(i);
		L[A[i] + i + 1].push_back(i);
	}

	for(auto pl: L){
		if(R.count(pl.first)){
			ans += pl.second.size() * R[pl.first].size();
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 45272
import math

def a():
    x = int(input())
    
    if x < 600:
        print(8)
    elif x<800:
        print(7)
    elif x<1000:
        print(6)
    elif x<1200:
        print(5)
    elif x<1400:
        print(4)
    elif x<1600:
        print(3)
    elif x<1800:
        print(2)
    else:
        print(1)

def b():
    pass



def c():
    pass



def d():
    pass


a()
# b()
# c()
# d()

Measured memory_bytes: 9176
import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque
from decimal import *


def lcm(x, y):
    return (x * y) // math.gcd(x, y)


if __name__ == '__main__':
    b, c = map(int, input().split())

    a = [int(i) for i in input().split()]
    t = sum(a)
    a.sort(reverse=True)
    count = 0
    for i in range(c):
        if a[i] / t >= 1 / (4 * c):
            count += 1
    if count == c:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 5784
#include <iostream>
#include <algorithm>
using namespace std;

int n;
int t[10];

int main(){
  while(cin >> n, n){
    int idx = 0;
    int ba = 0;

    fill(t, t + n, 0);

    for(int i = 0; i < 100; i++){
      char ch;
      cin >> ch;

      t[idx]++;

      if(ch == 'S'){
        ba += t[idx];
        t[idx] = 0;
      }
      else if(ch == 'L'){
        t[idx] += ba;
        ba = 0;
      }

      idx = (idx + 1) % n;
    }

    sort(t, t + n);

    for(int i = 0; i < n; i++){
      cout << t[i] << " ";
    }
    cout << ba << endl;
  }
}

Measured memory_bytes: 1184
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

using namespace std;

int main() {
  char b;
  cin >> b;
  char ret;
  if (b == 'A') ret = 'T';
  else if (b == 'T') ret = 'A';
  else if (b == 'C') ret = 'G';
  else ret = 'C';
  cout << ret << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>

using namespace std;
#define sqr(x) ((x)*(x))
#define cube(x) ((x)*(x)*(x))
#define GCD(a, b) __gcd(a, b)
#define LCM(a, b) ((a)*(b)/GCD(a,b))
#define MP make_pair
#define n1 first
#define n2 second
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define SI set<int>
#define SL set<ll>
#define MS multiset
#define MSI multiset<int>
#define MSLL multiset<ll>
#define PB push_back
#define PF push_front
#define VI vector<int>
#define VPI vector<pair<int,int>>
#define VLL vector<ll>
#define VS vector<string>
#define SZ(x) ((int)x.size())

typedef long long ll;

typedef unsigned long long ull;
typedef long double ld;
typedef double db;
const int INF = 1e9;
const ld PI = 3.1415926535;
const int MOD = 1000000007;
const int N = 250555;
const int M = 1155;

void solve() {
    int n;
    string s;
    cin >> n >> s;

    int cnt = 0;
    for (int i = 0; i < n-2; i++){
        if (s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C') cnt++;
    }

    cout << cnt;

}

int main() {
    ios_base::sync_with_stdio(false);
#ifdef dxz05
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else

#endif

    int T = 1;
    // cin >> T;

    while (T--) {
        solve();
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template<class T> inline bool chmax(T& a, T b) {if (a<b) {a=b; return true;} return false;}
template<class T> inline bool chmin(T& a, T b) {if (a>b) {a=b; return true;} return false;}

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    vll x(n); REP(i, n) cin >> x[i];
    stack<ll> st;
    ll ans = 1;
    REP(i, n) {
        if (x[i] < 2*(st.size()+1)-1) {
            ans = ans * (st.size()+1) % MOD;
        } else st.push(x[i]);
    }
    for (ll i=st.size(); i>=2; i--) ans = ans * i % MOD;
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 1920
n = int(input())
if n == 2:
    print(-1)
    exit()
if n % 2 == 1:
    for i in range(n):
        print(" ".join([str((item + i + 1) % n + 1) for item in range(n-1)]))
else:
    for i in range(n):
        ans = [(item + i + 1) % n + 1 for item in range(n-1) if item != n // 2 - 1]
        ans.insert(0, (n // 2 + i) % n + 1)
        if i < n // 2:
            ans[0], ans[1] = ans[1], ans[0]
        print(" ".join([str(item) for item in ans]))

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
using namespace std;
const int maxn=1e6+10;
int a[maxn];
int pri[maxn],vis[maxn];
int gcd(int a, int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
bool work(){
    int f1=1;
    for(int i=0; i<maxn; i++)pri[i]=1;
    pri[1]=pri[0]=0;
    for(int i=2; i<maxn; i++){
        if(pri[i]){
            int f2=0;
            if(vis[i])f2=1;
            for(int j=i*2; j<maxn; j+=i){
                pri[j]=0;
                if(f2&&vis[j])f1=0;
                if(vis[j])f2=1;//cout<<i<<' '<<j<<endl;}
               // break;
               if(!f1)return false;
            }
        }
    }
    return true;
}
int main()
{
    //cout<<gcd(3,4)<<endl;
    //cout<<gcd(8,4)<<endl;
    //cout<<gcd(6,10)<<endl;
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    int mx=0,maxx=0;
    for(int i=1; i<=n; i++){
        cin>>a[i];vis[a[i]]++;
        if(a[i]!=1)mx=max(vis[a[i]],mx);
        maxx=max(maxx,a[i]);
    }
    /*
    if(maxx==1){
        cout<<"pairwise coprime"<<endl;
        return 0;
    }
    */
    if(mx<=1){
        if(work()){
            cout<<"pairwise coprime"<<endl;
            return 0;
        }
    }
    int ans=a[1];
    for(int i=1; i<=n; i++)ans=gcd(ans,a[i]);
    if(ans==1)cout<<"setwise coprime"<<endl;
    else cout<<"not coprime"<<endl;
    return 0;
}


Measured memory_bytes: 14584
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

vector<vector<P>> G;
vl height;
bool ok = true;

void dfs(ll v, ll h) {
    // 行きの処理はこのへんに書く
    if(height[v] == -INF) {
        height[v] = h;
    }
    else {
        if(height[v] != h) {
            ok = false;
        }
        return;
    }
    for(auto p : G[v]) { 
        ll u = p.first;
        ll cost = p.second;
        dfs(u, h + cost);
        // 帰りの処理はこのへんに書く
    }
}

int main() {
    ll n, m;
    cin >> n >> m;    
    
    G.resize(n);
    rep(i, m) {
        ll a, b, c;
        cin >> a >> b >> c;
        a--;  b--;
        G[a].pb(make_pair(b, c));
        G[b].pb(make_pair(a, -c));
    }

    height.assign(n, -INF);
    rep(v, n) {
        if(height[v] == -INF) {
            dfs(v, 0);
        }
    }

    if(ok) {
        out("Yes");
    }
    else {
        out("No");
    }

    re0;
}

Measured memory_bytes: 15488
using System;

namespace ConsoleApplication11
{
    class Program
    {
        static void Main(string[] args)
        {
            string [] s = Console.ReadLine().Split(' ');
            int m = int.Parse(s[0]);
            int n = int.Parse(s[1]);
            Console.WriteLine(m*n+" "+(m+n)*2);
        }
    }
}

Measured memory_bytes: 9200
#include <bits/stdc++.h>
#define range(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, b) for (int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x) cerr << #x << " = " << (x) << endl;
#define int long long
using namespace std;

template <typename X, typename T>
auto vectors(X x, T a) {
	return vector<T>(x, a);
}

template <typename X, typename Y, typename Z, typename... Zs>
auto vectors(X x, Y y, Z z, Zs... zs) {
	auto cont = vectors(y, z, zs...);
	return vector<decltype(cont)>(x, cont);
}

template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
	rep(i, v.size()) { os << v[i] << (i == v.size() - 1 ? "" : " "); }
	return os;
}
template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
	for (T& x : v) { is >> x; }
	return is;
}

signed main() {
	int a, b;
	cin >> a >> b;
	if (a < 10 and b < 10)
		cout << a * b << endl;
	else
		cout << -1 << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

typedef char                SINT8;
typedef unsigned char       UINT8;
typedef short               SINT16;
typedef unsigned short      UINT16;
typedef int                 SINT32;
typedef unsigned int        UINT32;
typedef long long           SINT64;
typedef unsigned long long  UINT64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))


SINT32 main() {
    SINT32 ans = 0;
    SINT32 max = 5;
    SINT32 buf = 10;
    
    SINT32 *data = malloc(sizeof(SINT32)*max);
    for (SINT32 i = 0; i < max; i++) {
        scanf("%d", &data[i]);
        if ((data[i] % 10) == 0) {

        } else {
            if (buf > (data[i] % 10)) {
                buf = (data[i] % 10);
            }
            data[i] = ((data[i] / 10) + 1) * 10;
        }
        ans = data[i] +ans;

    }
    if (buf == 10) {

    } else {
        ans = ans - 10 + buf;
    }

    

    printf("%d\n",ans);
    free(data);
	return 0;
}

Measured memory_bytes: 128
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

#define FOR(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)

using namespace std;

int main() {
	int x, p;
	cin >> x >> p;
	if (p == 100) {
		int tim = (x+1) / 2;
		cout << tim << endl;
		return 0;
	}

	double pp = p / 100.0;
	// 奇数
	if (x % 2) {
		printf("%.14f\n", (double)(1 - pp) / pp + 1 + (double)(x/2) / pp);
	}
	else
		printf("%.14f\n", (double)(x/2) / pp);

	return 0;
}

Measured memory_bytes: 256
def slove():
    import sys
    import collections
    input = sys.stdin.readline
    n, qq = list(map(int, input().rstrip('\n').split()))

    ls = collections.defaultdict(list)
    ls[1]
    for i in range(n-1):
        a, b = list(map(int, input().rstrip('\n').split()))
        ls[a] += [b]
        ls[b] += [a]

    ans = [0 for _ in range(n)]
    for i in range(qq):
        p, x = list(map(int, input().rstrip('\n').split()))
        ans[p-1] += x

    q = collections.deque()
    q.append(1)
    fq = collections.defaultdict(list)
    while True:
        if len(q) != 0:
            p = q.popleft()
            fq[p]
            for i in ls[p]:
                if i not in fq:
                    q.append(i)
                    ans[i-1] += ans[p-1]
        else:
            break
    print(*ans)


if __name__ == '__main__':
    slove()


Measured memory_bytes: 107440
#include <iostream>
#include <cmath>
#include <string>
using namespace std;

int gcd(int a, int b){
    int g = max(a,b);
    int l = min(a,b);
    if(g % l == 0){
        return l;
    }else{
        return gcd(l, g % l); 
    }
}


int main(){
    int N,X;
    int x[100000];
    int y[100000];
    int M;
    cin >> N >> X;
    for(int i=0;i<N;i++){
        cin >> x[i];
        y[i] = abs(x[i] - X);
        //m = min(m, y[i]);
    }
    M = y[0];
    for(int i=1;i<N;i++){
        M = gcd(M,y[i]);
    }   

    cout << M << endl;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>

int main(void)
{
	char str[32];
	int i;
	
	fgets(str, sizeof(str), stdin);
	
	for (i = strlen(str) - 2; i >= 0; i--)
		printf("%c", str[i]);
	printf("\n");
	
	return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007,MOD2=998244353,INF=1e18;



int main() {
    int N;
    cin>>N;
    vector<ll> A(N);
    ll now=0;
    rep(i,N){
        cin>>A.at(i);
        now=now^A.at(i);
    }
    if(now==0){cout<<0<<endl;return 0;}
    now=now^A.at(0);
    now=now^A.at(1);
    ll p=A.at(0)+A.at(1)-now;
    if(p%2){cout<<-1<<endl;return 0;}
    p/=2;
    //cout<<p<<" "<<now<<endl;
    if(p>=A.at(0) || p&now){cout<<-1<<endl;return 0;}
    for(int i=42;i>=0;i--){
        if(1ll<<i & now){
            if((p + (1ll<<i)) <A.at(0)){
                p+= (1ll<<i);
            }
        }
    }
    if(p==0){cout<<-1<<endl;return 0;}
    cout<<A.at(0)-p<<endl;
}

Measured memory_bytes: 3588
def main():
    K, N = map(int, input().split())
    A = list(map(int, input().split()))
    ans = K - A[-1] + A[0]
    for i in range(N-1):
        d = A[i + 1] - A[i]
        ans = max(ans, d)
    print(K - ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 26444
/**
*    author:  Dooloper
*    created: 06.06.2020 00:59:13
**/

#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>
#include <cmath>
#include <functional>
#include <cassert>


using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main() {
    cin.tie(0);
    ll N;
    cin >> N;
    vector<int> Eratosthenes((int)sqrt(N)+10,0);
    vector<int> factor;
    vector<ll> prime;

    /*エラトステネス*/
    for (ll i = 2; i * i < N; i++)
    {
        if(!Eratosthenes[i]){
            for (ll j = 2; i*i * j*j <= N;j++)
                Eratosthenes[i * j] = 1;
        }
    }

    for (ll i = 2; i * i < N; i++){
        prime.emplace_back(i);
    }

    for(ll i: prime){
        int keep = 0;
        while (N % i == 0)
        {
            keep++;
            N /= i;
        }
        factor.emplace_back(keep);
    }
    if(N > 1)
        factor.emplace_back(1);

    //     for (int i = 2; i * i < N; i++)
    // {
    //     int keep = 0;
    //     while (N % i == 0)
    //     {
    //         keep++;
    //         N /= i;
    //     }
    //     factor.push_back(keep);
    // }
    // if(N > 1)
    //     factor.push_back(1);

    int ans = 0;
    for (int i : factor)
    {
        for (int j = 1; j <= i; j++){
            ans++;
            i -= j;
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 22796
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <math.h>
using namespace std;

int main(void) {

	// TODO: submit前にprintf-debugの削除確認！
	int H, W;
	cin >> H >> W;

	string S[H];
	int ansMap[H][W];
	for(int i=0; i<H; i++) {
		string s;
		cin >> s;
		S[i] = s;
	}

	int horizon[H][W];
	for(int i=0; i<H; i++) {
		int side = 0;
		for(int j=0; j<W; j++) {
			if(S[i][j] == '#') {
				side = 0;
				horizon[i][j] = 0;
				continue;
			}

			if(side == 0) {
				int tmp = j+1;
				while(tmp < W) {
					if(S[i][tmp] == '#') break;

					side++;
					tmp++;
				}
			}
			horizon[i][j] = side;
		}		
	}

	int ans = 0;
	for(int j=0; j<W; j++) {
		int vertical = 0;
		for(int i=0; i<H; i++) {
			if(S[i][j] == '#') {
				vertical = 0;
				continue;
			}

			if(vertical == 0) {

				int tmp = i+1;
				while(tmp < H) {
					if(S[tmp][j] == '#') break;

					vertical++;
					tmp++;
				}
			}
			ans = max(ans, horizon[i][j]+vertical+1);
		}
	}

	cout << ans;

	return 0;
}

Measured memory_bytes: 19968
import Data.List
import Data.Maybe
import Data.Ord
import qualified Data.ByteString.Char8 as B

main :: IO ()
main = readParams >>= mapM_ print . solve . tail

readParams :: IO [Int]
readParams = map b2int . B.words <$> B.getContents
  where b2int = fst . fromJust . B.readInt

solve :: [Int] -> [Int]
solve as = map f as
  where f a     = if a == x then y else x
        (x:y:_) = sortOn Down as


Measured memory_bytes: 45308
#include<iostream>
#include<algorithm>
#include<vector>
#include<unordered_set>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define N 100010
ll a[N],n,t;
int main(){
    cin>>n>>t;
    for(int i=0;i<n;i++)cin>>a[i];
    ll mi=1e9,ma=0;
    for(int i=0;i<n;i++){
      ma=max(ma,a[i]-mi);
      mi=min(mi,a[i]);
    }
    unordered_set<ll> s;
    ll ans=0;
    for(int i=0;i<n;i++){
      if(s.find(a[i])!=s.end()){
	ans++;
	s.erase(a[i]);
      }
      s.insert(a[i]+ma);
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 5156
//  ROAD TO GREEN
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <stack>
#include <iomanip>
#include <queue>
#include <set>
#include <bitset>

#define ll long long
#define uint unsigned int
#define ull unsigned ll
#define mp make_pair
#define pb push_back
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define speedhack() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);


using namespace std;
const ll MAXN = 2e9+2;
const ll SIZE = 1e5+2;
const ll mod = 1e9+7;

int main(){ 
	speedhack()
	int n; cin >> n;
	cout << 3 * n * n << endl;
	return 0;
}


Measured memory_bytes: 256
//#pragma GCC target ("avx2")
//#pragma GCC optimize ("Ofast")
//#pragma GCC optimize ("unroll-loops")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define int long long

using namespace std;
using namespace __gnu_pbds;

template <class T> using ordered_set =
tree<T, null_type, less<T>,
rb_tree_tag, tree_order_statistics_node_update>;

const int N = (int)(1e6 + 5);
const int M = (int)(1e9 + 7);
const int INF = (int)(1e18 + 9);
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};

int a[N];

signed main() {
  ios_base :: sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; ++i)
    cin >> a[i];
  int sum = 0;
  sort(a + 1, a + 1 + n);
  set <int> s;
  map <int, int> mp;
  for (int i = 1; i <= m; ++i) {
    int b, c;
    cin >> b >> c;
    mp[c] += b;
    s.insert(c);
  }
  for (int i = 1; i <= n; ++i) {
    if (!s.size()) {
      sum += a[i];
      continue;
    }
    auto it = s.end();
    it--;
    if (*it > a[i]) {
      sum += *it;
      mp[*it]--;
      if (!mp[*it])
        s.erase(it);
    }
    else
      sum += a[i];
  }
  cout << sum;
  return 0;
}


Measured memory_bytes: 12032
use std::io;
use std::cmp::Ordering;

fn main() {
    let (input1, input2, input3) = input_3_number();

    match input1.cmp(&input2) {
        Ordering::Greater    => println!("No"),
        Ordering::Equal   => println!("No"),
        Ordering::Less => {
            match input2.cmp(&input3) {
                Ordering::Greater    => println!("No"),
                Ordering::Equal   => println!("No"),
                Ordering::Less => {
                    println!("Yes");
                    return;
                }        
            }
        },
    }
}

#[allow(dead_code)]
fn input_3_number() -> (i32, i32, i32) {
    let mut input = String::new();

    io::stdin().read_line(&mut input)
        .expect("Failed to read line");

    let vec: Vec<&str> = input.split_whitespace().collect();

    let input1: i32 = vec[0].parse().unwrap_or(0);
    let input2: i32 = vec[1].parse().unwrap_or(0);
    let input3: i32 = vec[2].parse().unwrap_or(0);

    (input1, input2, input3)
}

#[allow(dead_code)]
fn input() -> i32 {
    let mut input = String::new();

    io::stdin().read_line(&mut input)
        .expect("Failed to read line");
    let input: i32 = input.trim().parse()
        .expect("Failed to parse");

    input
}



Measured memory_bytes: 5028
import math
n1 = int(input())
n =  n1 * 100
x1 = (n // 108)
x2 = -(-n // 108)
if x1*108//100 == n1:
    print(x1)
    exit(0)
if x2*108//100 == n1:
    print(x2)
    exit(0)
print(":(")

Measured memory_bytes: 3060
#include <bitset>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <stdio.h>
#include <math.h>

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

typedef vector<vector<int>> vvi;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<ll> vll;

typedef pair<int, int> pii;

typedef queue<int> qi;
typedef queue<string> qs;


#define rep(i, n) for(int i=0; i<(n); ++i)
#define repp(i, a, b) for(int i = (a); i <= (b); i++)
#define repm(i, a, b) for(int i = (a); i >= (b); i--)

#define all(v) v.begin(), v.end()
//sort( all(v) )　などと使える

int main(){
    int n, k; cin >> n >> k;
    vector<vector<int>> a(k);
    int cnt = 0;

    rep(i, k){
        int d_i; cin >> d_i;
        a[i].resize(d_i);
        rep(j, d_i){
            cin >> a[i][j];
            a[i][j]--;
        }
    }

    rep(j, n){
        bool flag = false;
        
        rep(i, k){
            rep(l, a[i].size()) if(a[i][l] == j) flag = true;
        }

        if(!flag) cnt++;
    }


    cout << cnt << endl;
}

Measured memory_bytes: 3676
#include<bits/stdc++.h>
using namespace std;

#define ll long long int

ll lcm(ll org_a, ll org_b)  {
    ll a = org_a;
    ll b = org_b;
    if (a < b) {
        swap(a, b);
    }
    ll r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }

    return (org_a * org_b / b);
}

int main() {

    ll A, B, C, D;
    cin >> A >> B >> C >> D;

    ll c;
    c = B / C - (A - 1) / C;
    ll d;
    d = B / D - (A - 1) / D;
    ll c_d;
    c_d = B / (lcm(C, D)) - (A - 1) / (lcm(C, D));

    cout << B - (A - 1) - (c + d) + c_d << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;

int main(){
  string s;
  cin >> s;
  int A = s[0]-'0';
  int B = s[1]-'0';
  int C = s[2]-'0';
  int D = s[3]-'0';
  s += "000=7";
  s[6]=s[3];
  s[5]='+';
  s[4]=s[2];
  s[3]='+';
  s[2]=s[1];
  s[1]='+';
  bool flag = false;
  for(int i=0; i<8; i++){
    switch(i){
      case 0: if(A+B+C+D==7) flag=true; break;
      case 1: if(A+B+C-D==7) {flag=true; s[5]='-';} break;
      case 2: if(A+B-C+D==7) {flag=true; s[3]='-';} break;
      case 3: if(A+B-C-D==7) {flag=true; s[3]=s[5]='-';} break;
      case 4: if(A-B+C+D==7) {flag=true; s[1]='-';} break;
      case 5: if(A-B+C-D==7) {flag=true; s[1]=s[5]='-';} break;
      case 6: if(A-B-C+D==7) {flag=true; s[1]=s[3]='-';} break;
      case 7: if(A-B-C-D==7) {flag=true; s[1]=s[3]=s[5]='-';} break;
      default: break;
    }
    if(flag) break;
  }
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		// for (; solver.hasNext();) {
		// solver.readBody(in.readLine());
		// }
		// solver.solve();
	}
}

class Solver {
	int N;
	int cnt;

	public void init() {
		N = 0;
		cnt = 0;
	}

	public void readHead(String str) {
		// String[] strArr = str.split("\\s+");
		// N = Integer.parseInt(strArr[0]);
		// System.out.println(N);
		int ans = 0;
		for (int i = 0; i < str.length() / 2; i++) {
			if (str.charAt(i) != str.charAt(str.length() - i - 1))
				ans++;
		}
		System.out.println(ans);
	}

	public boolean hasNext() {
		return cnt < N;
	}

	public void readBody(String str) {
		// System.out.println(str);
		cnt++;
	}

	public void solve() {

	}
}


Measured memory_bytes: 22484
#include <iostream>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>

#define PI 3.14159265359
using namespace std;


int main(){
	int tmp;
	vector<int> d(6);
	for (int i = 0; i < 6; i++) cin >> d[i];
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i++){
		if (s[i] == 'W'){
			tmp = d[3];
			d[3] = d[0];
			d[0] = d[2];
			d[2] = d[5];
			d[5] = tmp;
		}
		else if (s[i] == 'E'){
			tmp = d[5];
			d[5] = d[2];
			d[2] = d[0];
			d[0] = d[3];
			d[3] = tmp;
		}
		else  if (s[i] == 'N'){
			tmp = d[0];
			d[0] = d[1];
			d[1] = d[5];
			d[5] = d[4];
			d[4] = tmp;
		}
		else {
			tmp = d[4];
			d[4] = d[5];
			d[5] = d[1];
			d[1] = d[0];
			d[0] = tmp;
		}
	}
	cout << d[0] << endl;
}

Measured memory_bytes: 3164
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

#define EPS (1e-7)
#define INF (1e15)
#define PI (acos(-1))
#define MOD 1000000007

#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,f,n) for(int i=(f);i<(n);i++)
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define arrdump(n,a) for(int i=0;i<n;i++) {cout<<((i>0)? " ":"")<<a[i];}cout<<"\n";


typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// https://atcoder.jp/contests/abc079/tasks/abc079_c

string A;
string OP;

static bool dfs(int sum, string op) {
    if (op.length() == 3) {
        OP = op;
        return sum == 7;
    }

    if (dfs(sum + (A[op.length()+1] - '0'), op+"+")) return true;
    if (dfs(sum - (A[op.length()+1] - '0'), op+"-")) return true;

    return false;
}

int main() {
    cin >> A;

    if (dfs(A[0] - '0', "")) {
        printf("%c%c%c%c%c%c%c=7\n", A[0], OP[0], A[1], OP[1], A[2], OP[2], A[3]);
    }

    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter

val br = BufferedReader(InputStreamReader(System.`in`))
val pw = PrintWriter(System.out)
fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    // 回答をここに書く
    val s = next()
    val r = s.firstOrNull { s.contains("$it$it$it") }?.let{
        "Yes"
    } ?: "No"
    println(r)
}

// 入力取得
fun next() = br.readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun listOfString() = next().split(" ")
fun listOfInt() =listOfString().map { it.toInt() }
fun listOfLong() =listOfString().map { it.toLong() }
fun listOfDouble() =listOfString().map { it.toDouble() }

// 約数のList
fun divisor(value : Long) : List<Long> {
    val max = Math.sqrt(value.toDouble()).toLong()
    return (1..max)
            .filter { value % it == 0L }
            .map { listOf(it, value / it) }
            .flatten()
            .sorted()
}

// 範囲内の素数を取得
// fromだけ指定すると戻り値の個数で素数判定ができる
fun prime(from : Long, to : Long = from) : List<Long> {
    return (from..to).filter { i ->
        val max = Math.sqrt(i.toDouble()).toLong()
        (2..max).all { j ->  i % j != 0L }
    }
}

// 素因数分解
fun decom(value : Long) : List<Long>{
    if (value == 1L) return listOf(1)
    val max = Math.sqrt(value.toDouble()).toLong()
    return prime(2, max).filter { value % it == 0L }
}

// 最大公約数
fun gcd(a : Long, b : Long) : Long {
    return if (a % b == 0L) b else gcd(b, a % b)
}

// 文字列を入れ替え
fun swap(base : String, a : String, b : String) : String {
    return base.map {
        when (it) {
            a.toCharArray()[0] -> b
            b.toCharArray()[0] -> a
            else -> it.toString()
        }
    }.joinToString()
}

fun println(value : Any) {
    pw.println(value)
}

Measured memory_bytes: 31404
#include <bits/stdc++.h>
using namespace std;
string s;
bool solve(int l,int r)
{
	bool f=true;
	int len=r-l+1;
	for(int i=0;i<len;i++)
	{
		if(s[l+i]!=s[r-i])
		{
			f=false;break;
		}
	}
	return f;
}

int main()
{
	cin>>s;
	int n=s.length();
	if(solve(0,n-1) && solve(0,n/2-1) && solve(n/2+1,n-1)) cout<<"Yes";
	else cout<<"No";
	return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>
#include <cmath>
#include <set>   

using namespace std;


int main() {
	
	int n, m;
	string x, y;
	string s[150] = {};
	string t[150] = {};
	int max = 0;

	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}

	cin >> m;
	for (int j = 0; j < m; j++) {
		cin >> t[j];
	}

	sort(begin(s), end(s), greater<string>());

	

	for (int i = 0; i < n; i++)
	{
		int count = 0;


		for (int j = 0; j < n; j++)
		{
			if (s[i] == s[j]) {
				count++;
			}
		}

		for (int j = 0; j < m; j++)
		{
			if (s[i] == t[j]) {
				count--;
			}
		}

		if (max < count) {
			max = count;
		}

		if (count > 0) {
			i += count - 1;
		}
	}


	cout << max << endl;

}

Measured memory_bytes: 256
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    _LI = lambda : [int(x)-1 for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()

    x = NI()
    if x >= 30:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()

Measured memory_bytes: 68852