akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long unsigned int ll;

int main() {

  vector<int> A(3);
  cin >> A[0];
  cin >> A[1];
  cin >> A[2];
  
  sort(A.begin(),A.end());
  if(A[0]==5&&A[1]==5&&A[2]==7){
	cout << "YES" <<endl;
  }else{
    cout <<"NO" <<endl;
  }
}


Measured memory_bytes: 512
import java.util.*;
import static java.lang.Math.*;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int r = sc.nextInt();
		
		
		// 計算
		double result = 2*r*PI;
		
		
		// 出力
		System.out.println(result);
	}
}



Measured memory_bytes: 27188
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<bitset>
using namespace std;

int main() {

	int N, M;
	cin >> N >> M;

	long long A;
	long long sum = 0;
	for (int i = 0; i < M; i++) {
		cin >> A;
		sum += A;
	}

	if (sum > N) {
		cout << -1 << endl;
	}
	else {
		cout << N - sum << endl;
	}

	return 0;
}



Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define be(v) v.begin(), v.end()
typedef long long ll;
typedef vector<int> vint;
#define scout cout << fixed << setprecision(5) 
ll INF = 1e9;
ll mod = 1e9+7;

int main() {
	int n,k; cin >> n >> k;
	int ans=0;
	while(n>0) {
		n/=k;
		ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <queue>
#include <map>
#include <cstring>
#include <vector>
#include <algorithm>
using namespace std;
#define mst(a,b) memset((a),(b),sizeof(a))
#define f(i,a,b) for(int i=(a);i<(b);++i)
#define rush() int T;scanf("%d",&T);while(T--)
typedef long long ll;
const int maxn= 100005;
const ll mod = 1e9+7;
const int INF = 0x3f3f3f3f;
const double eps = 1e-6;

int main()
{
    int x,a,b;
    while(~scanf("%d%d%d",&x,&a,&b))
    {
        if(a>=b)
        {
            puts("delicious");
            continue;
        }
        if(a+x>=b)
        {
            puts("safe");
            continue;
        }
        puts("dangerous");
    }
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c,d;
  cin >> a >> b >> c >>d;
  if (a+b > c+d){
  	cout << "Left" << endl;
  }else if(a+b < c+d){
    cout << "Right" << endl;
  }else{
  	cout << "Balanced" <<endl;
  }
}

Measured memory_bytes: 3512
S = str(input())
N = len(S)
a = (N - 1) // 2
b = (N + 3) // 2
x = 0
for i in range(N):
  if S[i] != S[N - 1 - i]:
    x = 1

for i in range(a):
  if S[i] != S[a - 1 - i]:
    x = 1

for j in range(a):
  if S[j + b - 1] != S[N - 1 - j]:
    x = 1
    
if x == 0:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(v) v.begin(),v.end()
#define mod 1000000007


int main(){
  ll n;
  cin >> n;
  string s;
  cin >> s;
  ll po[200100]={0},sh[200100]={0};
  ll ponum=0,shnum=0;
  rep(i,n){
    if(s[i]=='.'){
      ponum++;
    }else{
      shnum++;
    }
    po[i]=ponum;
    sh[i]=shnum;
  }
  //cout <<po[n-1] <<" "<< sh[n-1] <<endl;
  ll res=0,ans=1e9;
  rep(i,n){
    res=sh[i]+(po[n-1]-po[i]);
    ans=min(ans,res);
  }
  ans=min(ans,po[n-1]);
  cout << ans <<endl;
}


Measured memory_bytes: 3716
import java.util.*;
import java.io.*;
import java.math.*;
 
public class Main
{
    public static void process(int test_number)throws IOException
    {
        char arr[] = nln().toCharArray();
        long sum = 0l;
        for(char c : arr){
            long dig = (long)(c - '0');
            sum += dig;
        }
        pn((sum % 9 == 0) ? "Yes" : "No");
    }
 
    static final long mod = (long)1e9+7l;
    
    static FastReader sc;
    static PrintWriter out;
    public static void main(String[]args)throws IOException
    {
        out = new PrintWriter(System.out);
        sc = new FastReader();
 
        long s = System.currentTimeMillis();
        int t = 1;
       // t = ni();
        for(int i = 1; i <= t; i++)
            process(i);
 
        out.flush();
        System.err.println(System.currentTimeMillis()-s+"ms");
    }

    static void trace(Object... o){ System.err.println(Arrays.deepToString(o)); };
    static void pn(Object o){ out.println(o); }
    static void p(Object o){ out.print(o); }
    static int ni()throws IOException{ return Integer.parseInt(sc.next()); }
    static long nl()throws IOException{ return Long.parseLong(sc.next()); }
    static double nd()throws IOException{ return Double.parseDouble(sc.next()); }
    static String nln()throws IOException{ return sc.nextLine(); }
    static long gcd(long a, long b)throws IOException{ return (b==0)?a:gcd(b,a%b);}
    static int gcd(int a, int b)throws IOException{ return (b==0)?a:gcd(b,a%b); }
    static int bit(long n)throws IOException{ return (n==0)?0:(1+bit(n&(n-1))); }
    
    static class FastReader{ 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader(){ 
            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(); 
        } 
  
        String nextLine(){ 
            String str = ""; 
            try{ str = br.readLine(); } catch (IOException e) { e.printStackTrace(); } 
            return str; 
        } 
    } 
}


Measured memory_bytes: 39632
#include<cstdio>
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
	int n,m;
	while(scanf("%d%d",&n,&m),n){
		double g[n][n],c[n][m],ans=0;
		rep(i,n){
			rep(j,n)scanf("%lf",g[i]+j);
			rep(j,m)c[i][j]=j?0:1;
		}
		rep(i,m-1)rep(j,n)rep(k,n)if(c[k][i+1]<c[j][i]*g[j][k])
		c[k][i+1]=c[j][i]*g[j][k];
		rep(i,n)if(c[i][m-1]>ans)ans=c[i][m-1];
		printf("%.2f\n",ans);
	}
	return 0;
}

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

vector<string> ans;

void dfs(int N,string s, char cur){
    if(s.size() == N){
        ans.push_back(s);
    }

    else {
        for(char c='a'; c<=cur; c++){
            dfs(N,s+c,((c == cur) ? (char)(cur + 1) : cur));
        }
    }
}

int main(){
    int N;
    cin>>N;
    dfs(N,"",'a');
    for(auto a : ans){
        cout<<a<<endl;
    }
    return 0;
}

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

char floor[100][101];
bool visited[100][100];

int main() {
	int w, h;
	while (cin >> h >> w, h||w) {
		for (int j = 0; j < h; j++) {
			cin >> floor[j];
			for (int i = 0; i < w; i++)
				visited[j][i] = false;
		}

		int x = 0, y = 0;
		while (floor[y][x] != '.' && !visited[y][x]) {
			visited[y][x] = true;
			switch (floor[y][x]) {
				case '>': x++; break;
				case '<': x--; break;
				case 'v': y++; break;
				case '^': y--; break;
			}
		}

		if (visited[y][x])
			cout << "LOOP" << endl;
		else
			cout << x << " " << y << endl;
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        new Main().run();
    }

    private void run() {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        long K = scanner.nextLong();
        int[] A = new int[N];

        long g = 0;
        long h = 0;
        long tmp = 0;
        long tmp2 = 0;
        for (int i = 0; i < N; i++) {
            int f = scanner.nextInt();
            A[i] = f;
        }
        for (int j = 0; j < N - 1; j++) {
            for (int i = j; i < N; i++) {
                if(A[j] > A[i]) {
                    g++;
                }
            }
        }
        for (int j = 0; j < N; j++) {
            for (int i = 0; i < N; i++) {
                if(A[j] > A[i]) {
                    h++;
                }
            }
        }

        g += tmp;
        h += tmp2;

        long ans = ((g % 1000000007) * (K % 1000000007)) % 1000000007;
        ans = (ans + (h % 1000000007) * ((K*(K-1)/2) % 1000000007)) % 1000000007;
//        ans = (ans + (total % 1000000007) * (m % 1000000007)) % 1000000007;

        System.out.println(ans);

    }
}


Measured memory_bytes: 26120
n,t = map(int,input().split())
routes = [list(map(int,input().split())) for _ in range(n)]
routes2 = list(filter(lambda x: x[1]<=t,routes))
routes3 = sorted(routes2,key=lambda x: x[0])
if len(routes3) == 0:print("TLE")
else:print(routes3[0][0])

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define X first
#define Y second
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define ini(x, y) memset(x, y, sizeof(x))
#define endl '\n'
#define fastio cin.sync_with_stdio(false); cin.tie(nullptr)
using namespace std;

using ll = long long;
using pii = pair<int, int>;
const int MOD = 1e9 + 7;
const int dx[] = { -1, 0, 1, 0, -1, 1, 1, -1 };
const int dy[] = { 0, 1, 0, -1, 1, 1, -1, -1 };

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

	if (c - a - b < 0) cout << "No";
	else if (4 * a * b < (c - a - b) * (c - a - b)) cout << "Yes";
	else cout << "No";

	return 0;
}

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

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

  int count = 0;
  int i;
  vector<bool> list(1e6, false);
  for(i=1; count<n; i++){
    count+=i;
    list[i]=true;
  }

  int diff = count-n;
  for(int j=i; j>0; j--){
    if(j<=diff){
      diff -= j;
      list[j] = false;
    }
    if(diff==0) break;
  }

  for(int j=1; j<i; j++){
    if(list[j]){
      cout << j << endl;
    }
  }
  
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int N,M;
  cin >> N >> M;
  vector<int> a(M),b(M);
  set<int> s;
  rep(i,M) 
  {
    cin >> a[i] >> b[i];
    a[i] --;
    b[i] --;
    if(a[i]==0)
    {
      s.insert(b[i]);
    }
  }
  rep(i,M)
  {
    if(b[i]==N-1&&s.count(a[i]))
    {
      cout << "POSSIBLE" << endl;
      return 0;
    }
  }
  cout << "IMPOSSIBLE" << endl;
  return 0;
}


Measured memory_bytes: 9536
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = []
cnt = 0
if sum(a) < sum(b):
    print(-1)
    exit()
diff = []
for i in range(n):
    diff.append(a[i] - b[i])
diff.sort()
stack = 0
stackcnt = 0
for i in range(n):
    # print(i, stack, diff[i])
    if diff[i] >= 0:
        continue
    if stack < -diff[i]:
        cnt += 1
        stackcnt += 1
        stack += diff[-stackcnt]
        a[-stackcnt] = b[i]
    cnt += 1
    stack -= -diff[i]
    a[i] += -diff[i]
print(cnt)




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

using namespace std;

int main(){
    int r, g, b; cin >> r >> g >> b;

    if((r*100+g*10+b)%4 == 0){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
t = [list(map(int, input().split())) for _ in range(n)]
t.sort(key=lambda x:(x[1]*x[0] + x[2]*(m-x[0])), reverse=True)
full = [x[1]*x[0] + x[2]*(m-x[0]) for x in t]
cum = [0]
for i in range(n):
	cum.append(cum[-1] + full[i])
aoki = sum([p[0]*p[1] for p in t])
ans = n*m
for i in range(n):
	ok, ng = n*m, -1
	while ok-ng > 1:
		x = (ok+ng) // 2
		res = cum[x//m]
		if (x//m)-1 >= i:
			res -= full[i]
			res += full[x//m]
		res += t[i][1] * min(t[i][0], x%m) + t[i][2] * max(0, (x%m) - t[i][0])
		if res >= aoki:
			ok = x
		else:
			ng = x
	ans = min(ans, ok)
print(ans)

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

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

    string S;
    cin >> S;
    int N = S.size();

    for (int i = 0; i <= 7; ++i) {
        for (int j = 7 - i; j >= 0; --j) {
            string T = (j == 0) ? S.substr(0, i) : S.substr(0, i) + S.substr(N - j, j);
            if (T == "keyence") {
                cout << "YES" << endl;
                exit(0);
            }
        }
    }
    cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
a = list(map(int, input().split()))
mod = 10**9 + 7
ans = 0
fflag = 0
bflag = 0

for i in range(n):
    for j in range(n):
        if i > j:
            if a[i] > a[j]:
                fflag += 1
        elif i < j:
            if a[i] > a[j]:
                bflag += 1

ans = ((fflag+bflag)*k*(k+1)//2 - fflag*k)%mod
print(ans)


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

int main()
{
    int a, b, c;
    // scanf("%d %d", &a, &b);
    cin >> a >> b >> c;
    if (a < b && b < c)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
#define ALL(obj) obj.begin(),obj.end()
#define pb(obj) push_back(obj)
#define REP(i,N) for(ll i=0;i<N;i++)
typedef long long ll;
vector<ll>thick(51);
ll thickness(ll L){//レベルLの厚さ
    if(L==0)return thick[0]=1;
    if(thick[L]!=0)return thick[L];
    return thick[L]=thickness(L-1)*2+3;
}
ll num_of_P(ll L,ll n){//レベルL,下からn番目まで食べる時のパティの数
    if(L==0)return 1;
    if(n==1)return 0;
    else if(n<=1+thickness(L-1))return num_of_P(L-1,n-1);
    else if(n==2+thickness(L-1))return num_of_P(L-1,thickness(L-1))+1;
    else if(n<=2+2*thickness(L-1))return num_of_P(L-1,thickness(L-1))+1+num_of_P(L-1,n-2-thickness(L-1));
    else return 2*num_of_P(L-1,thickness(L-1))+1;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,X;
    cin>>N>>X;
    cout<<num_of_P(N,X)<<endl;
}

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

using namespace std;

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

        if (s[0] == s[1] && s[1] != s[2] && s[2] == s[3]){
                cout << "Yes" << endl;
        }
        else if (s[0] == s[3] && s[1] == s[2] && s[3] != s[1]){
                cout << "Yes" << endl;
        }
        else if (s[0] == s[2] && s[1] == s[3] && s[2] != s[1]){
                cout << "Yes" << endl;
        }
        else {
                cout << "No" << endl;
        }
}

Measured memory_bytes: 3580
#include <cstdio>

using namespace std;
typedef long long lint;


int main()
{
	int n;
	
	while (scanf("%d", &n) == 1){
		lint tbl[2001] = {0};
		
		for (int i = 0; i <= 1000; i++)
			for (int j = 0; j <= 1000; j++)
				tbl[i + j]++;
		
		lint ans = 0;
		for (int i = 0; i <= 2000; i++)
			for (int j = 0; j <= 2000; j++)
				if (i + j == n) ans += tbl[i] * tbl[j];
		
		printf("%lld\n", ans);
	}
	
	return (0);
}

Measured memory_bytes: 1052
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std; 
int main(){
  int a,b,c;
   char g[6];
    cin >> a>>b>>c;
	if(b-a*c>=0) cout <<c;
  else if(a>b) cout <<0;
  else cout <<b/a;
}

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

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        
        int cx1 = scanner.nextInt();
        int cy1 = scanner.nextInt();
        int r1 = scanner.nextInt();
        int cx2 = scanner.nextInt();
        int cy2 = scanner.nextInt();
        int r2 = scanner.nextInt();
        
        // Calculate distance between two centers
        double dist = Math.sqrt(Math.pow(cx1-cx2,2) + Math.pow(cy1-cy2,2));
        
        int sum_r = r1 + r2;
        int dif_r = Math.abs(r1 - r2);
        
        if(sum_r < dist) System.out.println(4);
        else if(sum_r == dist) System.out.println(3);
        else if(dif_r < dist && dist < sum_r) System.out.println(2);
        else if(dist == dif_r) System.out.println(1);
        else if(dist < dif_r) System.out.println(0);
    }
}


Measured memory_bytes: 26328
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iomanip>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;

int list[100020];
bool check[100020];
int a[100020];
int N;
int ans;

int main(void){

	scanf("%d",&N);

	for (int i = 1; i <= N; ++i)
	{
		scanf("%d",a+i);
	}

	for (int i = 1; i <= N; ++i)
	{
		list[i]=a[i];
	}

	for (int i = 1; i <= N; ++i)
	{
		if(i==list[a[i]]&&!check[i]){
			ans++;
			check[a[i]]=true;
		}
	}

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

	return 0;

}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
  using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define int long long
  #define all(v) v.begin(),v.end()
  #define rep(i,a,b) for(int i = a; i <=b; i++)
  #define rep2(i,a,b) for(int i = a; i>=b; i--)
  #define f first
    #define s second
  #define PB push_back
  #define MP make_pair
  #define db long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
 

int32_t main()
{
       

    
     int ans = 0;

     string s;
      cin >> s;

     int i = 0,j = s.length()-1;

     while(i<j)
     {
      if(s[i]!=s[j])
      {
        ans++;
      }
      i++;
      j--;
     }

     cout << ans;
  
   return 0;
}       

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES // for C++  
#include <cmath> 
using namespace std;
int main(){
	double pi=3.1415926535;
	double r;
	cin>>r;
	
	double men,en;
	men=r*r*M_PI;
	en=2*r*M_PI;
	
	

	cout<<fixed<<setprecision(6)<<men<<' '<<en<<endl;
	
}


Measured memory_bytes: 3268
def parallel(h, w):
    q, r = divmod(h, 3)
    if r == 0:
        return 0
    else:
        return w


def t(h, w):
    ret = h * w

    q = h // 3
    c = w // 2
    for r in range(q, q + 2):
        set_ = (r * w, (h - r) * c, (h - r) * (w - c))
        ret = min(ret, max(set_) - min(set_))

    return ret


def main():
    h, w = map(int, input().split())
    print(min(parallel(h, w), parallel(w, h), t(h, w), t(w, h)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
template<typename T = int> vector<T> create(size_t n){ return vector<T>(n); }
template<typename T, typename... Args> auto create(size_t n, Args... args){ return vector<decltype(create<T>(args...))>(n, create<T>(args...)); }
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	long long a, v, b, w, t;
	cin >> a >> v >> b >> w >> t;
	if(a > b){
		a *= -1;
		b *= -1;
	}
	a += t * v;
	b += t * w;
	if(a >= b) cout << "YES\n";
	else cout << "NO\n";
	return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int x; cin >> x;
	for(; ;x++){
		for(int i = 2; i * i <= x; i++) if(x % i == 0) goto SKIP;
		cout << x << endl; break;
		SKIP:;
	}
	
	return 0;
}

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

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

    string s;
	int ans = 0;
	cin >> s;

	rep(i,s.size()){
		if(s[i] == 'o') ans += 100;
	}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for ((i)=1;(i)<=(n);(i)++)
#define foreach(c,it) for (__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
using namespace std;
long long a,b,c,d,t;
int main(){
	cin>>a>>c>>b>>d>>t;
	if(a==b){
		puts("YES");
		return 0;
	}
	if(c<=d){
		puts("NO");
		return 0;
	}
	if(abs(a-b)<=(c-d)*t){
		puts("YES");
		return 0;
	}
	puts("NO");
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define MOD 100000007
#define PI 3.141592653589793238
#define pb push_back
#define ALL(V) (V).begin(), (V).end()
#define rep(i, a, b) for(int i = (a); i < (b); ++i)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long long int lint;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
inline ll gcd(ll a, ll b) { return (a % b == 0 ? b : gcd(b, a % b)); }
inline ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
inline ll char_to_ll(char c) { return (int)(c - '0'); }
inline ll string_to_ll(string s) { return atoi(s.c_str()); }
inline bool is_prime(ll x){ if(x <= 1) return false; for(ll i = 2; sqrt(i) <= x; i++) if(x % i == 0) return false; return true; }

int main(){
    ll X, Y, Z;
    cin >> X >> Y >> Z;

    cout << Z << " " << X << " " << Y << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){

    int n;
    int k;
    int q;

    cin >> n;
    cin >> k;
    cin >> q;

    int a[100000];

    for (int i=0;i<q ;i++) cin >> a[i];

    int b[100000];

    for (int i=0;i<n;i++) b[i] = k-q;

    for (int i=0;i<q;i++) 
        b[a[i]-1]=b[a[i]-1]+1;

    for (int i=0;i<n;i++)
        if (b[i] > 0)
        cout << "Yes" << endl;
        else cout << "No" << endl;
}

Measured memory_bytes: 1408
# -*- coding: utf-8 -*-

import sys
from collections import Counter

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N=INT()
A=LIST()

if all([a==0 for a in A]):
    Yes()
    exit()

if N%3!=0:
    No()
    exit()

C=Counter(A)
if len(C.keys())==2:
    for k, v in C.items():
        if k==0:
            if v!=N//3:
                No()
                exit()
        else:
            if v!=N//3*2:
                No()
                exit()
    Yes()
elif len(C.keys())==3:
    xor=0
    for k, v in C.items():
        xor^=k
        if v!=N//3:
            No()
            exit()
    if xor==0:
        Yes()
    else:
        No()
else:
    No()


Measured memory_bytes: 14468
#include"bits/stdc++.h"
using namespace std;


int main()
{
    int n;
    cin>>n;
    int c=100;
    while(n>0)
    {

       int x=n/c;
         n=n%c;
       if(x==1)
        cout<<"9";
       else if(x==9)
        cout<<"1";
       else
        cout<<x;
       c/=10;
    }
    return 0;
}


Measured memory_bytes: 256
unittest
{
	assert( [ "3 5", "4 2 1", "2 3 1" ].parse.expand.solve == 2 );
	assert( [ "3 8", "4 2 1", "2 3 1" ].parse.expand.solve == 0 );
	assert( [ "11 14", "3 1 4 1 5 9 2 6 5 3 5", "8 9 7 9 3 2 3 8 4 6 2" ].parse.expand.solve == 12 );
}



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

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

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

auto solve( long k, long[] as, long[] fs )
{
	as.sort();
	fs.sort!( ( x, y ) => y < x );
	
	// 完食にかかる時間の最小値を二分探索
	auto l = 0L;
	auto r = 10L ^^ 6 * 10L ^^ 6;
	while( l < r )
	{
		// 完食にかかる時間を仮決めして、達成に必要な修行回数を計算
		auto c = ( l + r ) / 2;
		auto kk = 0L;
		foreach( a, f; lockstep( as, fs ) )
		{
			auto t = a * f;
			if( c < t ) kk += ( t - c + f - 1 ) / f;
		}
		
		// 必要な修行回数がK回以内なら実際に可能
		if( kk <= k ) r = c;
		else          l = c + 1;
	}
	return l;
}


Measured memory_bytes: 20536
/*input
2
1 0 0
*/
#include <bits/stdc++.h>
using namespace std;

const int maxm = 16;
const int maxn = 100005;

int read() {
	int x = 0, c = getchar();
	for(; !(c > 47 && c < 58); c = getchar());
	for(; (c > 47 && c < 58); c = getchar()) x = x * 10 + c - 48;
	return x;
}

int n;
int b[maxn];
int mark[maxm];
int f[1 << maxm];
int g[1 << maxm];

int main(){
	n = read();

	for(int i = 1; i < n; ++ i) {
		int u = read(), v = read(), w = read();
		b[u] ^= w, b[v] ^= w;
	}

	int ans = 0;
	for(int i = 0; i < n; ++ i) {
		if(b[i] == 0) {
			++ ans; continue;
		}
		if(mark[b[i]]) {
			mark[b[i]] = 0;
			++ ans; continue;
		}
		mark[b[i]] = 1;
	}


	vector<int> v;
	for(int i = 0; i < maxm; ++ i) if(mark[i]) {
		v.emplace_back(i);
		f[1 << ((int)v.size() - 1)] = i;
	}

	int m = (int)v.size();
	for(int mask = 1; mask < (1 << m); ++ mask) {
		int bit = __builtin_ctz(mask);
		f[mask] = f[mask ^ (1 << bit)] ^ f[1 << bit];
	}

	memset(g, -69, sizeof g), g[0] = 0;
	for(int mask = 1; mask < (1 << m); ++ mask)
		for(int s = mask; s > 0; s = (s - 1) & mask)
			if(f[s] == 0) g[mask] = max(g[mask], g[mask ^ s] + 1);

	cout << n - g[(1 << m) - 1] - ans << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(v) v.begin(),v.end()
using namespace std;
typedef pair<int,int> pii;


int main(){
	bool prime[55560];
	rep(i,55560)prime[i]=true;
	prime[0]=prime[1]=false;
	for(int i=2;i<1000;i++){
		for(int j=i*2;j<55560;j+=i)prime[j]=false;
	}
	int n,cnt=0;
	cin>>n;
	rep(i,55560){
		if(prime[i]&&i%5==1){
			if(!cnt)cout<<i;
			else cout<<" "<<i;
			cnt++;
		}
		if(cnt>=n)break;
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define INF 1e+9


int main() {
	int k,x,ans;
	cin >> k;
	x = k / 2;
	if (k % 2 == 0)
	{
		ans = x * x;
	}
	else
	{
		ans = x * (x + 1);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const ll mod=1e9+7;

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  int ans = max(0,c - (a-b));
  printf("%d\n", ans);
  return 0;
}


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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intll int long long
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main() {
  int n ;
  cin >> n ;
  vector<int> a(n),b(n);
  
  rep(i,n) cin >> a.at(i) ;
  rep(i,n) cin >> b.at(i) ;
  
  int ans = 0;
  
  rep(i,n){
    int now = 0;
    for(int j=0;j<=i;j++)
      now += a.at(j);
    for(int h=i;h<n;h++)
      now += b.at(h) ;
    
    ans = max(ans,now) ;
  }
  
  cout << ans ;


}


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

struct InitCpp { InitCpp() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10); } } initCpp;

using comp = complex<double>;

static const double pi = std::acos(-1.0);

void show(comp p) {
  cout << p.real() << " " << p.imag() << endl;
}

void koch(comp p, comp q, int n) {
  if (n == 0) {
    show(p);
  } else {
    comp d = (q - p) / 3.0;
    comp s = p + d;
    comp u = s + d * polar(1.0, pi / 3.0);
    comp t = s + d;
    koch(p, s, n - 1);
    koch(s, u, n - 1);
    koch(u, t, n - 1);
    koch(t, q, n - 1);
  }
}

signed main() {
  int n;
  cin >> n;
  koch(comp(0.0, 0.0), comp(100.0, 0.0), n);
  show(comp(100.0, 0.0));
}



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

int main(){
	int k;
	string s;
	cin >> k >> s;
	
	if (s.size() <= k) {
		cout << s << endl;
	} else {
		rep(i, k) {
			cout << s.at(i);
		}
		cout << "..." << endl;
	}
}


Measured memory_bytes: 3632
N , K = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
A.append(0)
cnt = []
i_cnt = 1
for i in range(N):
    if A[i] == A[i + 1]:
        i_cnt += 1
    else:
        cnt.append(i_cnt)
        i_cnt = 1
cnt.sort()
result = 0
for i in range(len(cnt) - K):
    result += cnt[i]
print(result)

Measured memory_bytes: 24836
#include<bits/stdc++.h>
#define M 1000000000
using std::stack;
using std::pair;
using std::vector;
stack<pair<int,int>> Q;
int n;
int a[200020];
vector<int> V;
long long pow(int a,int pw){
    if(pw==0) return 1;
    long long ans=pow(a,pw/2);
    if(ans==-1) return -1;
    ans=ans*ans;
    if(ans>=M) return -1;
    if(pw%2) ans*=a;
    if(ans>=M) return -1;
    return ans;
}
void reallocate(int no, int dim){
    pair<int,int> temp = Q.top(); Q.pop();
    pair<int,int> temptemp=Q.top();
    int mm = std::max(temptemp.first,no);
    if(temptemp.first<no && pow(dim,temp.first-mm)!=-1){
        Q.push({mm,1+(temp.second-1)/pow(dim,temp.first-mm)});
    }
    else if(temptemp.first>=no && pow(dim,temp.first-mm)!=-1){
        Q.pop();
        temptemp.second += (temp.second-1)/pow(dim,temp.first-mm);
        Q.push(temptemp);
    }
}
void input(int no,int dim){
    while(!Q.empty() && Q.top().first>no){
        reallocate(no,dim);
    }
    if(!Q.empty() && Q.top().first==no){
        pair<int,int> temp = Q.top(); Q.pop();
        ++temp.second;
        Q.push(temp);
    }
    else{
        Q.push({no,1});
    }
}
/*class comp{
public:
    bool operator()(const int& dim,const int& x){
        
        while(!Q.empty()) Q.pop();
        Q.push({1,1});
        if(a[0]>1) Q.push({a[0],1});
        for(int i=1;i<n;i++) input(a[i],dim);
        input(1,dim);
        if(Q.top().second>dim){
            return true;
            puts("T");
        }
        else return false;
    }
} CMP;*/
bool CMP(const int& dim,const int& x){
    //printf("%d %d\n",dim,x);
    while(!Q.empty()) Q.pop();
    Q.push({1,1});
    if(a[0]>1) Q.push({a[0],1});
    for(int i=1;i<n;i++) input(a[i],dim);
    input(1,dim);
    //printf("%d %d\n",Q.top().first,Q.top().second);
    if(Q.top().second>dim+1){
        //puts("T");
        return true;
    }
    else return false;
}
int main(){
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    for(int i=1;i<=n;i++) {V.push_back(i);}
    std::cout << *std::lower_bound(V.begin(),V.end(),1,CMP);
}

Measured memory_bytes: 3444
import java.util.Scanner;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
class Main{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        long sc = scanner.nextLong() - 1;
        long sc2 = scanner.nextLong();
        long sc3 = scanner.nextLong();
        long sc4 = scanner.nextLong();
        long bet = sc2 - sc + 1;
        
        long tmp = sc2/sc3;
        long tmp2 = sc/sc3;
        long minus1 = tmp - tmp2;

        long tmp3 = sc2/sc4;
        long tmp4 = sc/sc4;
        long minus2 = tmp3 - tmp4;
        
        long tmp5 = sc2/lcm(sc3,sc4);
        long tmp6 = sc/lcm(sc3,sc4);
        long minus3 = tmp5 - tmp6;
        long ans = bet - minus1 - minus2 + minus3;
        System.out.println(ans - 1);
    }
    private static long gcd(long m, long n) {
    if(m < n) return gcd(n, m);
    if(n == 0) return m;
    return gcd(n, m % n);
    }
    private static long lcm(long m, long n) {
        return m * n / gcd(m, n);
    }
}

Measured memory_bytes: 22868
keys = ([chr(x) for x in range(ord('a'), ord('a') + 26)])
counts = {x:0 for x in keys}

while True:
    text = ''
    try:
        text = input()
    except EOFError:
        break

    for i in range(len(text)):
        target = text[i].lower()
        if 'a' <= target <= 'z':
            counts[target] += 1

for k in keys:
    print(k, counts[k], sep=' : ')

Measured memory_bytes: 6724
#include <stdio.h>
int main(void){
    int a,b,d,r;
    double f;
    scanf("%d %d",&a,&b);
    d = a / b;
    r = a % b;
    f = 1.00000 * a / b;
    printf("%d %d %.5lf\n",d,r,f);
    
    return 0;
}


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

int main()
{
    int N; cin>>N;
    vector<int> par(N,-1),lch(N),rch(N);
    for(int i=0;i<N;i++){
        int v; cin>>v;
        cin>>lch[v]>>rch[v];
        if(lch[v]!=-1) par[lch[v]]=v; 
        if(rch[v]!=-1) par[rch[v]]=v;
    }

    function<void(int)> preorder=[&](int v)
    {
        printf(" %d",v);
        if(lch[v]!=-1) preorder(lch[v]);
        if(rch[v]!=-1) preorder(rch[v]);
    }; 

    function<void(int)> inorder=[&](int v)
    {
        if(lch[v]!=-1) inorder(lch[v]);
        printf(" %d",v);
        if(rch[v]!=-1) inorder(rch[v]);
    }; 

    function<void(int)> postorder=[&](int v)
    {
        if(lch[v]!=-1) postorder(lch[v]);
        if(rch[v]!=-1) postorder(rch[v]);
        printf(" %d",v);
    }; 

    int root=-1;
    for(int i=0;i<N;i++) if(par[i]==-1) root=i;

    puts("Preorder"); preorder(root); puts("");
    puts("Inorder"); inorder(root); puts("");
    puts("Postorder"); postorder(root); puts("");

    return 0;
}


Measured memory_bytes: 3228
#include<stdio.h>

int main()
{
  int a[30], i, x;

  for(i=0; i<=30; i++){
    a[i] = 0;
  }
  
  for(i=0; i<=27; i++){
    scanf("%d",&x);
    a[x] = 1;
  }
  
  for(x=1; x<=30; x++){
    if(a[x]==0){
      printf("%d\n", x);
    }
  }

  return 0;
}

  
    

Measured memory_bytes: 596
#include<stdio.h>
int main()
{
int a,b,c;
scanf("%d %d %d",&a,&b,&c);
if(c<b)
{
 int cTemp = c;
 c = b;
 b = cTemp;
}
if(b<a)
{
 int bTemp = b;
 b = a;
 a = bTemp;
}
if(c<b)
{
 int cTemp = c;
 c = b;
 b = cTemp;
}
printf("%d %d %d\n",a,b,c);
return 0;
}

Measured memory_bytes: 596
H, W = map(int, input().split(' '))

ans = []

for h in range(1, H):
    r1 = h * W

    h = H - h

    r2a = h // 2 * W
    r3a = -1 * (-h // 2) * W
    r2b = W // 2 * h
    r3b = -1 * (-W // 2) * h

    ans.append(max(r1, r2a, r3a) - min(r1, r2a, r3a))
    ans.append(max(r1, r2b, r3b) - min(r1, r2b, r3b))

for w in range(1, W):
    r1 = H * w

    w = W - w

    r2a = H // 2 * w
    r3a = -1 * (-H // 2) * w
    r2b = w // 2 * H
    r3b = -1 * (-w // 2) * H

    ans.append(max(r1, r2a, r3a) - min(r1, r2a, r3a))
    ans.append(max(r1, r2b, r3b) - min(r1, r2b, r3b))

print(min(ans))


Measured memory_bytes: 24584
#include <iostream>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>

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


#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(long i=s;i<e;i++)
#define repeq(i,s,e) for(long i=s;i<=e;i++)



int main() {
	string s, t;
	ll k, cnt = 1, a = 0, b = 0,c=0,ans;
	in(s);
	in(k);

	rep(i, 1, s.size()) {
		if (s[i] == s[i - 1]) {
			cnt++;
		}
		else {
			a += cnt / 2;
			cnt = 1;
		}
	}
	a += cnt / 2;

	t = s + s;
	cnt = 1;
	rep(i, 1, t.size()) {
		if (t[i] == t[i - 1]) {
			cnt++;
		}
		else {
			b += cnt / 2;
			cnt = 1;
		}
	}

	b += cnt / 2;
	b = b - 2 * a;
	ans = a * k + b * (k - 1);


	t = t + s;
	cnt = 1;
	rep(i, 1, t.size()) {
		if (t[i] == t[i - 1]) {
			cnt++;
		}
		else {
			c += cnt / 2;
			cnt = 1;
		}
	}
	c += cnt / 2;
	c = c - (a * 3 + b * (3 - 1));

	outn(a * k + b * (k - 1) + c*(k/2));

	return 0;

}


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

using namespace std;

typedef pair<int,int> pi;
typedef long long ll;

const ll mod = 998244353;

ll A, B, C, D;

ll dp[3005][3005][4];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> A >> B >> C >> D;

	dp[A][B][0] = 1;

	dp[A+1][B][0] = 0;
	dp[A+1][B][1] = B;
	dp[A+1][B][2] = 0;

	dp[A][B+1][0] = 0;
	dp[A][B+1][1] = 0;
	dp[A][B+1][2] = A;

	dp[A+1][B+1][0] = A * B;
	dp[A+1][B+1][1] = B;
	dp[A+1][B+1][2] = A;
	for (ll i = A+2; i <= C; ++i){
		dp[i][B][0] = dp[i-1][B][0];
		dp[i][B][1] = (B*dp[i-1][B][1]) % mod;
		dp[i][B][2] = dp[i-1][B][2];
	}

	for (ll i = B+2; i <= D; ++i){
		dp[A][i][0] = dp[A][i-1][0];
		dp[A][i][1] = dp[A][i-1][1];
		dp[A][i][2] = (A*dp[A][i-1][2]) % mod;
	}
	for (ll i = A+1; i <= C; ++i){
		for (ll j = B+1; j <= D; ++j){
			if (i == A+1 && j == B+1) continue;
			dp[i][j][0] = ((((i-1) * (dp[i][j-1][0] + dp[i][j-1][1])) % mod + ((j-1) * (dp[i-1][j][0] + dp[i-1][j][2])) % mod  - ((i-1)*(j-1) * (dp[i-1][j-1][0] + dp[i-1][j-1][1] + dp[i-1][j-1][2]))%mod) % mod + mod) % mod;
			dp[i][j][1] = (dp[i-1][j][0] + (dp[i-1][j][1] * (j))%mod + dp[i-1][j][2]) % mod;
			dp[i][j][2] = (dp[i][j-1][0] + (dp[i][j-1][2] * (i))%mod + dp[i][j-1][1]) % mod;

		}
	}
	cout << ((dp[C][D][0] + dp[C][D][1] + dp[C][D][2]) % mod + mod) % mod << '\n';
}

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

int main(){
  int N;
  cin >> N;
  int dup = N;
  vector<pair<int,int>> v(N);
  for(int i = 0; i < N; i++){
    int x,y;
    cin >> x >> y;
    v[i] = make_pair(x,y);
  }
  float sum = 0.0;
  for(int i = 0; i < N; i++){
    for(int j = i + 1; j < N; j++){
      float tmp = sqrt((v[j].second - v[i].second)*(v[j].second - v[i].second) + (v[j].first - v[i].first)*(v[j].first - v[i].first));
      sum += tmp;
    //  cout << tmp << endl;
      
    }
  }
 // cout << sum << endl;
  int fact = 1;
  while(N != 0){
    fact = fact * N;
    N --;
  }
  int denom = ((dup)*(dup - 1))/2;
  int mul = (fact * (dup - 1))/denom;
  
  float res = (float)(mul * sum)/fact;
  cout << setprecision(12) <<res;
}
  


Measured memory_bytes: 3788
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(){
  ll n,l;cin>>n>>l;
  ll MIN=INF;
  ll k;
  for(int i=1;i<=n;i++){
    if(MIN>abs(l+i-1)){
      k=i;
      MIN=abs(l+i-1);
    }
  }
  ll ans=0;
  for(int i=1;i<=n;i++){
    if(i==k)continue;
    else ans+=l+i-1;
  }
  cout<<ans<<endl;
}
    

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include <stdio.h>
#include<algorithm>
#include<cstring>
#include <string>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#include<bits/stdc++.h>
#include <set>
#define ll   long long
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#define inf 0x3f3f3f3f3f3f3f3f
#define pi 3.1415926535898

#define N 200010
using namespace std;
vector <int >g[N];
const ll mod=1e9+7;
int n,x,y;
ll power(ll a,ll b)
{
    return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;
}
ll p[N],f[N],c[N];
void dfs(int u)
{
    c[u]=1;
    f[u]=1;
    for(auto v: g[u])
    {
        if(!c[v])
        {
            dfs(v);
            c[u]+=c[v];
            p[v]=u;
            f[u]=f[u]*f[v]%mod;
        }
    }
    f[u]=f[u]*c[u]%mod;
}
void calculate(int u)
{
    for(auto v:g[u])
    {
        if(v!=p[u])
        {
            f[v]=f[u]*(n-c[v])%mod*power(c[v],mod-2)%mod;
            calculate(v);
        }
    }
}
int main()
{
    cin>>n;
    for(int i=0; i<n-1; i++)
    {
        cin>>x>>y;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    ll S=1;
    for(int i=1; i<=n; i++)
        S=S*i%mod;
    dfs(1);
    calculate(1);
    for(int i=1; i<=n; i++)
        cout<<S*power(f[i],mod-2)%mod<<endl;
    return 0;
}


Measured memory_bytes: 19556
def slove():
    import sys
    input = sys.stdin.readline
    a, b = list(map(int, input().rstrip('\n').split()))
    a = a if a != 1 else 14
    b = b if b != 1 else 14
    if a > b:
        print("Alice")
    elif a < b:
        print("Bob")
    else:
        print("Draw")


if __name__ == '__main__':
    slove()


Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
#define INF 1<<30
#define endl '\n'
#define maxn 100005
#define tc printf("Case %d: ", cs)
#define tcn printf("Case %d:\n", cs);
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
typedef long long ll;
const double PI = acos(-1.0);
#define dbg(x) cerr << #x << " = " << x << endl;
#define dbg2(x, y) cerr << #x << " = " << x << ", " << #y << " = " << y << endl;
#define dbg3(x, y, z) cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;


int main()
{
    FASTIO
    /*
    //double start_time = clock();
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif
//*/
    int T;
    //cin >> T;
    T = 1;
    for (int cs = 1; cs <= T; cs++) {
        int n, m;
        cin >> n >> m;
        int ans = 1;
        for (int i = 1; i * i <= m; i++) {
            if (m % i == 0) {
                if (m / i >= n) ans = max(ans, i);
                if (i >= n) ans = max(ans, m / i);
                //dbg3(ans, i, m/i);
            }
        }
        cout << ans << endl;
    }

    //double end_time = clock();
    //printf( "Time = %lf ms\n", ( (end_time - start_time) / CLOCKS_PER_SEC)*1000);
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const (
	N        = 8
	FREE     = -1
	NOT_FREE = -2
)

var row, col [N]int
var dpos, dneg [2*N - 1]int
var X [N][N]bool

func initialize() {
	for i := 0; i < N; i++ {
		row[i], col[i] = FREE, FREE
	}
	for i := 0; i < 2*N-1; i++ {
		dpos[i], dneg[i] = FREE, FREE
	}
}

func print() {
	// 回答となる配置パターンの数だけprintがコールされる
	for i := 0; i < N; i++ {
		for j := 0; j < N; j++ {
			if X[i][j] {
				if row[i] != j {
					// 回答の配置パターンの内、
					// 入力条件として指定されているQの配置先を含まないものは表示しない
					return
				}
			}
		}
	}

	for i := 0; i < N; i++ {
		for j := 0; j < N; j++ {
			if row[i] == j {
				fmt.Print("Q")
			} else {
				fmt.Print(".")
			}
		}
		fmt.Println()
	}
}

func recursive(i int) {
	if i == N {
		// 最後まで到達したときは配置成功
		// 結果を表示
		print()
		return
	}

	for j := 0; j < N; j++ {
		if row[j] == NOT_FREE || col[j] == NOT_FREE ||
			dpos[i+j] == NOT_FREE || dneg[i-j+N-1] == NOT_FREE {
			continue
		}

		// 1. 配置
		row[i], col[j], dpos[i+j], dneg[i-j+N-1] = j, NOT_FREE, NOT_FREE, NOT_FREE

		recursive(i + 1)

		// 1.の配置の状態をもとに戻して、次のマスに配置した時の配置パターンを検索
		row[i], col[j], dpos[i+j], dneg[i-j+N-1] = FREE, FREE, FREE, FREE
	}

	// 無理だった
}

func main() {
	initialize()

	for i := 0; i < N; i++ {
		for j := 0; j < N; j++ {
			X[i][j] = false
		}
	}

	var k int
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	scanner.Scan()
	k, _ = strconv.Atoi(scanner.Text())

	for i := 0; i < k; i++ {
		var r, c int

		scanner.Scan()
		r, _ = strconv.Atoi(scanner.Text())
		scanner.Scan()
		c, _ = strconv.Atoi(scanner.Text())

		X[r][c] = true
	}

	recursive(0)
}



Measured memory_bytes: 1096
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main{

	public static void main(String[] args) throws IOException
	{
		int m;
		String strSub;

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in) );

        while(true)
        {
    		String str = br.readLine();
    		
    		if(str.equals("-") ) break;
    		
    		String strM = br.readLine();
    
    		m = Integer.parseInt(strM);
    		int[] h = new int[m];
    		
    		for(int i=0; i<m; i++)
            {
                String strH = br.readLine();
                h[i] = Integer.parseInt(strH);
                
        		strSub = str.substring(0, h[i]);
        
        		str = str + strSub;
        		
        		strSub = str.substring(h[i]);
        		str = null;//init string
        		str = strSub;
        		//System.out.println(strSub);
            }
            System.out.println(str);
            
        }
	}
}

Measured memory_bytes: 24416
/*
 * Click `Run` to execute the snippet below!
 */

import java.io.*;
import java.util.*;

/*
 * To execute Java, please define "static void main" on a class
 * named Solution.
 *
 * If you need more classes, simply define them inline.
 */

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int H = sc.nextInt(), W = sc.nextInt();
    int h = sc.nextInt(), w = sc.nextInt();
    boolean tbl[][] = new boolean[H][W];
    for(int i = 0; i<h; i++){
      for(int j = 0; j<W; j++){
        tbl[i][j] = true; 
      }
    }
    for(int j = 0; j<w; j++){
      for(int i = 0; i<H; i++){
        tbl[i][j] = true; 
      }
    }
    int cnt = 0;
    for(int i = 0; i<H; i++){
      for(int j = 0; j<W; j++){
        if(!tbl[i][j]){
          cnt++; 
        }
      }
    }
    System.out.println(cnt);
  }
}


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

int main() {
	int n,m,i,j,k,ans=0,cur;
	cin >> n;
	vector<long> d(n);
	for(i=0; i<n; i++){
		cin >> d[i];
	}
	for(i=0; i<n-1; i++){
		for(j=i+1; j<n; j++){
			ans+=d[i]*d[j];
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
using namespace std;

int main()
{
    int N;
    int a[11000];
    int cnt = 0;

    bool minus_flg = false;
    bool end_flg = true;

    cin >> N;

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

    while(true)
    {
        minus_flg = false;
        end_flg = true;

        for(int i=0; i<N;i++)
        {
            if( (a[i]%2) == 0 )  
            {
                minus_flg = true;
                end_flg = false;
                a[i] /= 2;
                break;
            }
        }

        if(end_flg == true) 
        {
            cout << cnt << endl;
            return 0;
        }
        cnt++;
    }
}

Measured memory_bytes: 256