akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(int (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define debugP int debug_point; cin>>debug_point;
const ll MOD= 1e9 + 7;
template <typename T>
void putv(vector<T>& V){
	// cout << "The elements in the vector are: " << endl;
	for(auto x: V)
		cout << x << " ";
	cout << endl;
}
ll pown(ll fi,ll se){
  ll ans=1;
  rep(i,se){
    ans*=fi;
  }
  return ans;
}
template <class T>
vector<T> getv(ll n){
	vector<T> Vector_temp;
	rep(i,n){
		T input;
		cin >> input;
		Vector_temp.emplace_back(input);
	}
	return Vector_temp;
}
ll gcd(ll c,ll b){
    while(1){
        if(c%b!=0){
        ll tmp=b;
        b=c%b;
        c=tmp;
        }else{
            return b;
        }
    }
}
/* <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3*/
vec(d,10);
ll up(ll num){
  for (ll i = num; i < 10; i++) {
    if(d[i]==0){
      return i;
    }
  }
  return -1;
  
}

int main(){
  ll a,b,c,d;
  cin>>a>>b>>c>>d;
  if(abs(a-c)<=d){
    op("Yes");
  }else if(abs(a-b)<=d&&abs(b-c)<=d){
    op("Yes");
  }else op("No");
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n - 1); 0 <= i; --i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

namespace My
{
template <typename ArrayT>
static void DumpArray(const ArrayT &arr)
{
#if defined(HOME)
	for (auto it = std::begin(arr); it != std::end(arr); ++it) {
		cerr << *it << " ";
	}
	cerr << endl;
#endif
}
template<typename T>
static void DumpGrid(const vector<vector<T>> &grid){
#if defined(HOME)
	REP (i, grid.size()) {
		REP (j, grid[i].size()) {
			cerr << grid[i][j] << " ";
		}
		cerr << endl;
	}
#endif
}
template <class ArrayT, typename T>
static void InitArray(ArrayT &arr, T initValue){
	for (auto &v : arr){
		v = initValue;
	}
}
template <typename T>
static bool ReplaceIfSmaller(T &target, T value)
{
	if (value < target) {
		target = value;
		return true;
	} else {
		return false;
	}
}
template <typename T>
static bool ReplaceIfBigger(T &target, T value)
{
	if (target < value) {
		target = value;
		return true;
	} else {
		return false;
	}
}

class Solver
{
  public:
	Solver() {}
	void Solve(istream &cin, ostream &cout)
	{
		string S;
		cin >> S;

		// 特別扱いで0回チェックだけやっておく
		char firstC = S[0];
		if (all_of(S.begin(), S.end(), [&](auto c) { return c == firstC; })){
			cout << 0 << endl;
			return;
		}

		// a-z を全部試す
		int minIter = INT_MAX;
		REP (i, 26) {
			char c = 'a' + i;
			string s = S;

			// 0,1 -> 0
			// 1,2 -> 1
			// 2,3 -> 2
			for (int len = s.size()-1; 0 < len; len--) {
				bool foundOther = false;
				REP (j, len) {
					// j番目を決める
					if (s[j] == c || s[j+1] == c){
						s[j] = c;
					}else{
						// 文字はそのままで
						foundOther = true;
					}
				}
				if (!foundOther){
					ReplaceIfSmaller(minIter, (int)(s.size() - len));
					break;
				}
			}
		}

		cout << minIter << endl;
	}
};
} // namespace My

#if !defined(BOOST_TEST_MODULE)
#if !defined(GTEST_INCLUDE_GTEST_GTEST_H_)
int main()
{
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);

	My::Solver solver;
	solver.Solve(std::cin, std::cout);

	return 0;
}
#endif
#endif


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,int>
const int MOD=1e9+7;
const int INF=2e9;
const double PI=acos(-1);


int main() {
    ios_base::sync_with_stdio(false); 

    int h,w,m;
    cin >> h >> w >> m;
    map<P,int> mp;
    vector<P> icnt(h),jcnt(w);
    rep(k,m) {
        int i,j;
        cin >> i >> j;
        --i;
        --j;
        ++icnt[i].first;
        ++jcnt[j].first;
        ++mp[{i,j}];
    }
    rep(i,h) icnt[i].second=i;
    rep(j,w) jcnt[j].second=j;

    sort(icnt.begin(),icnt.end(),greater<>());
    sort(jcnt.begin(),jcnt.end(),greater<>());
    int im=icnt[0].first;
    int jm=jcnt[0].first;
    int ans=im+jm;
    vector<int> ii,jj;
    rep(i,h) {
        if (icnt[i].first==im) ii.push_back(icnt[i].second);
    } 
    rep(j,w) {
        if (jcnt[j].first==jm) jj.push_back(jcnt[j].second);
    }  
    ll ni=ii.size(),nj=jj.size();
    ll sum=ni*nj;
    if (sum<=m) {
        bool flag=0;
        rep(i,ni) {
            rep(j,nj) {
                if (mp.find({ii[i],jj[j]})==mp.end()) flag=1;
            }
        }
        if (!flag) --ans;
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 30848
import java.util.*;
import java.io.*;

public class Main {
	private static void solve(){
	//Implement solution here.
		int n = ni();
		int[] ary = na(n);
		Arrays.sort(ary);
		int result = ary[0];
		
		for(int i = 1; i <= n - 1; i++){
			result = euclidDiv(result, ary[i]);
		}
		System.out.println(result);
	}
	
	static int euclidDiv(int a,int b){
        if(b == 0) return a;
        int mod = a%b;
        return euclidDiv(b,mod);
    }

    //Switch input source (stdin/file)
	private static Scanner scanner = new Scanner(System.in);
	public static void main(String[] args){
        String debugDataPath = System.getenv("DD_PATH");        
        if(debugDataPath != null){
            try{
                scanner = new Scanner(new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath)))));
            }catch(Exception e){
                throw new RuntimeException(e);
            }
        }
        solve();
	}

    //Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(scanner.nextLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
    //Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
    //Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
    //Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
    //Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
    //Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}

Measured memory_bytes: 46356
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define Fast_IO ios::sync_with_stdio(false);
#define fir first
#define sec second
#define mod 1000000007
#define ll long long
#define int long long
inline int read()
{
	char ch=getchar(); int nega=1; while(!isdigit(ch)) {if(ch=='-') nega=-1; ch=getchar();}
	int ans=0; while(isdigit(ch)) {ans=ans*10+ch-48;ch=getchar();}
	if(nega==-1) return -ans;
	return ans;
}
typedef pair<int,int> pii;
int add(int x,int y){return x+y>=mod?x+y-mod:x+y;}
int sub(int x,int y){return x-y<0?x-y+mod:x-y;}
int mul(int x,int y){return 1LL*x*y%mod;}
int qpow(int x,int y)
{
	int ans=1;
	while(y)
	{
		if(y&1) ans=ans*x%mod;
		x=x*x%mod;
		y>>=1;
	}
	return ans;
}
int inv(int x)
{
	return qpow(x,mod-2);
}
int C(int x,int y)
{
	int ans=1;
	for(int i=0;i<y;i++) ans=ans*(x-i)%mod;
	int sub=1;
	for(int i=1;i<=y;i++) sub=sub*i%mod;
//	cout<<ans<<" "<<sub<<endl;
//	printf("%d %d %d\n",x,y,ans*inv(sub)%mod);
	return ans*inv(sub)%mod;
}
signed main()
{
#ifdef __LOCAL__
	freopen("in.txt","r",stdin);
#endif
	int n,a,b;
	cin>>n>>a>>b;
	int tot=qpow(2,n)-1;
	tot=(tot-C(n,a)-C(n,b))%mod;
	tot=(tot+mod)%mod;
	cout<<tot<<endl;
#ifdef __LOCAL__
	cout<<"Time Used : "<<clock()<<endl;
#endif
	return 0;
}



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

using namespace std;
typedef long long ll;

int main(){
    int r;
    cin >> r;
    if(r < 1200){
        cout << "ABC" << endl;
    }else if(1200 <= r && r < 2800){
        cout << "ARC" << endl; 
    }else{
        cout << "AGC" << endl;
    }
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int count = 0;
        int ans = 0;
        for(int i = 1;i<=n;i++){
            for(int j = 1;j<=i;j+=2){
                if(i%j == 0){
                    count++;
                }
                if(count == 8){
                    ans++;
                }
                if(count == 9){
                    ans--;
                    break;
                }
            }
            count = 0;
        }
        System.out.println(ans);
    }
}

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

using namespace std;

int c[52][52];

void er(int i,int j){
    c[i][j]--;
    if(c[i+1][j-1])
        er(i+1,j-1);
    if(c[i][j+1])
        er(i,j+1);
    if(c[i+1][j])
        er(i+1,j);
    if(c[i+1][j+1])
        er(i+1,j+1);
    if(c[i-1][j+1])
        er(i-1,j+1);
    if(c[i-1][j])
        er(i-1,j);
    if(c[i-1][j-1])
        er(i-1,j-1);
    if(c[i][j-1])
        er(i,j-1);
}

int main(void){
    int w,h;
    int i,j;
    int a;
    while(true){
        cin >> w >> h;
        if(w == 0){
            break;
        }
        for(i = 0;i < 52;i++){
            for(j = 0;j < 52;j++){
                c[i][j] = 0;
            }
        }
        for(i = 1;i <= h;i++){
            for(j = 1;j <= w;j++){
                cin >> c[i][j];
            }
        }
        a = 0;
        for(i = 1;i <= h;i++){
            for(j = 1;j <= w;j++){
                if(c[i][j]){
                    er(i,j);
                    a++;
                }
            }
        }
        cout << a << endl;
    }
}

Measured memory_bytes: 1424
#include <cstdio>
#include <cmath>
using namespace std;

double dist(double dx, double dy){
	return sqrt(pow(dx, 2) + pow(dy, 2));
}

int main(){
	int N;
	double xa, ya, ra, xb, yb, rb;
	int res;
	double p_d;
	
	scanf("%d", &N);
	
	for(int i = 0; i < N; i++){
		scanf("%lf%lf%lf%lf%lf%lf", &xa, &ya, &ra, &xb, &yb, &rb);
		
		p_d = dist(xa - xb, ya - yb);
		
		if(ra + rb < p_d) res = 0;
		else if(p_d + ra < rb) res = -2;
		else if(p_d + rb < ra) res = 2;
		else res = 1;
		
		printf("%d\n", res);
	}
	
	return 0;
}

Measured memory_bytes: 1068
//Love and Freedom.
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<iostream>
#define ll long long
#define inf 20021225
#define N 128
using namespace std;
int read()
{
	int s=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-') f=-1; ch=getchar();}
	while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+ch-'0',ch=getchar();
	return f*s;
}
char s[N+10],qr[N+10],ch[N]; int n,cnt[N],tot,pre[N];
bool check(int len){qr[len]=0; cout<<'?'<<' '<<qr<<endl; int ans; cin>>ans; return ans==n-len;}
void solve(int cl,int cr,int l,int r)
{ 
	if(cl==cr)	return;
	int mid=cl+cr>>1;
	solve(cl,mid,cl?pre[cl-1]:0,pre[mid]-1), solve(mid+1,cr,pre[mid],pre[cr]-1);
	int pl=cl?pre[cl-1]:0,pr=pre[mid]; int tot=0;
	while(pl<=pre[mid]-1 && pr<=r)
	{
		int cur=tot; qr[cur++]=s[pl];
		for(int j=pr;j<=r;j++)	qr[cur++]=s[j];
		if(check(cur))	qr[tot++]=s[pl++];
		else	qr[tot++]=s[pr++];
	}
	while(pl<=pre[mid]-1)	qr[tot++]=s[pl++];
	while(pr<=r)	qr[tot++]=s[pr++];
	for(int i=0;i<tot;i++)	s[l+i]=qr[i];
}
int main()
{
	int w=0;
	for(char c='0';c<='9';c++)
	{
		for(int j=0;j<N;j++)	qr[j]=c; ch[w]=c;
		cout << '?' << ' ' << qr << endl; cin >> cnt[w];
		pre[w]=cnt[w]=N-cnt[w];
		for(int j=0;j<cnt[w];j++)	s[tot++]=c;
		w++;
	}
	for(char c='A';c<='Z';c++)
	{
		for(int j=0;j<N;j++)	qr[j]=c; ch[w]=c;
		cout << '?' << ' ' << qr << endl; cin >> cnt[w];
		pre[w]=cnt[w]=N-cnt[w];
		for(int j=0;j<cnt[w];j++)	s[tot++]=c;
		w++;
	}
	for(char c='a';c<='z';c++)
	{
		for(int j=0;j<N;j++)	qr[j]=c; ch[w]=c;
		cout << '?' << ' ' << qr << endl; cin >> cnt[w];
		pre[w]=cnt[w]=N-cnt[w];
		for(int j=0;j<cnt[w];j++)	s[tot++]=c;
		w++;
	}
	for(int i=1;i<w;i++)	pre[i]+=pre[i-1];
	n=tot;
	solve(0,w-1,0,n-1);
	cout<<'!'<<' '<<s<<endl;
	return 0;
}


Measured memory_bytes: 3768
#include<bits/stdc++.h>
using namespace std;
int main(){
    int h1, h2, m1, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int m = 60 * (h2 - h1) + (m2 - m1);
    cout << m - k << endl;
    return 0;
}

Measured memory_bytes: 3580
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const long long INF = (long long)1e18+1;
#define DIV 1000000007
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    long idx=0;
    long N;
    cin >> N;
    vector<long> L(N);
    for(size_t i=0;i<N; i++)
    {
        cin >> L[i];
    }
    sort(L.rbegin(), L.rend());
    long count = 0;
    for(size_t i=0;i<L.size(); i++)
    {
        for(size_t j=i+1;j<L.size(); j++)
        {
            for(size_t k=j+1;k<L.size(); k++)
            {
                if(L[i] < L[j] + L[k] && L[j] < L[i] + L[k] && L[k] < L[i] + L[j]) count++;
            }
        }
    }
    cout << count << endl;
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
char c[1000][1000]={};
int main()
{
    int a,b;
    cin>>a>>b;
    for (int i=0; i<a; i++)
    {
        for (int k=0; k<b; k++)
        {
            cin>>c[i][k];
        }
    }
    for (int i=0; i<a; i++)
    {
        for (int k=0; k<b; k++)
        {
            cout<<c[i][k];
        }
        cout<<endl;
        for (int k=0; k<b; k++)
        {
            cout<<c[i][k];
        }
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 384
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Point[] points = new Point[n];
		for (int i = 0; i < n; i++) {
			points[i] = new Point();
			points[i].a = sc.nextInt();
		}
		for (int i = 0; i < n; i++) {
			points[i].b = sc.nextInt();
		}
		Arrays.sort(points, new Comparator<Point>() {
		public int compare(Point p1, Point p2) {
			return p1.getSa() - p2.getSa();
		}
		});
		
		int aIdx = 0;
		int bIdx = n - 1;
		int cnt = 0;
		int sa = 0;
		while (true) {
			int tmp = points[aIdx].getSa();
			if (tmp >= 0) {
				System.out.println(cnt);
				return;
			}
			sa += tmp;
			cnt++;
			aIdx++;
			if (cnt > n) {
				System.out.println(-1);
				return;
			}
			while (sa < 0) {
				sa += points[bIdx].getSa();
				bIdx--;
				cnt++;
				if (cnt > n) {
					System.out.println(-1);
					return;
				}
			}
		}
	}
	
	static class Point {
		int a;
		int b;
		
		public int getSa() {
			return a - b;
		}
	}
}


Measured memory_bytes: 94220
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<deque>
#include<chrono>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
const ll E=1e17+7;
#define F first
#define S second
#define MK make_pair


vector<int> a(110000);


int main(){
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        int b;
        cin>>b;
        a[b]++;
        if(b!=0){a[b-1]++;}
        a[b+1]++;
    }
    int mx=1;
    for(int i=0;i<n+1;i++){
        mx=max(mx,a[i]);
    }
    cout<<mx<<endl;
    
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<algorithm>
using namespace std;


int main(){
    int n,debt=100000;
    scanf("%d",&n);
    for (int i=0;i<n;i++) {
        debt=debt+(debt/20);
        if (debt%1000>0) debt=debt/1000*1000+1000;
    }
    printf("%d\n",debt);
    return 0;
}

Measured memory_bytes: 3216
c=[0,2,5,5,4,5,6,3,7,6];N=gets.split[0].to_i;A=gets.split.map &:to_i;d=[0]+A.map{};0.upto(N){|i|q=A.map{|x|c[x]<=i&&d[t=i-c[x]]?d[t]*10+x:p}.compact;q.any?&&d[i]=q.max};p d[N]

Measured memory_bytes: 36220
main :: IO ()                                                                                                                                         
main = do                                                                                                                                             
  [h1,w1] <- map read . words <$> getLine                                                                                                             
  [h2,w2] <- map read . words <$> getLine                                                                                                             
  print $ (h1-h2) * (w1-w2)

Measured memory_bytes: 508
n = int(input())
l = list(map(int, input().split()))

if len(l) < 3:
    print(0)
    exit()

cnt = 0

for i in range(len(l)):
    j = i + 1
    for j in range(len(l)):
        k = j + 1
        for k in range(len(l)):
            a = l[i]
            b = l[j]
            c = l[k]
            if (a < b < c) and (((a + b) > c) and ((b + c) > a) and ((c + a) > b)):
                cnt += 1

print(cnt)


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

int main() {
    int r,g,b;
    cin >> r >> g >> b;

    if((g*10+b)%4 == 0){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		//sort(all(vi S)) sort(all(string S))

typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int INF = 1e9;

int main() {
	string S;
	cin>>S;
	int N = S.size();
	int cnt0 = 0;
	rep(i,N){
		if(S[i] ==  '0')cnt0++;
		else cnt0--;
	}
	int ans = N-abs(cnt0);
	cout<<ans<<endl;
}

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

#define FastRead        ios_base::sync_with_stdio(0);cin.tie(NULL);
#define endl            "\n"
#define NUM             100005
typedef long long ll;

int main()
{
    FastRead

    ll a,b,c;

    cin>>a>>b>>c;

    if((a==b and a!=c) or (a==c and a!=b) or (b==c and a!=b))
        cout<<"Yes";
    else
        cout<<"No";
}


Measured memory_bytes: 256
use proconio::input;

fn main() {
    input! {
        n: usize,
        m: usize,
        k: u32,
        a: [u32; n],
        b: [u32; m],
    }

    let mut s: u32 = 0;

    let mut a_itr = a.iter().enumerate();
    let mut i = a_itr.next();
    while i != None && *i.unwrap().1 + s <= k {
        s += *i.unwrap().1;
        i = a_itr.next();
    }
    let a_1 = match i {
        Some(x) => &a[..x.0],
        None => &a[..],
    };

    let mut b_itr = b.iter().enumerate();
    let mut j = b_itr.next();
    while j != None && *j.unwrap().1 + s <= k {
        s += *j.unwrap().1;
        j = b_itr.next();
    }
    let b_1 = match j {
        Some(x) => &b[x.0..],
        None => &b[..0],
    };    
    // println!("{:?}", a_1);
    // println!("{:?}", b_1);

    let mut n: usize = a_1.len() + b.len() - b_1.len();
    let mut ans: usize = n;

    let mut a_1_itr = a_1.iter().rev();
    let mut b_1_itr = b_1.iter();
    // println!("{:?}", a_1_itr);
    // println!("{:?}", b_1_itr);
    let mut i_1 = a_1_itr.next();
    let mut j_1 = b_1_itr.next();

    while i_1 != None && j_1 != None {
        s -= *i_1.unwrap();
        n -= 1;
        i_1 = a_1_itr.next();
        while j_1 != None && *j_1.unwrap() + s <= k {
            s += *j_1.unwrap();
            n += 1;
            j_1 = b_1_itr.next();
        }
        if n > ans {
            ans = n;
        }
    }

    // while i < n && a[i] + s <= k {
    //     s += a[i];
    //     i += 1;
    // }
    // while j < m && b[j] + s <= k {
    //     s += b[j];
    //     j += 1;
    // }

    // let mut n: usize = i + j;
    // let mut ans: usize = n;
    // while i > 0 && j < m {
    //     i -= 1;
    //     n -= 1;
    //     s -= a[i];
    //     while j < m && b[j] + s <= k {
    //         s += b[j];
    //         j += 1;
    //         n += 1;
    //     }
    //     if n > ans {
    //         ans = n;
    //     }
    // }
    println!("{}", ans);
}


Measured memory_bytes: 7684
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  
  if(n == 0){
    cout << 2 << endl;
    return 0;
  } else if(n == 1){
    cout << 1 << endl;
    return 0;
  }

  int64_t l0 = 2;
  int64_t l1 = 1;
  int64_t next = 0;
  for(int i=0; i<n-1; i++){
    next = l1 + l0;
    l0 = l1;
    l1 = next;
    //cout << next << endl;
  }
  cout << next << endl;
  return 0; 
}

Measured memory_bytes: 3628
let ( *@ ) a b = (a * b) mod 1000000007
let fact = let rec f v n = if n <= 0 then v else f (n *@ v) (n-1) in f 1
let n, m = Scanf.scanf "%d %d" (fun x y -> x, y)
let () =
  let mul = 2 - abs (n - m) |> max 0 in
  fact n *@ fact m *@ mul |> Printf.printf "%d\n"

Measured memory_bytes: 4480
using System;

class Problem
{
  public static void Main()
  {
    var prices = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
    int A = prices[0], B = prices[1], C = prices[2];
    var min = Math.Min(A + B, Math.Min(A + C, B + C));
    Console.WriteLine($"{min}");
  }
}


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

int main(void){
	int n;
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		int an;
		double bmi=1000000;
		for(int i=0;i<n;i++){
			int num;
			double h,w,b;
			cin >> num >> h >> w;
			h=(double)h/100;
			b=w/pow(h,2);
			if(abs(b-22)<bmi){
				an=num;
				bmi=abs(b-22);
			}
		}
		printf("%d\n",an);
	}
    return 0;
}

Measured memory_bytes: 0
#include <stdio.h>

int d[15];

int main(){
    int N, K;
    scanf("%d%d", &N, &K);
    for(int i=0; i<K; i++){
        int x;
        scanf("%d", &x);
        d[x] = 1;
    }
    for(int i=N; ; i++){
        int temp = i;
        int valid = 1;
        while(temp){
            if(d[temp%10]){ valid = 0; break; }
            temp /= 10;
        }
        if(valid){ printf("%d", i); return 0; }
    }
    return 0;
}

Measured memory_bytes: 128
s=[input()for _ in range(3)]
i=0
A=0;B=1;C=2;
while True:
  if len(s[i])==0:
    print(t.upper())
    exit()
  if len(s[i])>0:
    t=s[i][0]
    s[i]=s[i][1:]
    i=eval(t.upper())
  else:
    s[i]=''


Measured memory_bytes: 3060
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
using namespace std;
int n;
int x, y;
int z;
int t1, t2;
int fp, sp;
int a[100000];
vector<int> p[100000];
stack<int>pass;
int pasize;
void search(int now){
	pass.push(now);
	pasize++;
	a[now] = 1;
	if (now == n - 1)z = 1;
	if (z == 1) return;
	for (int i = 0; i < p[now].size(); i++){
		if (a[p[now][i]] == 0){
			search(p[now][i]);
			if (z == 1) return;
		}
	}
	pass.pop();
	pasize--;
	return;
}
void paintf(int now){
	if (a[now] < 2)a[now] = 2;
	fp++;
	for (int i = 0; i < p[now].size(); i++){
		if (now == t1&&p[now][i] == t2){}
		else if (now == t2&&p[now][i] == t1){}
		else if (a[p[now][i]] < 2){
		paintf(p[now][i]);
		}
	}
	return;
}
void paints(int now){
	if (a[now] < 2)a[now] = 3;
	sp++;
	for (int i = 0; i < p[now].size(); i++){
		if (now == t1&&p[now][i] == t2){}
		else if (now == t2&&p[now][i] == t1){}
		else if (a[p[now][i]] < 2){
			paints(p[now][i]);
		}
	}
	return;
}
int main(void){
	scanf("%d", &n);
	for (int i = 0; i < n; i++){
		a[i] = 0;
	}
	for (int i = 0; i < n - 1; i++){
		scanf("%d %d", &x, &y);
		x--;
		y--;
		p[x].push_back(y);
		p[y].push_back(x);
	}
	z = 0;
	pasize = 0;
	search(0);
	for (int i = 0; i <(pasize-2)/2; i++)pass.pop();
	t1 = pass.top();
	pass.pop();
	t2 = pass.top();
	fp = 0;
	sp = 0;
	paintf(0);
	paints(n - 1);
	if (fp > sp)printf("Fennec\n");
	else printf("Snuke\n");
	return 0;
}

Measured memory_bytes: 9600
import math
def is_prime(n):
    if n <= 1:
        return False
    for i in range(2,int(math.sqrt(n))+1):
        if n % i == 0:
            return False
    return True

if __name__=="__main__":
    n=int(input())
    cnt=0
    while cnt == 0:
        if is_prime(n):
            cnt+=1
        else:
            n+=1
            continue
    print(n)


Measured memory_bytes: 38896
#coding:utf-8
S = input()
if len(S)<26:
    for i in [chr(i) for i in range(97, 97+26)]:
        if not i in S:
            print (S+i)
            exit()
else:
    
    for i in range(len(S)-1):


        if (S[-i-1] > S[-i-2]):
            for j in S[-i-1:][::-1]:
                #print (j)
                if (S[-i-2]<j):
                    print (S[:-i-2]+j)
                    exit()
        else:
            pass
print (-1)
            

Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
int main(void) {
  int n, a, b;
  cin >> n >> a >> b;
  cout << min(a * n, b) << endl;
  return 0;
}

Measured memory_bytes: 256
//{{{
#include<algorithm>
#include<cmath>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printw) FUNC(printwe) FUNC(printb) FUNC(printbe) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ return in >> p.first >> p.second; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    cout << 180 * (n - 2) << '\n';
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
#define int long long int
using namespace std;

signed main() {
    int n,t;
    cin>>n;
    map<int,int> m;
    map<int,int> m2;
    int arr[n+1];
    for(int i=1;i<=n;i++)
    {
        cin>>t;
        arr[i]=t;
        m2[i-t]++;
        m[t+i]++;
    }
    int ans=0;
    for(int i=1;i<=n;i++)
    {
       
        //cout<<m2[i + arr[i]]<<endl;
        ans += m2[i + arr[i]];
        
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 39388
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc *bufio.Scanner

func maxInt(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func commonSubSeq(a, b string) string {
	res := make([]byte, 0, 4096)
	la, lb := len(a), len(b)
	subs := make([][]int, la + 1)
	for i := 0; i < la + 1; i++ {
		subs[i] = make([]int, lb+1)
	}

	var k int
	for i := 1; i < la+1; i++ {
		for j := 1; j < lb+1; j++ {
			k = maxInt(subs[i-1][j], subs[i][j-1])
			if a[i-1] == b[j-1] && subs[i-1][j-1]+1 > k {
				k = subs[i-1][j-1] + 1
			}
			subs[i][j] = k
		}
	}

	for la > 0 && lb > 0 {
		if subs[la-1][lb] == subs[la][lb] {
			la--
		} else if subs[la][lb-1] == subs[la][lb] {
			lb--
		} else {
			res = append(res, a[la - 1])
			la--
			lb--
		}
	}

	reversedString := func(s string) string {
		runes := []rune(s)
		for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
			runes[i], runes[j] = runes[j], runes[i]
		}
		return string(runes)
	}

	return reversedString(string(res))
}

func ScanString() string {
	sc.Scan()
	return sc.Text()
}

func ScanInt() int {
	sc.Scan()
	res, _ := strconv.Atoi(sc.Text())
	return res
}

func ScanIntArray(size int) []int {
	res := make([]int, size)
	for i := 0; i < size; i++ {
		sc.Scan()
		res[i], _ = strconv.Atoi(sc.Text())
	}
	return res
}

func main() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	strA := ScanString()
	strB := ScanString()
	fmt.Println(commonSubSeq(strA, strB))
}


Measured memory_bytes: 75392
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
 
#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);
 
template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;
 
constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433;
 
template <class T> vector<T> multivector(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto multivector(size_t N,T... t){return vector<decltype(multivector(t...))>(N,multivector(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

int main() {
    ll N,K; cin >> N >> K;
    vector<ll> A(N);
    for(int i = 0; i < N; ++i){
        cin >> A[i];
    }
    sort(ALL(A));
    ll sum = 0;
    for(int i = 0; i < N - K; ++i) sum += A[i];
    cout << sum << endl;


    return 0;
}

Measured memory_bytes: 1792
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);

		int num = Integer.parseInt(scanner.nextLine());

		List<Integer> h = new ArrayList<Integer>();

		for (int i = 0; i < num; i++) {
			h.add(Integer.parseInt(scanner.next()));
		}

		int times = 0;
		int preH = 0;
		int min = 0;

		for (int tmp : h) {
			if (tmp < preH) {
				times += preH - min;
				min = tmp;
			}
			preH = tmp;
		}
		times += preH - min;

		System.out.println(times);
	}

}


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

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] str = in.readLine().split(" ");
    int a = Integer.parseInt(str[0]);
    int b = Integer.parseInt(str[1]);
    System.out.println((int)Math.ceil((double)(b-1)/(double)(a-1)));
  }
}

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

using namespace std;

int main() {
	string S, subS, T;
	cin >> S >> T;
	int n = S.size(), m = T.size(), ans=n;
	for (int i=0; i<n-m+1; i++){
		subS = S.substr(i, i+m);
		int cnt = 0;
		for (int j=0; j<m; j++){
			if (subS[j] != T[j]) cnt++;
		}
		ans = min(ans, cnt);
	}
	cout << ans << endl;
}

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

const int maxn = 505;
int n, m, arr[maxn][maxn], p[maxn], alive[maxn], cnt[maxn], ans = maxn;

int main(){
    ios_base::sync_with_stdio(false);

    cin >> n >> m;

    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            cin >> arr[i][j];
        }

        p[i] = 1;
        cnt[arr[i][1]]++;
    }

    for(int i = 1; i <= m; i++){
        alive[i] = true;
    }

    for(int i = 0; i < m; i++){
        int mx = 0, id = 0;
        for(int j = 1; j <= m; j++){
            if(cnt[j] > mx){
                mx = cnt[j];
                id = j;
            }
//            cout << j << ',' << cnt[j] << ' ';
        }
//        cout << endl;

//        cout << i << " !!! " << mx << ' ' << id << endl;

        ans = min(ans, mx);
        alive[id] = false;

        if(i < m - 1){
            for(int j = 1; j <= n; j++){
                while(alive[arr[j][p[j]]] == 0){
//                    cout << "-> " << j << ' ' << p[j] << " ," << arr[j][p[j]] << endl;
                    cnt[arr[j][p[j]]]--;
                    p[j]++;
                    cnt[arr[j][p[j]]]++;
                }
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 896
package main

import (
	"fmt"
)

func main() {
	var H, W int
	fmt.Scanf("%d%d", &H, &W)
	a := make([][]rune, H)
	for i := 0; i < H; i++ {
		a[i] = make([]rune, W)
	}
	h := 0
	z := make([]int, W)
	for i := 0; i < H; i++ {
		zz := 0
		for j := 0; j < W; j++ {
			fmt.Scanf("%c", &a[h][j])
			if a[h][j] == '#' {
				zz++
				z[j]++
			}
		}
		if zz != 0 {
			h++
		}
		if i != H-1 {
			fmt.Scanf("\n")
		}
	}
	for i := 0; i < h; i++ {
		for j := 0; j < W; j++ {
			if z[j] != 0 {
				fmt.Printf("%c", a[i][j])
			}
		}
		fmt.Printf("\n")
	}
}


Measured memory_bytes: 1152
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <algorithm>
#include <functional>

using namespace std;

#define rep(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define foreach(itr,c) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)

int H,W;
char field[110][110];
int dx[4] = {0,1,0,-1}, dy[4] = {1,0,-1,0};

void dfs(int i, int j){// cout << i << ' ' << j << endl;
  int k;
  char e = field[i][j];

  field[i][j] = '.';

  rep(k,4){
    int my = i + dy[k];
    int mx = j + dx[k];
    if(0 <= my && my < H && 0 <= mx && mx < W && field[my][mx] == e) dfs(my,mx);
  }
}

int main(){
  int i,j;

  for(;;){
    scanf("%d %d",&H,&W); if(H == 0 && W == 0) break;
    rep(i,H) scanf("%s",&field[i]);

    int res = 0;
    rep(i,H) rep(j,W){
      if(field[i][j] == '#' || field[i][j] == '*' || field[i][j] == '@'){
        dfs(i,j);
        res++;
      }
    }

    printf("%d\n",res);
  }

  return 0;
}

Measured memory_bytes: 0
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
#include<unordered_map>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b)-1);i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int, int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))

int main(void){
	char c[100005]; scanf("%s", &c);
	int n = strlen(c);
	int p = 0;
	rep(i, n) if(c[i]=='p') p++;
	
	cout << n/2 - p << endl;
	
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main() {
  int repeating; cin >> repeating;
  rep(kaisuu , repeating){
    int gx, gy;cin>>gx>>gy;
    ll route[100][100]={0};
    bool vert[100][100]={0};
    bool hori[100][100]={0};
    int mata; cin >> mata;
    rep(i, mata){
      int x1,y1,x2,y2; cin >> x1 >> y1 >> x2 >> y2;
      if(x1 == x2) vert[x1+1][max(y1,y2)+1] = true;
      if(y1 == y2) hori[max(x1,x2)+1][y1+1] = true;
    }
    //cout << gx<<" "<< gy<<" "<< mata; ok
    /*rep(i,5){
      rep(j,6) cout << vert[j][i] <<" ";
      cout << endl;
    }
    cout << endl;
    rep(i,5){
      rep(j,6) cout << hori[j][i] <<" ";
      cout << endl;
    }ok*/

    // calc route
    for(int i = 0; i<30; i++){
      for(int j= 0; j<30; j++){
        if(i==0 || j==0) route[j][i]=0;
        else if(i==1 && j==1) route[j][i]=1;
        else if(!vert[j][i] && !hori[j][i]) route[j][i]=route[j-1][i] + route[j][i-1];
        else if(!vert[j][i]) route[j][i] = route[j][i-1];
        else if(!hori[j][i]) route[j][i] = route[j-1][i];
        else route[j][i]=0;
      }
    }

    if(route[gx+1][gy+1]!=0)cout << route[gx+1][gy+1] << endl;
    else cout << "Miserable Hokusai!" << endl;
  }

}



Measured memory_bytes: 3196
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<62;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

const int MOD = 1000000007;

int main(){
    int n; cin >> n;
    vector<int> v(n);
    rep(i,n) cin >> v[i];

    map<int, int> even_counter;
    map<int, int> odd_counter;

    for(int i = 0; i < n; i=i+2){
        even_counter[v[i]]++;
    }

    for(int i = 1; i < n; i=i+2){
        odd_counter[v[i]]++;
    }

    int max_even = 0;
    int max_even2 = 0;
    int max_even_num = -1;
    for(auto ec : even_counter){
        if (ec.second >= max_even){
            max_even2 = max_even;
            max_even = ec.second;
            max_even_num = ec.first;
        }
        else{
            if (ec.second >= max_even2){
                max_even2 = ec.second;
            }
        }
    }
    int max_odd = 0;
    int max_odd2 = 0;
    int max_odd_num = -1;
    for(auto oc : odd_counter){
        if (oc.second >= max_odd){
            max_odd2 =  max_odd;
            max_odd = oc.second;
            max_odd_num = oc.first;
        }
        else{
            if(oc.second >= max_odd2){
                max_odd2 = oc.second;
            }
        }
    }

    int ans = 0;
    if (max_even_num != max_odd_num){
        ans = n - max_even - max_odd;
    }
    else{
        ans = min(n-max_even-max_odd2, n-max_odd-max_even2);
    }

    cout << ans << endl;
}



Measured memory_bytes: 8284
#include<bits/stdc++.h>
using namespace std;
using ll=long long;

int main(){
  int i,j;ll cnt=0;
  int n;
  string s;
  cin>>n;
  cin>>s;
  string t="",r=s;
  while(t!=s){
    t=s;
    for(i=1;i<s.size();i++){
      if(s[i-1]=='(' && s[i]==')'){
        s.erase(i-1,2);
        break;
      }
    }
  }
  int a=0,b=0;
  for(i=0;i<s.size();i++){
    if(s[i]==')')a++;
    else b++;
  }
  for(i=0;i<a;i++)cout<<'(';
  cout<<r;
  for(i=0;i<b;i++)cout<<')';
}

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

int n;
vector<string> A;

void f(int digitNum, string s, int lim){
    bool a = false, b = false, c = false;
    for(int i = 0; i < s.size(); i++){
        if(s[i] == '3') a = true;
        if(s[i] == '5') b = true;
        if(s[i] == '7') c = true;
    }
    if(a && b && c){
        A.push_back(s);
    }
    if(digitNum == lim){
        return;
    }
    f(digitNum + 1, s + '3', lim);
    f(digitNum + 1, s + '5', lim);
    f(digitNum + 1, s + '7', lim);
    return;
}

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

    cin >> n;

    int lim = to_string(n).length();

    // 七五三数は必ず'7', '5', '3'を含むので三桁以上は確定
    // nの桁数がが二桁以下の場合0
    if(lim < 3){
        cout << 0 << endl;
        return 0;
    }

    // nの桁数と同じ桁数までの七五三数を列挙
    f(0, "", lim);

    // vector Aにはstring型で七五三数が格納されているので数値に直す
    vector<int> B;
    for(auto &x : A){
        B.push_back(stoi(x));
    }

    sort(B.begin(), B.end());

    // upper_boundを使用
    // もし配列の最後に欲しいものがあった場合、思わしくない動作をするのではないかと思ったが，
    //　vector<int >A = {i, 2, 3}でupper_boundの第三引数を3とした場合，3が返ってくる（指定した数値より大きい数がでてくるところを指すが範囲外参照的な感じになってもいいらしい）
    int idx = upper_bound(B.begin(), B.end(), n) - B.begin();

    cout << idx << endl;

    return 0;
}


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

int main(){
    int N;
    char c;
    bool flag=0;
    cin >> N;
    for(int i=0;i<N;i++){
        cin >> c;
        if(c=='Y')
        flag=1;
    }
    if(flag)
    cout << "Four" << endl;
    else
    cout << "Three" << endl;
}

Measured memory_bytes: 256
/*
Author : N_o_o_B
Created : December 08 2019 17:31:51 
*/
#include <bits/stdc++.h>
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
*/
#define TRACE
#ifdef TRACE
#define trace(...) { cerr<<"[ "; __trace__(#__VA_ARGS__, __VA_ARGS__);}
#undef endl
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const pair<Arg1,Arg2> &x) {
    return out<<"("<<x.first<<","<<x.second<<")";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const vector<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const set<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
void __trace__(const string name, Arg1&& arg1){
    cerr << name << " : " << arg1 << " ] " << endl;
}
 
template <typename Arg1, typename... Args>
void __trace__(const string names, Arg1&& arg1, Args&&... args){
    const string name = names.substr(0,names.find(','));
    cerr<<name<<" : "<<arg1<<" | ";
    __trace__(names.substr(1+(int)name.size()), args...);
}
#else
    #define trace(args...)
#endif
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vll;
typedef vector<vl> vvl;
//typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
#define fori(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define ford(i,n)  for(int i=n-1;i>=0;i--)
#define trav(x,a) for(auto& x:a)
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define sz(a) (int)a.size()
#define fi first
#define se second
clock_t time_p=clock();
void time_taken()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
//const ll mod=998244353;
const ll mod=1e9+7;
const ll INF=1e18;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cout.precision(12);cout << fixed;

    string s;
    cin >> s;
    int n=sz(s);
    int ans = 0;
    fori(i,n/2){
        ans += (s[i]!=s[n-1-i]);
    }
    cout << ans << endl;



    time_taken();
    return 0;
}

Measured memory_bytes: 256
M=10**9+7
n,k=map(int,input().split())
l=[0]*(k+1)
a=0
for i in range(k,0,-1):
  l[i]=pow(k//i,n,M)-sum(l[j] for j in range(i*2,k+1,i))
  a+=i*l[i]
print(a%M)

Measured memory_bytes: 11304
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define clr(a) memset(a, 0, sizeof(a))
#define sz(x) x.size()
#define printvector(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout<<*it<<" "; cout<<endl;
#define rep(n) for (int i = 0; i < n; i++)
#define repc(i, n) for (int i = 0; i < n; i++)
#define FOR(i, x, y) for (int i = x; i < y; i++)
#define DEC(i, x, y) for (int i = x; i >= y; i--)
#define all(v) v.begin(), v.end()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define alla(a, n) a, a + n
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a * b)/gcd(a, b)
#define int long long int
#define ull unsigned long long
#define printarray(arr, n) for(int i= 0;i<n;i++) cout<<a[i]<<' '; cout<<endl;
#define printvecpairs(vec) for(auto it: vec) cout<<it.fr<<' '<<it.sc<<endl;
#define initdp(a) memset(a, -1, sizeof(a));

using namespace std;
const int MOD = 1e9 + 7;
const int INF = 2e15;
const int MAXN = 1e5 + 5;

int fastexpo(int b, int exp){
    if(exp == 0) return 1;
    if(exp == 1) return b;
    int ans = (fastexpo(b,exp/2) % MOD);
    ans *= ans;
    ans %= MOD;
    if(exp % 2 == 1){
        ans *= b;
    }
    ans %= MOD;
    return ans;
}



signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
  	cin>>n;
  	cout<<(n+1)%2<<endl;
    return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef pair<int,int> pii;

const int INF = 1e9;

int main(){
  int n; cin >> n;
  vector< vector<pii> > g(n);

  vector<int> sizes(3);
  rep(i,3)cin >> sizes[i];

  vector< vector<int> > friends(3);
  rep(i,3){
    friends[i].resize(sizes[i]);
    rep(j,sizes[i]){
      cin >> friends[i][j]; friends[i][j]--;
      if(j){
	g[friends[i][j-1]].push_back(pii(0,friends[i][j]));
	g[friends[i][j]].push_back(pii(0,friends[i][j-1]));
      }
    }
  }
  
  int m; cin >> m;
  rep(i,m){
    int a,b; cin >> a >> b; a--; b--;
    g[a].push_back(pii(1,b));
    g[b].push_back(pii(1,a));
  }

  vector< vector<pii> > d(3, vector<pii>(n, pii(INF,INF)));
  deque<int> q;
  rep(x,3){
    d[x][friends[x][0]] = pii(0, friends[x][0]);
    q.push_back(friends[x][0]);

    while(q.size()){
      int v = q.front(); q.pop_front();

      for(pii e : g[v]){
	int w = e.first, u = e.second;
	pii nxt = pii(d[x][v].first+w, min(d[x][v].second, u));
	if(d[x][u] > nxt){
	  d[x][u] = nxt;
	  if(w == 0) q.push_front(u);
	  else q.push_back(u);
	}
      }
    }
  }

  pii ans = pii(INF,INF);
  rep(i,n){
    int sum = 0, id = INF;
    rep(x,3){
      sum += d[x][i].first;
      id = min(id, d[x][i].second);
    }
    ans = min(ans, pii(sum,id));
  }
  cout << ans.first << " " << ans.second+1 << endl;
}

Measured memory_bytes: 14996
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(I,J,K) for(ll I=J;I<K;I++)

ll dp[3001][3001][4];
int item[3001][3001];
int main(){

  ll r,c,k;
  cin >> r >> c >> k;


  rep(i,0,k){
    ll a,b,x;
    cin >> a >> b >> x;
    item[a][b] = x;
  }

  rep(i,0,c+1){//列
    rep(j,0,r+1){//行
      if(j){
        dp[j][i][0] = max({dp[j-1][i][0],dp[j-1][i][1],dp[j-1][i][2],dp[j-1][i][3]});
        dp[j][i][1] = max({dp[j-1][i][0],dp[j-1][i][1],dp[j-1][i][2],dp[j-1][i][3]}) + item[j][i];
      }
      if(i){
        dp[j][i][0] = max(dp[j][i][0],dp[j][i-1][0]);
        dp[j][i][1] = max({dp[j][i][1],dp[j][i-1][0]+item[j][i],dp[j][i-1][1]});
        dp[j][i][2] = max({dp[j][i][2],dp[j][i-1][1]+item[j][i],dp[j][i-1][2]});
        dp[j][i][3] = max({dp[j][i][3],dp[j][i-1][2]+item[j][i],dp[j][i-1][3]});
      }
    }
  }

  ll ans = 0;
  rep(i,0,4) ans = max(dp[r][c][i],ans);
  cout << ans << endl;

}




Measured memory_bytes: 320056