akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<pii> vpii;
typedef vector<pair<ll,ll> > vpll;
typedef vector<vector<pair<ll,ll> > > vvpll;
typedef vector<bool> vb;
typedef map<int,int> mii;
typedef map<char,int> mci;
typedef map<ll,ll> mll;

#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define all(x) x.begin() , x.end()
#define pb push_back
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define mp make_pair
#define F first
#define S second
#define left (node << 1)
#define right (node << 1) + 1
// #define mod 998244353
#define mod 1000000007 

#define trace1(x)                       cerr<<#x<<": "<<x<<endl
#define trace2(x, y)                    cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)                 cerr<<#x<<": " <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(x, y, z , t)             cerr<<#x<<": " <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<" | "<<#t<<": "<<t<<endl
#define trace5(x, y, z , t , u)         cerr<<#x<<": " <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<" | "<<#t<<": "<<t<<" | "<<#u<<": "<<u<<endl
#define trace6(x, y, z , t , u , v)     cerr<<#x<<": " <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<" | "<<#t<<": "<<t<<" | "<<#u<<": "<<u<<" | "<<#v<<": "<<v<<endl

#define repa(i,sta,end,inc) for(int i = sta ; i <= end ; i += inc)
#define repb(i,sta,end,inc) for(int i = sta ; i >= end ; i -= inc)

ll power(ll x , ll y , ll z){ll res = 1;x %= z;while(y){if(y&1){res = res * x % z;}x = x*x % z;y /= 2;}return res%z;}
ll gcd(ll a , ll b){return (b == 0 ? a : gcd(b , a % b));}

void solve(){
    int n , r;
    cin >> n >> r;
    if(n >= 10){
        cout << r << endl;
    }
    else {
        cout << r + 100 * (10 - n) << endl;
    }
}


int main(){
    FIO;
    int tc = 1;
    // cin >> tc;
    repa ( i , 1 , tc , 1){
        solve();
    }
    return 0;
}


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

int head[10];
int tail[10];

int sum[10][301010];

const int inf = 4e5;

signed main(void){
  
  int N; cin >> N;
  string S; cin >> S;

  for(int i = 0; i < 10; i++){ head[i] = inf;}
  
  for(int i = 0; i < N; i++){ 
    int s = (int)(S[i]-'0');
    head[s] = min(head[s],i);
    tail[s] = max(tail[s],i);
    sum[s][i]++;
  }
  
  //ここまでOK
  
  for(int c = 0; c < 10; c++){
   for(int i = 1; i < N; i++){
    sum[c][i] += sum[c][i-1];
   }
  }
  
  int cnt = 0;
  
  for(int i = 0; i < 10; i++){
    for(int j = 0; j < 10; j++){
      for(int k = 0; k < 10; k++){ 
        //ijkがパスワードとしてありうるかどうかを調べる
        
        int former = head[i];
        int later = tail[k];
        int is_exist = 0;
        
        if( former >= later ){ continue;}
  
        if(later){
        is_exist = sum[j][later-1]-sum[j][former];
        }
        if(is_exist){ cnt++;}
        
      }
    }
  }
  
  cout << cnt << endl;
  
  return 0;
}
      

Measured memory_bytes: 20992
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#define LL long long
#define DB double
#define INF 1145141919810364364
#define PI 3.14159265358979
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define rep(i,n) FOR(i,0,n)
#define MOD 1000000007
//#define MOD 998244353
#define ERR 0.00000001
#define NUM 200010

void swap(LL* a,LL* b){LL tmp=*a;*a=*b;*b=tmp;}
void YN(int a){if(a==1)printf("Yes\n");if(a==0)printf("No\n");}
LL lpow(LL a,LL n){LL ans=pow(a,n)*10;if(ans%10<5)return ans/10;return ans/10+1;}
LL dup(LL a,LL d){if(a%d==0)return a/d;else return a/d+1;}
LL GCD(LL a,LL b){LL c=1,tmp=MAX(a,b);b=MIN(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
LL LCM(LL a,LL b){return a*b/GCD(a,b);}
int lcmp(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return 1;if(*(LL*)a<*(LL*)b)return -1;return 0;}
int lcmpr(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return -1;if(*(LL*)a<*(LL*)b)return 1;return 0;}
int ccmp(const void* a,const void* b){return *(char*)a-*(char*)b;}
int ccmpr(const void* a,const void* b){return *(char*)b-*(char*)a;}
int scmp(const void* a,const void* b){return strcmp((char*)a,(char*)b);}
int scmpr(const void* a,const void* b){return strcmp((char*)b,(char*)a);}
LL mod(LL a,LL m){if(a<0)return a%m+m;else return a%m;}
LL DIV(LL a,LL d){LL m=MOD,x=1,y=0,k;while(m){k=d/m;d-=k*m;swap(&m,&d);x-=k*y;swap(&x,&y);}return mod(a*mod(x,MOD),MOD);}
LL FAC(LL a){LL i,ans=1;FOR(i,1,a+1){ans*=i;if(MOD>0&&ans>MOD)ans%=MOD;}return ans;}
LL POW(LL a,LL n){LL ans=1;while(n>0){if(n&1)ans=ans*a%MOD;a=a*a%MOD;n>>=1;}return ans;}
LL fact[NUM],finv[NUM],inv[NUM];
void comi(){LL i;fact[0]=fact[1]=1;finv[0]=finv[1]=1;inv[1]=1;FOR(i,2,NUM){fact[i]=fact[i-1]*i%MOD;inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;finv[i]=finv[i-1]*inv[i]%MOD;}}
LL com(LL n,LL k){if(n<k||n<0||k<0)return 0;return fact[n]*(finv[k]*finv[n-k]%MOD)%MOD;}

int main(){
  LL i,ans=1;
  char S[11];
  scanf("%s",S);
  if(strlen(S)%2==1){
    YN(0);
    return 0;
  }
  for(i=0;i<strlen(S);i+=2){
    if(!(S[i]=='h'&&S[i+1]=='i'))ans=0;
  }
  YN(ans);

  //printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int main(){

  int all,x1,y1,w,h,neko,result,x,y,i,j;

  scanf("%d",&all);

  for(j = 0; j < all; j++){

    scanf("%d %d %d %d",&x1,&y1,&w,&h);

    scanf("%d",&neko);

    result=0;
    for(i = 0; i < neko; i++){

      scanf("%d %d",&x,&y);

      if(0 <= x-x1 && x-x1 <= w && 0 <= y-y1 && y-y1 <= h) result++;

    }

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

  }

  return 0;

}

Measured memory_bytes: 600
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
#include <functional>

using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main()
{
	int N,r;
	vector<int>H;
	cin>>N;
	for(int i=0;i<N;i++)
	{
		int t;
		cin>>t;
		H.push_back(t);
		r=t;
	}

	for(int i=N-1;i>=0;i--)
	{
		if(H[i]-r>1)
		{
			cout<<"No"<<endl;
			return 0;
		}
		r=min(r,H[i]);
	}
	cout<<"Yes"<<endl;
}

Measured memory_bytes: 892
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring> 
#include <cmath> 
#include <algorithm>
using namespace std; 
inline int gi() {
    register int data = 0, w = 1;
    register char ch = 0;
    while (!isdigit(ch) && ch != '-') ch = getchar(); 
    if (ch == '-') w = -1, ch = getchar(); 
    while (isdigit(ch)) data = 10 * data + ch - '0', ch = getchar(); 
    return w * data; 
}
const int MAX_N = 2e5 + 5;
const int INF = 2e9; 
struct Edge { int u, v, w; } e[MAX_N << 1]; 
bool operator < (const Edge &l, const Edge &r) { return l.w < r.w; } 
int N, cnt, Q, ds[MAX_N]; 
int pa[MAX_N]; 
int getf(int x) { return x == pa[x] ? x : pa[x] = getf(pa[x]); }
long long ans = 0; 
int main () {
	N = gi(), Q = gi();
	for (int i = 1; i <= N; i++) ds[i] = INF; 
	while (Q--) { 
		int A = gi() + 1, B = gi() + 1, C = gi(); 
		e[++cnt] = (Edge){A, B, C};
		ds[A % N + 1] = min(ds[A % N + 1], C + 1); 
		ds[B % N + 1] = min(ds[B % N + 1], C + 2); 
	} 
	int pos = min_element(&ds[1], &ds[N + 1]) - ds; 
	for (int i = pos % N + 1, j = pos; i != pos; j = i, i = i % N + 1) ds[i] = min(ds[j] + 2, ds[i]); 
	for (int i = 2; i <= N; i++) e[++cnt] = (Edge){i - 1, i, ds[i]}; 
	e[++cnt] = (Edge){N, 1, ds[1]}; 
	sort(&e[1], &e[cnt + 1]);
	for (int i = 1; i <= N; i++) pa[i] = i; 
	for (int i = 1; i <= cnt; i++) {
		int u = getf(e[i].u), v = getf(e[i].v); 
		if (u == v) continue;
		ans += e[i].w, pa[u] = v; 
	} 
	printf("%lld\n", ans); 
    return 0; 
} 

Measured memory_bytes: 9600
#include <iostream>
#include <string>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int k,flag=0;
    k=s.size();
    for(int i=0;i<=k;i++)
    {
        if(s[i]=='9')
        {
        cout<<"Yes"<<endl;
        flag=1;
        break;
        }
    }
    if(flag==0)
    {cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int A,B,C,ans;
	scanf("%d %d %d",&A,&B,&C);
	if(A==B){
		ans=C;
	}else if(A==C){
		ans=B;
	}else{
		ans=A;
	}
	printf("%d\n",ans);
}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    cout << ((abs(c - a) <= d || (abs(b - a) <= d && abs(c - b) <= d)) ? "Yes" : "No") << '\n';
    return (0);
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1LL << 60;
const int MAX = 1000000010;
const ll MOD = 1000000007;

int main() {
    int N; cin >> N;
    cout << (1000 - N % 1000) % 1000 << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
using namespace std;
int a,b,c,d;
long long ans;
constexpr long long mod=1e9+7; 
long long M[222222]={1,1};
long long inv[222222]={1,1};
long long C(int x,int y){
    return M[x]*inv[y]%mod*inv[x-y]%mod;
}
long long I(int i){
    if(inv[i]==-1){
        inv[i]=I(mod%i)%mod*(mod-mod/i)%mod;
    }
    return inv[i];
}
int main(){
    cin>>a>>b>>c>>d;
    fill(inv+2,inv+222222,-1);
    for(int i=2;i<222222;i++){
        M[i]=M[i-1]*i%mod;
        I(i);
    }
    for(int i=2;i<222222;i++){
        inv[i]*=inv[i-1];
        inv[i]%=mod;
    }
    for(int i=0;a-c-1>=i&&b-d-1>=i;i++){
        ans+=C(a-c+d-1,d+i)*C(b-d+c-1,c+i);
        ans%=mod;
    }
    cout<<ans<<endl;
    return 0;
}


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

public class Main {

	final static long MOD = 1000000007L;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static ArrayList<int[]> list = new ArrayList<>();
	public static void main(String[] args) throws Exception {

		long a=nextLong();
		long b=nextLong();
		long c=nextLong();
		String ans ="No";

		if((c-a-b)>0&&4*a*b<(c-a-b)*(c-a-b)){
			ans ="Yes";
		}

		System.out.println(ans);

	}

public static long gcd(long a, long b) {
	long x, y;
	if (a < b) {
		x = b;
		y = a;
	} else {
		x = a;
		y = b;
	}
	long r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
	public static long lcm(long a, long b) {
		long x, y;

		return ((a / gcd(a, b)) * b);
	}

	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static String concatStringArray(String[] s){
		StringBuffer sb = new StringBuffer();
		for(String x:s){
			sb.append(x);
		}
		return sb.toString();
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}

Measured memory_bytes: 21332
#include <map>
#include <set>
#include <ctime>
#include <queue>
#include <stack>
#include <cmath>
#include <vector>
#include <bitset>
#include <cstdio>
#include <cctype>
#include <string>
#include <cstring>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std ;
#define rep(i, a, b) for (int (i) = (a); (i) <= (b); (i)++)
#define per(i, a, b) for (int (i) = (a); (i) >= (b); (i)--)
#define clr(a) memset(a, 0, sizeof(a))
#define ass(a, sum) memset(a, sum, sizeof(a))
#define lowbit(x) (x & -x)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define enter cout << endl
#define siz(x) ((int)x.size())
typedef long long ll ;
typedef unsigned long long ull ;
typedef vector <int> vi ;
typedef pair <int, int> pii ;
typedef map <int, int> mii ;
typedef map <string, int> msi ;
const int N = 410 ;
const int INF = 0x3f3f3f3f ;
const int iinf = 1 << 30 ;
const ll linf = 2e18 ;
const int MOD = 1000000007 ;
void print(int x) { cout << x << endl ; exit(0) ; }
void PRINT(string x) { cout << x << endl ; exit(0) ; }
void douout(double x){ printf("%lf\n", x + 0.0000000001) ; }

int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, -1, 1};
vector<string> vec;
int h, w;
vector<vector<bool> > visited;
long long white;
long long black;
void dfs(int i, int j, char cur){
	visited[i][j]=true;
	if(cur == '.')white++;
	if(cur == '#')black++;
	for(int k = 0; k < 4; ++k){
		int r = i + dx[k];
		int c = j + dy[k];
		if(r >= 0 && c >= 0 && r < h && c < w){
			if(vec[r][c] == '.' && cur == '#' && !visited[r][c]){
			    dfs(r, c, '.');
			}
			if(vec[r][c] == '#' && cur == '.' && !visited[r][c]){
				dfs(r, c, '#');
			}
		}
	}
}
int main(){
	cin>>h>>w;
	vec.resize(h);
	for(int i = 0; i < h; ++i){
		cin>>vec[i];
	}
	vector<bool> e(w, false);
	visited.resize(h, e);
	long long res = 0;
	for(int i = 0; i < h; ++i){
		for(int j = 0; j < w; ++j){
			if(vec[i][j]=='#' && !visited[i][j]){
				white=black=0;
				dfs(i, j, '#');
				res += white * black;
			}
		}
	}
	cout<<res<<endl;
	return 0;
}

/*
写代码时请注意：
	1.ll？数组大小，边界？数据范围？
	2.精度？
	3.特判？
	4.至少做一些
思考提醒：
	1.最大值最小->二分？
	2.可以贪心么？不行dp可以么
	3.可以优化么
	4.维护区间用什么数据结构？
	5.统计方案是用dp？模了么？
*/


Measured memory_bytes: 15488
import heapq as hq
def solve():
    N, M = list(map(int, input().split()))
    plan = []
    for _ in range(N):
        plan.append(list(map(int, input().split())))
    task = {}
    for p in plan:
      if p[0] in task.keys():
        task[p[0]].append(-p[1])
      else:
        task[p[0]] = [-p[1]]
    choices = []
    res = 0
    d = task.keys()
    for day in range(1, M+1):
        if day in d:
            for j in task[day]:
                hq.heappush(choices, j)
        if len(choices) > 0:
            res += - hq.heappop(choices)
    print(res)

if __name__ == "__main__":
    solve()

Measured memory_bytes: 44984
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <algorithm>
#include <string>
using namespace std;
int main() {
  int N, K, Q;
  cin >> N >> K >> Q;
  vector <int> c(N + 1, 0);
  for (int i = 0; i < Q; i++) {
	  int A;
	  cin >> A;
	  c[A]++;
	}
  for (int i = 1; i <= N; i++) {
	  if (K - (Q - c[i]) > 0) {
		  cout << "Yes" << endl;
		}
	  else {
		  cout << "No" << endl;
		}
	}
  return 0;
}


Measured memory_bytes: 1024
S = input()

if len(S) == 1:
    print(1)
    exit()


one = [0]*len(S)
two = [0]*len(S)
one[0] = 1
one[1] = 2*int(S[0] != S[1])
two[1] = 1

for i in range(2,len(S)):
    if S[i] == S[i-1]:
        n1 = two[i-1]+1
    else:
        n1 = max(one[i-1],two[i-1])+1
    if i < 3 or S[i-1:i+1] == S[i-3:i-1]:
        n2 = one[i-2]+1
    else:
        n2 = max(one[i-2],two[i-2])+1
    one[i],two[i] = n1, n2

print(max(one[-1],two[-1]))

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

int main() {
    int N, K; cin >> N >> K;
	vector<int> A(N);
	for(int i=0; i<N; ++i) cin >> A[i];

	for(int i=K; i<N; ++i) {
	    if(A[i] > A[i - K]) cout << "Yes\n";
		else cout << "No\n";
	}
}



Measured memory_bytes: 4040
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String res = "";
		for(int i=0;i<s.length();i++) {
			if(s.substring(i,i+1).equals("1")) {
				res+="9";
			}else {
				res+="1";
			}
		}
		System.out.println(res);
	}

}




Measured memory_bytes: 22612
/*
2^5000兆 >> 10^18なので
1...x...が入力の場合、1...xxxxxxxxxx以下無限と考えてよい
*/

#include <bits/stdc++.h>
using namespace std;

int main()
{
  string S;
  long K;
  cin >> S >> K;
  
  int first = -1;
  for(int i = 0; i < S.length(); ++i)
  {
    if(S[i] != '1')
    {
      first = i;
      break;
    }
  }
  
  // 1だけか、それともK文字以上の1の連続＋何らかの数字か
  if(first == -1 || first > K - 1)
  {
    cout << 1 << endl;
  }
  else
  {
    cout << S[first] << endl;
  }
  
  return 0;
}

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

using namespace std;

int main(void) {
	int n;
	cin >> n;
	vector<int> even, odd;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		if (i % 2 == 0) even.push_back(a);
		else odd.push_back(a);
	}
	if (n % 2 == 0) {
		for (int i = odd.size() - 1; i >= 0; i--) {
			cout << odd[i] << " ";
		}
		for (int i = 0; i < even.size(); i++) {
			if (i == even.size() - 1) cout << even[i];
			else cout << even[i] << " ";
		}
	}
	else {
		for (int i = even.size() - 1; i >= 0; i--) {
			cout << even[i] << " ";
		}
		for (int i = 0; i < odd.size(); i++) {
			if (i == odd.size() - 1) cout << odd[i];
			else cout << odd[i] << " ";
		}
	}
	cout << endl;
	system("pause");
	return 0;
}

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

#define N 50

int n, m;
int a[N], b[N];

bool graph[N][N];
bool visited[N];

void dfs( int v )
{
	visited[v] = true;
	for( int v2 = 0; v2 < n; v2++ ) {
		if( graph[v][v2] == false ) {
			continue;
		}
		if( visited[v2] == true ) {
			continue;
		}
 		dfs( v2 );
 	}
}

int main()
{
	cin >> n >> m;
	for( int i = 0; i < m; i++ ) {
		cin >> a[i] >> b[i];
		a[i]--;
		b[i]--;
		graph[ a[i] ][ b[i] ] = true;
		graph[ b[i] ][ a[i] ] = true;
	}

	int ans = 0;

	for( int i = 0; i < m; i++ ) {
		graph[ a[i] ][ b[i] ] = false;
		graph[ b[i] ][ a[i] ] = false;

		for( int j = 0; j < n; j++ ) {
			visited[j] = false;
		}

		dfs( 0 );

		bool bridge = false;
		for( int j = 0; j < n; j++ ) {
			if( visited[j] == false ) {
				bridge = true;
			}
		}
		if( bridge ) {
			ans++;
		}

		graph[ a[i] ][ b[i] ] = true;
		graph[ b[i] ][ a[i] ] = true;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	int a[10010];
	cin>>n;
	int maxx=-0x3f3f3f3f;
	int sum=0;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		maxx=max(maxx,a[i]);
		sum+=a[i];
	}
	sum-=maxx;
	if(maxx<sum)
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<set>
#include<iomanip>
#define sqr(x)(x)*(x)
#define fz1(i,n) for (i=1;i<=n;i++)
#define fd1(i,n) for (i=n;i>=1;i--)
#define fz0g(i,n) for (i=0;i<=n;i++)
#define fd0g(i,n) for (i=n;i>=0;i--)
#define fz0k(i,n) for (i=0;i<n;i++)
#define fd0k(i,n) for (i=(long long)(n-1);i>=0;i--)
#define fz(i,x,y) for (i=x;i<=y;i++)
#define fd(i,y,x) for (i=y;i>=x;i--)
#define ff(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define rdst(st,len){char ss[len];scanf("%s",ss);(st)=ss;}
using namespace std;
//struct bit{T_ arr[1000005];int lowbit(int x){return x&(-x);}void add(int x,T_ y){for (int i=x;i<=n;i+=lowbit(i)) arr[i]+=y;}T_ query(int x){T_ s=0;for (int i=x;i>0;i-=lowbit(i)) s+=arr[i];return s;}};
//struct seg{struct treedot{int l,r;T_ sum,add;void update(T_ x){sum+=(r-l+1)*x; add+=x;}}c[800005];void pushdown(int id){if (c[id].add){c[id*2].update(c[id].add);c[id*2+1].update(c[id].add);c[id].add=0;}}void pushup(int id){c[id].sum=c[id*2].sum+c[id*2+1].sum;}void build(int id,int l,int r){if (l>r) return;c[id].l=l;c[id].r=r;c[id].sum=0;c[id].add=0;if (l==r) c[id].sum=0;else{int mid=l+(r-l)/2;build(id*2,l,mid);build(id*2+1,mid+1,r);pushup(id);}}void update(int id,int le,int ri,T_ x){if (le>c[id].r||ri<c[id].l) return;if (le<=c[id].l&&c[id].r<=ri) c[id].update(x);else{pushdown(id);update(id*2,le,ri,x);update(id*2+1,le,ri,x);pushup(id);}}T_ query(int id,int le,int ri){if (ri<c[id].l||c[id].r<le) return 0;if (le<=c[id].l&&c[id].r<=ri) return c[id].sum;T_ ans=0;pushdown(id);ans+=query(id*2,le,ri);ans+=query(id*2+1,le,ri);pushup(id);return ans;}};
long long n,m,q,i,j,a[100005],dp[100005][18],x,y,ans;
int main()
{
	scanf("%lld",&n);
	fz1(i,n)
	{
		scanf("%lld",&a[i]);
	}
	scanf("%lld",&m);
	fz1(i,n)
	{
		while (j<n&&a[j+1]-a[i]<=m) j++;
		dp[i][0]=j;
	}
	fz1(j,17) fz1(i,n) dp[i][j]=dp[dp[i][j-1]][j-1];
	scanf("%lld",&q);
	while (q--)
	{
		scanf("%lld%lld",&x,&y);
		if (x==y)
		{
			puts("0");
			continue;
		}
		if (x>y) swap(x,y);
		ans=0;
		for (i=17;i>=0;i--)
		{
			if (dp[x][i]<y)
			{
				ans+=(1<<i);
				x=dp[x][i];
			}
		}
		printf("%lld\n",ans+1);
	}
	return 0;
}

Measured memory_bytes: 15616
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <numeric>
using namespace std;
using ll = long long;
const ll mod =  998244353;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REP_FROM(i, j, n) for (int i = (j); i < (n); ++i)
#define all(x) (x).begin(),(x).end()

ll power(ll base, ll exponent, ll module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ ll root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
ll inverse(ll x){ return power(x, mod - 2, mod);}
ll gcd(ll a, ll b) {if(a < b) gcd(b, a);ll r;while(r=a%b) {a=b;b=r;}return b;}
struct combination{ vector<ll> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } ll C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };

ll dp[100010][2] = {};

signed main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<ll> a(n);
  REP(i, n) cin >> a[i];
  ll even = 0;
  REP(i, n) even += (a[i] < 0? 1: 0);
  REP(i, n) even = (a[i] == 0? 0: even);
  if(even % 2 == 0) {
    ll ans = 0;
    REP(i, n) {
      ans += abs(a[i]);
    }
    cout << ans << endl;
    return 0;
  }
  REP(i, n) a[i] = abs(a[i]);
  sort(all(a));
  ll ans = -a[0];
  REP_FROM(i, 1, n) ans += a[i];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
H,W,M=map(int,input().split())
HW=[tuple(map(lambda x:int(x)-1,input().split()))for i in range(M)]
st=set(HW)
countH=[0]*H
countW=[0]*W
for h,w in HW:
    countH[h]+=1
    countW[w]+=1
maxH=max(countH)
maxW=max(countW)
candiH=[]
candiW=[]
for i in range(H):
    if maxH==countH[i]:
        candiH.append(i)
for i in range(W):
    if maxW==countW[i]:
        candiW.append(i)
count=0
ans=maxH+maxW-1
add=0
for i in candiH:
    for j in candiW:
        if (i,j) not in st:
            add=1
        if count>300000:
            break
        count+=1
print(ans+add)

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


#define INF 1000000000000


signed main()
 {
int n,k;
cin>>n>>k;
vector<int>a(n);
rep(i,k){
  int l;
  cin>>l;
  rep(j,l){
    int t;
    cin>>t;
    a[t-1]=1;
  }

}
int ans=0;
rep(i,n){
  if(a[i]==0)ans++;
}
cout<<ans;
}


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

int main(void){
	int N, M, P;
	int sum, ans;
	int X[1001];

	while(scanf("%d %d %d", &N, &M, &P) != EOF){
		if(!N && !M && !P)	break;

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

		P = 100 - P;

		if(X[M-1] == 0)	ans = 0;
		else ans = sum * P / X[M-1];

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

Measured memory_bytes: 1244
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
#include <climits>
#include <cmath>
#include <utility>
#include <iomanip>

using namespace std;

long long int gojohou(long long int a, long long int b)
{
	long long int r, tmp;

	/* 自然数 a > b を確認・入替 */
	if (a<b){
		tmp = a;
		a = b;
		b = tmp;
	}

	/* ユークリッドの互除法 */
	r = a % b;
	while (r != 0){
		a = b;
		b = r;
		r = a % b;
	}

	return b;
}


int main(int argc, char *argv[])
{

	//input
	long long int a, b, c, d;
	cin >> a >> b >> c >> d;


	//calc
	long long int multiple_count_c = (b / c) - ((a - 1) / c);
	long long int multiple_count_d = (b / d) - ((a - 1) / d);
	long long int baisuu = c / gojohou(c, d) * d;
	long long int multiple_count_baisuu = (b / (baisuu)) - ((a - 1) / baisuu);
	long long int ans = (b - a + 1) - (multiple_count_c + multiple_count_d - multiple_count_baisuu);


	//ans
	cout << ans << endl;



	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
const ll mod = 1000000007;
const ll INF = 1e+14;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define _GLIBCXX_DEBUG

int main(){
    int n; cin>>n;
    int maisuu=(n+1000-1)/1000;
    cout<<maisuu*1000-n<<endl;

}

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

from fractions import gcd
def two(n):
    ans = 0
    while n%2==0:
        n //= 2
        ans += 1
    return ans

def multi_lcm(A):
    ans = A[0]
    for a in A:
        ans *= a//gcd(ans,a)
    return ans

def solve(N,M,A):
    ans = 0
    num_two = len(set(map(two,A)))
    if num_two != 1:
        return 0
    l = multi_lcm(A)
    ans = (M+l//2)//l
    return ans
print(solve(N,M,A))


Measured memory_bytes: 89600
#include<bits/stdc++.h>
using namespace std;
int i,j,n,a,x[1<<17],z;
int main(){
  for(cin>>n;i++<n;x[a]++)cin>>a;
  if(n>1)for(j=2;j<1<<17;++j)z=max(z,x[j-2]+x[j-1]+x[j]);
  else z=1;
  cout<<z<<endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using vll = vector<ll>;
using vi = vector<int>;
using vb = vector<bool>;
using pii = pair<int, int>;

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;
}

//pow(llpow,modpow)
template <class T>
ll llpow(ll x, T n)
{
    ll ans = 1;
    if (x == 0)
        ans = 0;
    while (n)
    {
        if (n & 1)
            ans *= x;
        x *= x;
        n >>= 1;
    }
    return ans;
}
long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
template <class T>
inline T gcd(T x, T y)
{
    if (y == 0)
        return x;
    else
    {
        return gcd(y, x % y);
    }
}
//最小公倍数
template <class T>
inline T lcm(T x, T y) { return x / gcd(x, y) * y; }
//逆元
long long modinv(long long a, long long m)
{
    long long b = m, u = 1, v = 0;
    while (b)
    {
        long long t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0)
        u += m;
    return u;
}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)

long long INF = 1LL << 60;
int main()
{
    int n;
    cin >> n;
    vector<vi> a(n,vector<int> (n));
    rep(i, 0, n)
    {
        rep(j, 0, n)
        {
            cin >> a[i][j];
            if(a[i][j]==-1)a[i][j]=1<<30;
        }
    }
    ll res = 0;
    set<int> rem,visited;
    visited.insert(0);
    rep(i,1,n)rem.insert(i);
    while(!rem.empty()){
        int minv=1<<30,mini=-1;
        for(int prev:visited){
            for(int next:rem){
                if(a[prev][next]<minv){
                    minv=a[prev][next];
                    mini=next;
                }
            }
        }
        res+=minv;
        rem.erase(mini);
        visited.insert(mini);
    }
    cout<<res<<endl;
    return 0;
}



Measured memory_bytes: 3144
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 10007;
const ld PI = acosl(-1);

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

    int H, W, N;
    cin >> W >> H >> N;
    vector<pii> v(N);
    for (int i = 0; i < N; ++i) {
        cin >> v[i].first >> v[i].second;
        v[i].first--, v[i].second--;
    }
    sort(v.begin(), v.end());

    int cnt = 0, idx = 0;
    for (int i = 0; i < W; ++i) {
        bool inc = true;
        while (idx < N && i + 1 >= v[idx].first) {
            if (v[idx].second <= cnt) {
                cout << i + 1 << endl;
                return 0;
            }
            if (v[idx].second == cnt + 1 || cnt + 1 >= H)
                inc = false;
            idx++;
        }
        if (inc)
            cnt++;
    }

    cout << W << endl;
    return 0;
}


Measured memory_bytes: 4728
#include<iostream>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<limits.h>
#include<utility>
#include<bits/stdc++.h>
#include<vector>
#include<tuple>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(A) A.begin(),A.end()
bool comparator(P a, P b) {
	return a.first / a.second < b.first / b.second;
}

int main() {
	int h, w;
	cin >> h >> w;
	vector<vector<char>> board(h, vector<char>(w));
	rep(i, h) {
		rep(j, w) {
			cin >> board[i][j];
		}
	}
	vector<vector<int>> a(h, vector<int>(w, INT_MAX));
	if (board[0][0] == '.') {
		a[0][0] = 0;
	}
	else {
		a[0][0] = 1;
	}
	rep(i, h-1) {
		a[i + 1][0] = a[i][0];
		//if (board[i + 1][0] == '#')a[i + 1][0]++;
		if (board[i + 1][0] != board[i][0])a[i + 1][0]++;
	}
	rep(i, w - 1) {
		a[0][i + 1] = a[0][i];
		///if (board[0][i + 1] == '#')a[0][i + 1]++;
		if (board[0][i + 1] != board[0][i])a[0][i + 1]++;
	}
	for (int i = 1; i < h; i++) {
		for (int j = 1; j < w; j++) {
			//a[i][j] = min(a[i - 1][j], a[i][j - 1]);
			//if (board[i][j] == '#')a[i][j]++;
			int x = a[i][j - 1];
			if (board[i][j] != board[i][j - 1])x++;
			int y = a[i - 1][j];
			if (board[i][j] != board[i - 1][j])y++;
			a[i][j] = y;
			if (x < y)a[i][j] = x;
		}
	}
	//cout << a[h - 1][w - 1] << endl;
	cout << a[h-1][w-1] / 2 + a[h-1][w-1] % 2;
}


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

int main(void){
  int H,W;
  char grid[103][103];

  scanf("%d%d",&H,&W);

  for(int i=0; i<H; i++){
    scanf("%s",&grid[i]);
  }

  for(int i=0; i<W+2; i++){
    printf("#");
  }
  printf("\n");


  for(int i=0; i<H; i++){
    printf("#%s#\n",grid[i]);
  }

  for(int i=0; i<W+2; i++){
    printf("#");
  }
  printf("\n");

}


Measured memory_bytes: 128
import sys
sys.setrecursionlimit(10 ** 6)


def dfs(v, c):
    nc = 0
    k = 0
    for nv, idx in edge[v]:
        if status[nv] == 0:
            nc = nc + 1 + ((nc + 1) == c)
            color[idx] = nc
            status[nv] = 1
            k = max(k, dfs(nv, nc))
    return max(nc, k)


N = int(input())
edge = [[] for _ in range(N)]
for idx, line in enumerate(sys.stdin.readlines()):
    a, b = map(lambda x: int(x) - 1, line.split())
    edge[a].append((b, idx))
    edge[b].append((a, idx))

status = [0] * N
color = [0] * (N - 1)
status[0] = 1
K = dfs(0, 0)

print(K)
for c in color:
    print(c)


Measured memory_bytes: 75112
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define per(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define INF 2e9
#define LINF 1e18
typedef long long ll;
typedef pair<int, int> P;

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

    vector<vector<ll> > dp(n, vector<ll>(1e5+1, LINF));
    rep(j, 1e5+1) {
        if (j == 0) {
            dp[0][j] = 0;
            continue;
        }
        if (j%v[0] == 0) {
            dp[0][j] = w[0];
            break;
        }
    }

    rep(i, n-1) {
        rep(j, 1e5+1) {
            if (j >= v[i+1]) {
                dp[i+1][j] = min(dp[i][j], dp[i][j-v[i+1]]+w[i+1]);
            }
            else {
                dp[i+1][j] = dp[i][j];
            }
        }
    }

    int ans;
    rep(j, 1e5+1) {
        if (dp[n-1][j] <= W) ans = j;
    }
    cout << ans << endl;

}

Measured memory_bytes: 79488
//Hey u r far away to know this
#include <bits/stdc++.h>
using namespace std;
#define     ff      	    	first
#define     pb 	         	push_back
#define     ss          		second
#define     ll      	    	long long
#define     MAX  	       	5000
#define     mpi         		map<int, int>
#define     mpll        		map<ll, ll>
#define     pll         		pair<ll, ll>
#define     plld        		pair<ll, double>
#define     SKILLER     		ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define     vi          		std::vector<int>
#define     vll         		std::vector<ll>
#define     vs          		std::vector<string>
#define     vvi         		std::vector<std::vector<int>>
#define     vvll        		std::vector<std::vector<ll>>
#define     all(v)      		v.begin(), v.end()
#define     allr(v)      		v.rbegin(), v.rend()
#define     loop(i, a, b) 	for(int i = a; i < b; i++)
#define 	  debug(x) 		cout << x <<" " <<"\n";
#define 	  debug1(x, y) 	cout << x << " " << y  << "\n";
#define 	  debug2(x, y, z) 	cout << x << " " << y << " " << z<<"\n";
#define 	  int 			ll
const   int N = 1e6+5, Mod = 1e9 + 7;
int32_t main(){
    	SKILLER;
    	
        int n; cin >> n;
        int ans = 0;
        for(int i = 1; i <= n; i++){
        	int x; cin>>x;
        	if(x&1 && i&1)
        		ans++;
        }
        cout << ans;
    	return 0;
}

Measured memory_bytes: 3636
# Modified from https://atcoder.jp/contests/abc179/submissions/16893796

import sys

input = sys.stdin.buffer.readline

n, q = map(int, input().split())


class SegmentTree:
    ele = 10 ** 10
    func = min
    # SEG木は1-index
    # Aに関しては0-index

    def __init__(self, n):  # Aは0-idx
        self.n = n
        self.num = 2 ** ((self.n - 1).bit_length())
        self.SEG = [self.ele] * (2 * self.num)

    def search(self, idx):
        return self.SEG[idx + self.num]

    def initialize(self, A):
        for i in range(self.n):
            self.SEG[i + self.num] = A[i]
        for i in range(self.num - 1, 0, -1):
            self.SEG[i] = self.func(self.SEG[2 * i], self.SEG[2 * i + 1])

    def update(self, idx, val):
        if self.search(idx) < val:
        	return
        idx += self.num
        self.SEG[idx] = val
        idx //= 2
        while idx:
            self.SEG[idx] = self.func(self.SEG[2 * idx], self.SEG[2 * idx + 1])
            idx //= 2

    def query(self, left, right):
        # maspy式。開区間のママ処理する
        # left, rightで値を分けているのは交換法則不成立のときのため
        # 開区間→Rが奇数→右端が偶数→1ずらしてから計算
        # 　下から上への遷移は2で割る
        # juppy氏は閉区間に直していた
        resleft = self.ele
        resright = self.ele
        left += self.num
        right += self.num
        while right - left > 0:
            if left % 2 == 1:
                resleft = self.func(resleft, self.SEG[left])
                left += 1
            if right % 2 == 1:
                right -= 1
                resright = self.func(resright, self.SEG[right])
            left //= 2
            right //= 2
        return self.func(resleft, resright)


ans = 0

tate = SegmentTree(n)
yoko = SegmentTree(n)

for i in range(q):
    s, x = map(int, input().split())
    x -= 1
    if s == 1:
        temp = tate.query(x, n)
        # print("t", i, temp)
        if temp == 10 ** 10:
            temp = n - 1
        yoko.update(temp, x)
        ans += max(0, temp - 1)
    else:
        temp = yoko.query(x, n)
        # print("t", i, temp)
        if temp == 10 ** 10:
            temp = n - 1
        tate.update(temp, x)
        ans += max(0, temp - 1)
    # print("a", i, temp - 1)
print((n - 2) ** 2 - ans)


Measured memory_bytes: 97284
import sys
input = sys.stdin.readline


n = int(input())
costs = list(map(int, input().split()))

dp = [float('inf')] * (n + 1)
dp[0] = 0

for i in range(1, n):
    dp[i] = min(dp[i], dp[i-1] + abs(costs[i] - costs[i-1]))
    if i > 1:
        dp[i] = min(dp[i], dp[i-2] + abs(costs[i] - costs[i-2]))

print(dp[n-1])


Measured memory_bytes: 13708
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <map>
#include <tuple>

#define INF 100100100100
#define rep(i,n) for(int i=0; i<(n); i++)
typedef long long ll;
using namespace std;

 
int main(){
    int H,W,A,B;
    cin >> H >> W >> A >> B;
    
     
    vector<vector<int>> ans(H, vector<int>(W));
    
    int x=0,y=1;
    int cnt = 0;
    rep(i,H){
        if(cnt >= B){
            x = 1;
            y = 0;
        }
        int count = 0;
        rep(j,W){
            
            if(count<A){
                ans[i][j] = x;
                count++;
            }else{
                ans[i][j] = y;
            }
        }
        cnt++;
        
        
    }
    
    rep(i,H){
        rep(j,W){
            cout << ans[i][j];
            }
        cout << endl;
        
    }
    
    
    
    
    
}


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

const int N=1e6;
bool vis[N+5];
int p[N+5],a[N+5],f[N+5];
int cnt,n,gcdtot;
void initial()
{
	int i,j;
	for(i=2;i<=N;i++)
	{
		if(!vis[i])
		{
			f[i]=i;
			p[++p[0]]=i;
		}
		int t;
		for(j=1;(t=i*p[j])<=N;j++)
		{
			vis[t]=1;
			f[t]=p[j];
			if(i%p[j]==0)
				break;
		}
	}
}
int main()
{
	int i,j;
	initial();
	scanf("%d",&n);
	for(i=1;i<=n;i++)
		scanf("%d",&a[i]);
	gcdtot=a[1];
	for(i=2;i<=n;i++)
		gcdtot=__gcd(gcdtot,a[i]);
	if(gcdtot!=1)
	{
		printf("not coprime\n");
		return 0;
	}
	memset(vis,0,sizeof(vis));
	for(i=1;i<=n;i++)
	{
		j=a[i];
		int last=0;
		while(j!=1)
		{
			if(vis[f[j]]&&last!=f[j])
			{
				printf("setwise coprime\n");
				return 0;
			}
			vis[f[j]]=1;
			last=f[j];
			j/=f[j];
		}
	}
	printf("pairwise coprime\n");
	return 0;
}

Measured memory_bytes: 12776
N, D = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(N)]
cnt = 0
for i in range(N - 1):
    for j in range(i + 1, N):
        d = sum(abs(a[i][k] - a[j][k]) ** 2 for k in range(D)) ** 0.5
        cnt += d % 1 == 0
print(cnt)

Measured memory_bytes: 9296
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int,int>
using namespace std;
const int MAXN = 100005;
const int INF = (LL)1e9 + 5;
const LL MOD = 998244353;

int N, W, dp[100005];

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin >> N >> W;
	fill(dp + 1, dp + MAXN, INF);
	for (int i = 0; i < N; i++) {
		int w, v;
		cin >> w >> v;
		for (int j = MAXN - 1; j >= v; j--) {
			if (dp[j - v] != INF) {
				dp[j] = min(dp[j], dp[j - v] + w);
			}
		}
	}
	
	for (int i = MAXN - 1; i >= 0; i--) {
		if (dp[i] <= W) {
			cout << i << "\n";
			break;
		}
	}
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <queue>
#include <utility>
#include <tuple>
using namespace std;
using Int = long long;

int main()
{
    int X, A, B;
    cin >> X >> A >> B;
    cout << (X - A) % B << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>

using namespace std;

const int mod = 1000000007;
int a[26];
char s[100001];

int main() {
    int n, i;
    long long ans = 1;
    
    scanf("%d", &n);
    scanf("%s", s);
    
    for (i = 0; i < n; i++) a[s[i] - 'a']++;
    
    for (i = 0; i < 26; i++) ans = ans * (a[i] + 1) % mod;
    
    printf("%lld\n", (ans - 1 + mod) % mod);
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int _b=(b),i=(a);i<=_b;++i)
#define ROF(i, b, a) for(int _a=(a),i=(b);i>=_a;--i)
#define REP(n) for(int _n=(n);_n--;)
#define _1 first
#define _2 second
#define PB(x) push_back(x)
#define SZ(x) int((x).size())
#define ALL(x) (x).begin(), (x).end()
#define MSET(m,v) memset(m,v,sizeof(m))
#define MAX_PQ(T) priority_queue<T>
#define MIN_PQ(T) priority_queue<T,vector<T>,greater<T>>
#define IO(){ios_base::sync_with_stdio(0);cin.tie(0);}
#define cint1(a) int a;cin>>a
#define cint2(a,b) int a,b;cin>>a>>b
#define cint3(a,b,c) int a,b,c;cin>>a>>b>>c
typedef long long int ll; typedef pair<int,int> PII;typedef unsigned long long int ull;
typedef vector<int>VI; typedef vector<ll> VL; typedef vector<PII> VP;
template<class A,class B>inline bool mina(A &x,const B &y){return(y<x)?(x=y,1):0;}
template<class A,class B>inline bool maxa(A &x,const B &y){return(x<y)?(x=y,1):0;}

string s;
int main() {
	IO();
	cin >> s;
	int n = s.size();
	ll tmp = s[0] - '0';
	queue<vector<ll>> q;
	q.push(vector<ll>(1, tmp));
	FOR(i, 1, n - 1) {
		int qsize = q.size();
		FOR(j, 1, qsize) {
			vector<ll> v = q.front(); q.pop();
			vector<ll> v1 = v;
			ll t = v.back() * 10 + (s[i] - '0');
			v.pop_back();
			v.push_back(t);
			q.push(v);
			v1.push_back(s[i] - '0');
			q.push(v1);	
		}
	}
	ll out = 0;
	while(!q.empty()) {
		vector<ll> v = q.front(); q.pop();
		ll ans = accumulate(v.begin() , v.end() , ll(0));
		out += ans;
	}
	cout << out << endl;
	return 0;
}

Measured memory_bytes: 508
#include <bits/stdc++.h>
#include<math.h>
typedef long long ll;
using namespace std;
vector<vector<int>>comp;
vector<int>onecycle;
vector<int>clength;
vector<int>v9;
vector<int>v8;
int cycle_start;
int cycle_end;
vector<int>vbip1;
vector<int>vbip2;
#define FIO  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
int main()
{
    int n;
    cin>>n;
    int dp[n+1];
    dp[0]=0;
    int i;
    ll sum=0;
    int h[n];
    for(i=0;i<n;i++)
    {
        cin>>h[i];
    }
    for(i=1;i<=n;i++)
    {
        if(i-3>=0)
        {
            dp[i]=min(dp[i-2]+max(h[i-3]-h[i-1],h[i-1]-h[i-3]),dp[i-1]+max(h[i-2]-h[i-1],h[i-1]-h[i-2]));
        }
        else if(i-2>=0)
        {
            dp[i]=dp[i-1]+max(h[i-2]-h[i-1],h[i-1]-h[i-2]);
        }
        else
        {
            dp[i]=0;
        }
    }
    cout<<dp[n];
    
}


Measured memory_bytes: 4312
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define vint(a,n) vint a(n); rep(i, n) cin >> a[i];
#define vll(a,n) vll a(n); rep(i, n) cin >> a[i];
#define ALL(n) begin(n),end(n)
#define RALL(n) rbegin(n),rend(n)
#define MOD (1000000007)
#define INF (2e9)
#define INFL (2e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
using vint=vector<int>;
using vll=vector<ll>;
using vbool=vector<bool>;
template<class T>using arr=vector<vector<T>>;
template<class T>int popcount(T &a){int c=0; rep(i, 8*(int)sizeof(a)){if((a>>i)&1) c++;} return c;}
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} pr(a[a.size()-1]);}
template<class T>void prarr(arr<T>& a){rep(i, a.size()) if(a[i].empty()) pr(""); else prvec(a[i]);}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main()
{
    int n; cin >> n;
    string s; cin >> s;
    map<char, int> m;
    rep(i, n) m[s[i]]++;

    ll ans = 1;
    for(auto p: m){
        ans *= (1+p.second);
        ans %= MOD;
    }
    pr((ans-1+MOD)%MOD);
    return 0;}

Measured memory_bytes: 3740
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
// const int N = ;
using ll = long long;
using ii = pair <int , int>;

int main() {
	int x; scanf("%d" , &x);
	printf("%d\n" , (x / 500) * 1000 + ((x % 500) / 5) * 5);
	return 0;
}


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

#素集合 無向グラフ
class UnionFind():
  def __init__(self, n):
    self.n = n
    self.parents = [-1] * n

  def find(self, x):
    if self.parents[x] < 0:
      return x
    else:
      self.parents[x] = self.find(self.parents[x])
      return self.parents[x]

  def union(self, x, y):
    x = self.find(x)
    y = self.find(y)
    if x == y:
      return False

    if self.parents[x] > self.parents[y]:
      x, y = y, x
    self.parents[x] += self.parents[y]
    self.parents[y] = x
    return True

  def size(self, x):
    return -self.parents[self.find(x)]

  def same(self, x, y):
    return self.find(x) == self.find(y)

  def members(self, x):
    root = self.find(x)
    return [i for i in range(self.n) if self.find(i) == root]

  def roots(self):
    return [i for i, x in enumerate(self.parents) if x < 0]

  def group_count(self):
    return len(self.roots())

  def all_group_members(self):
    return {r: self.members(r) for r in self.roots()}

  def __str__(self):
    return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

uf = UnionFind(n)
for i in range(m):
  x,y=map(int,input().split())
  uf.union(x-1,y-1)
print(uf.group_count()-1)

Measured memory_bytes: 12768
x1, y1, x2, y2 = map(int, input().split())
dx = x2 - x1
dy = y2 - y1

dx, dy = -dy, dx
x3 = x2 + dx
y3 = y2 + dy

dx, dy = -dy, dx
x4 = x3 + dx
y4 = y3 + dy

print(x3, y3, x4, y4)


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

int main () {
	string N;
	cin >> N;
	int sum = 0;

	rep(i,N.size()) {
		sum += N[i] - '0';
	}
	
	if (sum % 9 == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 3752
#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 FOR(i, m, n) for(int i = m; i < n; i++)
#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;}

#define MAX 500000
int L[MAX/2 + 2], R[MAX/2 + 2];
int cnt;


signed main()
{   
    gearup;
    int n,k,q; cin >> n >> k >> q;
    map<int,int> mp;
    rep(i,q){
        int m; cin >> m;
        mp[m-1]++;
    }
    rep(i,n){
        if(k - q + mp[i] > 0)cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}

Measured memory_bytes: 5376