akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>
#include <list>

using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define reps(x,c) for(auto x:c)
#define all(x) begin(x), end(x)
#define pb(a,b,c) emplace_back(a,b,c) 
#define mp(a,b) make_pair((a),(b))
#define pl pair<ll,ll>
#define INF 2147483600
#define MOD 1000000007
#define fi first
#define se second
#define dbg(x) cout << #x"="<< (x) << endl
#define dbgv(x) cout<<#x<<endl;reps(y,x){cout<<y<<" ";}cout<<endl

typedef int Capacity;
struct Edge {
    int src, dst;
    Capacity cap;
    Edge(int src_, int dst_, Capacity cap_) :
        src(src_), dst(dst_), cap(cap_) { }
};
 
using Edges = vector<Edge>;
using Graph = vector<Edges>;
 
struct Dinic {
    int n, s, t;
    vector<int> level, prog, que;
    vector<vector<Capacity>> cap, flow;
    vector<vector<int>> g;
    Capacity inf;
    Dinic(const Graph &graph)
        : n(graph.size()),
          cap(n, vector<Capacity>(n)), flow(n, vector<Capacity>(n)),
          g(n, vector<int>()), inf(numeric_limits<Capacity>::max()/8){
        for(int i = 0; i < n; i++){
            for(auto &e : graph[i]){
                int u = e.src, v = e.dst;
                Capacity c = e.cap;
                cap[u][v] += c; cap[v][u] += c; flow[v][u] += c;
                g[u].push_back(v); g[v].push_back(u);
            }
        }
    }
    inline Capacity residue(int u, int v){ return cap[u][v] - flow[u][v]; }
    Capacity solve(int s_, int t_){
        this->t = t_, this->s = s_;
        que.resize(n+1);
        Capacity res = 0;
        while(levelize()){ prog.assign(n, 0); res += augment(s, inf); }
        return res;
    }
    bool levelize(){
        int l = 0, r = 0;
        level.assign(n, -1); level[s] = 0; que[r++] = s;
        while(l != r){
            int v = que[l++]; if(v == t) break;
            for(const int &d : g[v]) if(level[d] == -1 && residue(v,d) != 0){
                level[d] = level[v] + 1; que[r++] = d;
            }
        }
        return level[t] != -1;
    }
    Capacity augment(int v, Capacity lim){
        Capacity res = 0;
        if(v == t) return lim;
        for(int &i = prog[v]; i < (int)g[v].size(); i++){
            const int &d = g[v][i];
            if(residue(v,d) == 0 || level[v] >= level[d]) continue;
            const Capacity aug = augment(d, min(lim, residue(v,d)));
            flow[v][d] += aug; flow[d][v] -= aug;
            res += aug; lim -= aug;
            if(lim == 0) break;
        }
        return res;
    }
};

int main(){
  ll n;cin>>n;
  Graph g(2*n+2);
  vector<pl> red(n),blue(n);
  ll a,b,c,d;
  rep(i,n){
    cin>>a>>b;
    red[i]=mp(a,b);
    g[0].pb(0,i+1,1);
  }
  rep(i,n){
    cin>>c>>d;
    blue[i]=mp(c,d);
    g[i+1+n].pb(i+1+n,2*n+1,1);
  }
  rep(i,n){
    rep(j,n){
      if((red[i].fi<blue[j].fi)&&(red[i].se<blue[j].se)){
        g[i+1].pb(i+1,n+j+1,1);
      }
    }
  }
  Dinic eg(g);
  cout<< eg.solve(0,2*n+1) << endl;
  return 0;
}


Measured memory_bytes: 640
import java.io.PrintWriter;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		
		int N = sc.nextInt();
		int K = sc.nextInt();
		int Q = sc.nextInt();
		int[] score = new int[N];
		Arrays.fill(score, K-Q);
		for(int i=0; i<Q; i++)
			score[sc.nextInt()-1]++;
		
		for(int i=0; i<N; i++)
			pw.println(score[i]>0 ? "Yes" : "No");

		sc.close();
		pw.close();
	}
}


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

int main() {
  long long N;
  cin >> N;
  for (long long i = sqrt(N); i > 0; i--) {
    if (N%i == 0) {
      int count = 1;
      long long n = N/i;
      while(n >= 10) {
        n /= 10;
        count++;
      }
      cout << count << endl;
      break;
    }
  }
}

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

using namespace std;

typedef long long int ll;
#define pb push_back
#define ALL(a) (a).begin() , a.end()

int mod = 1e9 + 7;
int add(int a, int b){
	if(a + b >= mod)return a+ b - mod;
	return a + b;
}
int mul(int a, int b){
	return 1LL * a * b  % mod;
}
int power(int a, int b){
	int re = 1;
	while(b){
		if(b&1)re= mul(re, a);
		a = mul(a, a);
		b>>=1;
	}
	return re;
}
int const N = 200 * 1010;

/********************i**********************************/
int fun(int a, int b){
	if(a == b)return 1;
	return 2;
}
vector<int> prime(1e6 + 5 , 1);
void sieve(){
	for(int x = 2; x<= 1e6; x++){
		if(prime[x] == 1){
			prime[x] = x;
			for(int y = x + x; y<= 1e6; y += x)if(prime[y] == 1)prime[y] = x;
		}
	}
}
void solve(){
	sieve();
	int n;
	cin >> n;
	vector<int> dp(1e6 + 1);
	dp[1] = 1;
	vector<int> vec(n);
	for(int x = 0; x<n; x++){
		cin >> vec[x];
		int w = vec[x];
		map<int,int> ma;
		while(w > 1){
			ma[prime[w]]++;
			w /= prime[w];
		}
		for(auto a : ma){
			dp[a.first] = max(a.second, dp[a.first]);
		}

	}
	int ans = 1, ro = 0;
	for(int x = 2; x<= 1e6; x++){
		ans = mul(ans, power(x, dp[x]));
	}

	for(int x =0; x<n; x++){
		int w = vec[x];
		map<int,int> ma;
 		ro = add(ro , mul(ans, power(vec[x], mod  - 2)));
	}	
	cout << ro;


}

/******************************************************/
int main()
{
	ios_base::sync_with_stdio(false);cin.tie(nullptr);
	int t;
	t = 1;
	// cin >> t;
	while(t--){
		solve();
	}
}

Measured memory_bytes: 8064
import sys

def main():
    input = sys.stdin.readline
    L, R = map(int, input().split())
    R = min(R, L + 2019)

    ans = 2019
    for i in range(L, R):
        for j in range(i+1, R+1):
            ans = min(ans, (i*j)%2019)

    return ans


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 3060
import java.io.*;

class Main{
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		while(true){
			String str = br.readLine();
			String strArr[] = str.split(" ");
			int a, b;
			a = Integer.parseInt(strArr[0]);
			b = Integer.parseInt(strArr[1]);
			

			if(a == 0 && b == 0){
				break;
			}
			else if(a < b){
				System.out.println(a + " " + b);
			}
			else{
				System.out.println(b + " " + a);
			}

		}

	}
}

Measured memory_bytes: 24436
N,M = map(int,input().split())
K = [list(map(int,input().split()))[1:] for _ in range(N)]
t = 0
for i in range(1,M+1):
    s = 0
    for l in K:
        if i in l:
            s += 1
    if s == N:
        t += 1
print(t)





Measured memory_bytes: 3060
import java.util.*;
import java.lang.*;

class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
    	// TODO &#232;&#135;&#170;&#229;&#139;&#149;&#231;&#148;&#159;&#230;&#136;&#144;&#227;&#129;&#149;&#227;&#130;&#140;&#227;&#129;&#159;&#227;&#131;&#161;&#227;&#130;&#189;&#227;&#131;&#131;&#227;&#131;&#137;&#227;&#131;&#187;&#227;&#130;&#185;&#227;&#130;&#191;&#227;&#131;&#150;

		Scanner in = new Scanner(System.in);
		
		int checkNum = in.nextInt();
		
		for(int i = 0; i < checkNum; i++) {
			int a = in.nextInt();
			int b = in.nextInt();
			int c = in.nextInt();
			
			int tmp = (a + b + c) / 2;
			
			double space = Math.sqrt(tmp * (tmp - a) * (tmp - b) * (tmp - c));
			double angleA = 0.0;
			double angleB = 0.0;
			double angleC = 0.0;
			double high = 0.0;
			
			if ( b < a && c < a) {
				high = (2 * space) / (double)a;
				angleB = Math.toDegrees(Math.asin(high / c));
				angleC = Math.toDegrees(Math.asin(high / b));
				angleA = 180.0 - angleB - angleC;
			} else if (a < b && c < b) {
				high = (2 * space) / (double)b;
				angleC = Math.toDegrees(Math.asin(high / a));
				angleA = Math.toDegrees(Math.asin(high / c));
				angleB = 180.0 - angleA - angleC;
				
			} else if (a < c && b < c) {
				high = (2 * space) / (double)c;
				angleA = Math.toDegrees(Math.asin(high / b));
				angleB = Math.toDegrees(Math.asin(high / a));
				angleC = 180.0 - angleA - angleB;
			} else {
				// &#227;&#129;&#130;&#227;&#130;&#138;&#227;&#129;&#136;&#227;&#129;&#170;&#227;&#129;&#132;
			}
			
			if (((int)angleA) == 90 || ((int)angleB) == 90 || ((int)angleC) == 90) {
				System.out.println("YES");
			} else {
				System.out.println("NO");
			}
		}
	}
}

Measured memory_bytes: 23396
#include<stdio.h>
int flg[1000000];
int main(void)
{
	int n,i,j,c;
	while(scanf("%d",&n)!=EOF){
	c=0;
		for(i=2;i<n;i++){
			flg[i]=0;
		}	
			for(i=2;i*i<=n;i++){
				for(j=2;i*j<=n;j++){
						flg[i*j]=1;	
				}
			}
		for(i=2;i<=n;i++){
			if(flg[i]==0){
					c++;
			}		
		}
	printf("%d\n",c);
	}
	return 0;
}	

Measured memory_bytes: 4932
k = int(input())
dp = [[0]*10 for i in range(12)]  # dp[i][j]: i桁で先頭がj

for i in range(10):
    dp[1][i] = 1

for i in range(1,10):
    for j in range(10):
        dp[i+1][j] += dp[i][j]
        if j<9:
            dp[i+1][j] += dp[i][j+1]
        if j>0:
            dp[i+1][j] += dp[i][j-1]

ans = 0
for i in range(11):
    for j in range(1,10):
        if k > dp[i][j]:
            k -= dp[i][j]
        else:
            ni = i-1
            nj = j
            ans = j
            break
    if ans > 0:
        break


while ni > 0:
    for j in range(nj-1,nj+2):
        if j<0 or j>9:
            continue
        if k > dp[ni][j]:
            k -= dp[ni][j]
        else:
            ans = ans*10+j
            nj = j
            break
    ni -= 1
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B;
  cin >> A >> B;
  int C[]={0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};
  if(C[A]==C[B]){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }  
}

Measured memory_bytes: 256
t[101];main(a,b){for(t[1]=t[2]=1;;){
	if(scanf("%d%d",&a,&b)<2)exit(0);
	if(!a){
		for(b=1;b<=101;b++)if(t[b]&1)break;
		puts(b>101?"OK":"NG");
		memset(t,0,sizeof(t)),t[1]=t[2]=1;
	}else t[a]++,t[b]++;
}}

Measured memory_bytes: 584
S = input()
l = len(S)
mod = int(1e9) + 7

'''def saiki(s):
  if s == "0":
    return 1
  elif s == "1":
    return 3
  else:
    if s[0] == '0':
      return saiki(s[1:])
    else:
      SS = 2*saiki(s[1:]) + 3 ** (len(s) - 1)
      return SS'''

cnt = int(S[l-1]) * 2 + 1
base = 3
for i in range(l-1, 0, -1):
  x = int(S[i-1])
  cnt *= x+1
  cnt += base * int(x)
  cnt %= mod
  base *= 3
  base %= mod
print(cnt)

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

typedef pair<int, int> pii;

bool greaterP(pii lhs, pii rhs) {
    if (lhs.first != rhs.first) {
        return lhs.first > rhs.first;
    } else {
        return lhs.second < rhs.second;
    }
}

int main(void) {
    int n, m;

    while (cin >> n >> m, n+m) {
        vector<pii> Q(m);
        for (int i = 0; i < m; i++) {
            Q[i].first = 0;
            Q[i].second = i+1;
        }
        int q;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                cin >> q;
                if (q) {
                    Q[j].first++;
                }
            }
        }

        sort(Q.begin(), Q.end(), greaterP);

        cout << Q[0].second;
        for (int i = 1; i < m; i++) {
            cout << " " << Q[i].second;
        }
        cout << endl;
    }

    return 0;
}

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

int main()
{
string s,t,res;
cin>>s>>t;
int dp[s.length()+1][t.length()+1];
for(int i=0;i<=s.length();i++)
{
for(int j=0;j<=t.length();j++)
{
if(i==0||j==0)
dp[i][j]=0;
else if(s[i-1]==t[j-1])
dp[i][j]=1+dp[i-1][j-1];
else
dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
}
}
int m=s.length();
int n=t.length();
int len=dp[m][n];
while(len)
{
if(dp[m][n]==dp[m-1][n])
m--;
else if(dp[m][n]==dp[m][n-1])
n--;
else
{
res+=s[m-1];
len--;
m--;
n--;
}
}
reverse(res.begin(),res.end());
cout<<res<<endl;
return 0;
}

Measured memory_bytes: 35456
import java.util.ArrayList;
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        int n, m, A[][], i, j, c, a = 1, cnt;
        Scanner sc = new Scanner(System.in);
        ArrayList<Integer> b = new ArrayList<Integer>();
        n = sc.nextInt();
        m = sc.nextInt();
        A = new int[n][m];
         
        for(i = 0; n  > i; i++){
            for(j = 0; m > j; j++){
                A[i][j] = sc.nextInt();
            }
        }
         
        for(cnt = 0; cnt < m ; cnt++){
            a = sc.nextInt();
            b.add(new Integer(a));
        }
         
        for(i = 0; n > i ; i++){
            c = 0;
            for(j = 0;m > j; j++){
                c += b.get(new Integer(j)) * A[i][j];
            }
            System.out.println(c);
        }
    }
}

Measured memory_bytes: 41444
n=int(input())
s=input()
ans=''
ss='ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'
for i in s:
    x=ss.index(i)
    ans+=ss[x+n]
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> x;
  rep(i,n){
    int a;
    cin >> a;
    x.push_back(a);
  }
  x.push_back(0);
  sort(x.begin(), x.end());
  //cout << x.size() << endl;
  vector<int> L, R;
  rep(i,n+1){
    if(x[i]<=0) L.push_back(x[i]);
    if(x[i]>=0) R.push_back(x[i]);
  }
  sort(L.rbegin(), L.rend());
  int minn = 1000000000;
  //cout << L.size() << " " << R.size() << endl;
  for(int i=1; i<L.size(); i++){
    if(i<=k && k<=i+R.size()-1){
      if(k==i) minn = min(minn, abs(L[i]));
      else minn = min(minn, abs(L[i])+abs(L[i]-R[k-i]));
    }
    //cout << minn << endl;
  }
  for(int i=1; i<R.size(); i++){
    if(i<=k && k<=i+L.size()-1){
      if(k==i) minn = min(minn, abs(R[i]));
      else minn = min(minn, abs(R[i])+abs(R[i]-L[k-i]));
    }
  }
  cout << minn << endl;
}

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

// Segment-Tree
struct SegmentTree {
  int n;
  vector<int> dat;
  
  SegmentTree(int _n) {
    init(_n);
  }
  
  void init(int _n) {
    n = 1;
    while (n < _n) n *= 2;
    dat.assign(2 * n - 1, 0);
  }
  
  // i番目の値にxを追加
  void add(int i, int x) {
    i += n - 1; // 葉のノード
    dat[i] += x;
    while (i > 0) { // 更新
      i = (i - 1) / 2;
      dat[i] = dat[2 * i + 1] + dat[2 * i + 2];
    }
  }
  
  // [a, b)の和
  // k:ノードの番号 [l, r)がkに対応づいている
  // query(a, b, 0, 0, n)と呼ぶ
  int query(int a, int b, int k = 0, int l = 0, int r = -1) {
    if (r == -1) r = n;
    if (r <= a || b <= l) return 0;
    if (a <= l && r <= b) return dat[k];
    else {
      int vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
      int vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
      return vl + vr;
    }
  }
};

bool compare(vector<int> &a, vector<int> &b) {
  return a[2] < b[2];
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n, q;
  cin >> n >> q;
  
  vector<int> c(n);
  vector<vector<int>> G(n); // G[i]: the distance list from left end (color: i)
  vector<int> G_it(n, 0);
  for (int i = 0; i < n; i++) {
    cin >> c.at(i);
    c.at(i)--;
    G[c.at(i)].emplace_back(i);
  }
  
  vector<vector<int>> x(q, vector<int>(4)); // left, right, number, answer
  for (int i = 0; i < q; i++) {
    cin >> x.at(i).at(0) >> x.at(i).at(1);
    x.at(i).at(0)--;
    x.at(i).at(1)--;
    x.at(i).at(2) = i;
  }
  
  sort(x.begin(), x.end());
  
  SegmentTree st(n);
  for (int i = 0; i < n; i++) { // i: color
    if (G[i].size() > 0) st.add(G[i][0], 1);
  }
  
  int nowl = 0;
  for (int i = 0; i < q; i++) {
    while (x.at(i).at(0) > nowl) {
      st.add(nowl, -1);
      if (G[c[nowl]].size() > G_it[c[nowl]] + 1) {
        G_it[c[nowl]]++;
        st.add(G[c[nowl]].at(G_it[c[nowl]]), 1);
      }
      nowl++;
    }
    x.at(i).at(3) = st.query(x.at(i).at(0), x.at(i).at(1) + 1);
  }
  
  sort(x.begin(), x.end(), compare);
  
  for (int i = 0; i < q; i++) {
    cout << x.at(i).at(3) << '\n';
  }
}

Measured memory_bytes: 66592
import java.io.*;
import java.util.*;
public class Main implements Runnable {
    public void solve() throws Exception {
        MyScanner sc = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));
        long x = sc.nextLong();
        out.printf("%.20f",2*Math.PI*x);
    }

    //main function//
    public static PrintWriter out;
    public static void main(String[] args) throws Exception {
        new Thread(null, new Main(), "", 1 << 26).start();
    }
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;
        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine(){
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

    }
    public void run() {
        try {
           solve();
        } catch (Exception ex) {
            throw new RuntimeException(ex);
        } finally {
            out.close();
        }
    }
}


Measured memory_bytes: 34604
#include <stdio.h>
#define N 1000000
int main(void){
    int i,j;
    int n,l;
    int a[N];
    int minnum=-1;
    scanf("%d%d",&n,&l);
    for(i=0;i<n;i++) scanf("%d",&a[i]);
    for(i=0;i<=n-l;i++)
    {
        if(minnum>=i)
        {
            if(a[i+l-1]<=a[minnum]) minnum=i+l-1;
        }
        else
        {
            minnum=i;
            for(j=1;j<l;j++)
            {
               if(a[i+j]<=a[minnum]) minnum=i+j;
            }
        }
        if(i!=0) printf(" ");
        printf("%d",a[minnum]);
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 5696
n = int(input())
max_x = max_y = - 5 * 10**9
min_x = min_y = 5 * 10**9
for i in range(n):
    X, Y = map(int, input().split())
    x = X + Y
    y = X - Y
    max_x = max(max_x, x)
    max_y = max(max_y, y)
    min_x = min(min_x, x)
    min_y = min(min_y, y)
print(max(max_x - min_x, max_y - min_y))


Measured memory_bytes: 75352
#include<iostream>
#include<algorithm>
#include<string> 
#include<map>
#include<set>
#include<vector>
#include<string.h> 
#include<math.h>
#include<stdio.h> 
#include<queue>
using namespace std; 
int main()
{int a,b,c,x;
int g=0;
cin>>a>>b>>c>>x;
for(int i=0;i<=a && 500*i<=x;i++){
	for(int j=0;j<=b && 100*j+500*i<=x;j++){
		for(int k=0;k<=c && 50*k+100*j+500*i<=x;k++)
		if(50*k+100*j+500*i==x)g++;
	}
}
cout<<g;
system("pause");
return 0;
}

Measured memory_bytes: 504
#include <vector>

template<typename T>
bool warshall_floyd (std::vector<std::vector<T>> &g, const T &inf) {
    const int n = (int)g.size();
    for (int i = 0; i < n; i++) g[i][i] = T(0);
    bool ret = false;
    for (int k = 0; k < n; k++) {
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (g[i][k] == inf or g[k][j] == inf) continue;
                if (g[i][j] > g[i][k] + g[k][j]) g[i][j] = g[i][k] + g[k][j];
            }
        }
    }
    for (int i = 0; i < n; i++) ret |= (g[i][i] < 0);
    return ret;
}

template<class T>
using matrix = std::vector<std::vector<T>>;


#include <iostream>
constexpr long long inf = (1LL << 60);

int main() {
    int n, m;
    std::cin >> n >> m;
    matrix<long long> g(n, std::vector<long long>(n, inf));

    for (int i = 0; i < m; i++) {
        int s, t, d;
        std::cin >> s >> t >> d;
        g[s][t] = d;
    }

    bool neg = warshall_floyd(g, inf);

    if (not neg) {
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (g[i][j] == inf) std::cout << "INF" << " \n"[j + 1 == n];
                else std::cout << g[i][j] << " \n"[j + 1 == n];
            }
        }
    } else {
        std::cout << "NEGATIVE CYCLE" << '\n';
    }

    return 0;
}


Measured memory_bytes: 3232
eval"N,*A="+`dd`.split*?,
m=10**9+7
P=->a,b{b>0?a**b[0]*P[a,b/2]**2%m:1}
s=r=0
f=1
1.upto(N){|i|s+=P[i,m-2];r+=A[i-1]*~-s+A[-i]*s;f=f*i%m}
p r*f%m

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

int main(){
  int n;
  vector<int> ans;

  while(1){
    cin >> n;
    if(n<0)break;

    ans.clear();
    while(n/4){
      ans.push_back(n%4);
      n/=4;
    }
    ans.push_back(n);
    
    for(int i=ans.size()-1;i>=0;i--)cout << ans[i];
    cout << endl;
  }
}

Measured memory_bytes: 0
#include <algorithm>
#include <array>
#include <cmath>
#include <deque>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;


/* range: ± 3.27 * 10^4 */
using i16 = short int;
/* range: 0 to 65535 */
using u16 = unsigned short int;
/* range: ± 2.14 * 10^9 */
using i32 = int;
/* range: 0 to 4.29 * 10^9 */
using u32 = unsigned int;
/* range: ± 9.22 * 10^18 */
using i64 = long long int;
/* range: 0 to 1.84 * 10^19 */
using u64 = unsigned long long int;


i32 dfs(const vector<vector<u32>>& adj_list, vector<i32>& dp, u32 curr_node) {
    if (dp[curr_node] != -1) {
        return dp[curr_node];
    }

    i32 res = 0;
    for (auto child : adj_list[curr_node]) {
        res = max(res, 1 + dfs(adj_list, dp, child));
    }

    dp[curr_node] = res;
    return res;
}

int main() {
    u32 n = 0, m = 0;
    cin >> n >> m;

    vector<vector<u32>> adj_list(n + 1);
    for (u32 i = 0; i < m; i++) {
        u32 a = 0, b = 0;
        cin >> a >> b;
        adj_list[a].emplace_back(b);
    }

    vector<i32> dp(n + 1, -1);
    i32 ans = 0;
    for (u32 node = 1; node <= n; node++) {
        if (dp[node] == -1) {
            ans = max(ans, dfs(adj_list, dp, node));
        }
    }

    cout << ans << '\n';

    return 0;
}

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

#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

int dp[100000];

int main()
{
	fastio;
	int n, k;
	cin >> n >> k;
	int h[n];
	for(int i = 0; i < n; i++) cin >> h[i];
	dp[1] = abs(h[0] - h[1]);
	for(int i = 2; i < n; i++) {
		int min_val = INT_MAX;
		for(int j = 1; j <= k; j++) {
			if(i - j >= 0)
				min_val = min(min_val, dp[i - j] + abs(h[i] - h[i - j]));
		}
		dp[i] = min_val;
	}
	cout << dp[n-1] << endl;
	return 0;
}

Measured memory_bytes: 4368
#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <utility>
#include <map>
#include <stack>
#include <set>
#include <vector>
#include <queue>
#include <deque>
#include <sstream>
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define LL long long
#define Pair pair<int,int>
#define LOWBIT(x) x & (-x)
using namespace std;

const int MOD=1e9+7;
const int INF=0x7ffffff;
const int magic=348;

vector<Pair> v[100048];
int n;
LL dist[100048];

void dfs(int cur,int fa)
{
	int i,x,dd;
	for (i=0;i<v[cur].size();i++)
	{
		x=v[cur][i].x;dd=v[cur][i].y;
		if (x!=fa)
		{
			dist[x]=dist[cur]+dd;
			dfs(x,cur);
		}
	}	
}

int main ()
{
	int i,x,y,c;
	scanf("%d",&n);
	for (i=1;i<=n-1;i++)
	{
		scanf("%d%d%d",&x,&y,&c);
		v[x].pb(mp(y,c));
		v[y].pb(mp(x,c));
	}
	int q,k;
	scanf("%d%d",&q,&k);
	dfs(k,-1);
	int s,t;
	LL ans;
	for (i=1;i<=q;i++)
	{
		scanf("%d%d",&s,&t);
		ans=dist[s]+dist[t];
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 14336
n, m = map(int, input().split())
a = [""] * m
b = [""] * m
c = [0] * n
d = [0]*n
for i in range(m):
    a[i], b[i] = input().split()
for i in range(m):
    if (b[i] == "WA" and 0 == d[int(a[i])-1]):
        c[int(a[i])-1] += 1
    if (b[i] == "AC"):
        d[int(a[i])-1] = 1
p = 0
for i in range(n):
    if (d[i] == 1):
        p += c[i]
print(sum(d), p)

Measured memory_bytes: 17268
#include <iostream>

using namespace std;

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

  int res = 1001, sl = s.size(), tl = t.size();
  for (int offset = 0; offset <= sl - tl; ++offset) {
    int cnt = 0;
    for (int i = 0; i < tl; ++i) if (s[offset + i] != t[i]) cnt++;
    res = min(cnt, res);
  }

  cout << res << endl;
}


Measured memory_bytes: 3636
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <stack>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <list>
#include <string.h>
#include <functional>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <utility>
#include <memory>
#include <sstream>
#include <complex>
#include <cassert>
#include <bitset>
#define rep(i, n) for(int i = 0; i < n; i++)
#define fi first
#define se second
using namespace std;
typedef long long int ll; typedef pair <int, int> P; typedef vector <int> vecint; typedef pair<int, P> P1; typedef pair<P, P> P2;
const int inf = 1000000000;
const ll INF = 9000000000000000000;
const double EPS = 10e-9;
int main()
{
	int n; cin >> n;
	int l = 0, r = n, mid;
	int ls, rs, ms;
	cout << 0 << endl;
	string s;
	cin >> s;
	if (s[0] == 'F') ls = 1;
	else if (s[0] == 'M') ls = 0;
	else return 0;
	while (true)
	{
		mid = (l + r) / 2;
		cout << mid << endl;
		cin >> s;
		if (s[0] == 'F') ms = 1;
		else if (s[0] == 'M') ms = 0;
		else return 0;
		if ((mid - l) % 2)
		{
			if (ms == ls)
				r = mid;
			else
			{
				ls = ms;
				l = mid;
			}
		}
		else
		{
			if (ms == ls)
			{
				ls = ms;
				l = mid;
			}
			else r = mid;
		}
	}
	return 0;
}

Measured memory_bytes: 852
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5 + 5;
int n;
ll k;
vector<ll> neg, pos;
ll smaller_than(ll mid)
{
    mid++;
    ll ret = 0;
    ll neg_num = neg.size(), pos_num = pos.size();
    if (mid == 0)
    {
        for (int i = 0; i < pos_num; i++)
            if (pos[i] == 0)
                ret += neg_num;
        ret += (ll)neg_num * (neg_num - 1) / 2;
        ret += (ll)pos_num * (pos_num - 1) / 2;
        ret = (ll)n * (n - 1) / 2 - ret;
       return ret;
    }
    if (mid > 0)
    {
        for (int i = 0; i < neg_num - 1; i++)
        {
            ll x = mid / neg[i];
            if (mid % neg[i])
                x++;
            int k = lower_bound(neg.begin() + i + 1, neg.end(), x) - neg.begin();
            ret += neg_num - k;
        }
        for (int i = 0; i < pos_num - 1; i++)
        {
            if (pos[i] == 0)
                continue;
            ll x = mid / pos[i];
            if (mid % pos[i])
                x++;
            int k = lower_bound(pos.begin() + i + 1, pos.end(), x) - pos.begin();
            ret += pos_num - k;
        }
        ret = (ll)n * (n - 1) / 2 - ret;
       return ret;
    }
    if (mid < 0)
    {
        mid *= -1;
        ret += (ll)neg_num * (neg_num - 1) / 2;
        ret += (ll)pos_num * (pos_num - 1) / 2;
        for (int i = 0; i < neg_num; i++)
        {
            ll x = mid / neg[i];
            int k = upper_bound(pos.begin(), pos.end(), x) - pos.begin() - 1;
            ret += k + 1;
        }
        ret = (ll)n * (n - 1) / 2 - ret;
       return ret;
    }
}
int main()
{
    scanf("%d%lld", &n, &k);
    for (int i = 1; i <= n; i++)
    {
        int x;
        scanf("%d", &x);
        if (x < 0)
            neg.push_back(-x);
        else
            pos.push_back(x);
    }
    sort(neg.begin(), neg.end());
    sort(pos.begin(), pos.end());
    ll l = -1e18, r = 1e18, ans;
    while (l <= r)
    {
        ll mid = l + r >> 1;
        if (smaller_than(mid) >= k)
            ans = mid, r = mid - 1;
        else
            l = mid + 1;
    }
    printf("%lld\n", ans);
}


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


void solve(std::vector<long long> M, std::vector<long long> D){
    if(M[0]+1==M[1]) cout<<1<<endl;
    else cout<<0<<endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
signed main(){
    std::vector<long long> M(2);
    std::vector<long long> D(2);
    for(int i = 0 ; i < 2 ; i++){
        scanf("%lld",&M[i]);
        scanf("%lld",&D[i]);
    }
    solve(std::move(M), std::move(D));
    return 0;
}


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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

int main(){
  int n, p;cin>>n>>p;
  string s;cin>>s;

  if(p==2 || p==5){
    ll result=0;
    rep(i, n)if((s[i]-'0')%p==0){
      result += i+1;
    }

    cout<<result<<endl;

    return 0;
  }

  vector<int>a;
  rep(i, n)a.push_back(s[i]-'0');
//rep(i, n)cout<<a[i]<<' ';cout<<endl;
  int c=1;
  rrep(i, n)a[i]=(a[i]*c)%p, c= c*10%p;

//rep(i, n)cout<<a[i]<<' ';cout<<endl;
  rrep1(i, n-1)a[i-1]=(a[i-1]+a[i])%p;
//rep(i, n)cout<<a[i]<<' ';cout<<endl;
  map<ll, ll> m;
  for(auto cc:a)m[cc]++;
  ll result = 0;
  for(auto p:m){
    result += p.second*(p.second-1)/2;
  }
  cout<<result+m[0]<<endl;

  return 0;
}

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

int main(void) {
	int A[3];
	int D[3];
	for (int i = 0; i < 3; ++i)
		cin >> A[i];

	D[0] = abs(A[1] - A[2]);
	D[1] = abs(A[2] - A[0]);
	D[2] = abs(A[0] - A[1]);
	sort(D, D + 3);
	int ans = D[0] + D[1];

	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 256
def d_axis_parallel_rectangle(N, K, P):
    x_array, y_array = [], []  # 点のx,y座標
    for x, y in P:
        x_array.append(x)
        y_array.append(y)

    x_sorted = sorted(x_array)
    y_sorted = sorted(y_array)  # 個別にソートしたため、点の座標と無関係

    # すべての点を内部に含む、最大の面積を持つ矩形が初期値
    ans = (x_sorted[N - 1] - x_sorted[0]) * (y_sorted[N - 1] - y_sorted[0])

    # 全探索
    for xi in range(N):
        for xj in range(xi + 1, N):
            for yi in range(N):
                for yj in range(yi + 1, N):
                    num = 0
                    left = x_sorted[xi]
                    right = x_sorted[xj]
                    bottom = y_sorted[yi]
                    top = y_sorted[yj]

                    for i in range(N):
                        if left <= x_array[i] <= right and bottom <= y_array[i] <= top:
                            num += 1
                            if num == K:
                                ans = min(ans, (right - left) * (top - bottom))
                                break
    return ans

N,K = [int(i) for i in input().split()]
P = [[int(i) for i in input().split()] for j in range(N)]
print(d_axis_parallel_rectangle(N, K, P))

Measured memory_bytes: 48132
import java.util.Scanner;

public class Main {

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

    static void solve(Scanner in) {
        int N = in.nextInt();
        int K = in.nextInt();

        long ans = K;
        for (int i = 1; i < N; i++)
            ans *= (K - 1);
        System.out.println(ans);
    }
}

Measured memory_bytes: 9044
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
typedef long long ll;
const ll LINF = 1e18;
const int INF = 1e8;
using namespace std;

#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")

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

	
	string b;
	cin >> b;
	int max = 0;
	int tmp = 0;
	for (int i = 0;i < b.size();i++)
	{
		if (b[i] == 'A' || b[i] == 'T' || b[i] == 'C' || b[i] == 'G')
		{
			tmp++;
			if (max < tmp)
			{
				max = tmp;
			}
		}
		else
		{
			tmp = 0;
		}
	}

	cout << max << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const unsigned int MOD = 1000000007;
#define ll long long
#define PI 3.1416
string day [] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
vector <string> v;
void dfs (string str, string t = "", int cnt = 0) {
    if (cnt == 2) {
        v.push_back (t);
        return;
    } else {
        for (int i = 0; i <str.size (); i ++) {
            dfs (str, t + str [i], cnt + 1);
        }
    }
}
int main () {
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int a, b, c, d;
    while (cin >> a >> b >> c >> d) {
        if (abs (a-c) <= d) cout << "Yes" << endl;
        else if (abs (a-b) <= d && abs (b-c) <= d) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long lint;
//d,edge,g,P,q
#define MAX_N 100010
lint d[MAX_N];
struct edge{
	int to;
	lint cost;
};
vector<edge> g[MAX_N];
typedef pair<lint,int> P;
priority_queue<P,vector<P>,greater<P> > q;
void pfs(int s){
	d[s]=0;q.push({0,s});
	lint cd,v;
	while(q.size()){
		cd=q.top().first;v=q.top().second;q.pop();
		if(cd>d[v])continue;
		for(edge &e:g[v])if(d[e.to]>cd+e.cost){
			d[e.to]=cd+e.cost;
			q.push({d[e.to],e.to});
		}
	}
}

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

	lint v,e,r;cin>>v>>e>>r;
	int a,b,c;
	for(int i=0;i<v;++i)d[i]=INT_MAX;
	for(int i=0;i<e;++i){
		cin>>a>>b>>c;
		g[a].push_back({b,c});
		//g[b].push_back({a,c});
	}pfs(r);
	for(int i=0;i<v;++i){
		if(d[i]==INT_MAX)cout<<"INF"<<endl;
		else cout<<d[i]<<endl;
	}getchar();getchar();
	return 0;
}


Measured memory_bytes: 19576
#include <iostream>
#include <stdio.h>
#include <cmath>
using namespace std;

int main()
{
    double a, b, c;
    double s, l, h;

    cin >> a >> b >> c;

    s = a * b * sin((c / 180) * M_PI) / 2;
    l = a + b + sqrt(a * a + b * b - 2 * a * b * cos((c * M_PI) / 180));
    h = s * (double)2 / a;

    printf("%.8f\n%.8f\n%.8f\n", s, l, h);

    return (0);
}

Measured memory_bytes: 3432
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    while (n > 0)
    {
        if (n % 10 == 7)
        {
            cout << "Yes\n";
            return 0;
        }
        n/=10;
    }
    cout << "No\n";
    return 0;
}


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

p = set()
q = set()

for _ in range(m):
    a, b = map(int, input().split())
    if a == 1:
        p.add(b)
    elif b == n:
        q.add(a)
else:
    if p & q:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")

Measured memory_bytes: 24080
a, b, c = map(int, input().split())
k = int(input())

ans = False

for i in range(k + 1):
    for j in range(k-i+1):
        for l in range(k-i-j+1):
            aa = a * pow(2,i)
            bb = b * pow(2,j)
            cc = c * pow(2,l)
            # print("{0} {1} {2}".format(aa,bb,cc))
            if(aa  < bb  and bb < cc):
                ans = True            

if(ans):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9108
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    ll z = 0;
    string s;
    cin >> s;
    for (int i = 0; i < (1 << (s.length() - 1)); i++) {
        ll c = s[0] - '0';
        for (int j = 1; j < s.length(); j++) {
            if (i & (1 << (j - 1))) {
                c *= 10;
                c += s[j] - '0';
            } else {
                z += c;
                c = s[j] - '0';
            }
        }
        z += c;
    }
    cout << z;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int n, mmax = 1000;
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        int a, k = 0;
        cin >> a;
        while(a % 2 == 0)
        {
            a /= 2;
            k++;
        }
        if(mmax > k)
            mmax = k;
    }
    cout << mmax;
    return 0;
}

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


//型変換
int henkan(char s){
    if(s=='0'){
        return 0;
    }
    if(s=='1'){
        return 1;
    }
    if(s=='2'){
        return 2;
    }
    if(s=='3'){
        return 3;
    }
    if (s=='4'){
        return 4;
    }
    if(s=='5'){
        return 5;
    }
    if(s=='6'){
        return 6;
    }
    if(s=='7'){
        return 7;
    }
    if(s=='8'){
        return 8;
    }
    if(s=='9'){
        return 9;
    }
}

int main(){
    string s;
    cin>>s;
    char A,B,C,D;
    A=s.at(0);
    B=s.at(1);
    C=s.at(2);
    D=s.at(3);

    int a,b,c,d;
    a=henkan(A);
    b=henkan(B);
    c=henkan(C);
    d=henkan(D);

    int ans=7;
    string rrr;
    rrr="";
//rrr.push_back('-');
    ans-=a;
    if (b+c+d==ans){
        rrr.push_back(A);
        rrr.push_back('+');
        rrr.push_back(B);
        rrr.push_back('+');
        rrr.push_back(C);
        rrr.push_back('+');
        rrr.push_back(D);
        rrr+="=7";
    }
    else if (b+c-d==ans){
        rrr.push_back(A);
        rrr.push_back('+');
        rrr.push_back(B);
        rrr.push_back('+');
        rrr.push_back(C);
        rrr.push_back('-');
        rrr.push_back(D);
        rrr+="=7";
    }
    else if (b-c+d==ans){
        rrr.push_back(A);
        rrr.push_back('+');
        rrr.push_back(B);
        rrr.push_back('-');
        rrr.push_back(C);
        rrr.push_back('+');
        rrr.push_back(D);
        rrr+="=7";
    }
    else if (-b+c+d==ans){
        rrr.push_back(A);
        rrr.push_back('-');
        rrr.push_back(B);
        rrr.push_back('+');
        rrr.push_back(C);
        rrr.push_back('+');
        rrr.push_back(D);
        rrr+="=7";
    }
    else if (b-c-d==ans){
        rrr.push_back(A);
        rrr.push_back('+');
        rrr.push_back(B);
        rrr.push_back('-');
        rrr.push_back(C);
       rrr.push_back('-');
        rrr.push_back(D);
        rrr+="=7";
    }
    else if (-b-c+d==ans){
        rrr.push_back(A);
        rrr.push_back('-');
        rrr.push_back(B);
        rrr.push_back('-');
        rrr.push_back(C);
        rrr.push_back('+');
        rrr.push_back(D);
        rrr+="=7";
    }
    else if (-b+c-d==ans){
       rrr.push_back(A);
        rrr.push_back('-');
        rrr.push_back(B);
        rrr.push_back('+');
        rrr.push_back(C);
        rrr.push_back('-');
        rrr.push_back(D);
        rrr+="=7";
    }
    else if (-b-c-d==ans){
        rrr.push_back(A);
        rrr.push_back('-');
        rrr.push_back(B);
        rrr.push_back('-');
        rrr.push_back(C);
        rrr.push_back('-');
        rrr.push_back(D);
        rrr+="=7";
    }
    cout<<rrr<<endl;

    
}


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

int S[100003];
int n;
void swap(int *a, int *b){
    int tem = *b;
    *b = *a;
    *a = tem;
}

int Partition(){
    int i=-1,j=0;
    for(j;j<n-1;++j){
        if(S[j]<=S[n-1]){
            i++;
            swap(&S[i],&S[j]);
        }
    }
    swap(&S[i+1],&S[n-1]);
    return (i+1);
}

int main(){
    scanf("%d",&n);
    for(int i=0;i<n;++i) scanf("%d",&S[i]);
    int pos = Partition();
    for(int i=0;i<n;++i){
        if(i==pos)printf("[");
        printf("%d",S[i]);
        if(i==pos)printf("]");
        if(i < n-1) printf(" ");
    }
    printf("\n");
    return 0;

}



Measured memory_bytes: 3532
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#pragma region Macros
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define all(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
#define CEIL(a,b) ((a+b-1)/b)
int GCD(int a, int b) // assuming a,b >= 1
{
	if (a < b)
		swap(a, b);
	if (b == 0)
		return a;
	if (a % b == 0)
		return b;
	return GCD(b, a % b);
}
int LCM(int a, int b) // assuming a,b >= 1
{
	return  a * b / GCD(a, b);
}
inline bool BETWEEN(int x, int min,int max) {
	if (min <= x && x <= max)
		return true;
	else
		return false;
}
using namespace std;
#pragma endregion
signed main() {
	int M,N;
	cin >> M >> N;
	if (N * M % 2 == 0)
		cout << "Even";
	else
		cout << "Odd";
}

Measured memory_bytes: 256
package main

import "fmt"

var N, M int
var graph [][]int
var dp []int

func main() {
	fmt.Scan(&N, &M)
	graph = make([][]int, N)
	var x, y int
	for i := 0; i < M; i++ {
		fmt.Scan(&x, &y)
		graph[x-1] = append(graph[x-1], y-1)
	}

	dp = make([]int, N)
	for i := range dp {
		dp[i] = -1
	}

	ans := 0
	for i := range dp {
		chmax(&ans, rec(i))
	}
	fmt.Println(ans)
}

func rec(v int) int {
	if dp[v] != -1 {
		return dp[v]
	}
	res := 0
	for _, nv := range graph[v] {
		chmax(&res, rec(nv)+1)
	}
	dp[v] = res
	return res
}

const INF = 1 << 60

func chmax(a *int, b int) {
	if *a < b {
		*a = b
	}
}

func chmin(a *int, b int) {
	if *a > b {
		*a = b
	}
}


Measured memory_bytes: 15232
# -*- coding: utf-8 -*-
"""
Created on Sun Apr 26 20:57:33 2020
"""

import sys
#import numpy as np

sys.setrecursionlimit(10 ** 9)
#def input():
#    return sys.stdin.readline()[:-1]
mod = 10**9+7

#N = int(input())
a,b,c,d = map(int,input().split())
#A = list(map(int,input().split()))

counta = 0
ans = 0
while a > 0 and c > 0:
    if counta % 2 == 0:
        c -= b
        ans = 'Yes'
    else:
        a -= d
        ans = 'No'
    counta += 1
#    print(a,b,c,d,ans)

print(ans)



Measured memory_bytes: 9188
#include <stdio.h>


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

  int k, x;
  scanf("%d", &k);
  scanf("%d", &x);
  
  for (int i = x-k+1; i <= x+k-1; i++){
      printf("%d\n", i);
  }

  
  return 0;
}

Measured memory_bytes: 128
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#define F first
#define S second
#define vec vector
#define pb push_back
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define pnn pair<Node*, Node*>
#define uid uniform_int_distribution
#define FILE ifstream in("input.txt");ofstream out("output.txt");
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

int main() {
    fast;
    char c; cin>>c;
    cout<<(c>='a' ? 'a' : 'A');
}

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

//////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////// ここからコピペ ////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////


//////////////////
// Union-Find木 //
//////////////////

// 0-indexed
class UnionFind {
private:
	std::vector<int> parent_, size_;
public:
	UnionFind(const int size)
		:parent_(size), size_(size, 1)
	{
		for (int i{}; i < size; i++) parent_[i] = i;
	}
	int calcRoot(const int index)
	{
		int &parent{parent_[index]};
		if (parent == index) return index;

		parent = calcRoot(parent);
		return parent;
	}
	bool areConnected(const int index1, const int index2)
	{
		return calcRoot(index1) == calcRoot(index2);
	}
	void unite(const int index1, const int index2)
	{
		const int root1{calcRoot(index1)}, root2{calcRoot(index2)};
		if (root1 == root2) return;
		if (size_[root1] <= size_[root2])
		{
			size_[root2] += size_[root1];
			parent_[root1] = root2;
		}
		else
		{
			size_[root1] += size_[root2];
			parent_[root2] = root1;
		}
		return;
	}
	int calcSize(const int index)
	{
		return size_[calcRoot(index)];
	}
};

//////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////// ここまでコピペ ////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////


// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_1_A&lang=jp
int main()
{
	int n, q;
	scanf("%d%d", &n, &q);
	UnionFind uf(n);
	for (int i{}; i < q; i++)
	{
		int com, x, y;
		scanf("%d%d%d", &com, &x, &y);
		if (!com) uf.unite(x, y);
		else if (uf.areConnected(x, y))
			puts("1");
		else
			puts("0");
	}
	return 0;
}


Measured memory_bytes: 3236
include Math

a, b, h, m = gets.chomp.split.map(&:to_f)

hour = 2.0 * Math::PI * ( (h * 60.0 + m) / (12.0 * 60.0) )
min = 2.0 * Math::PI * ( m / 60.0 )

hx = a * Math.cos(hour)
hy = a * Math.sin(hour)

mx = b * Math.cos(min)
my = b * Math.sin(min)

puts Math.sqrt((hx - mx) ** 2 + (hy - my) ** 2)


Measured memory_bytes: 14740
import java.util.Scanner;


public class Main {
	
	public static void main(String[] args){
		final Scanner sc = new Scanner(System.in);
		
		while(true){
			final int n = sc.nextInt();
			
			if(n == 0){
				break;
			}
			
			int max = Integer.MIN_VALUE;
			int min = Integer.MAX_VALUE;
			
			for(int i = 0; i < n; i++){
				final int sum = sc.nextInt()
								+ sc.nextInt()
								+ sc.nextInt()
								+ sc.nextInt()
								+ sc.nextInt();
				
				max = Math.max(max, sum);
				min = Math.min(min, sum);
			}
			
			System.out.println(max + " " + min);
		}
		
	}
}	

Measured memory_bytes: 12000
k = int(input())

s = 0
# 3つ違う
for i1 in range(1, k+1):
    s = s + i1
    for i2 in range(1, i1):
        x1, x2 = i1, i2
        while x2 != 0:
            x1, x2 = x2, x1 % x2
        gcd1 = x1
        s = s + gcd1 * 6
        for i3 in range(i1+1, k+1):
            x1, x2 = gcd1, i3
            while x2 != 0:
                x1, x2 = x2, x1 % x2
            gcd2 = x1
            s = s + gcd2 * 6

print(s)


Measured memory_bytes: 9096
#include <bits/stdc++.h>
using namespace std;
int a[400];
typedef long long ll;
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	ll ans=1000;
	for(int i=1;i<=n;i++)
	{
		int st=i;
		while(a[st+1]>a[st]) 
		{
		st++;}
		int res=a[st]-a[i];
		ans=1ll*a[st]*(ans/a[i])+ans%a[i];
		i=st;
	}
	printf("%lld",ans);
 } 

Measured memory_bytes: 3812
#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"a=[1]+[0]*4\n"
"m=10**9+7\n"
"for s in input():\n"
" i=ord(s)-64\n"
" if i>0:a[i]+=a[i-1]\n"
" else:a=[a[i]*3%m+a[i-1]for i in range(4)]+[0]\n"
"print(a[3]%m)\n"
"\"";
  system(s);
  return 0;
}            

Measured memory_bytes: 3536