akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<bitset>
#include<math.h>
#include<stack>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef long double db;
typedef vector<int> vi;
typedef pair<int,int> pii;
const int N=5000+100;
const db pi=acos(-1.0);
#define lowbit(x) ((x)&(-x))
#define sqr(x) (x)*(x)
#define rep(i,a,b) for (register int i=a;i<=b;i++)
#define per(i,a,b) for (register int i=a;i>=b;i--)
#define go(u,i) for (register int i=head[u],v=sq[i].to;i;i=sq[i].nxt,v=sq[i].to)
#define fir first
#define sec second
#define mkp make_pair
#define pb push_back
#define maxd 1000000007
#define eps 1e-8
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

inline ll readll()
{
    ll x=0;int f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

namespace My_Math{
    #define N 100000

    int fac[N+100],invfac[N+100];

    int add(int x,int y) {return x+y>=maxd?x+y-maxd:x+y;}
    int dec(int x,int y) {return x<y?x-y+maxd:x-y;}
    int mul(int x,int y) {return 1ll*x*y%maxd;}
    ll qpow(ll x,int y)
    {
        ll ans=1;
        while (y)
        {
            if (y&1) ans=mul(ans,x);
            x=mul(x,x);y>>=1;
        }
        return ans;
    }
    int getinv(int x) {return qpow(x,maxd-2);}

    int C(int n,int m)
    {
        if ((n<m) || (n<0) || (m<0)) return 0;
        return mul(mul(fac[n],invfac[m]),invfac[n-m]);
    }

    void math_init()
    {
        fac[0]=invfac[0]=1;
        rep(i,1,N) fac[i]=mul(fac[i-1],i);
        invfac[N]=getinv(fac[N]);
        per(i,N-1,1) invfac[i]=mul(invfac[i+1],i+1);
    }
    #undef N
}
using namespace My_Math;

int n,m,f[N][N];

int main()
{
    n=read();m=read();
    rep(i,1,m) f[0][i]=1;
    rep(i,1,n)
    {
        int sum=0;
        rep(j,1,m)
        {
            f[i][j]=add(sum,mul(j+1,f[i-1][j]));
            sum=add(mul(sum,2),mul(f[i-1][j],j));
        }
    }
    printf("%d",f[n][m]);
    return 0;
}

Measured memory_bytes: 103232
N = int(input())
A = list(map(int, input().split()))

accSum = [0]*N
accSum[0] = A[0]
for i in range(1, N):
    accSum[i] = accSum[i-1] + A[i]
S = sum(A)

ans = 0

for i in range(N):
    ans += A[i] * (S - accSum[i]) % (10**9+7)
ans = ans % (10**9+7)
print(ans)


Measured memory_bytes: 94016
use std::io::*;
use std::str::FromStr;

pub fn read<t: FromStr>() -> t {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

use std::cmp::max;

fn main() {
    let a: usize = read();
    let b: usize = read();
    let c: usize = read();
    let k: usize = read();
    let maxv = max(a, max(b, c));

    let mut ans = a + b + c;
    let mut kmaxv = maxv;
    let mut cnt = 0;

    while cnt < k {
        cnt += 1;
        kmaxv *= 2;
    }
    ans += kmaxv;
    println!("{}", ans - maxv);
}


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

int main(void){
    ll n, k;
    ll s;
    cin>>n>>k>>s;
    if(s==1e9){
        rep(i, k) cout<<s<<" ";
        rep(i, n-k) cout<<s-1<<" ";
        cout<<endl;
    }
    else{
        rep(i, k) cout<<s<<" ";
        rep(i, n-k) cout<<s+1<<" ";
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 1280
#include <stdio.h>

int main(void){
    int num;

    scanf("%d", &num);
    if(num/100==7){
        printf("Yes");
    }else if((num/10-num/100*10)==7){
        printf("Yes");
    }else if(num-(num/10-num/100*10)*10-num/100*100==7){
        printf("Yes");
    }else{
        printf("No");
    }
}

Measured memory_bytes: 1732
#include<iostream>
#include<string>
using namespace std;
int main(){
  int N,K;
  cin >> N >> K;
  int A[110]={0};
  for(int d=0;d<K;d++){
    int i;
    cin >> i;
    for(int j=0;j<i;j++){
      int m;
      cin >> m;
      A[m-1]++;
    }
  }
  int count=0;
  for(int k=0;k<N;k++){
    if(A[k]==0)count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <algorithm>
#include <utility> 
#include <unordered_set>
#include <vector>
#include <list> 
#include <string>
#include <iterator> 
#include <deque>
#include <array>
#include <forward_list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <climits>
#include <bitset>
using namespace std;

#define N 6
#define EPS 1e-9


int g[N][N];
int n, m, k;

int solve() {
	int sol = 0;
	int blk;
	for (int i = 0; i <= (1 << n) - 1; ++i) {
		for (int j = 0; j <= (1 << m) - 1; ++j) {
			blk = 0;
			for (int r = 0; r < n; ++r) {
				if ((1 << r) & i) continue;
				
				for (int c = 0; c < m; ++c) {
					if ((1 << c) & j) continue;
					blk += g[r][c];
				}
			}
			if (blk == k)
				++sol;
		}
	}

	return sol;
}
	
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	string ins;
	cin >> n >> m >> k;
	for (int i = 0; i < n; ++i) {
		cin >> ins;
		for (int j = 0; j < m; ++j)
			g[i][j] = (ins[j] == '#' ? 1 : 0);
	}
	
	cout << solve() << '\n';

}


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

#define REP(i, n, m) for(int i = n; i < m; i++)
#define REPR(i, n, m) for(int i = n; i >= m; i--)
#define LREP(i, n, m) for(ll i = n; i < m; i++)
#define LREPR(i, n, m) for(ll i = n; i >= m; i--)

//#define INF 1e9 + 1
//#define MOD 1e9 + 7


typedef long long ll;


//functions 
int gcd(int a, int b){
    if(a < b) swap(a, b);
    return b?gcd(b, a%b):a;
}

int s2i(string num){stringstream ss; ss << num << flush; int n; ss >> n; return n;}
string i2s(int n){stringstream ss; ss << n << flush; return ss.str();}

int  N;
int ans[1001];
int main(){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);

    cin >> N;
    int res, idx;
    idx = 0;
    do{
        res = abs(N) % 2;
        ans[idx] = res;
        N = (N - res) / (-2);
        idx += 1;
    }while(N != 0);

    REPR(i, idx - 1, 0) cout << ans[i];
    cout << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;

int main(){
  vector<vector<int> > a(3, vector<int>(3));
  rep(i, 3) rep(j, 3) cin >> a[i][j];
  int n;
  cin >> n;
  vector<int> b(n);
  rep(i, n) {
    int b;
    cin >> b;
    rep(i, 3){
      rep(j, 3){
        if(a[i][j] == b) a[i][j] = -1;
      }
    }
  }
  bool ans = false;
  rep(i, 3){
    if(a[i][0] == -1 && a[i][1] == -1 && a[i][2] == -1) ans=true;
  }
  rep(i, 3){
    if(a[0][i] == -1 && a[1][i] == -1 && a[2][i] == -1) ans=true;
  }
  if(a[0][0] == -1 && a[1][1] == -1 && a[2][2] == -1) ans = true;
  if(a[0][2] == -1 && a[1][1]== -1 && a[2][0] == -1) ans = true;
  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;
  
}

Measured memory_bytes: 256
N, K = map(int, input().split())
A = list(map(int, input().split()))
graph = [set() for i in range(N)]
for i, a in enumerate(A):
    graph[i].add(a - 1)

queue = [0]
seen = {0}
path = []
while queue:
    new = []
    for cur in queue:
        path.append(cur)
        for nei in graph[cur]:
            if nei not in seen:
                new.append(nei)
                seen.add(nei)
    queue = new

if 0 in graph[path[-1]]:
    rest = K % len(path)
    print(path[rest] + 1)
else:
    if K < len(path):
        print(path[K] + 1)
    else:
        start = graph[path[-1]].pop()
        index = path.index(start)
        rest = (K - len(path[:index])) % len(path[index:])
        print(path[index:][rest] + 1)

Measured memory_bytes: 83840
#include <vector>
#include <iostream>
using namespace std;
vector<vector<char>> Sdata;
int H, W, K;

int MaxVerticalBar (int offset, vector<int> RegionEdge, int BarNumber)
{
	int MAX = offset;
	vector<int> Chocolates (BarNumber+1, 0);
	int ChocoEnd = 0;		

	for (MAX = offset; MAX < W; MAX++)
	{
		for (int i = 0; i <= BarNumber; i++)
			for (int i2 = RegionEdge[i]; i2 < RegionEdge [i+1]; i2++)
			{	
				Chocolates [i] += (int) (Sdata [i2] [MAX] - '0');
				if (Chocolates [i] > K)
				{
					if (MAX != 0)
						return MAX-1;
					else
						return 0;
				}
			}
	}
	return MAX;
};

int main(void)
{
    cin >> H >> W >> K;
    Sdata.resize (H);
    for (auto& e: Sdata)
    {
    	e.resize (W);
    	for (auto& e2: e)
 			cin >> e2;
 	}

	int BarNumber = 0;
	vector<int> RegionEdge (H+1, 0);
	int WorldRecord = H + W;
	for (int UnderBar = 0; UnderBar < (1 << (H-1)); UnderBar++)
	{
		BarNumber = 0;
		for (int i = 0; i < H; i++)
		{
			if (((UnderBar >> i) & 1) != 0)
			{
				RegionEdge [BarNumber+1] = i+1;
				BarNumber++;
			}
		}
		RegionEdge [BarNumber+1] = H;

		if (BarNumber < WorldRecord)
        {
          int answer = BarNumber;
		  for (int offset = 0; offset < W; offset++)
		  {
			  int VerticalBar;
			  VerticalBar = MaxVerticalBar (offset, RegionEdge, BarNumber);
			  if (VerticalBar != W)
			    answer++;
			  if (WorldRecord <= answer)
			    break;
			  offset = VerticalBar;
		  }
		  WorldRecord = answer;
		}
	}
	
	cout << WorldRecord << endl;
}


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

using namespace std;

int main()
{
    int nr=0,a;
    int n;
    cin>>n;

    for(int i=1;i<=n;i++)
    {
        cin>>a;
        while(a%2==0)
        {
            a=a/2;
            nr++;
        }
    }
    cout<<nr<<"\n";
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections
from decimal import Decimal # 10進数で考慮できる

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

S = str(input())
T = str(input())

cnt = 0
for i in range(len(S)):
    if S[i] != T[i]:
        cnt += 1

print(cnt)

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int ans[256]={};
    const int MX=1201;
    //char s[MX]={};
    //cin.getline(s,sizeof(s));
    bool flg=true;
    while(true){
        flg=true;
        char s[MX]={};
        cin.getline(s,sizeof(s));
        REP(i,MX){
            if(s[i]<65 || s[i]>122) continue;
            flg = false;
            if((int)s[i]-(int)'a' < 0)
                ans[s[i]+32]++;
            else
                ans[s[i]]++;
        }
        if(flg) break;
    }

    FOR(i,97,122+1){
        cout << (char)i << " : " << ans[i] << endl;
    }
    
    return 0;
}


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

int main() {
    string s;
    cin >> s;
    int fst, lst;
    fst = s.find('A');
    reverse(s.begin(), s.end());
    lst = s.find('Z');
    cout << s.size() - lst - fst << endl;
}


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

typedef pair<int, int> pii;
typedef long long ll;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

#ifdef LOCAL
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else 
#define dump(x) true
#endif

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U> void chmin(T& t, const U& u) { if (t > u) t = u; }
template<class T, class U> void chmax(T& t, const U& u) { if (t < u) t = u; }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

const int INF = TEN(9) + 10;

int main() {
	int N; cin >> N;
	V<pii> vec(N);
	int L = -INF, R = INF;

	int ml = -1;

	rep(i, N) {
		int x, y; cin >> x >> y;
		++y;
		vec[i] = mp(x, y);
		chmax(L, x);
		chmin(R, y);
		chmax(ml, y - x);
	}

	int ans = ml + max(R - L, 0);
	dump(ans);

	V<pii> v;
	rep(i, N) v.eb(max(vec[i].se - L, 0), -max(R - vec[i].fi, 0));
	sort(ALL(v));

	int mini = INF;
	rep(i, N) {
		if (mini != INF) {
			chmax(ans, mini + v[i].fi);
		}
		chmin(mini, -v[i].se);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2168
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let k: u64 = read();

    if k % 5 == 0 || k % 2 == 0 {
        print!("{}", -1);
        return;
    }
    let l;
    if k % 7 == 0 {
        l = 9 * (k / 7);
    } else {
        l = 9 * k;
    }
    let mut modulo = 10;
    let mut counter = 1;
    loop {
        modulo %= l;
        if modulo == 1 {
            break;
        }
        modulo *= 10;
        counter += 1;
    }
    print!("{}", counter);
}


Measured memory_bytes: 2144
#include<bits/stdc++.h>
#define int long long
#define ll long long
inline int read(){
	char c=getchar();while (c!='-'&&(c<'0'||c>'9'))c=getchar();
	int k=1,kk=0;if (c=='-')c=getchar(),k=-1;
	while (c>='0'&&c<='9')kk=kk*10+c-'0',c=getchar();return kk*k;
}using namespace std;
void write(int x){if (x<0)putchar('-'),x=-x;if (x/10)write(x/10);putchar(x%10+'0');}
void writeln(int x){write(x);puts("");}
ll n,ans,sum;
map<ll,ll> mp;
signed main(){
	n=read();mp[0]++;
	for (int i=1;i<=n;i++)sum+=read(),ans+=mp[sum],mp[sum]++;
	writeln(ans);
} 


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

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

    if(N%10 == 2||N%10 == 4||N%10 == 5||N%10 == 7 || N %10 == 9){
        cout << "hon" << endl;
    
    }

    else if(N%10 == 3){
        cout << "bon " << endl;
    }

    else {cout << "pon "<<endl;}
}

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

struct Card { char suit, value;};

void selection(struct Card A[], int n) {
   for(int i = 0; i < n; i++) {
	   int minj = i;
	   for(int j = i+1; j < n; j++) {
		   if(A[minj].value > A[j].value) minj = j;
	   }
	Card t = A[i]; A[i] = A[minj]; A[minj] = t;   
   }
}

void print(struct Card A[], int n) {
	for(int i = 0; i < n; i++) {
		if(i) cout << " ";
		cout << A[i].suit << A[i].value;
	} cout << endl;
}

void bubble(struct Card a[], int n) {
	for(int i = 0; i < n; i++) {
		for(int j = n-1; j >= i+1; j--) {
			if(a[j].value < a[j-1].value) {
				Card t = a[j]; a[j] = a[j-1]; a[j-1] = t;
			}
		}
	}
}

bool isStable(struct Card c1[], struct Card c2[], int n) {
	for(int i = 0; i < n; i++) {
		if(c1[i].suit != c2[i].suit) return false;
	}
	return true;
}

int main(void){
   Card c1[100], c2[100];
   int n;
   char ch;

   cin >> n;
   for(int i = 0; i < n; i++) {
	   cin >> c1[i].suit >> c1[i].value;
	   c2[i].suit = c1[i].suit;
	   c2[i].value = c1[i].value;
   }

   bubble(c1, n);
   selection(c2, n);
   print(c1, n);
   cout << "Stable" <<endl;
   print(c2, n);
   if( isStable(c1, c2, n) ) cout << "Stable" <<endl;
   else cout << "Not stable" <<endl;

   return 0;
}

Measured memory_bytes: 1156
#include <iostream>
#include <vector>
#include <utility>
using namespace std;



vector<bool> used;
vector<vector<int>> v;


bool dfs(int start_v,int now_v,int parent_v){
  if(now_v == start_v)return true;

  used[now_v] = true;

  for(int i = 0;i < v[now_v].size();i++){
    if(v[now_v][i] != parent_v && used[v[now_v][i]] == false && dfs(start_v,v[now_v][i],now_v))return true;
  }

  return false;
}



int main(){

  int N,M;
  cin >> N >> M;
  used.resize(N);
  v.resize(N);

  vector<pair<int,int>> e;

  for(int i = 0;i < M;i++){
    int a,b;
    cin >> a >> b;
    a--;
    b--;
    v[a].push_back(b);
    v[b].push_back(a);
    e.push_back(make_pair(a,b));
  }




  int ans = 0;

  for(int i = 0;i < M;i++){
    for(int j = 0;j < N;j++)used[j] = false;

    int a = e[i].first;
    int b = e[i].second;

    if(!(dfs(a,b,a)))ans++;
  }

  cout << ans << endl;

}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int max(int x, int y){return x<y?y:x;}
int main(void){
	int a,b,c,d;
	scanf("%d%d%d",&a,&b,&c);
	d = max(max(a*10+b+c,b*10+a+c),c*10+a+b);
	printf("%d",d);
	return 0;
}

Measured memory_bytes: 128
import sys
def MI(): return map(int,sys.stdin.readline().rstrip().split())

N,K = MI()

if K > ((N-1)*(N-2))//2:
    print(-1)
    exit()

print(N-1+((N-1)*(N-2))//2-K)

for i in range(2,N+1):
    print(1,i)

a = 0
for i in range(2,N):
    for j in range(i+1,N+1):
        if a < ((N-1)*(N-2))//2-K:
            print(i,j)
            a += 1


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

using namespace std;

typedef long long int LL;
typedef unsigned long long int ULL;
typedef pair<int, int> PII;
typedef map<int, int> MII;

const int SZ = 212345;
const int MOD = 1e9 + 7;

int n, k;
LL a[SZ];
double e[SZ];

int main() {
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; i++) {
    scanf("%d", a + i);
    e[i] = (a[i] + 1.) / 2.;
  }
  double ans = 0, s = 0;
  for (int i = 0; i < k; i++) {
    ans += e[i];
  }
  s = ans;
  for (int i = 0, j = k; j < n; i++, j++) {
    s = s - e[i] + e[j];
    ans = max(ans, s);
  }
  printf("%.10f\n", ans);
  return 0;
}


Measured memory_bytes: 3328
Var     n,kq,t: Longint;
        a: Array[0..1000005] Of Longint;

Procedure       Nhap;
Var     i: Longint;
Begin
Readln(n);
For i:=1 to n do
        Readln(a[i]);
End;

Procedure       XuLy;
Begin
t:=1; kq:=0;
Repeat
        Inc(kq);
        //If a[a[t]]=t Then Break;
        t:=a[t];
Until (t=2) or (kq>n+1);
End;

Procedure       Xuat;
Begin
If t<>2 Then Writeln(-1)
Else    Writeln(kq);
End;

Begin
Nhap;
XuLy;
Xuat;
End.

Measured memory_bytes: 512
memo=[0]*(10**6+1)
memo[0]=memo[1]=1
mod=10**9+7
for i in range(2,10**6+1):
  memo[i]=(memo[i-1]*i)%mod
def comb(n,k,p):
  return (memo[n]*pow(memo[k],p-2,p)*pow(memo[n-k],p-2,p))%mod
h,w,a,b=map(int,input().split())
ans=0
for i in range(h-a):
  ans+=(comb(b+i-1,i,mod)*comb(h-i-1+w-b-1,w-b-1,mod))%mod
  ans%=mod
print(ans)

Measured memory_bytes: 44660
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define tcase int _; cin >> _; while(_--)
const int MAX = 1e6;

int n, d;
int ans;

void solve() {
	ans = 0;
	cin >> n >> d;
	for(int i=0; i<n; i++) {
		int p, q;
		cin >> p >> q;
		if(p*p + q*q <= d*d) ans++;
	}
	cout << ans;
}

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

 	solve();

  	return 0;
}



Measured memory_bytes: 3644
n,ma,mb=map(int,input().split())
dp=[[[10**30 for j in range(401)]for i in range(401)]for k in range(n+1)]
dp[0][0][0]=0 
l=[]
for i in range(n):
    a,b,c=map(int,input().split())
    l.append([a,b,c])
for i in range(1,n+1):
    a,b,c=l[i-1][0],l[i-1][1],l[i-1][2]
    for x in range(401):
        for y in range(401):
            if x<a or y<b:
                dp[i][x][y]=dp[i-1][x][y]
                continue 
            dp[i][x][y]=min(dp[i-1][x][y],dp[i-1][x-a][y-b]+c)
            
mini=10**30 
for i in range(1,40):
    mini=min(mini,dp[n][ma*i][mb*i])
if mini>=10**30 :
    print(-1)
else:
    print(mini)

Measured memory_bytes: 100956
H, W = map(int, input().split())
A = [list(input()) for _ in range(H)]
tmp = []
for h in range(H):
    if set(A[h]) != {'.'}:
        tmp.append(A[h])
H = len(tmp)
ans = [[] for _ in range(H)]

for w in range(W):
    if set(tmp[h][w] for h in range(H)) != {'.'}:
        for h in range(H):
            ans[h].append(tmp[h][w])

for h in range(H):
    print(''.join(map(str, ans[h])))


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

#define loop(i, n) for(int i = 0;i < int(n);i++)
#define rloop(i, n) for(int i = int(n);i >= 0;i--)
#define range(i, a, b) for(int i = int(a);i <= int(b);i++)
#define sz(c) int(c.size())
#define clr(v, d)   memset(v, d, sizeof(v))
#define ALL(c) c.begin(), c.end()
#define RALL(c) c.rbegin(), c.rend()
#define PI acos(-1)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define INF             INT64_MAX
#define NINF            INT64_MIN
#define ROW 1001
#define COL 1001

typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<pll> vll;
typedef vector<ll> vl;


int main(void){
    vector<set<int>> alpha(26);
    int N;
    int l,r;
    string S;
    int q;
    cin>>N>>S>>q;

    loop(i,N)
    {
         alpha[S[i]-'a'].insert(i);
    }
    set<int>::iterator lf,rf;
    while(q--)
    {
        int cmd;
        cin>>cmd;
        if(cmd == 2)
        {
            int cnt = 0;
            cin>>l>>r;
            loop(i,26)
            {
                 if(cnt >= r-l+1)
                     break;
                 if(alpha[i].size()==0)
                     continue;
                 lf=alpha[i].lower_bound(l-1);
                 rf=alpha[i].lower_bound(r-1);


                 if(lf!=alpha[i].end() && ((*lf)>=(l-1)) &&((*lf)<=(r-1)))
                      cnt++;
                 else if((rf!=alpha[i].end()) &&((*rf)>=(l-1)) &&((*rf)<=(r-1)))
                     cnt++;
            }
            cout<<cnt<<endl;
        }
        else
        {
            char c;
            int idx;
            cin>>idx>>c;
            if(c == S[idx-1])
                continue;
            alpha[S[idx-1]-'a'].erase(alpha[S[idx-1]-'a'].find(idx-1));
            alpha[c-'a'].insert(idx-1);
            S[idx-1]=c;
        }
    }



    return 0;
}

Measured memory_bytes: 24196
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	bool th=false;
	int k=1;
	char s[1001];
	while((s[k]=getchar())!='\n')k++;k--;
	for(int i=1;i<=k;i++)
	{
		if(s[i]=='C')th=true;
		if(s[i]=='F'&&th)
		{
			cout<<"Yes\n";
			return 0;
		}
	}
	cout<<"No\n";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define input freopen("1.txt","r",stdin);
#define output freopen("output.txt","w",stdout);
#define ll long long int
#define pb push_back
#define ppb pop_back
#define eb emplace_back
#define vi vector<int>
#define vii vector<vi>
#define vl vector<ll>
#define vll vector<vl>
#define pii pair<int, int>
#define pll pair<ll,ll>
#define mp make_pair
#define vpi vector<pii>
#define vpl vector<pll> 
using namespace std;
 
const int p=1e9+7;
const int maxn=1e5+2;

void solve() {
    int N, W, w, v; cin>>N>>W;
    vpl pairs(N+1);
    for(int i=1;i<=N;i++) {
        cin>>w>>v;
        pairs[i] = {w,v};
    }
    sort(pairs.begin(), pairs.end());
    ll DP[N+1][W+1]; 
    for(int i=0; i<=N; i++) DP[i][0] = 0;
    for(int i=0; i<=W; i++) DP[0][i] = 0;
    for(int i=1; i<=N; i++) {
        for(int j=1; j<=W; j++) {
            if(pairs[i].first <= j) DP[i][j] = max(pairs[i].second + DP[i-1][j-pairs[i].first], DP[i-1][j]);
            else DP[i][j] = DP[i-1][j];
        }
    }
    cout<<DP[N][W]<<"\n";
}

int main() {
    fast 
    // input output
    int t=1; 
    // cin>>t; 
    while(t--) solve();
    return 0;
}

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

int main(){
    int n, m;
    cin >> n >> m;

    vector<long long int> div;
    for (long long int i=1; i*i<=m; i++){
        if (m % i == 0){
            div.push_back(i);

            long long int j = m / i;// counterpart
            if (j != i) div.push_back(j);
        }
    }
    sort(div.begin(), div.end());
    cout << m / *lower_bound(div.begin(), div.end(), n) << endl;
    return 0;
}

Measured memory_bytes: 256
#from collections import deque
#from heapq import heapify, heappop, heappush
#from bisect import insort
#from math import gcd
#mod = 10**9 + 7
N = int(input())
#N, K = map(int, input().split())
#A = list(map(int, input().split()))
flag1 = False
flag2 = False
flag3 = False
c, d = map(int, input().split())
if c == d:
	flag1 = True
c, d = map(int, input().split())
if c == d:
	flag2 = True
c, d = map(int, input().split())
if c == d:
	flag3 = True

k = 3
while k < N:
	if flag1 and flag2 and flag3:
		break
	k += 1
	c, d = map(int, input().split())
	flag1 = flag2
	flag2 = flag3
	if c == d:
		flag3 = True
	else:
		flag3 = False
		

#ans = 0
#print(ans)
#print('Yes')
if flag1 and flag2 and flag3:
	print('Yes')
else:
	print('No')

Measured memory_bytes: 9056
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

ll aaa(ll a) {
    ll count = 0;
    while (1) {
        if (a % 2) return count;
        else {
            a /= 2;
            count ++;
        }
    }
}

int main() {

    int n;
    cin >> n;

    ll a, cnt = 0;
    REP(i, n) {
        cin >> a;
        cnt += aaa(a);
    }

    cout << cnt << endl;

    return 0;
}

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

int main(){
  string s;
  cin >>s;
  s[5] = ' ';
  s[13] = ' ';
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque, defaultdict
#deque(l), pop(), append(x), popleft(), appendleft(x)
#q.rotate(n)で → にn回ローテート
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする
from functools import reduce,lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printe(*x):print("## ",*x,file=sys.stderr)
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reverse=True)  #二個目の要素で降順並び替え

    #N = int(input())
    N, M = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    S = list(list(map(int, input().split()))[1:] for i in range(M)) #改行行列
    ps = tuple(map(int, input().split()))
    #print(S)
    ans=0
    for i in range(2**N):
        cnt=0
        for j in range(M):
            p=ps[j]
            tot=0
            for s in S[j]:
                tot^=((i>>(s-1))&1)
            if tot==p:
                cnt+=1
        if cnt==M:
            ans+=1
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 73056
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <functional>
#include <iostream>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n,n_;
vector<int> v[2];
vector<int> ind;

int dat[1<<22];

void add(int k,int a){
	k+=n_-1;
	dat[k]+=a;
	while(k>0){
		k=(k-1)/2;
		dat[k]=dat[k*2+1]+dat[k*2+2];
	}
}

int query(int a,int b,int k=0,int l=0,int r=n_){
	if(r<=a || b<=l)return 0;
	if(a<=l && r<=b)return dat[k];
	int vl=query(a,b,k*2+1,l,(l+r)/2);
	int vr=query(a,b,k*2+2,(l+r)/2,r);
	return vl+vr;
}

int a[100005];

int main(void){
	scanf("%d",&n);
	n_=1;
	while(n_<n)n_*=2;
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
		v[i%2].push_back(a[i]);
		ind.push_back(a[i]);
	}
	sort(ind.begin(),ind.end());
	/*
	sort(v[0].begin(),v[0].end());
	sort(v[1].begin(),v[1].end());
	*/
	ll res=0;
	for(int i=0;i<n;i++){
		int ga=lower_bound(ind.begin(),ind.end(),a[i])-ind.begin();
		if((ga%2)!=(i%2))res++;
	}
	printf("%lld\n",res/2);
	return 0;
}


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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    ll x,y,z;cin >> x >> y >> z;
    rep(i,100010){
        if(x<y*i+z*i+z){
            out(i-1);
            break;
        }
    }
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;

const int MAX_N = 2005, MOD = 1000000007;

int N, M, K, f[MAX_N], g[MAX_N];

void update(int &x, int y) {
  x = (x + y) % MOD;
}

int main() {
  scanf("%d%d%d", &N, &M, &K);
  M--;
  
  int len = (N + M) / (K - 1), result = 0, sum = 0;
  f[0] = 1;
  
  for (int i = 1; i <= len; ++i) {
    memset(g, 0, sizeof g);
    sum += K - 1;
    
    for (int j = 0; j <= N; ++j) {
      for (int k = 0; k <= K - 1; ++k) {
	if (j + k <= N && sum - j - k <= M) {
	  update(g[j + k], f[j]);
	  if (k > 0 && (j + k) % (K - 1) == N % (K - 1) && (sum - j - k) % (K - 1) == M % (K - 1))
	    update(result, f[j]);
	}	  
      }
    }
    
    memcpy(f, g, sizeof g);
  }

  printf("%d\n", result);
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(N: int, A: int, B: int, C: int, D: int, E: int):
    R = [A, B, C, D, E]
    mn = min(R)
    ret = max(5, 5 + (N - 1) // mn)
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    E = int(next(tokens))  # type: int
    solve(N, A, B, C, D, E)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
unittest
{
	assert( [ "5", "1 2 1 3 7" ].parse.expand.solve == 3 );
	assert( [ "15", "1 3 5 2 1 3 2 8 8 6 2 6 11 1 1" ].parse.expand.solve == 7 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	input.popFront;
	auto as = input.front.split.to!( long[] );
	return tuple( as );
}

auto solve( long[] as )
{
	auto d = reduce!( ( a, b ) => a + b[ 1 ] - 1 )( 0L, as.sort().group );
	d += ( d % 2 == 1 );
	return as.length.signed - d;
}


Measured memory_bytes: 4284
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repp(i, m, n) for(int i = m; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define srep(i) for(int i = 0; i < s.size(); i++)
#define ll long long
#define ull unsigned long long
#define push(a) push_back(a)
#define pop(a) pop_back(a)
#define debug(x) cout << #x << ": " << x << endl
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 1e9
#define PI 3.14159265358979
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int N, W;
int w[105] = {}, v[105] = {};
ll dp[105][100005];

template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

ll all_search(int i, int j) {
    ll res = 0;
    if(i - 1 == N) {
        return 0;
    } else if(j < w[i]) {
        res = all_search(i + 1, j);
    } else {
        res = max(all_search(i + 1, j), all_search(i + 1, j - w[i]) + v[i]);
    }
    return res;
}

ll dp_recursive(int i, int j) {
    if(dp[i][j] != -1) {
        return dp[i][j];
    }

    ll res = 0;
    if(i - 1 == N) {
        return 0;
    } else if(j < w[i]) {
        res = dp_recursive(i + 1, j);
    } else {
        res = max(dp_recursive(i + 1, j), dp_recursive(i + 1, j - w[i]) + v[i]);
    }

    return dp[i][j] = res;
}

void dp_for(int N, int W) {

    for(int i = 0; i < N; i++)
        dp[i][0] = 0;
    for(int i = 0; i < W; i++)
        dp[0][i] = 0;

    for(int i = 0; i < N; i++) {
        for(int j = 0; j <= W; j++) {
            if(j < w[i]) {
                dp[i + 1][j] = dp[i][j];
            } else {
                dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i]);
            }
        }
    }
}

int main() {
    cin >> N >> W;
    rep(i, N) cin >> w[i] >> v[i];
    memset(dp, -1, sizeof(dp));
    cout << dp_recursive(0, W) << endl;
}


Measured memory_bytes: 82304
#include <iostream>
#define ARY_SIZE(array) (sizeof(array) / sizeof(array[0]))
using namespace std;
void swap(int* ogn,int* cpy) {
    int tmp = *ogn;
    *ogn = *cpy;
    *cpy = tmp;
}
void print(int* ary,size_t len) {
    for(size_t i=0;i < len;i++) {
        cout << ary[i];
        if(i==len-1)
            cout << "\n";
        else
            cout << " ";
    }
}
int main(void){
    /* initialize */
    int loop=0;
    cin >> loop;
    int iVal[loop];//input_value
    for(int i=0;i<loop;i++) {
        cin >> iVal[i];
    }
    /* logic phase */
    int j;
    for(int i=0;i<loop;i++) {
        j=i;
        while((j > -1) && (iVal[j-1] > iVal[j])) {
            swap(iVal[j-1], iVal[j]);
            j--;
        }
        print(iVal,ARY_SIZE(iVal));
    }
}

Measured memory_bytes: 1160
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

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

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 998244353;

int64 power_mod(int64 a, int n) {
  int64 ret = 1;
  for (; n; n >>= 1) {
    if (n & 1) ret = ret * a % MOD;
    a = a * a % MOD;
  }
  return ret;
}

const int N = 3e5 + 10;
int64 F[N], G[N];

int64 comb(int n, int m) {
  if (m > n) return 0;
  return F[n] * G[m] % MOD * G[n - m] % MOD;
}

int main() {
  F[0] = G[0] = 1;
  for (int i = 1; i < N; ++i) {
    F[i] = F[i - 1] * i % MOD;
    G[i] = power_mod(F[i], MOD - 2);
  }

  int n;
  int64 A, B, k;
  cin >> n >> A >> B >> k;
  int ret = 0;
  for (int64 x = 0; x <= n && A * x <= k; ++x) {
    if ((k - A * x) % B) continue;
    int64 y = (k - A * x) / B;
    // trace(n, x, y);
    ret += comb(n, x) * comb(n, y) % MOD;
    ret %= MOD;
  }
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 4992
#include<cstdio>

int n,a,b,tmp=1e9+7;
long long sum;

int main() {
	scanf("%d",&n);
	for(int i=1;i<=n;i++) {
		scanf("%d %d",&a,&b);
		sum+=a;
		if(a>b)
			if(b<tmp)
				tmp=b;
	}
	if(tmp==1e9+7) printf("0\n");
	else printf("%lld\n",sum-tmp);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define endl "\n"
#define pi 3.14159265358979323846264338327950288
#define MOD 1000000007
#define INF -100000000000000
#define ordered_set tree<pair< ll int ,ll  int>, null_type,less<pair<ll int, ll int>>, rb_tree_tag,tree_order_statistics_node_update> 
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
using namespace std;
#define lld long double
using namespace __gnu_pbds;
int main()
{
    fast;	
    //#ifndef ONLINE_JUDGE
   // freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //#endif
    string s,t;
    cin>>s>>t;
    ll int i,c=0;
    for(i=0;i<s.size();i++)
    {
    	if(s[i]!=t[i])
    		c++;
    }
    cout<<c<<endl;
}

Measured memory_bytes: 3880
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;
 
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
 
template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
 
template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) { 
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }
 
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) {is >> x;} return is;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'['; for(T i: a) {out<<i<<',';} out<<']'; return out;
}
 
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const int MOD = 1000000007;

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

  ll n, q;
  cin >> n >> q;
  vector<ll> a(n), x(q), y(q);
  REP(i, n) cin >> a[i];
  REP(i, q) cin >> x[i] >> y[i], x[i]--, y[i]--;

  vector<vector<ll>> p(n, vector<ll>(n));
  REP(i, n) REP(j, n) p[i][j] = a[i] > a[j];

  ll inv2 = (MOD+1) / 2;
  REP(i, q) {
    REP(j, n) {
      if(j == x[i] || j == y[i]) continue;
      ll tmp = (p[j][x[i]] + p[j][y[i]]) * inv2 % MOD;
      p[j][x[i]] = p[j][y[i]] = tmp;
      tmp = (p[x[i]][j] + p[y[i]][j]) * inv2 % MOD;
      p[x[i]][j] = p[y[i]][j] = tmp;
    }
    ll tmp = (p[y[i]][x[i]] + p[x[i]][y[i]]) * inv2 % MOD;
    p[x[i]][y[i]] = p[y[i]][x[i]] = tmp;
  }

  ll ans = 0;
  REP(i, n) FOR(j, i+1, n) (ans += p[i][j]) %= MOD;
  REP(i, q) (ans *= 2) %= MOD;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 72704
N = int(input())
T = [int(i) for i in input().split()]
M = int(input())

L = []
for i in range(M):
    p,x = map(int, input().split())
    L.append((p,x))
    
T_sum = sum(T)
for i in L:
    check = T[i[0]-1] - i[1]
    print(T_sum - check)

Measured memory_bytes: 3064
/*
 * SharpDevelopによって生成
 * ユーザ: t
 * 日付: 2014/09/23
 * 時刻: 23:10
 * 
 * このテンプレートを変更する場合「ツール→オプション→コーディング→標準ヘッダの編集」
 */
using System;

namespace sample
{
	class Program
	{
		public static void Main(string[] args)
		{
			var n= int.Parse(Console.ReadLine());
			
			Console.WriteLine("{0}",n*n*n);
			
			// TODO: Implement Functionality Here
			
			//Console.Write("Press any key to continue . . . ");
			//Console.ReadKey(true);
		}
	}
}

Measured memory_bytes: 5608
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<iomanip>
#include<cstring>
#define initdp(a,b) for(int i=0;i<=a;i++)for(int j=0;j<=b;j++)dp[i][j]=-1;
#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define repd(i,n) for(int i=n-1;i>=0;i--)
#define waste ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inf 1e9+1
#define ll long long int
#define inf1 1e18+1
#define mod 1000000007
#define pie 3.14159265358979323846
#define N 1000005
#define mid(l,r) l+(r-l)/2
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
void mad(ll &a,ll b){a=(a+b)%mod;if(a<0)a+=mod;}
ll gcd(ll a,ll b){ if(a>b)swap(a,b);if(!a)return b;return gcd(b%a,a);}

void solve(){
	double w,h,x,y;
	cin>>w>>h>>x>>y;
	int f=0;
	if((w/2.0)==x&&(h/2.0)==y)f=1;
	cout<<(w*h)/2<<" "<<f<<"\n";
}
int main()
{
	waste;
	int t;
	//cin>>t;
	t=1;
	while(t--){
		solve();
	}
}

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

using namespace std;

int main(){
	int n; cin >> n;
	vector< pair <double, double> > xy(n);

	for(int i = 0; i < n; i++){
		double x, y;
		cin >> x >> y;
		xy[i].first = x;
		xy[i].second = y;
	}

	vector<vector<double>>a(n);
	double ans_b = 0;
	for(int i = 0;i < n-1; i ++){
		for(int j = i+1; j < n; j++){
			ans_b += sqrt((xy[i].first - xy[j].first)*(xy[i].first - xy[j].first)+(xy[i].second - xy[j].second)*(xy[i].second - xy[j].second));
//			ans_b += a[i][j];
		}
	}

	double ans = (ans_b*2 / n);

	 cout << fixed << setprecision(10) << ans << endl;
}

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

using namespace std;

vector<int> graf[100001];
vector<int> pom_graf[100001];
int dp[100001];
bool nije_granicni[100001];

bool mark[100001];

void DFS(int cvor)
{
    mark[cvor] = true;

    int d = pom_graf[cvor].size();
    int maxi = -1;

    for(int i = 0; i < d; i++)
    {
        int pom_cvor = pom_graf[cvor][i];
        if(!mark[pom_cvor]){DFS(pom_cvor); maxi = max(maxi,dp[pom_cvor]+1);}
        else maxi = max(maxi,dp[pom_cvor]+1);
    }

    if(d == 0) dp[cvor] = 0;
    else dp[cvor] = maxi;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n,m;
    cin>> n >> m;

    for(int i = 0; i < m; i++)
    {
        int a,b;
        cin>> a >> b;
        graf[a].push_back(b);
        nije_granicni[b] = true;
        pom_graf[b].push_back(a);
    }

    for(int i = 1; i<= n; i++)
    {
        if(nije_granicni[i])
        {
            if(!mark[i]) DFS(i);
        }
    }

    int maxi = -1;

    for(int i = 1; i <= n; i++)
        maxi = max(maxi,dp[i]);

    cout<< maxi;

    return 0;
}


Measured memory_bytes: 17792
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<algorithm>
#define ll long long int
#define ld long double
#define pi acos(-1)
#define pb push_back
using namespace std;

#define MAXN 1000001

int spf[MAXN],ar[MAXN];

void sieve()
{
    spf[1] = 1;
    for (ll i=2; i<MAXN; i++)
        {spf[i] = i; ar[i]=0;}
    for (ll i=4; i<MAXN; i+=2)
        {spf[i] = 2; ar[i]=0;}

    for (ll i=3; i*i<MAXN; i++)
    {
        if (spf[i] == i)
        {   ar[i] = 0;
            for (ll j=i*i; j<MAXN; j+=i)
                if (spf[j]==j)
                    {spf[j] = i;
                    ar[j]=0;}
        }
    }
}

int main()
{
    ll i,j,a,k,b,c,n,t,m,p,q,d,e,f,y,g,z,h,r,l,x,o;
    ld aa,bb,cc,ee,dd,ff,kk,gg;
    vector<ll > v,s;
//    map<ll,vector<ll> > me;
    map<ll,ll > sa,ta,pa,ma;
//    priority_queue<ll, vector<ll>, greater<ll> > aq,tq,pq;
    string st,et,ft,pt,ct;
//    deque<ll> de,pe,ne;
    ios_base::sync_with_stdio(false);
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    cin>>st;
    cin>>et;
    e = et.size();
    c = 0;
    for(i=0;i<st.size();i++){
            c = 0;
        for(j=i,k=0;k<et.size() && j<st.size();j++,k++){
            if(st[j]!=et[k]){
                c++;
            }
            if(k==et.size()-1 && j<st.size())e = min(c,e);
        }
    }
    cout<<e<<endl;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin >> n;
    vector<int> p(n);
    int count = 0;
    for(int i = 0; i < n; i++) {
        cin >> p[i];
        if (i + 1 != p[i]) {
            count++;
        }
    }

    if (count <= 2) {
        cout << "YES";
    } else {
    cout << "NO";
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
long long dp[301][301][301] = {};

void add(long long &a, long long b) {
    a = (a + b) % MOD;
}

int main() {
    int N, M;
    cin >> N >> M;

    dp[0][1][1] = 1;
    for(int n=0; n<M; ++n) {
        for(int x=1; x<=N; ++x) {
            for(int y=1; y<=N; ++y) {
                if(x < N) add(dp[n + 1][x + 1][y], dp[n][x][y] * (N - x));
                add(dp[n + 1][x][y], dp[n][x][y] * (x - y));
                add(dp[n + 1][x][x], dp[n][x][y] * y);
            }
        }
    }
    cout << dp[M][N][N] << endl;
}

Measured memory_bytes: 212608
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()

int main() {
   int n,x;
   cin >> n >> x;
   int ans=1,d=0;
   rep(i,n){
      int l; cin >> l;
      d+=l;
      if(d<=x)
      ans++;
   }
   cout << ans << endl;
}

Measured memory_bytes: 256