akhauriyash/Code-Regression huggingface dataset:
// AOJ GRL_1_A Shortest Path - Single Source Shortest Path
// 2018.4.26 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define QMAX 100000
typedef struct { int t, s; } QUE;
QUE que[QMAX]; int qsize;

#define PARENT(i) ((i)>>1)
#define LEFT(i)   ((i)<<1)
#define RIGHT(i)  (((i)<<1)+1)

void min_heapify(int i)
{
	int l, r, min;
	QUE qt;

	l = LEFT(i), r = RIGHT(i);
	if (l < qsize && que[l].t < que[i].t) min = l; else min = i;
	if (r < qsize && que[r].t < que[min].t) min = r;
	if (min != i) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		min_heapify(min);
	}
}

void deq()
{
	que[0] = que[--qsize];
	min_heapify(0);
}

void enq(int s, int t)
{
	int i, min;
	QUE qt;

	i = qsize++;
	que[i].s = s, que[i].t = t;
	while (i > 0 && que[min = PARENT(i)].t > que[i].t) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		i = min;
	}
}

#if 1
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif
int in()
{
	int n = 0, c = gc();
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

#define INF    0x70707070
#define MAX_V  100002
int V;         // 頂点数
int hi[MAX_V], *to[MAX_V], *d[MAX_V];
int dist[MAX_V];

void dijkstra(int start)
{
	int i, s, e, t, nt;

	memset(dist, INF, V<<2);
	qsize = 0;
	dist[start] = 0, enq(start, 0);
	while (qsize) {
		s = que[0].s, t = que[0].t, deq();
		if (dist[s] < t) continue;
		for (i = 0; i < hi[s]; i++) {
			e = to[s][i], nt = t + d[s][i];
			if (dist[e] > nt) dist[e] = nt, enq(e, nt);
		}
	}
}

char buf[20];
void mypr(int n)
{
	int i = 0;
	if (n == 0) buf[i++] = '0';
	else while (n) buf[i++] = n%10 + '0', n/=10;
	while (i) pc(buf[--i]);
	pc('\n');
}

int main()
{
	int E, r, i, j, k, s;
	int *memo;

	V = in(), E = in(), r = in();
	memo = malloc(sizeof(int)*3*E);
	j = 0; for (i = 0; i < E; i++) {
		memo[j++] = s = in(), hi[s]++;
		memo[j++] = in(), memo[j++] = in();
	}
	for (i = 0; i < V; i++) {
		if (hi[i]) to[i] = malloc(hi[i]<<2), d[i] = malloc(hi[i]<<2);
	}
	memset(hi, 0, V<<2);
	j = 0; while (E--) {
		s = memo[j++];
		k = hi[s]++, to[s][k] = memo[j++], d[s][k] = memo[j++];
	}
	free(memo);
	dijkstra(r);
	for (i = 0; i < V; i++) {
		if (dist[i] == INF) pc('I'), pc('N'), pc('F'), pc('\n');
		else mypr(dist[i]);
	}
	return 0;
}


Measured memory_bytes: 15648
#include<stdio.h>
int main(void){
int i,j,H,W;
while(1){
scanf("%d %d",&H ,&W);
if (H == 0 && W == 0)break;
for(i=0;i < H;i++){
for(j=0;j < W;j++){
if (i == 0 || i == H-1 || j == 0 || j == W-1){
printf("#");
}else{
printf(".");
}
}
printf("\n");
}
printf("\n");
}
return 0;
}

Measured memory_bytes: 572
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author AnandOza
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        APainting solver = new APainting();
        solver.solve(1, in, out);
        out.close();
    }

    static class APainting {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int h = in.nextInt(), w = in.nextInt();
            int n = in.nextInt();

            int s = Math.max(h, w);

            int answer = (n + s - 1) / s;

            out.println(answer);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



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

int main(){
  int n;
  cin >> n;
  vector<int>vec(n);
  for (int i = 0; i < n; i++){
    cin >> vec.at(i);
  }
  sort(vec.begin(),vec.end());
  cout << vec.at(n-1) - vec.at(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;
using P = pair<int,int>;

void Main()
{
  int N, M; cin >> N >> M;
  vector<int> p(M), y(M);
  map<int,vector<int>> PY;
  rep(i,M) {
    cin >> p[i] >> y[i];
    PY[p[i]].push_back(y[i]);
  }
  map<int, vector<int>>::iterator it;
  for (it = PY.begin(); it != PY.end(); it++) {
    sort(it->second.begin(), it->second.end());
  }
  vector<int> prefId(N);
  rep(i,N) prefId[i] = 1;
  rep(i,M) {
    cout << std::setw(6) << std::setfill('0') << p[i];
    vector<int>::iterator low = std::lower_bound (PY[p[i]].begin(), PY[p[i]].end(), y[i]);
    cout << std::setw(6) << std::setfill('0') << (int)(low-PY[p[i]].begin())+1 << endl;
    prefId[p[i]]++;
  }
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  Main();
  return 0;
}


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

int main() {
  int A , B , C;
  string T;
  
  cin >> A >> B >> C;
  
  if(abs(A-B)+abs(B-C)+abs(C-A) != 0 && (A-B)*(B-C)*(C-A) == 0){
    
  T = "Yes";
    
  }else{
    
  T = "No";
    
  }
  
  cout << T << endl;
}


Measured memory_bytes: 256
#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 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;}

int main(){
  LL N,K,i;
  DB ans=0;
  scanf("%lld%lld",&N,&K);
  LL p[N],s[N+1];
  FOR(i,0,N)scanf("%lld",&p[i]);
  s[0]=0;
  FOR(i,0,N)s[i+1]=s[i]+p[i];
  FOR(i,0,N-K+1)ans=MAX(ans,(s[i+K]-s[i]+K)/2.0);

  printf("%.10f\n",ans);
	return 0;
}


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

int main() {
  int A, B;
  cin >> A >> B;
  if ((A + B) % 2 == 1)
    cout << "IMPOSSIBLE" << endl;
  else 
    cout << (A + B) / 2 << endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll=long long;
using namespace std;
#define rep_i(i, n) for (int i = 0; i < (n); ++i)
#define rep_ll(i, n) for (long long i = 0; i < (n); ++i)
#define r_rep_i(i, start, end) for (int i = (start); i < (end); ++i)
#define r_rep_ll(i, start, end) for (long long i = (start); i < (end); ++i)
#define debug_vi(v) copy((v).begin(), (v).end(), ostream_iterator<int>(cout, " "));
#define debug_vll(v) copy((v).begin(), (v).end(), ostream_iterator<long long>(cout, " "));
#define debug_vd(v) copy((v).begin(), (v).end(), ostream_iterator<double>(cout, " "));
#define sort_v(v) sort((v).begin(), (v).end()); //昇順
#define d_sort_vi(v) sort((v).begin(), (v).end(), greater<int>()); //降
#define d_sort_vd(v) sort((v).begin(), (v).end(), greater<double>()); //昇順
#define say(t) cout << (t) << endl;
#define sum_vi(v) accumulate((v).begin(), (v).end(), 0);
#define sum_vll(v)accumulate((v).begin(), (v).end(), 0LL);

ll gcd(ll a, ll b) { return b?gcd(b, a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a, b)*b;}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  int n, m; cin >> n >> m;
  int ac_c = 0;
  int wa_c = 0;
  int p;
  string ans;
  int ac_p[1000000];
  int wa_p[1000000];
  rep_i(i, m){
    cin >> p >> ans;
    if(ans == "AC"){
      if(ac_p[p] == 1){
        continue;
      }else{
        ac_c += 1;
        ac_p[p] = 1;
        wa_c += wa_p[p];
      }
    }else{
      if(ac_p[p] == 1){
        continue;
      }else{
        wa_p[p] += 1;
      }
    }
  }
  cout << ac_c << " " << wa_c << endl;
}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define Vector Point
#define INF 2000000000
#define sq(x) ((x)*(x))
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define EQ(a,b) (abs((a)-(b))<eps)

// ***** 幾何ライブラリ　線分と直線に注意!! 誤差に注意すること!! *****

inline double add(double a,double b){
	if(abs(a+b)<eps*(abs(a)+abs(b)))return 0;
	return a+b;
}

struct Point{
	double x,y;
	Point() {}
	Point(double x,double y) : x(x),y(y){}
	Point operator + (Point p){return Point(add(x,p.x),add(y,p.y));}
	Point operator - (Point p){return Point(add(x,-p.x),add(y,-p.y));}
	Point operator * (double d){return Point(x*d,y*d);}
	double dot(Point p){return add(x*p.x,y*p.y);}
	double det(Point p){return add(x*p.y,-y*p.x);}
	double norm(){return sqrt(x*x+y*y);}
	double norm2(){return x*x+y*y;}
	double dist2(Point p){return sq(x-p.x)+sq(y-p.y);}
	Point vert(){return Point(y,-x);}
	void dump(const char* msg=""){printf("%s(%.12f,%.12f)\n",msg,x,y);return;}
	
	// following functions for vector operation

	// signed area of triange (0,0) (x,y) (p.x,p.y)
	double area(Point p){
		return (x*p.y-p.x*y)/2.0;
	}

};
struct Line{
	Point a,b;
	Line(){}
	Line(Point a,Point b):a(a),b(b){}
	bool on(Point q){
		return (a-q).det(b-q)==0; 
	}
	bool is_parallel(Line l){
		return (a-b).det(l.a-l.b)==0;
	}
	Point intersection(Line l){
		assert(!is_parallel(l));
		return a+(b-a)*((l.b-l.a).det(l.a-a)/(l.b-l.a).det(b-a));
	}
	// projection of p to this line
	// verified AOJ CGL_1_A
	Point projection(Point p){
		return (b-a)*((b-a).dot(p-a)/(b-a).norm2())+a;
	}
};
struct Segment{
	Point a,b;
	Segment(){}
	Segment(Point a,Point b):a(a),b(b){}
	Line line(){
		return Line(a,b);
	}
	bool on(Point q){
		return ((a-q).det(b-q)==0&&(a-q).dot(b-q)<=0); 
	}
	bool is_intersect(Segment s){
		if(a.x>b.x)swap(a,b);
		if(s.a.x>s.b.x)swap(s.a,s.b);
		Point k = line().intersection(s.line());
		if((a.x<=k.x)&&(k.x<=b.x)&&(s.a.x<=k.x)&&(k.x<=s.b.x))return true;
		else return false;
	}
	bool is_intersect(Line l){
		if(a.x>b.x)swap(a,b);
		if(l.a.x>l.b.x)swap(l.a,l.b);
		Point k = line().intersection(l);
		if((a.x<=k.x)&&(k.x<=b.x))return true;
		else return false;
	}
};
typedef vector<Point> Polygon;

int main(){
	Point p1,p2;
	cin >> p1.x >> p1.y >> p2.x >> p2.y;
	int q;
	cin >> q;
	for(int i=0;i<q;i++){
		Point p;
		cin >> p.x >> p.y;
		Point ans = Line(p1,p2).projection(p);
		cout << setprecision(30) << ans.x << ' ' << ans.y << endl;
	}
	return 0;
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for (int i = (int)(k); i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define rREP(i, k, n) for (int i = (int)(n)-1; i >= k; i--)

#define fi first
#define se second

#define vi vector<int>
#define pb push_back
#define mp make_pair

#define pcnt __builtin_popcount

typedef long long ll;

const int inf = 100100100;
const int MOD = (int) 1e9 + 7;
const double EPS = 1e-9;

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() {
    string s;
    cin >> s;
    bool f = true;
    if(s[0]!='A') f=false;
    int cnt =0;
    REP(i,1,s.size()){
        if(s[i]=='C'){
            if(i>=2&&i<=s.size()-2){
                cnt++;
            }else{
                f=false;
            }
        }

        else if(s[i]<='Z'&&'A'<=s[i]){
            f=false;
        }
    }
    if(cnt!=1) f=false;
    if(f) cout<<"AC" <<endl;
    else cout << "WA" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>



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

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

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




















 
int main(){
    ll x, a;
    cin >> x >> a;
    if(x < a) cout << 0 << endl;
    else cout << 10 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void init () { ios::sync_with_stdio(0); cin.tie(nullptr); }
void chmax (int &a, int b) { if (a < b) { a = b; } }
void chmin (int &a, int b) { if (a > b) { a = b; } }

constexpr int INF = 1e9;

int main() {
    init();
    string s;
    cin >> s;
    const int n = s.length();
    int ans = INF;
    
    for (char c = 'a'; c <= 'z'; c++) {
        int res = 0, len = 0;
        for (const char &a : s) {
            if (c == a) { chmax(res, len); len = 0; }
            else len++;
        }
        chmax(res, len);
        chmin(ans, res);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    int n;
    int ans=0;
    int ansm=0;
    char s[199];
    int a[99]={};
    int tmp=0;
    
    cin >> n;
    cin >> s;
    
    for(int i=1; i<=n-1; i++){
        
        for(int k=0; k<=99; k++){
            
            a[k] = 0;
            
        }
        
        ans = 0;
        
        for(int j=0; j<=n-1; j++){
            
            if(j<i){
                
                tmp = s[j] - 'a';
                
                a[tmp] = 1;
                
            } else {
                
                tmp = s[j] - 'a';
                
                if(a[tmp]==1){
                    
                    ans += 1;
                    a[tmp] = 0;
                    
                }
                
            }
            
        }
        
        ansm = max(ans, ansm);
        
    }
    
    cout << ansm << endl;
    
    return 0;
    
}

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

int main(){
  long long int n,k;
  cin >> n >> k;
  if(n==k){
    cout << '0' << endl;
    return 0;
  }else if(n>k){
    long long int x=n/k;
    n=n-x*k;
    n=min(n,abs(n-k));
    cout << n << endl;
    return 0;
  }else{
    n=min(n,abs(n-k));
    cout << n << endl;
    return 0;
  }
  cout << n << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<int(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define show(x) cout<< #x << " = " << x << endl
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b/gcd(a,b);}	

const ll mod=1e9+7;
const int INF=INT_MAX/2;
const int N_MAX=100010;
const double PI=3.14159265359;

int main(){
	int n;
	cin>>n;
	for(int i=1;i<=9;i++){
		for(int j=1;j<=9;j++){
			if(i*j == n){
				cout<<"Yes"<<endl;
				return 0;
			}
		}
	}
	cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int l;
		for(l=1; l<N; l++){
			N -= l;
		}
		if(N != l){
			System.out.println("No");
			System.out.flush();
			return;
		}
		System.out.println("Yes");
		System.out.printf("%d\n", l+1);
		int[][] answer = new int[l+1][l];
		int Index = 1;
		for(int i=0; i<=l; i++){
			System.out.printf("%d", l);
			int j=0;
			for(; j<i; j++){
				System.out.printf(" %d", answer[i][j]=answer[j][i-1]);
			}
			for(; j<l; j++){
				System.out.printf(" %d", answer[i][j]=Index++);
			}
			System.out.printf("\n");
		}
		System.out.flush();
		return;
	}

}


Measured memory_bytes: 74932
# coding: utf-8

def getBList(A):
    bList = []
    for i in range(1, len(A)+1):
        bList.append(A[i-1]-i)
    return bList

def getMedian(bList):
    tmp = sorted(bList)
    if len(bList) % 2 == 1:
        return tmp[len(bList)//2]
    else:
        return (tmp[len(bList)//2]+tmp[len(bList)//2-1])//2

def solve(A, b):
    ssum = 0
    for i in range(len(A)):
        ssum += abs(A[i] - (b+i+1))
    return ssum

if __name__ == "__main__":

    N = int(input())
    A = [int(x) for x in input().split()]
    print(solve(A, getMedian(getBList(A))))
 


Measured memory_bytes: 25836
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 105;
const ll INF = 1000000000000000000;
vector<int> adjlist[N];
int d[N];
int a[N], b[N];
int mx[N];
int n;
using namespace std;
queue<int> q;
void process(){
    memset(mx,0,sizeof(mx));
    while (q.size()){
        int u = q.front(); q.pop();
        for (auto v : adjlist[u]){
            if (d[v] == -1){
                d[v] = d[u]+1;
                mx[d[v]] = max(mx[d[v]],(int)adjlist[v].size()-1);
                q.push(v);
            }
        }
    }
}
int main(){
    scanf("%d",&n);
    if (n == 2){
        printf("1 2");
        return 0;
    }
    for (int i = 1; i < n; i++){
        scanf("%d%d",&a[i],&b[i]);
        adjlist[a[i]].push_back(b[i]);
        adjlist[b[i]].push_back(a[i]);
    }
    pair<int,ll> ans = {n,LLONG_MAX};
    for (int i = 1; i <= n; i++){
        memset(d,-1,sizeof(d));
        d[i] = 0;
        q.push(i);
        process();
        ll P = (int)adjlist[i].size();
        int dist;
        for (dist = 1; dist < n; dist++){
            if (mx[dist] == 0) break;
            if (LLONG_MAX/mx[dist] < P){
                P = LLONG_MAX;
            }
            else P *= mx[dist];
        }
        dist++;
        ans = min(ans,{dist,P});
    }
    for (int i = 1; i < n; i++){
        q.push(a[i]);
        q.push(b[i]);
        memset(d,-1,sizeof(d));
        d[a[i]] = d[b[i]] = 0;
        process();
        ll P = 2*(max((int)adjlist[a[i]].size(),(int)adjlist[b[i]].size())-1);
        int dist;
        for (dist = 1; dist < n; dist++){
            if (mx[dist] == 0) break;
            if (INF/mx[dist] < P){
                P = INF;
            }
            else P *= mx[dist];
        }
        dist++;
        //printf("%d %d %d %lld\n",a[i],b[i],dist,P);
        ans = min(ans,{dist,P});
    }
    printf("%d %lld\n",ans.first,ans.second);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define reprr(i, m, n) for (ll i = m; i < n; i++)
#define inf 2e9
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll N, K; cin >> N >> K;
    string S; cin >> S;

    ll i = 0;
    vector<pair<ll, ll>> v; // {{count_1, count_0}}
    while (i < S.size()) {
        ll count_1 = 0;
        while (i < S.size() && S[i] == '1') i++, count_1++;
        if (i == S.size()) {
            v.push_back({count_1, 0});
            break;
        }
        ll count_0 = 0;
        while (i < S.size() && S[i] == '0') i++, count_0++;
        v.push_back({count_1, count_0});
    }
    // for (auto elem : v) {
    //     cout << elem.first << " " << elem.second << endl;
    // }

    v.push_back({0, 0});

    if (v.size()-1 <= K) {
        ll total = 0;
        for (auto elem : v) {
            total += elem.first + elem.second;
        }
        cout << total << endl;
        return 0;
    }

    ll max_num = 0;
    ll total = 0;
    rep(i, K - 1) {
        total += v[i].first + v[i].second;
    }
    //cout << "total: " << total << endl;

    reprr(i, K - 1, v.size()-1) {
        total += v[i].first + v[i].second;
        total += v[i+1].first;
        //cout << "total(before): " << total << " ";
        max_num = max(max_num, total);
        total -= v[i+1].first;
        total -= (v[i - K + 1].first + v[i - K + 1].second);
        //cout << "total(after): " << total << endl;
    }
    cout << max_num << endl;
    return 0;
}

Measured memory_bytes: 1528
#include <algorithm>
#include <iostream>
#include <vector>
#include <stdio.h>
#include <map>
#include <set>
#include <math.h>
#include <queue>
#include <bitset>
#include <list>
#include <math.h>
#include <string.h>
#include <tuple>
using namespace std;
#define long long long
#define name "digit"
#define ini freopen(name".inp","r",stdin);freopen(name".out","w",stdout)
#define fio ios_base::sync_with_stdio(false);cin.tie(0)
#define fo(i,a,b) for(long i=(long)a;i<=(long)b;i++)
#define fu(i,a,b) for(long i=(long)a;i>=(long)b;i--)
#define foe(it,c) for( __typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define endl '\n'
#define PLL pair<long,long>
#define x first
#define y second
#define db(a) cout << a << " ";
#define de(a) cout << a << endl;

#define tu tuple<long,long,long>
long a[2000][5];
long so;
main()
{
    long n, m; cin >> n >> m;

    fo(i,0,n - 1)
    {
        long x, y, z; cin >> x >> y >> z;
        a[i][0] = x;
        a[i][1] = y;
        a[i][2] = z;
    }

    fo(i,0,7)
    {
        long jj = i;
        long b[2000][5];

        fo(j,0,n - 1) fo(k,0,2) b[j][k] = a[j][k];

        long cn = -1;
        while (jj)
        {
            cn++;
            if (jj & 1)
            {
                fo(j,0,n - 1)
                {
                    b[j][cn] *= -1;
                    //db(b[j][cn]);
                    //if (j == n - 1) de("");
                }
            }
            jj >>= 1;
        }

        long t = 0;
        multiset<long> se;
        fo(j,0,n - 1)
        {
            se.insert(-b[j][0] - b[j][1] - b[j][2]);
        }
        long j = m;
        foe(it,se)
        {
            //db(-*it);
            if (!j) break;
            j --;
            t -= *it;
        }
        //de("");
        so = max(so, t);
    }

    db(so);
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#pragma GCC optimize ("O2")
#pragma GCC optimize ("unroll-loops")
//#pragma GCC optimize("no-stack-protector,fast-math")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<ll, ll> pll;
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugp(x) cerr<<#x<<"= {"<<(x.first)<<", "<<(x.second)<<"}"<<endl;
#define debug2(x, y) cerr<<"{"<<#x<<", "<<#y<<"} = {"<<(x)<<", "<<(y)<<"}"<<endl;
#define debugv(v) cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;
#define all(x) x.begin(), x.end()
#define pb push_back
#define kill(x) return cout<<x<<'\n', 0;

const ld eps=1e-7;
const int inf=1000000010;
const ll INF=10000000000000010LL;
const int mod = 1000000007;
const int MAXN = 2010, LOG=20;

ll n, m, k, u, v, x, y, t, a, b, ans;
ll X[200001], Y[200001];
int dp[MAXN*2][MAXN*2];
int C[MAXN*4][MAXN*2];

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin>>n;
	for (int i=1; i<=n; i++) cin>>X[i]>>Y[i], dp[MAXN-X[i]][MAXN-Y[i]]++;
	for (int i=1; i<MAXN*2; i++) for (int j=1; j<MAXN*2; j++) dp[i][j]=(dp[i][j] + dp[i-1][j] + dp[i][j-1])%mod;
	for (int i=0; i<MAXN*4; i++){
		C[i][0]=C[i][i]=1;
		for (int j=1; j<min(i, MAXN*2); j++) C[i][j]=(C[i-1][j] + C[i-1][j-1])%mod;
	}
	for (int i=1; i<=n; i++){
		ans=(ans + dp[MAXN+X[i]][MAXN+Y[i]])%mod;
		ans=(ans - C[X[i]*2+Y[i]*2][X[i]*2])%mod;
	}
	ans=ans*(mod+1)/2%mod;
	if (ans<0) ans+=mod;
	cout<<ans<<'\n';
		
	return 0;
}

Measured memory_bytes: 191232
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let a: i32 = read(&mut stdin_lock, &mut buf, b' ');
    let b: i32 = read(&mut stdin_lock, &mut buf, b'\n');
    let d = b - a;
    let ans = d * (d + 1) / 2 - b;
    println!("{}", ans);
}


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

int main(void) {
    int N;
    char* buffer;
    int side_value = 0, max_side = 0, side_sum = 0;;

    if (scanf("%d ", &N) != EOF) {
        buffer = malloc(sizeof(char)*N*4);
        if (fgets(buffer, N*4, stdin) != NULL) {
            side_value = atoi(strtok(buffer, " "));
            max_side  = side_value;
            side_sum += side_value;
            for (int i = 1; i < N; i++) {
                side_value = atoi(strtok(NULL, " "));
                side_sum += side_value;
                if (max_side < side_value) {
                    max_side = side_value;
                }
            }
        }
    }

    if (side_sum-max_side > max_side) {
        printf("Yes");
    } else {
        printf("No");
    }
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
static int fast_io = []() { std::ios::sync_with_stdio(false); cin.tie(nullptr); return 0; }();
int main(){
  int n,m;
  cin>>n>>m;
  int tmp;
  for(int i = 0;i<m;i++){
    cin>>tmp;
    n-=tmp;
  }
  n=max(-1,n);
  cout<<n<<"\n";  
  return 0;
}


Measured memory_bytes: 3664
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;

int main() {
    int a, b, h; cin >> a >> b >> h;
    cout << (a + b) * h / 2 << endl;
}


Measured memory_bytes: 256
# 入力
import sys
stdin = sys.stdin

def li(): return [int(x) for x in stdin.readline().split()]
def li_(): return [int(x)-1 for x in stdin.readline().split()]
def lf(): return [float(x) for x in stdin.readline().split()]
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(ns())
def nf(): return float(ns())

x1, y1, x2, y2 = li()

mean = (abs(x2-x1) + abs(y2-y1)) / 2
cent_x, cent_y = 0,0

if x1 >= x2 and y2 >= y1:
    cent_x, cent_y = x1-mean, y2-mean
    
elif x1 >= x2 and y1 >= y2:
    cent_x, cent_y = x2+mean, y1-mean
    
elif x2 >= x1 and y1 >= y2:
    cent_x, cent_y = x1+mean, y2+mean
    
else:
    cent_x, cent_y = x2-mean, y1+mean
    
x2_v, y2_v = x2-cent_x, y2-cent_y

x3_v, y3_v = -y2_v, x2_v 
x4_v, y4_v = -y3_v, x3_v

x3, y3 = int(x3_v+cent_x), int(y3_v+cent_y)
x4, y4 = int(x4_v+cent_x), int(y4_v+cent_y)

print(x3,y3,x4,y4)

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

int d[MAX], q[MAX], a[MAX], b[MAX];
signed main(){
	int N, D, Q;
	scanf("%lld%lld", &N, &D);
	for(int i = 1;i <= N;i++)scanf("%lld", &d[i]);
	scanf("%lld", &Q);
	for(int i = 1;i <= Q;i++)scanf("%lld", &q[i]);
	
	a[0] = D;
	for(int i = 1;i <= N;i++){
		a[i] = min(llabs(d[i]-a[i-1]), a[i-1]);
	}
	b[N+1] = 1;
	for(int i = N;i >= 1;i--){
		if(b[i+1] <= d[i]/2)b[i] = b[i+1];
		else b[i] = b[i+1]+d[i];
	}
	
	for(int i = 1;i <= Q;i++){
		int t = q[i];
		if(a[t-1] != 0 && a[t-1] >= b[t+1])printf("YES\n");
		else printf("NO\n");
	}
	/*for(int i = 1;i <= N;i++)printf("%2lld ", a[i]);
	printf("\n");
	for(int i = 1;i <= N;i++)printf("%2lld ", b[i]);*/
	return 0;
}


Measured memory_bytes: 24448
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int inf = 1e9;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, b, a) for (int i = a - 1; i >= b; i--)
#define int long long
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dxx[8] = {1, 1, 1, 0, 0, -1, -1, -1}, dyy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

signed main() {
    int h, w, k;
    cin >> h >> w >> k;
    char g[h][w];
    rep (i, 0, h) rep (j, 0, w) cin >> g[i][j];
    int ans = 0;
    for (int bith = 0; bith < (1 << h); bith++) {
        for (int bitw = 0; bitw < (1 << w); bitw++) {
            int cnt = 0;
            rep (i, 0, h) {
                if (bith & (1 << i)) continue;
                rep (j, 0, w) {
                    if (bitw & 1 << j) continue;
                    if (g[i][j] == '#') cnt++;
                }
            }
            if (cnt == k) ans++;
        }
    }
    cout << ans << "\n";
}


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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) ((a+b-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX/2

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;

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;}
template<class T> void YesNo(T a) {cout<<(a?"Yes":"No")<<endl;}
template<class T> void YESNO(T a) {cout<<(a?"YES":"NO")<<endl;}
void vin(Vi &v){REP(i,0,(v).size()) cin>>v[i];}
void vin(Vi &v,Vi &v2){REP(i,0,(v).size()) cin>>v[i]>>v2[i];}
void vout(Vi &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());}
int ctoi(char c){if(c>='0'&&c<='9'){return c-'0';}return 0;}
void accum(Vi &v){REP(i,1,(v).size()) v[i]+=v[i-1];}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

signed main(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    int n;
    cin>>n;
    Vi t(n),a(n);
    vin(t);
    vin(a);
    a.pb(0);

    VPii m(n);
    REP(i,0,n){
        if(i==0) m[i]=mp(t[i],1);
        else{
            if(t[i-1]<t[i]) m[i]=mp(t[i],1);
            if(t[i-1]==t[i]) m[i]=mp(t[i],0);
            if(t[i-1]>t[i]){cout<<0<<endl;return 0;}
        }
    }

    REPR(i,n-1,-1){
        if(m[i].second==1){
            if(a[i]<m[i].first){cout<<0<<endl;return 0;}
            if(a[i]>a[i+1] && a[i]!=m[i].first){cout<<0<<endl;return 0;} 
        }else{
            if(a[i]>a[i+1] && a[i]>m[i].first){cout<<0<<endl;return 0;}
            if(a[i]<m[i].first) m[i]=mp(a[i],0);
            if(a[i]>a[i+1]) m[i]=mp(a[i],1);
        }
    }
    int ans=1;
    REP(i,0,n){
        if(m[i].second==0) ans = (ans*m[i].first)%MOD;
    }
//    REP(i,0,n) cout<<"i="<<i<<" "<<m[i].first<<" "<<m[i].second<<endl;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3440
solve [] b_h b_b = b_h ++ reverse b_b
solve (a:as) b_h b_b = solve as (a:b_b) b_h

main = do
  getLine
  s <- getLine
  let as = map (read::String -> Int) $ words s
  putStrLn $ unwords $ map (show) $ solve as [] []

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

int main(){
	string n="";
	cin >> n;
	int i=0;
	while(1){
		if(i>n.size()){
			break;
		}
		if(n[i]=='1'){
			n[i]='9';
			i++;
		}else if(n[i]=='9'){
			n[i]='1';
			i++;
		}else{
			i++;
		}
	}

	for(int i=0;i<n.size();i++){
		cout << n[i];
	}	
	cout << endl;
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = n;i >= m;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define ALL(n) n.begin(),n.end()

int main() {
	int a, b;
	cin >> a >> b;
	cout << (a + b) % 24 << endl;
}

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int main() {
  int n, s;

  while(cin >> n >> s, n+s) {
    VI r(n);
    REP(i, n) cin >> r[i];

    int ans = 0;
    REP(i, n-1) {
      FOR(j, i+1, n) {
	if(r[i]+r[j] > s) ans++;
      }
    }
    cout << ans << endl;
  }
}

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

using namespace std;

typedef long long int ll;
#define inf 0x3f3f3f3f
#define endl '\n'
// #define case(i) "Case #" << i << ": "
const ll INF = 1e18;

vector<int> v, w;

ll dp[101][100001];
ll solve(int i, int val) {
    if(i < 0) {
        if(val == 0) return 0;
        else return INF;
    }
    else {
        if(v[i] > val) return solve(i-1, val);
        else return min(w[i] + solve(i-1, val - v[i]), solve(i-1, val));
    } 
}


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

    int n, W;
    cin >> n >> W;

    v.resize(n+1);
    w.resize(n+1);

    ll V(0);

    for(int i = 1; i <= n; ++i) {
        cin >> w[i] >> v[i];
        V += v[i];
    }

    for(int i = 0; i <= n; ++i) {
        for(int j = 0; j <= V; ++j) {
            if(i == 0) {
                if(j == 0) dp[i][j] = 0;
                else dp[i][j] = INF;
            }
            else {
                // if(v[i] > val) return solve(i-1, val);
                // else return min(w[i] + solve(i-1, val - v[i]), solve(i-1, val));
                if(v[i] > j) dp[i][j] = dp[i-1][j];
                else dp[i][j] = min(w[i] + dp[i-1][j - v[i]], dp[i-1][j]);
            }
        }
    }

    ll ans(0);

    for(int i = V; i >= 0; --i) {
        if(dp[n][i] <= W) {
            ans = i;
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 79104
#include<stdio.h>
int main(){
	char s[128],p[128];
	int i,j,flag,res=0;
	scanf("%s\n%s",s,p);
	for(i=0;i<strlen(s);i++){
		if(s[i]==p[0]){
			flag=0;
			for(j=0;j<strlen(p);j++){
				if(s[(j+i)%strlen(s)]!=p[j])flag=1;
			}
			if(!flag)res=1;
		}
	}
	if(res)printf("Yes\n");
	else printf("No\n");
	return 0;
}
			

Measured memory_bytes: 524
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

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,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)

int main() {
	ll K;
	std::cin >> K;

	ll ans = 0;
	repeq(i, 1, K) {
		repeq(j, 1, K) {
			repeq(k, 1, K) {
				ans += gcd(i, gcd(j, k));
			}
		}
	}

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


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    string S;
    vector <char> C;
    cin >> S;
    FOR(i,0,4)
        C.push_back(S[i]);
    sort(C.begin(),C.end());
    if(C[0]==C[1] && C[2]== C[3] && C[0] != C[3])
        cout << "Yes";
    else
        cout << "No";
    return 0;
}

Measured memory_bytes: 256
def resolve():
    n = int(input())
    s = input()
    l, r = 0, 0
    for c in s:
        if c == "(":
            l += 1
        elif l > 0 and c == ")":
            l -= 1
    for c in s[::-1]:
        if c == ")":
            r += 1
        elif r > 0 and c == "(":
            r -= 1
    ans = "(" * r + s + ")" * l
    print(ans)


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 3060
N, M = map(int,input().split())
p = []
S = []
AC_cnt = [0 for i in range(N)]
WA_cnt = [0 for i in range(N)]
for i in range(M):
    tmp_p, tmp_S = input().split()
    tmp_p = int(tmp_p)
    p.append(tmp_p)
    S.append(tmp_S)
p_cnt = [0 for i in range(N)]
for i in range(M):
    if p_cnt[p[i]-1]==1:
        continue
    if S[i]=="AC":
        AC_cnt[p[i]-1]+=1
        p_cnt[p[i]-1]=1
    elif S[i]=="WA":
        WA_cnt[p[i]-1]+=1

ac_cnt = sum(AC_cnt)
wa_cnt = 0
for i in range(N):
    if AC_cnt[i]==1:
        wa_cnt+=WA_cnt[i]
print(ac_cnt,wa_cnt)

Measured memory_bytes: 15808
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}

template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

int main()
{
  long long K, A, B;
  cin >> K >> A >> B;
  long long bisket = 1;
  long long T = -A + B - 2;
  if (T <= 0)
    bisket += K;
  else
  {
    long long M = max((K - A + 1) / 2, (long long)0);
    bisket = K + 1 + M * (B - A - 2);
  }
  cout << bisket << endl;
  long long ans = 48518828981938099;
  return 0;
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	string s;
	cin >> s;

	if(s=="Sunny") cout << "Cloudy" << endl;
	if(s=="Cloudy") cout << "Rainy" << endl;
	if(s=="Rainy") cout << "Sunny" << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String str = sc.nextLine();

		int N = str.length();
		
		char s[] = new char[N];
		
		for(int i=0;i<str.length(); i++){
			s[i]=str.charAt(i);
		}
		Arrays.sort(s);
		for(int i=0;i<N-1;i++){
			if(s[i]==s[i+1]){
				System.out.println("no");
				return;
			}
		}
		System.out.println("yes");
			
	}
}

Measured memory_bytes: 22740
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
#define all(x) (x).begin(), (x).end() 

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

long long INF=numeric_limits<long long>::max();

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
    int a,p; cin >> a >> p;
    p+=a*3;
    cout << p/2 << endl;
}	


Measured memory_bytes: 256
#include<stdio.h>

int main () {
	int a, b, c, d, e, f;

    scanf("%d", &a);
    scanf("%d", &b);
    scanf("%d", &c);

    if ( a > b ) {
		d = a;
        a = b;
        b = d;
    }

    if ( b > c ) {
		e = b;
        b = c;
        c = e;
    }

    if ( a > b ) {
		f = b;
        b = a;
        a = f;
    }

    printf("%d %d %d\n", a, b, c);

    return 0;
}



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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) sort(all(v)); reverse(all(v))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template<typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template<typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template<typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template<typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template<typename T> inline T power(T x, i64 n) { T r = 1; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template<typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }

template< typename Monoid >
struct SegmentTree {
  using F = function< Monoid(Monoid, Monoid) >;

  int sz;
  vector< Monoid > seg;

  const F f;
  const Monoid M1;

  SegmentTree(int n, const F f, const Monoid &M1) : f(f), M1(M1)
  {
    sz = 1;
    while (sz < n) sz <<= 1;
    seg.assign(2 * sz, M1);
  }

  void set(int k, const Monoid &x)
  {
    seg[k + sz] = x;
  }

  void build()
  {
    for (int k = sz - 1; k > 0; k--) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }

  void update(int k, const Monoid &x)
  {
    k += sz;
    seg[k] = x;
    while (k >>= 1) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }

  Monoid query(int a, int b)
  {
    Monoid L = M1, R = M1;
    for (a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
      if (a & 1) L = f(L, seg[a++]);
      if (b & 1) R = f(seg[--b], R);
    }
    return f(L, R);
  }

  Monoid operator[](const int &k) const
  {
    return seg[k + sz];
  }
};

void solve() {
  int N, M;
  cin >> N >> M;
  SegmentTree<int> se(N, [&](int a, int b) { return (a + b) % M; }, 0);
  rep(i, N) {
    int a; cin >> a;
    se.set(i, a);
  }
  se.build();
  map<int, int> cnt = {{0, 1}};
  rep(i, N) {
    cnt[se.query(0, i + 1)]++;
  }
  i64 ans = 0;
  each(c, cnt) {
    ans += (i64) c.second * (c.second - 1) / 2;
  }
  cout << ans << '\n';
}


Measured memory_bytes: 4224
#include <iostream>
#include <algorithm>
#include <cinttypes>

using namespace std;

int main() {
    cin.sync_with_stdio(false);

    int a, b, c, x, y;

    cin >> a >> b >> c >> x >> y;

    int minimal = INT32_MAX;
    for (int z = 0; z <= max(x, y)*2; z++) {
        int cost = z*c + max(0, (x - z/2)*a) + max(0, (y - z/2)*b);
        minimal = min(minimal, cost);
    }

    cout << minimal << endl;

    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <iostream>
#include <utility>
#include <algorithm>
#include <math.h>
#include <vector>
using namespace std;
int dp[1001][1001] = {};

int getLCS(string X, string Y)
{
    for (int i = 1; i <= X.size(); i++)
    {
        for (int j = 1; j <= Y.size(); j++)
        {
            dp[i][j] = X[i - 1] == Y[j - 1] ? dp[i - 1][j - 1] + 1 : max(dp[i - 1][j], dp[i][j - 1]);
        }
    }
    return dp[X.size()][Y.size()];
}

int main()
{
    int q;
    string X, Y;
    cin >> q;
    for (int i = 0; i < q; i++)
    {
        cin >> X >> Y;
        cout << getLCS(X, Y) << "\n";
    }
    return 0;
}


Measured memory_bytes: 6992
#include <iostream>
#include <cstdlib>
#include <algorithm>

using namespace std;

// change minimumのこと
// a>bならばaにbを代入し、trueを返す
// 他の場合はfalseを返す
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;
}

const long long INF = 1LL << 60;
const long long P = 1000000007;

int N,W,weight[110],value[110];
long long dp[110][100100] = {};

int main() {
  cin >> N >> W;
  for(int i = 0; i < N; i++) {
    cin >> weight[i] >> value[i];
  }

  for(int i = 0; i < N; i++) {
    for(int sum_w = 0; sum_w <= W; sum_w++) {
      // i番目の品物を選ぶ場合
      if(sum_w - weight[i] >= 0) {
        chmax(dp[i+1][sum_w], dp[i][sum_w - weight[i]] + value[i]);
      }
      // i番目の品物を選ばない場合
      chmax(dp[i+1][sum_w], dp[i][sum_w]);
    }
  }
  cout << dp[N][W] << endl;
  return 0;
}

Measured memory_bytes: 79360
// luogu-judger-enable-o2
#include<bits/stdc++.h>
using namespace std;
long long n,m,k,l,i;
int main(){
    cin>>n>>m>>k;
    l=k;
    do{
        l+=m+k;
        i++;
    }while(l<n);
    if(l>n)i--;
    cout<<i<<endl;
    return 0;
}

Measured memory_bytes: 256