akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int BinarySearch(int, int, int*);


main(){

  int n,q,i,s;
  int S[1000000];
  int count = 0;

  scanf("%d",&n);

  for(i=0;i<n;i++)scanf("%d",&S[i]);

  scanf("%d",&q);

  for(i=0;i<q;i++){
    scanf("%d",&s);
    if(BinarySearch(s,n,S) == 0){
      count++;
    }
  }

  printf("%d\n",count);

  return 0;
}


int BinarySearch(int key,int n,int S[]){

  int l=0,m,r;

  r = n;

  while(l < r){
    m = (r + l)/2;  
    
    if(S[m] == key)return 0;
    
    else if(S[m] > key)r = m;

    else l = m+1;
  }

  return 1;
}

Measured memory_bytes: 996
#include <algorithm>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define ll long long
#define eps LDBL_EPSILON
#define moder 1000000007
#define double long double
#define INF LLONG_MAX/10000
#define P pair<int,int>
#define prique priority_queue
using namespace std;
int h,w;
char a[510][510];
bool b[510][510],c[510][510];
signed main() {
	cin>>h>>w;
	rep(i,h){
		rep(j,w)cin>>a[i][j];
	}
	rep(i,h){
		if(!i){
			rep(j,w)b[i][j]=true;
		}
		else if(i%2==0){
			for(int j=1;j<w;j++)b[i][j]=true;
		}
		else b[i][w-1]=true;
	}
	rep(i,h){
		rep(j,w){
			if(!b[i][j])c[i][j]=true;
		}
	}
	rep(i,h){
		rep(j,w){
			if(a[i][j]=='#'){
				if(b[i][j])c[i][j]=true;
				else b[i][j]=true;
			}
		}
	}
	rep(i,h){
		rep(j,w){
			if(b[i][j])cout<<'#';
			else cout<<'.';
		}
		cout<<endl;
	}
	rep(i,h){
		rep(j,w){
			if(c[i][j])cout<<'#';
			else cout<<'.';
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
int v[109],w[109]; long long dp[109][100009];
long long  solve(int i, int wt) {
	if(wt<=0) {
		return 0;
	}
	if(i<0) {
		return 0;
	}
	if(dp[i][wt] != -1) {
		return dp[i][wt];
	}
	long long s1 = 0;
	if(wt >= w[i]) {
		s1 = solve(i-1, wt-w[i]) + v[i];
	}
	long long s2 = solve(i-1, wt);
	return dp[i][wt] = max(s1,s2);
}
int mod = 1e9+7;
int main() {
	int h,w;
	cin>>h>>w;
	string s[h];
	for(int i=0;i<h;++i) {
		cin>>s[i];
	}
	long long dp[h][w];
	memset(dp,0,sizeof dp);
	dp[0][0] = 1;
	for(int i=0;i<h;++i) {
		for(int j=0;j<w;++j) {
			if(s[i][j] == '#') {
				dp[i][j] = 0;
			} else {
				if(i>0) {
					dp[i][j] = (dp[i][j] + dp[i-1][j])%mod;
				}
				if(j>0) {
					dp[i][j] = (dp[i][j] + dp[i][j-1])%mod;
				}
			}
		}
	}
	cout<<dp[h-1][w-1];
	return 0;
}

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

#define pb push_back
#define ff first
#define ss second

const long long MAXN = 1e5 + 21, inf = 1e18 + 21, LG = 20;

long long n;

int main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cin >> n;
    vector<long long> p(n);

    for(auto &y: p) {
        cin >> y;
        y--;
    }

    vector <long long> q(n);

    for(int i = 0; i < n; i++)
        q[p[i]] = i;

    for(long long i = 0; i < n; i++)
        cout << 30000 * i + 1 << ' ';
    cout << '\n';

    for(long long i = 0; i < n; i++)
        cout << 30000 * (n - 1 - i) + q[i] + 1 << ' ';
    cout << '\n';
    return 0;
}


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

int main() {
  int N;cin>>N;
  vector<int> H(N);
  for(int i=0;i<N;i++) cin>>H.at(i);
  priority_queue<int> A;
  int count=0;
  for(int i=0;i<N-1;i++){
    if(H.at(i)>=H.at(i+1)) count++;
    else{
      A.push(count);
      count=0;
    }
  }
  A.push(count);
  int ans=A.top();
  cout<<ans<<endl;
}



Measured memory_bytes: 4200
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    s = s_input()

    if 'a' in s and 'b' in s and 'c' in s:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()


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

int main(void){
	int H,W;
	int count;

	cin >> H >> W;

	char field[W+2][H+2]={};

	for(int i=1;i<H+1;i++){
		for(int j=1;j<W+1;j++){
			cin >> field[j][i];
		}
	}

	for(int i=1;i<H+1;i++){
		for(int j=1;j<W+1;j++){
			if(field[j][i]=='.'){
				count=0;

				//check
				for(int gap_x=i-1;gap_x<=i+1;gap_x++){
					for(int gap_y=j-1;gap_y<=j+1;gap_y++){
						if(field[gap_y][gap_x]=='#')
							count++;
					}
				}

				field[j][i]=count+'0';
			}
		}
	}

	for(int i=1;i<H+1;i++){
		for(int j=1;j<W+1;j++){
			cout << field[j][i];
		}
		cout << 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 all(vec) vec.begin(),vec.end()
using ll=long long;
const ll MOD=1e9+7;
const int INF=1<<30;
const int dy[4]={0,0,1,-1};
const int dx[4]={1,-1,0,0};

int cnt[1000][1000];

int main(){
  int H,W; cin >> H >> W;
  vector<string> G(H);
  rep(i,H){
    cin >> G[i];
  }
  queue<pair<int,int> > que;
  rep(i,H){
    rep(j,W){
      if(G[i][j]=='#'){
        que.push(make_pair(i,j));
      }
    }
  }
  while(!que.empty()){
    int y,x;
    tie(y,x)=que.front();
    que.pop();
    rep(dir,4){
      int ny=y+dy[dir];
      int nx=x+dx[dir];
      if(0<=ny&&ny<H&&0<=nx&&nx<W&&G[ny][nx]=='.'&&cnt[ny][nx]==0){
        cnt[ny][nx]=cnt[y][x]+1;
        que.push(make_pair(ny,nx));
      }
    }
  }
  int ans=0;
  rep(i,H){
    rep(j,W){
      if(cnt[i][j]>ans) ans=cnt[i][j];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 10112
// Author: Wenxing Mei
//   File: b.cpp
//   Date: 2019-04-05 16:59
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define per(i, b, a) for (int i = (int)b; i >= (int)a; --i)
#define repv(ele, cont) for (auto &ele : cont)
#define all(x) x.begin(), x.end()
#define mp make_pair
#define eb emplace_back
#define ep emplace
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<ll> vll;
// END OF TEMPLATE

int main() {
#ifndef LOCAL
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#endif
    string s;
    cin >> s;
    s += 'Z';
    int ans = 0;
    int cur = 0;
    for (char &c : s) {
        if (c == 'A' || c == 'T' || c == 'C' || c == 'G')
            ++cur;
        else {
            ans = max(ans, cur);
            cur = 0;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
#include <map>
using namespace std;
using ll = long long;
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[100001];
//char str[1010][1010];
//vector<pair<int,int> > pc[100001];
//int ABS(int a){return max(a,-a);}
int main(){
	ll a,b;
	ll ans=0;
	cin>>a>>b;
	if(a==2||b==2) ans=0;
	else if(a==1&&b==1) ans=1;
	else if(a==1) ans=b-2;
	else if(b==1) ans=a-2;
	else ans=(a-2)*(b-2);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(n) for (int i = 0; i < n; ++i)
#define REP(n,i) for (int i = 0; i < n; ++i)
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define intinf 1000000000
#define llmax 9223372036854775807
#define nyan "(=^･ω･^=)"
#define mkp make_pair
#define mkt make_tuple
#define P pair<ll, ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;

int n,p;
bool b;
vector<int>v;

int main() {
	cin >> n;
	int i;
	b = false;
	for (i = 2; i*(i - 1) / 2 <= n; ++i) {
		if (i*(i - 1) / 2 == n) {
			b = true;
			break;
		}
	}
	if (b) {
		cout << "Yes" << endl;
		cout << i << endl;
		p = 1;
		REP(i, j) {
			cout << (2 * n) / i << sp;
			int cnt = n * 2 / i;
			REP(v.size(), k) {
				cout << v[k] << sp;
				++v[k];
				--cnt;
			}
			v.push_back(p);
			while (cnt > 0) {
				--cnt;
				cout << p << sp;
				++p;
			}
			cout << endl;
		}
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 1408
my_wallet = int(input())
price_of_a_cake = int(input())
price_of_a_donut = int(input())

# ドーナツを買うことができるお金
money_can_buy_donut = my_wallet - price_of_a_cake

# ドーナツを買えるだけ買ったあとのあまりのお金
remain_money = money_can_buy_donut % price_of_a_donut

print(remain_money)

Measured memory_bytes: 9100
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int inf = (1LL<<31) -1;
//range min
struct segmentTree{
	vector<int> node;
	int n;
	
	segmentTree(vector<int> &v){
		int s = v.size();
		n = 2;
		while(n < s) n *= 2;
		node = vector<int>(2*n -1, inf);
		for(int i=0; i<s; i++){
			node[i +n-1] = v[i];
		}
		for(int i=n-2; i>=0; i--){
			node[i] = min(node[2*i +1], node[2*i +2]);
		}
	}
	
	void Set(int val, int pos){
		int idx = n-1 + pos;
		node[idx] = val;
		do{
			idx = (idx -1)/2;
			node[idx] = min(node[2*idx +1], node[2*idx +2]);
		}while(idx != 0);
	}
	int Get(int l, int r){
		return _get(l, r, 0, 0, n);
	}
	int _get(int l, int r, int k, int cl, int cr){
		if(l <= cl && cr <= r){
			return node[k];
		}
		if(r <= cl || cr <= l){
			return inf;
		}
		int m = (cl +cr)/2;
		return min(_get(l, r, 2*k+1, cl, m), _get(l, r, 2*k+2, m, cr));
	}
};

signed main(){
	int n,q;
	cin >> n >> q;
	vector<int> v(n, inf);
	segmentTree segtree(v);
	for(int i=0; i<q; i++){
		int c,x,y;
		cin >> c >> x >> y;
		if(c==0){
			segtree.Set(y, x);
		}else{
			cout << segtree.Get(x, y+1) << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 5276
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <stdio.h>
 using namespace std;

int main()
{
    long long int n;
    cin >> n;
    long long int max = sqrt(1000000000000);
    
    long long int ans = n;
    for(long long int i=1; i<=max; i++){
        if(n%i != 0) continue;
        //cout << i << " * ";
        long long int j = n/i;
        //cout << j << " = ";
        long long int tmp = (i-1)+(j-1);
        //cout << tmp << endl;
        if(tmp < ans){
            ans = tmp;
        }
    }
    //if(ans == max) ans = n-1;
    cout << ans << endl;
 
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

//typedef pair<int,int> P;


int sum(long long a){
	int ret = 0;
	while(a > 0){
		ret += a%10;
		a/=10;
	}
	return ret;
}

int main(){
	long long ans = 1;
	int k;
	scanf("%d",&k);

	for(int i=0;i<k;i++){
		printf("%lld\n",ans);
		long long best = -1;
        for(long long add = 1;add<=1000000000000000;add*=10){
			if(best==-1 || best*sum(ans+add)>(ans+add)*sum(best)){
				best=ans+add;
				//printf("best : %lld, add : %lld\n",best,add);
			}
		}
		ans = best;
	}

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        if (s.equals("abc") ||s.equals("cba") || s.equals("acb") || s.equals("bac") || s.equals("bca") || s.equals("cab")) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

    }

}

Measured memory_bytes: 20948
/*
 * atcoder/abc111/c.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

const int MAX = 100001;
int N;
int counter[2][MAX] = {0};
int Rank[2][2] = {0};
int num[2][2] = {0};
void solve() {
  cin >> N;
  int a;
  loop(n,0,N) {
    cin >> a;
    counter[n%2][a]++;
  }

  // 偶奇それぞれ頻度ランク1, 2を記録する
  loop(v,1,MAX) {
    loop(n,0,2) {
      int count = counter[n][v];
      if (Rank[n][0] < count) {
        Rank[n][1] = Rank[n][0];
        Rank[n][0] = count;
        num[n][1] = num[n][0];
        num[n][0] = v;
      } else if (Rank[n][1] < count) {
        Rank[n][1] = count;
        num[n][1] = v;
      }
    }
  }
  // ぐう奇それぞれの数字が確定したら(数列の半分 - 出現回数)を偶奇それぞれ計算して和を出力
  int numEven = N/2;
  int numOdd = N-numEven;
  // 1位の数字が一緒なら使えない
  if (num[0][0] == num[1][0]) {
    cout << min(N - Rank[0][0] - Rank[1][1], N - Rank[0][1] - Rank[1][0]) << endl;
    return;
  }

  cout << N - Rank[0][0] - Rank[1][0] << endl;
}
int main() {
  // cout.precision(15);
  // cout << fixed << double

  solve();

  return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define DATA_SIZE 2000005
#define MAX 100

struct heap{
  int data[DATA_SIZE];
  int size;
};

int main(void){
  int i;
  struct heap array;
  void print_array(struct heap *array);
  void initialize(struct heap *array);
  void insert(struct heap *array,int integer);
  void delete_largest(struct heap *array);

  initialize(&array);
  while (1){
    char cmd[256];
    scanf("%s",cmd);
    if (strcmp(cmd,"end")==0) break;
    if (strcmp(cmd,"insert")==0){
      int t;
      scanf("%d",&t);
      insert(&array,t);
    }else{
      printf("%d\n",array.data[0]);
      delete_largest(&array);
    }
  }
  return (0);
}

void print_array(struct heap *array){
  int i;

  for (i=0;i<array->size;i++) printf("%d ",array->data[i]);
  printf("\n");
}

void swap(int *x,int *y){
  int temp;
  temp=*x;
  *x=*y;
  *y=temp;
}

void initialize(struct heap *array){
  array->size=0;
}

void insert(struct heap *array,int integer){
  int i;

  i=array->size;
  array->data[i]=integer;
  array->size++;
  while (i!=0 && array->data[(i-1)/2]<array->data[i]){
    swap(&array->data[(i-1)/2],&array->data[i]);
    i=(i-1)/2;
  }
}

void delete_largest(struct heap *array){
  int i=0,j=1;
  if (array->size==0) return;
  array->size--;
  if (array->size==0) return;
  array->data[i]=array->data[array->size];
  while (j<=array->size){
    if (j+1<=array->size){
      j=(array->data[j]>array->data[j+1])?j:j+1;
    }
    if (array->data[i]<array->data[j]){
      swap(&array->data[i],&array->data[j]);
      i=j;
      j=2*i+1;
    }else{
      break;
    }
  }
}


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

const long long MOD = 1000000007;

int main() {
    long long n, d;
    cin >> n;
    pair<long long, long long> a[n + 1];
    for (long long i = 0; i <= n; i++) {
        cin >> a[i].first;
        a[i].second = i;
    }
    sort(a, a + n + 1);
    for (long long i = 1; i <= n; i++) {
        if (a[i].first == a[i - 1].first) {
            d = a[i].second - a[i - 1].second;
        }
    }
    long long factorial[n + 2], ifactorial[n + 2], inv[n + 2];
    inv[1] = 1;
    factorial[0] = 1;
    factorial[1] = 1;
    ifactorial[0] = 1;
    ifactorial[1] = 1;
    for (long long i = 2; i <= n + 1; i++) {
        inv[i] = (-MOD / i + MOD) * inv[MOD % i] % MOD;
        factorial[i] = factorial[i - 1] * i % MOD;
        ifactorial[i] = ifactorial[i - 1] * inv[i] % MOD;
    }
    function<long long(long long, long long)> binomial = [&](long long n, long long k) {
        return factorial[n] * ifactorial[k] % MOD * ifactorial[n - k] % MOD;
    };
    for (long long k = 1; k <= n + 1; k++) {
        long long result = binomial(n + 1, k);
        if (n - d >= k - 1) {
            result = result - binomial(n - d, k - 1);
            if (result < 0) {
                result += MOD;
            }
        }
        cout << result << '\n';
    }
    return 0;
}


Measured memory_bytes: 5120
#include <iostream>
#include <vector>
#include <string>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <climits>
#include <map>
#include <functional>
#include <cmath>
#include <cassert>

using namespace std;

int main()
{
    string s, t;
    cin >> s >> t;

    int i;
    for (i = s.size() - t.size(); i >= 0; i--) {
        for (int j = 0; j < t.size(); j++) {
            if (s[i+j] != '?' && s[i+j] != t[j])
                goto Continue;
        }
        break;
    Continue:;
    }

    if (i < 0) {
        cout << "UNRESTORABLE\n";
        return 0;
    }

    for (int j = 0; j < t.size(); j++)
        s[i+j] = t[j];

    for (int j = 0; j < s.size(); j++)
        if (s[j] == '?')
            s[j] = 'a';

    cout << s << endl;

    return 0;
}

Measured memory_bytes: 256
// lcmとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF 1001001001
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define double long double
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n+1)
using namespace std;
bool my_compare(pair<ll, ll> a, pair<ll , ll> b) {
    // 基本はfirstで比較
    if(a.first != b.first){
         return a.first < b.first; // 昇順
        //return a.first > b.first; // 降順
    }

    // それ以外はsecondで比較
    if(a.second != b.second){
        return a.second > b.second;
    }else{
        // どちらも同じ
        return true;
    }
}

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

    ll a,b,c,m,n,maxi=0,f=0,mini=INF,sum=0;
    string str;
    ll h,w;
    cin>>str;
    rep(i,2) if(str[i]!=str[i+1]) f=1;
    if(f==1) Yes;
    else No;


    


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD=1e9+7;
ll inv(ll a, ll b = MOD){
    ll x0 = 1, y0 = 0, x1 = 0, y1 = 1;
    while (b != 0) {
        const ll q = a / b;
        ll tmp = a % b;
        a = b;
        b = tmp;
        tmp = x0 - q * x1;
        x0 = x1;
        x1 = tmp;
        tmp = y0 - q * y1;
        y0 = y1;
        y1 = tmp;
    }
    return (x0 + MOD) % MOD;
}
ll fact(ll x){
    // 再帰だとスタックオーバーフローするので
    ll ret = 1;
    for(ll a=2; a<=x; ++a){
        ret = (ret * a) % MOD;
    }
    return ret;
}
/*
【解法】
A = [1, 2, ..., n] と固定する（求める場合の数は、固定した場合の数の mPn 倍）。B を長さ n の数列とする

ある集合 S \subset {1, ..., n} の上で値が一致する（そのほかにも一致する値のある可能性がある）ような B の場合の数は g(S) = (m-|S|)P(n-|S|) 通り
（まだ決まっていない n-|S| 箇所の値を、使っていない m-|S| 個の値から重複しないように決める）

ある集合 S \subset {1, ..., n} の上でちょうど値が一致する（ S に属さない点 i ではA[i] != B[i] となる）ような
B の場合の数を f(S) 通りとすると、g(S) = \sum_{S\subset T} f(T) となる。

F(S) = f({1, ..., n} \setminus S), G(S) = g({1, ..., n} \setminus S) とおくと、
G(S) = \sum_{T\subset S} F(S) なので、包除原理から F(S) = \sum_{T\subset S} (-1)^|S\setminus T| G(T) が成り立つ。

求めるのは f(\emptyset)
= F({1, ..., n})
= \sum_{T\subset {1, ..., n}} (-1)^|{1, ..., n}\setminus T| G(T)
= \sum_{T\subset {1, ..., n}} (-1)^|{1, ..., n}\setminus T| g({1, ..., n} \setminus T)
= \sum_{T\subset {1, ..., n}} (-1)^|T| g(T)
（ T -> T\setminus {1, ..., n} で置換）
ここで g は size の関数なので g(T) = g(|T|) とおくと、 k 元集合の選び方が nCk 通りなので 
= \sum_{k=0}^n (-1)^k nCk g(k)
= \sum_{k=0}^n (-1)^k n! / (n-k)! / k! * (m-k)! / (m-n)!
となる。

これを高速に計算する。 k == 0 のとき m! / (m-n)! で、

    n! (m-k)!             n! (m-(k-1))!          n-k+1
---------------- == ------------------------ * ---------
(n-k)! k! (m-n)!    (n-(k-1))! (k-1)! (m-n)!   (m-k+1) k

なので、 k がふえるたびに (n-k+1) / (m-k+1) / k 倍すればよい
*/
ll inv_table[500001] = {};
int main()
{
    ll n, m;
    cin >> n >> m;

    const ll mpn = fact(m) * inv(fact(m-n)) % MOD;
    ll tmp = mpn;
    ll sum = tmp;
    const ll sign[2] = {1, MOD-1};
    for(int k=1; k<=m; ++k)inv_table[k] = inv(k);
    for(int k=1; k<=n; ++k){
        tmp = ((tmp * inv_table[m-k+1]) % MOD * inv_table[k] % MOD) * (n-k+1) % MOD;
        sum = (sum + sign[k%2] * tmp) % MOD;
    }
    cout << (sum * mpn) % MOD;
    return 0;
}


Measured memory_bytes: 7512
def main():
  import numpy as np

  s = np.array(list(input()), np.unicode)
  sl = len(s)
  t = np.array(list(input()), np.unicode)
  tl = len(t)
  equal = (s[:, None] == t[None, :])

  dp = [np.zeros(tl + 1, np.int32)]
  for i in range(sl):
    tmp = dp[-1].copy()
    np.maximum(tmp[1:], tmp[:-1] + equal[i], out=tmp[1:])
    np.maximum.accumulate(tmp, out=tmp)
    dp.append(tmp)

  answer = ''
  while sl > 0 and tl > 0:
    if s[sl - 1] == t[tl - 1]:
      sl -= 1
      tl -= 1
      answer += s[sl]
      continue

    if dp[sl - 1][tl] > dp[sl][tl - 1]:
      sl -= 1
    else:
      tl -= 1

  print(answer[::-1])

if __name__ == '__main__':
  main()

Measured memory_bytes: 56800
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long count = 0;
    for(int i = 1; i < n; i++) {
      count += i;
    }
    System.out.println(count);

  }
}


Measured memory_bytes: 21844
s = input()
ans = 0
for i in range(2**(len(s)-1)):
    l = [""]*(len(s)-1)
    x = 0
    sx = ""
    for j in range(len(s)-1):
        if ((i>>j)&1):
            l[x]="+"
        x+=1
    for si,p in zip(s,l):
        sx+=si
        sx+=p
    ans+=eval(sx+s[-1])
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int INF = 1e9;

int T, N;
vector<int> t;
int wktm[110];
int ed;

int memo[110];

int solve(int idx){
    if(memo[idx] != -1) return memo[idx];
    if(idx > ed) return 0;
    int res = INF;
    int startDay = idx;
    rep(i, idx, ed + 1){
        int nowDay = i;
        int wake = t[(nowDay - startDay) % T];
        // cout << idx << " " << i << ' ' << nowDay << " " << wake << endl;
        if(wake > wktm[i]) break;
        int wktmp = solve(i + 1);
        res = min(res, wktmp);
    }
    // cout << idx << ' ' << res + 1 << endl;
    return memo[idx] = res + 1;
}

signed main(){
    while(cin >> T, T){
        t.clear();
        t.resize(T);
        rep(i, 0, T) cin >> t[i];
        cin >> N;
        memset(memo, -1, sizeof(memo));
        rep(i, 0, 110) wktm[i] = INF;
        rep(i, 0, N){
            int a, b;
            cin >> a >> b;
            a--;
            wktm[a] = min(wktm[a], b);
        }
        rep(i, 0, 110){
            if(wktm[i] == INF) continue;
            ed = i;
            // cout << " " << i << " " << wktm[i] << endl;
        }
        int ans = solve(0);
        cout << ans - 1 << endl;
    }
}


Measured memory_bytes: 3004
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int i;
    for (i = s.length() - 2; i > 0; i -= 2) {
//      System.out.println(i);
      String a = s.substring(0, i / 2);
      String b = s.substring(i / 2, i);
//      System.out.println(a);
//      System.out.println(b);
      if (a.equals(b)) {
        break;
      }
    }
    System.out.println(i);
  }
}

Measured memory_bytes: 21844
//#pragma comment(linker,"/STACK:102400000,102400000")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int>pii;
const int INF=0x3f3f3f3f;
#define _for(i, a, b) for (int i = (a); i < (b); ++i)
#define _rep(i, a, b) for (int i = (a); i <= b; ++i)
const int max_number=1000000;



int main()
{
    int a, b;
    cin >> a;
    b = a * a * a;
    cout << b<<endl;
    return 0;
}


Measured memory_bytes: 3056
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <climits>
#include <string.h>
#include <algorithm>

using namespace std;
#define fast ios::sync_with_stdio(false);cin.tie(0); cout.tie(0)
#define pb push_back
#define sz(s) (int)s.size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int N = (int) 3e5 + 77;

int main(){
    ll h,w,ans=1e18;
    cin>>h>>w;
    
    ll a[3],x;
    
    for1(i,h-2){
        a[0] = i*w;
        x=(h-i)/2;
        a[1] = x*w;
        if((h-i)%2) x++;
        a[2] = x*w;
        
        sort(a,a+3);
        ans = min(ans,a[2] - a[0]);
    }
    
    for1(i,w-2){
        a[0] = i*h;
        x=(w-i)/2;
        a[1] = x*h;
        if((w-i)%2) x++;
        a[2] = x*h;
        
        sort(a,a+3);
        ans = min(ans,a[2] - a[0]);
    }
    
    for1(i,h-1){
        a[0] = i*w;
        x=w/2;
        a[1] = x*(h-i);
        if(w%2) x++;
        a[2] = x*(h-i);
        
        sort(a,a+3);
        ans = min(ans,a[2] - a[0]);
    }
    
    for1(i,w-1){
        a[0] = i*h;
        x=h/2;
        a[1] = x*(w-i);
        if(h%2) x++;
        a[2] = x*(w-i);
        
        sort(a,a+3);
        ans = min(ans,a[2] - a[0]);
    }
    
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
// https://ynucpc.github.io/blog/2018/04/15/cp_vscode/
// http://www.atmarkit.co.jp/ait/articles/1509/08/news019.html

#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i,n) for(ll i=1;i<=(ll)(n);i++)
#define rep3(i,n,m) for(ll i=(n);i<(ll)(m);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
// #define max(a, b) ((a) > (b) ? (a) : (b))
// #define min(a, b) ((a) < (b) ? (a) : (b)) 
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
int _stoi(string s, int tmp=10){
	istringstream stm(s);
	int res;
	stm >> res;
	return res;
}
double _stod(string s, int tmp=10){
	istringstream stm(s);
	double res;
	stm >> res;
	return res;
}
template<typename T>string to_string(const T& n){
	std::ostringstream stm;
	stm << n;
	return stm.str();
}

// 降順ソート: sort(A, A+N, greater<>());
// min: *min_element(A, A+N)
// argmin: min_element(A, A+N)-A

ll gcd(ll a, ll b){
	if (a==0){
		return b;
	}else{
		return gcd(b%a, a);
	}
}


int main(){	
	// ll A; cin >> A;
	// cout << "hello" << _stoi("14") << max({1,3}) << endl;
	ll N;
	cin >> N;
	double ans=0.0;
	rep(i, N){
		double x;
		string u;
		cin >> x >> u;
		if (u=="JPY")ans += x;
		else ans += x * 380000;
	}
	cout << ans << endl;


}








Measured memory_bytes: 256
#include <bits/stdc++.h>
const int N = 2e5+10;
const int M =1e9+7;
#define int long long int
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define MAX 1e15+1
#define pi  pair<int,int>




int a[4];

signed main(){
    fast;

    int n,k,x,y;
    cin>>n>>k;
    
   a[n]=1;
   a[k]=1;
   for(int i=1;i<=3;i++)
    if(a[i]==0)cout<<i;


  return 0;



    
 
    
 
 
}



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

using namespace std;

using ll = long long;

int main() {
    int X, Y, A, B, C;
    cin >> X >> Y >> A >> B >> C;
    vector<ll> reds(A);
    vector<ll> greens(B);
    vector<ll> anys(C);
    ll sum = 0;
    for (auto& x : reds) {
        cin >> x;
        sum += x;
    }
    for (auto& x : greens) {
        cin >> x;
        sum += x;
    }
    for (auto& x : anys)
        cin >> x;
    sort(reds.begin(), reds.end());
    sort(greens.begin(), greens.end());

    sort(anys.begin(), anys.end(), greater<int>());
    int a = 0;
    for (; a < A - X; a++)
        sum -= reds[a];
    int b = 0;
    for (; b < B - Y; b++)
        sum -= greens[b];
    ll ans = sum;
    for (int c = 0; c < min(C, X + Y); c++) {
        sum += anys[c];
        if (b == B || a < A && reds[a] < greens[b]) {
            sum -= reds[a++];
        } else {
            sum -= greens[b++];
        }
        ans = max(ans, sum);
    }
    cout << ans << endl;
}


Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#include <cassert>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) (int)(x).size()
using namespace std;
using ll = long long;
constexpr ll INF = 3000000000000000000;

int main() {
    int N;
    ll x;
    cin >> N >> x;
    vector<ll> a(N);
    REP(i, N) cin >> a[i];
    
    ll ans = INF;
    auto b = a;
    REP(i, N) {
        ll sum = 0;
        REP(j, N) sum += b[j];
        ans = min(ans, sum + x * i);
        REP(j, N) {
            if (j - i - 1 < 0) b[j] = min(b[j], a[j - i - 1 + N]);
            else b[j] = min(b[j], a[j - i - 1]);
        }
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3680
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include <iostream>
using namespace __gnu_pbds;
using namespace std;


typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update>
    ordered_set;
/*
ordered_set(both these operations in log)
1. find_by_order : it returns iterator to the ith largest element.
2. order_of_key  : The number of items in a set that are strictly smaller than k.
*/

//memset(dp,-1,sizeof(dp));
//fill(v.begin(), v.end(), -1);
//priority_queue< pii, vector <pii> , greater<pii>> pq;
//vector<int> dist(V, INF);


#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));
#define lb lower_bound
#define ub upper_bound

#define pb(x)               push_back(x)
#define mp(x,y)             make_pair(x,y)
#define pii                 pair<int,int>
#define vi                  vector<int>
#define vii                 vector<pii>
#define mi                  map<int,int>
#define mii                 map<pii,int>
#define all(a)              (a).begin(),(a).end()
#define fi                  first
#define se                  second
#define sz(x)               (int)x.size()
#define endl                '\n'
#define md                  1000000007
#define rep(i,a,b)          for(int i=a;i<b;i++)
#define pcout(x)	          cout<<fixed<<setprecision(x)
#define debug(x)            cout<<#x<<"::"<<x<<endl;
#define debug2(x,y)         cout<<#x<<"::"<<x<<"\t"<<#y<<"::"<<y<<endl;
#define boost               ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)



typedef long long ll;
typedef double ld;

inline ll prodm(ll a,ll b)  {return ((a%md)*(b%md))%md;}
inline ll summ(ll a,ll b)   {return ((a%md)+(b%md))%md;}
inline bool ispow2(ll x)    {return  x && (!(x&(x-1)));}

const int N = 1e5 + 5;
const ll  infl=0x3f3f3f3f3f3f3f3fLL;
const int infi=0x3f3f3f3f;

/**************************BounceBackBolt*********************************/
ll fastexpo(ll n,ll pwr)
{
  if(pwr==0)
    return 1;
  if(pwr==1)
    return n;
  ll ans=fastexpo(n,pwr/2);
  ans=prodm(ans,ans);
  if(pwr&1)
  {
      ans=prodm(ans,n);
  }
    return ans;
}

ll modInverse(ll base)
{return fastexpo(base,md-2);}


vector < int > g[N];
int d[N];
void dfs(int v, int p, int dd){
    d[v] = dd;
    for(int to : g[v]){
        if(to == p) continue;
        dfs(to, v, dd + 1);
    }
}

/*********************************************************************/
int main()
{
  boost;
  int T;
  T=1;
  while(T--)
  {
    int n;
    cin>>n;
    string s = to_string(n);
    if(s[0]=='7'||s[1]=='7'||s[2]=='7')
    cout<<"Yes";
    else
    cout<<"No";

  }
  return 0;
}


Measured memory_bytes: 6064
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;



int main(int argc, char* argv[]) {
  int H, W, N;
  cin >> H >> W >> N;

  vector<int> a(N);
  for (int i = 0; i < N; ++i) {
    cin >> a[i];
  }

  int m[H][W];
  int x = 0;
  int y = 0;
  bool forward = true;
  for (int i = 0; i < a.size(); ++i) {
    for (int j = 0; j < a[i]; ++j) {
      m[y][x] = i + 1;
      if (forward)
        ++x;
      else
        --x;
      if (forward && x == W) {
        forward = false;
        x = W - 1;
        ++y;
      } else if (!forward && x == -1) {
        forward = true;
        x = 0;
        ++y;
      }
    }
  }

  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      if (j > 0)
        cout << " ";
      cout << m[i][j];
    }
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 384
// template
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(size_t i = 0; i < (n); ++i)

int main()
{
    ll N;
    cin >> N;
    ll ans = 0;
    for (ll A = 1; A <= N; ++A)
    {
        for (ll B = 1; A * B <= N; ++B)
        {
            ll C = N - A * B;
            if (C > 0) ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
    int n;cin>>n;
    vector<int> edge(n);
    int sum = 0;
    for(int i=0; i<n; i++) {
        cin>>edge[i];
        sum += edge[i];
    }
    for (int i=0; i<n; i++){
            if(edge[i]*2 >= sum){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<stdlib.h>
#include<stack>
#include<vector>
#include<algorithm>

using namespace std;

typedef pair<int, int> P;

int main() {
    stack<int> stack1;
    stack<P> stack2;

    int step = 0;
    int sum = 0;
    int num = 0;
    char c;
    while (cin >> c) {
        ++step;
        if (c == '\\') {
            stack1.push(step);
        }
        else if (c == '/') {
            if (stack1.empty()) {
                continue;
            }
            int a = stack1.top();
            stack1.pop();

            int s = step - a;
            sum += s;

            if (stack2.empty()) {
                stack2.push(make_pair(a, s));
                continue;
            }

            while (!stack2.empty() && stack2.top().first > a) {
                s += stack2.top().second;
                stack2.pop();
            }
            stack2.push(make_pair(a, s));
        }
    }

    printf("%d\n", sum);

    vector<int> ans;
    while (stack2.size()) {
        ans.push_back(stack2.top().second);
        stack2.pop();
    }
    reverse(ans.begin(), ans.end());

    printf("%d", static_cast<int>(ans.size()));

    vector<int>::const_iterator itr = ans.begin();
    vector<int>::const_iterator end = ans.end();
    for (; itr != end; ++itr) {
        printf(" ");
        printf("%d", *itr);
    }
    printf("\n");

    return 0;
}

Measured memory_bytes: 3316
import java.util.Scanner;
class Main{
    public static void main(String args[]){
        Scanner scan = new Scanner(System.in);
        String a = scan.next();
        if(a.equals("ABC")){
            System.out.println("ARC");
        }
        if(a.equals("ARC")){
            System.out.println("ABC");
        }
    }

}

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

using namespace std;

typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(0);
    int n, k; cin >> n >> k;
    int ans = 0;
    int now = 1;
    while (n > 0 && now * 2 <= now + k)
    {
        now *= 2;
        n--;
    }
    while (n > 0 && now + k <= now * 2)
    {
        now += k;
        n--;
    }
    cout << now << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))

b = []

for i in range(n):
    b.append([i+1,a[i]])

b = sorted(b, key=lambda x: x[1])

ans = ""
for i in range(n):
    ans += str(b[i][0])
    if i != n-1:
        ans += " "
print(ans)

Measured memory_bytes: 23040
#include<iostream>
#include<map>
#include<set>
#include<unordered_set>
#include<unordered_map>
#include<vector>
#include<cstring>
#include<sstream>
#include<algorithm>
//#include<bits/stdc++.h>
using namespace std;

#define MOD 1000000007

long long power(long long n, long long k) {
    if (k == 0) return 1ll;
    else if (k == 1) return n;

    long long p = power(n, k/2)%MOD;
    p = (p*p)%MOD;

    if (k%2 == 0) return p;
    else return (p*n)%MOD;
}

long long C(long long n, long long k) {
    long long res = 1;
    for (int i = n; i > n-k; i--) {
        res *= i;
        res %= MOD;
    }

    for (int i = 1; i <= k; i++) {
        res = (res+MOD) * power(i, MOD-2)%MOD;
        res %= MOD;
    }

    return res;
}

int main() {
    long long k;
    cin >> k;
    string s;
    cin >> s;

    long long n = s.size();


    long long comb = C(n+k, n-1)%MOD;

    long long res = 0;
    for (int i = n; i <= n+k; i++) {
        comb = comb*(n+k-i+1)%MOD;
        comb = comb*power(i, MOD-2)%MOD;
        comb %= MOD;


        res += (comb*power(25, n+k-i))%MOD;
        res %= MOD;
    }
    
    cout << res << endl;

}


Measured memory_bytes: 4424
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------

int main(void){
    string s, t;
    int a, b;
    string u;
    cin >> s >> t >> a >> b >> u;

    if(s == u){
        cout << a - 1 << " " << b << endl;
    } else if(t == u){
        cout << a << " " << b - 1 << endl;
    } else {
        cout << a << " " << b << endl;
    }
}

Measured memory_bytes: 256
while True:
    l = list(input().split())
    a = int(l[0])
    op = l[1]
    b = int(l[2])
    
    if op == "?":
        break
    
    if op == "+":
        print(a + b)
    elif op == "-":
        print(a - b)
    elif op == "*":
        print(a * b)
    elif op == "/":
        print(a // b)

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

int main(void) {
	char S[5], T[5];
	int i,count=0;
	for (i = 0; i < 3; i++) {
		scanf("%c\n", &S[i]);
	}
	for (i = 0; i < 3; i++) {
		scanf("%c", &T[i]);
	}
	for (i = 0; i < 3; i++) {
		if (S[i] == T[i]) {
			count++;
		}
	}
	printf("%d",count );
}


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

int k, s;
int ta = 0;

int main(){
	cin >> k >> s;
	for (int i = 0; i <= k; i++) {
		for (int j = 0; j <= k; j++) {
			if (s - i - j >= 0 && s - i - j <= k) {
				ta++;
			}
		}
	}
	cout << ta << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

typedef long long ll;

int main(int argc, char const *argv[])
{
    int n;
    vector<string> svec;
    map<string, ll> mp;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        string s;
        cin >> s;
        sort(s.begin(), s.end());
        svec.emplace_back(s);
        mp[s]++;
    }
    ll ans = 0;

    for (int i = 0; i < n; ++i) {
        string s = svec[i];
        mp[s]--;
        ans += mp[s];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 18676
import java.util.*
import kotlin.math.*

fun main() {
    val n = readInt()
    val a = readIntList()

    val sum = a.fold(0L) { acc, e -> acc + e }
    var ans = Long.MAX_VALUE

    var sun = 0L
    for (i in 0 until n - 1) {
        sun += a[i]
        ans = min(ans, abs(sum - sun - sun))
    }
    println(ans)
}


fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)

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


int main(){
  int n;
  int k;
  cin >> n >> k;
  int ans=0;
  int d;
  map<int,int> tisa;
  for(int i=0; i<k; i++){
    cin >> d;
    vector<int> a(d);
    for(int j=0; j<d; j++){
      cin >> a.at(j);
      if(!tisa.count(a.at(j))){
        tisa[a.at(j)]=1;
        ans++;
      }
    }
  }
  
  cout << n-ans << endl;
}


Measured memory_bytes: 3632
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;

int main()
{
	char aho[1200];
	int len;

	cin >> aho;
	len = strlen(aho);
	for (int i = 0; i < len; i++)
	{
		if (aho[i] == 'B')
		{
			aho[i] = 'Y';
		}
		else if (aho[i] == 'A')
		{
			aho[i] = 'X';
		}
		else if (aho[i] == 'C')
		{
			aho[i] = 'Z';
		}else aho[i] -= 3;
	}
	cout << aho << endl;
	int k;
	cin >> k;
	return 0;
}

Measured memory_bytes: 1144
#include<stdio.h>
int main(void){
    int A,B;
    int x,y,r;
    scanf("%d%d%d%d%d",&A,&B,&x,&y,&r);
    if((0<=x-r)&&(x+r<=A)&&(0<=y-r)&&(y+r<=B)){
        printf("Yes\n");
    }
    else    printf("No\n");
    return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

	int n, T;
	cin >> n >> T;

	int INF = 1001;
	int cost = INF;
	rep(i, n){
		int c, t;
		cin >> c >> t;

		if(t <= T) cost = min(cost, c);
	}

	if(cost == INF){
		cout << "TLE" << endl;
	}else{
		cout << cost << endl;
	}
}


Measured memory_bytes: 384
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc =new Scanner(System.in);
  String s = sc.next();
  int A = Integer.valueOf(s.charAt(0)-'0');
  int B = Integer.valueOf(s.charAt(1)-'0');
  int C = Integer.valueOf(s.charAt(2)-'0');
  int D = Integer.valueOf(s.charAt(3)-'0');
  int e = 0,f = 0,g = 0,h = 0;
  out:
  for(int i = 0;i<2;i++){
    for(int j = 0;j < 2;j++){
      for(int k = 0;k < 2;k++){
        for(int l = 0;l < 2;l++){
          if(Math.pow(-1,i)*A + Math.pow(-1,j)*B + Math.pow(-1,k)*C + Math.pow(-1,l)*D == 7){
            e=i;f=j;g=k;h=l;
            break out;
          }
        }
      }
    }
  }
  System.out.print(e == 0 ? "":"-");
  System.out.print(A);
  System.out.print(f == 0 ? "+":"-");
  System.out.print(B);
  System.out.print(g == 0 ? "+":"-");
  System.out.print(C);
  System.out.print(h == 0 ? "+":"-");
  System.out.print(D);
  System.out.println("=7");
}}

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

int main(){
  string s; cin>>s;
  vector<int>v(4);
  for(int i=0; i<4; i++) v[i] = s[i] - '0';

  rep(bit, 1<<3){
    int sum = v[0];
    rep (i,3){
      if (bit & (1<<i)) sum += v[i+1];
      else sum -= v[i+1];
    }
    if (sum==7){
      rep(i,4){
        cout << v[i];
        if (i!=3){
          if (bit & (1<<i)) cout << "+";
          else cout << "-";
        }
      }
      cout << "=7" << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 1e2+10;
const int M = 1e5+10; 
const int INF = 2e9;
int v[N],w[N];
ll dp[N][M];
int main()
{
	int n, W;
	cin >> n >> W;
	for(int i=1;i<=n;i++)
	{
		cin >> w[i] >> v[i];
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=W;j++)
		{
			if(w[i]<=j)
			{
				dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i]]+v[i]);
			}
			else
			{
				dp[i][j]=dp[i-1][j];
			}
		}
	}
	cout<<dp[n][W];
	return 0;
}

Measured memory_bytes: 79360
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
	public class Program
	{
		public static void Main()
		{
			var nk = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();
			var n = nk[0];
			var k = nk[1];

			var hList = new List<int>();

			for(int i = 0; i < n; i++) {
				hList.Add(int.Parse(Console.ReadLine()));
			}

			hList.Sort();

			var hDif = int.MaxValue;

			for(int i = 0; i < n - (k - 1); i++) {
				var hmax = hList[i];
				var hmin = hList[i + (k - 1)];

				var dif = Math.Abs(hmax - hmin);
				if(dif < hDif) {
					hDif = dif;
				}

				if(hDif == 0) {
					break;
				}
			}

			Console.WriteLine(hDif);
		}
	}
}


Measured memory_bytes: 16224
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
int main(){ 
    string s;
  cin>>s;
    sort(s.begin(),s.end());
    REP(i,s.size()-1){
        if(s[i]==s[i+1]){
            cout<<"no";
            return 0;
        }
    }
    cout<<"yes";
    return 0;
}


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

#define _USE_MATH_DEFINES
#define reb(i,b,n)         for(int i=(int)(b); i<(int)(n); i++)
#define rep(i,n)           reb(i,0,n)
#define each(it,v)         for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define reach(it,v)        for(__typeof((v).rbegin()) it=(v).rbegin();it!=(v).rend();it++)
#define vsort(v)           sort((x).begin(), (x).end()
#define rvsort(v)          sort((x).rbegin(), (x).rend()
#define mp(a, b)           make_pair(a, b)
#define fi                 first
#define se                 second
#define pb                 push_back
#define dbg(x)             cerr<<__LINE__<<": "<<#x<<" = ["<<(x)<<"]"<<endl;
#define dbgArr(table, n)   rep(i,n){cout<<table[i]<<' ';}cout<<'\n';
#define dbg2Arr(table,W,H) rep(y,H){rep(x,W)cout<<table[y][x]<<' ';cout<<'\n';}

using namespace std; using std::stringstream;

typedef long long       ll; typedef unsigned long long ull; typedef long double     ld;
typedef pair <int, int> P;  typedef pair <int, P>      PP;
typedef vector<int>     vi; typedef vector<vi>         vvi; typedef vector<ll>      vl;
typedef vector<P >      vP; typedef vector<char>       vc;  typedef vector<string>  vs;

static const int    INF  = 0x3f3f3f3f;
static const ll     INFL = 0x3f3f3f3f3f3f3f3fLL;
static const double EPS  = 1e-9;
static const ll     MOD  = 1000000007LL;

static const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

int main(int argc, char *argv[])
{
    int x;
    int cnt=0;
    rep(i, 5) {
        cnt++;
        cin >> x;
        if (x == 0) {
            cout << cnt << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3632