akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

const int MOD = 1000000007;

int dp[3001][3001]; //! [up-to i-th item][time] => satisfaction level

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

    int N, T;
    cin >> N >> T;
    vector<pair<int, int>> AB(N);
    rep(i, N) {
        cin >> AB[i].first >> AB[i].second;
    }
    sort(AB.begin(), AB.end());
    rep(i, N) {
        rep(t, T+1) {
            if (t < AB[i].first) {
                dp[i][t] = (i == 0 ? 0 : dp[i-1][t]);
            } else {
                dp[i][t] = (i == 0 ? AB[i].second : max(dp[i-1][t], dp[i-1][t-AB[i].first] + AB[i].second));
            }
        }
    }

    int ans = 0;
    rep(i, N) {
        ans = (i == 0 ? AB[0].second : max(ans, AB[i].second + dp[i-1][T-1]));
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 35456
from heapq import heappop, heappush
import sys

input = sys.stdin.readline


class median_o1:
    def __init__(self):
        self.count = 0
        self.al = []
        self.ar = []
        self.sl = 0
        self.sr = 0
        self.b = 0

    def update_b(self, b):
        self.b += b

    def insert(self, x):
        if self.count % 2 == 0:
            if self.count == 0:
                heappush(self.al, -x)
                self.sl += x
            else:
                t = heappop(self.ar)
                self.sr -= t
                tl, tr = min(x, t), max(x, t)
                heappush(self.al, -tl)
                self.sl += tl
                heappush(self.ar, tr)
                self.sr += tr
        else:
            t = heappop(self.al)
            t *= (-1)
            self.sl -= t
            tl, tr = min(x, t), max(x, t)
            heappush(self.ar, tr)
            self.sr += tr
            heappush(self.al, -tl)
            self.sl += tl
        self.count += 1

    def get_median(self):
        return -self.al[0]

    def calc_min_value(self):
        # print(self.al, self.ar, self.b, self.sl, self.sr)
        m = self.get_median()
        return (m * ((self.count + 1) // 2) - self.sl) + (self.sr - m * (self.count // 2)) + self.b


q = int(input())

m = median_o1()

for _ in range(q):
    q_typ, *x = map(int, input().split())
    # 1, [a, b]
    # 2, []
    if q_typ == 1:
        m.update_b(x[1])
        m.insert(x[0])
    else:
        print(m.get_median(), m.calc_min_value())


Measured memory_bytes: 11208
#include <bits/stdc++.h>
#define ll long long
#define ls id << 1
#define rs id << 1 | 1
#define mem(array, value, size, type) memset(array, value, ((size) + 5) * sizeof(type))
#define memarray(array, value) memset(array, value, sizeof(array))
#define pb(x) push_back(x)
#define st(x) (1LL << (x))
#define pii pair<int, int>
#define mp(a, b) make_pair((a), (b))
#define Flush fflush(stdout)
using namespace std;
const int N = 500050;
const int inf = 0x3f3f3f3f;
const ll llinf = 0x3f3f3f3f3f3f;
const ll mod = 998244353LL;
clock_t TIME_START, TIME_END;
void program_end()
{
#ifdef ONLINE
    printf("\nTime used: %.6lf(s)\n", ((double)TIME_END - TIME_START) / CLOCKS_PER_SEC);
    system("pause");
#endif
}
ll a;

void solve()
{
    cin >> a;
    cout << a + a * a + a * a * a << endl;
}

int main()
{
    TIME_START = clock();
    int Test = 1;
    // cin >> Test;
    while (Test--)
        solve();
    TIME_END = clock();
    program_end();
    return 0;
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch ROTN | diff ROTN.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address ROTN.cpp && ./a.out

/*
 
 11/24/2019
 
 4:03-
 
 */

int N;
string S;

void solve() {
  REP(i,SZ(S)) S[i]=(S[i]-'A'+N)%26+'A';
  cout<<S<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>N>>S;
  solve();
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
priority_queue<int> i;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long a=0,b=0,c=0,d=0,e=1,f=0;
  cin >>a>>b;
  for(int n=0;n<a;n++) cin >>c,i.push(c);
  for(int n=0;n<b;n++){
    d=i.top();
    d=d/2,i.pop(),i.push(d);
  }
  while(!i.empty()) f+=i.top(),i.pop();
  cout <<f<<'\n';
  return (0);
}


Measured memory_bytes: 892
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <cmath>
using namespace std;

string s;
int num;

//s[pos]の直前に挿入するか考えている. used…既に挿入した文字数
bool dfs(int pos, int used, string t) {
	if (t.length() == 9) return t == "AKIHABARA";
	bool ret = false;
	if (used < num) ret |= dfs(pos, used + 1, t + "A");
	if (pos < s.length()) ret |= dfs(pos + 1, used, t + s[pos]);
	return ret;
}

int main() {
	cin >> s;
	
	if (s.length() >= 10) { cout << "NO" << endl; return 0; }
	num = 9 - s.length();
	
	bool res = dfs(0, 0, "");
	if (res) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
alpha = list(map(int, input().split()))

alpha = sorted(alpha)
ans = N
t = 0

for i in range(N-1, -1, -1) :
    if t+alpha[i] < K :
        t += alpha[i]
    else :
        ans = min(ans, i)

print(ans)

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

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

    vector<int> v(n);
    for(int i = 0; i < n; i++){
        cin >> v[i];
    }
    
    for(int i = n - 1; i >= 0; i--){
        cout << v[i];
        if(i != 0){
            cout << " ";
        }
    }
    cout << endl;

}    


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

public class Main {
	static final int mod = (int) 1e9 + 7;
	static final int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };
	static final int INF = Integer.MAX_VALUE / 3;
	static final long LINF = Long.MAX_VALUE / 3;
	static final String nextLine = "\n";

	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		int n = fs.nextInt();
		char cs[] = fs.next().toCharArray();
		int sumE[] = new int[n+2];
		int rsumE[] = new int[n+2];
		int sumW[] = new int[n+2];
		int rsumW[] = new int[n+2];
		
		for(int i=0;i<n;i++) {
			if(cs[i]=='W') {
				sumE[i+1] = sumE[i];
				sumW[i+1] = sumW[i] + 1;
			}
			else {
				sumE[i+1] = sumE[i] + 1;
				sumW[i+1] = sumW[i];				
			}
		}
		for(int i=n-1;i>=0;i--) {
			if(cs[i]=='W') {
				rsumE[i+1] = rsumE[i+2];
				rsumW[i+1] = rsumW[i+2] + 1;
			}
			else {
				rsumE[i+1] = rsumE[i+2] + 1;
				rsumW[i+1] = rsumW[i+2];				
			}
		}
		
		int ans = INF;
		for(int i=0;i<n;i++) {
			int res = sumW[i] + rsumE[i+2];//reverseの添字が１つずれるのなんとかできない？
			ans = Math.min(ans,res);
		}
		System.out.println(ans);
		
	}

	//MOD culculations
	static long plus(long x, long y) {
		long res = (x + y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long sub(long x, long y) {
		long res = (x - y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long mul(long x, long y) {
		long res = (x * y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long div(long x, long y) {
		long res = x * pow(y, mod - 2) % mod;
		return res < 0 ? res + mod : res;
	}

	static long pow(long x, long y) {
		if (y < 0)
			return 0;
		if (y == 0)
			return 1;
		if (y % 2 == 1)
			return (x * pow(x, y - 1)) % mod;
		long root = pow(x, y / 2);
		return root * root % mod;
	}
}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

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

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

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

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

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

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}

Measured memory_bytes: 33620
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define yes "YES"
#define no "NO"
#define rsort(a) sort(a.rbegin(),a.rend())
const int mod=1000000007;
//void dfs(int i);
long long modular_expo(long long x,long long y);

bool cmp(pair<double,int>p1,pair<double,int>p2)
{
    if(p1.first>p2.first)
        return true;
    else
    {
        if(p1.first<p2.first)
            return false;
        else if(p1.first==p2.first)
        {
            if(p1.second<p2.second)
                return true;
            else
                return false;
        }
    }
}
/*bool cmp1(map<int,int>a,map<int,int>b)
{
    if(a.first<b.first)
        return true;
    else
        return false;
}*/
//ll m;


/*
void bsf(int t)
{
    queue<int>q;
    visited[t]=true;
    q.push(t);
    while(!q.empty())
    {
        int temp=q.front();
        //cout<<temp<<" ";
        if(temp==n)
            {
                vector<int>ans;
    ans.pb(n);
        int tttt=n;
    for(int i=0;i<tttt;i++)
    {
        ans.pb(parent[n]);
        n=parent[n];
        if(n==1)
            break;
    }
    if(n!=1)
    {
        break;
    }
    cout<<ans.size()<<endl;
    for(int i=ans.size()-1;i>=0;i--)
        cout<<ans[i]<<" ";
        f=1;

            }
        q.pop();
        //cout<<temp<<" ";
        for(auto i=l[temp].begin();i!=l[temp].end();i++)
        {
            if(!visited[*i])
            {
                q.push(*i);
                parent[*i]=temp;
                visited[*i]=true;
            }
        }
    }
}
*/
long long modular_expo(long long x,long long y)
{

    if(y==0)
        return 1;
    if(y%2==0)
        return (modular_expo((x*x),y/2));
    if(y%2==1)
        return ((x)*modular_expo((x*x),(y-1)/2));


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

    int n,m,i,j,t;
    map<pair<int,int>,int>mpp;
    cin>>m>>n>>t;
    vector<ll>row(n+1,0),col(m+1,0);
    for(i=0;i<t;i++)
    {
        int x,y;
        cin>>y>>x;
        row[x]++;
        col[y]++;
        mpp[mp(x,y)]=1;
    }
    //int x,y;
    ll rx=-1;
    for(i=0;i<=n;i++)
    {
        rx=max(rx,row[i]);
    }
   ll mx=-1;
    for(i=0;i<=m;i++)
    {
        mx=max(mx,col[i]);
    }
    vector<int>x,y;
    for(i=0;i<=n;i++)
    {
        if(row[i]==rx)
            x.pb(i);
    }
    for(i=0;i<=m;i++)
    {
        if(col[i]==mx)
            y.pb(i);
    }
    int f=1;
    ll ans=-1;
    /*
    for(auto it:x)
        cout<<it<<" ";
    cout<<endl;
    for(auto it:y)
        cout<<it<<" ";
    cout<<endl;*/
    for(i=0;i<x.size();i++)
    {
        for(j=0;j<y.size();j++)
        {
            //cout<<row[x[i]]<<" "<<col[y[j]]<<" "<<mpp[mp(x[i],y[j])]<<endl;
            if(mpp[mp(x[i],y[j])]==0)
            {
                f=0;
                break;
            } 
        }
        if(f==0)
        {
            break;
        }
    }
    cout<<rx+mx-f;
}




Measured memory_bytes: 30720
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int num[255];

int main() {
    num['I'] = 1;
    num['V'] = 5;
    num['X'] = 10;
    num['L'] = 50;
    num['C'] = 100;
    num['D'] = 500;
    num['M'] = 1000;
    string s;
    while (cin >> s) {
        int n = num[s.back()];
        for (int i=0; i<(int)s.size()-1; ++i) {
            if (num[s[i]] < num[s[i+1]]) {
                n -= num[s[i]];
            } else {
                n += num[s[i]];
            }
        }
        cout << n << endl;
    }
    return 0;
}

Measured memory_bytes: 1180
#include<iostream>
using namespace std;
int prime[200];
int main(){
	int count=0;
	for(int i=3;i<1000;i+=2){
		bool t=true;
		for(int j=0;j<count;j++)
			if(i%prime[j]==0)t=false;
		if(t==true){
			prime[count]=i;
			count++;
		}
	}
	int n;
	while(true){
		cin>>n;
		if(n==0)
			break;
		n/=2;
		int ans=0,k=n*2-3;
		bool t;
		for(int i=3;i<=n;i+=2){
			t=true;
			for(int j=0;j<count;j++){
				if(i%prime[j]==0){
					if(i!=prime[j]){
						t=false;
						break;
					}
				}
				if(k%prime[j]==0){
					if(k!=prime[j]){
						t=false;
						break;
					}
				}
			}
			if(t)ans++;
			k-=2;
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#include <ctime>
#include <cstdlib>
#define rep(i, N) for (int i = 0; i < (N); i++)
#define swap(a, b) (a += b, b = a - b, a -= b)
using namespace std;
int main()
{
    long long N;
    cin >> N;
    vector<long long> a(N);
    long long count = 0;
    rep(i, N)
    {
        cin >> a[i];
    }
    long long Max = 0;
    for (int i = N - 1; i > 0; i--)
    {
        if (a[i] <= a[i - 1])
        {
            count++;
        }
        else
        {
            Max = max(Max, count);
            count = 0;
        }
    }
    Max = max(Max, count);
    cout << Max << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(){
  int n,l;cin>> n>>l;string s[n];
  for(int i=0;i<n;i++){
    cin>> s[i];
  }
  sort(s,s+n);
  for(int i=0;i<n;i++){
    cout << s[i];
  }
  cout << endl;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int N = scanner.nextInt();
    int[] a = new int[N];
    int max = -1_000_001;
    int min = 1_000_001;
    int maxi = -1;
    int mini = -1;
    for (int i = 0; i < N; i++) {
      a[i] = scanner.nextInt();
      if (a[i] > max) {
        max = a[i];
        maxi = i;
      }
      if (a[i] < min) {
        min = a[i];
        mini = i;
      }
    }

    List<int[]> operations = new ArrayList<>();
    boolean ltr;
    if (max >= 0 && min >= 0) ltr = true;
    else if (max < 0 && min < 0) ltr = false;
    else {
      if (max + min >= 0) {
        ltr = true;
        for (int i = 0; i < N; i++) {
          operations.add(new int[]{maxi, i});
          a[i] += max;
        }
      } else {
        ltr = false;
        for (int i = 0; i < N; i++) {
          operations.add(new int[]{mini, i});
          a[i] += min;
        }
      }
    }

    if (ltr) {
      for (int i = 0; i < N - 1; i++) {
        operations.add(new int[]{i, i + 1});
        a[i + 1] += a[i];
      }
    } else {
      for (int i = N - 1; i > 0; i--) {
        operations.add(new int[]{i, i - 1});
        a[i - 1] += a[i];
      }
    }

    System.out.println(operations.size());
    for (int[] p : operations) System.out.printf("%d %d\n", p[0] + 1, p[1] + 1);
  }
}


Measured memory_bytes: 23124
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

class Main {
	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		List<Integer> list = new ArrayList<>();
		int sumA = 0;

		for (int i = 0; i < n; i++) {
			list.add(scanner.nextInt());
			sumA += list.get(i);
		}

		int ans = 0;
		int harf = (int) Math.round( (double) sumA / list.size()) ;;
			for (int i : list) {
				ans += (i - harf) * (i - harf);
			}
		

		System.out.println(ans);
	}
}

Measured memory_bytes: 21844
N, W = map(int, input().split())
dp = [[0] * (W+1) for _ in range(N+1)]
w, v = [0]*N, [0]*N
for i in range(N):
    w[i], v[i] = map(int,input().split())
for i in range(N):
    for k in range(W+1):
        if w[i] <= k:
            dp[i+1][k] = max(dp[i][k-w[i]]+v[i], dp[i][k])
        else:
            dp[i+1][k] = dp[i][k]
print(dp[N][W])


Measured memory_bytes: 119916
#include <iostream>

using namespace std;

const int MIN = 0;
const int MAX = 10000;

void koukan(int &a, int &b)
{
    int tmp;
    tmp = a;
    a = b;
    b = tmp;
}

int main(int argc, char *argv[])
{
    int a, b, c;
    while (cin >> a >> b >> c)
    {
        if (((MIN <= a) && (a <= MAX)) && ((MIN <= b) && (b <= MAX)) && ((MIN <= c) && (c <= MAX)))
        {
            bool f;
            do{
                f = false;
                if(a > b)
                {
                    koukan(a, b);
                    f = true;
                }
                if(b > c)
                {
                    koukan(b, c);
                    f = true;
                }
            }while(f);
            cout << a << " " << b << " " << c << endl;
        }
    }
}

Measured memory_bytes: 3088
import math
n=int(input())
s=0
for i in range(n):
    x=int(input())
    a=0
    if x==2:
        s+=1
    else:
        for j in range(2,int(math.sqrt(x))+1):
            if x%j==0:
                a+=1
                break
        if a==0:
            s+=1
print(s)


Measured memory_bytes: 5676
#include<iostream>
#include<vector>
#include<algorithm>
#include<tuple>
#include<utility>

using namespace std;

typedef long long int64;

int main(void){
    int64 N,M;
    cin>>N>>M;
    vector<int64> p(M);
    vector<string> S(M);
    vector<int64> q(N+1);
    int64 cor=0,pen=0;

    for (int64 i = 0; i < N+1; i++){
        q[i]=0;
    }

    for (int64 i = 0; i < M; i++){
        cin>>p[i]>>S[i];
        if(S[i]=="WA"&&q[p[i]]!= -1){
            q[p[i]]++;
        }else if(S[i]=="AC"&&q[p[i]]!= -1){
            pen+=q[p[i]];
            cor++;
            q[p[i]]=-1;
        }
    }
    
    cout<<cor<<" "<<pen<<endl;
    
    return 0;
}

Measured memory_bytes: 7296
#include "bits/stdc++.h"
#define rep(i, j) for (int i = 0; i < j; i++)
#define srep(i, j, k) for (int i = j; i < k; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using ull = unsigned long long;

ll gcd(ll x, ll y);
int fac(ll n, vector<int> num);

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

//�G�X�g���l�X���
vector<ll> estora(vector<ll> num) {
    int sel = 0;
    while (sel < num.size()) {
        int d = num[sel];
        for (int i = 0; i < num.size(); i++) {
            if (num[i] % d == 0 && num[i] != d && d != 1) {
                num.erase(num.begin() + i);
                i--;
            }
        }
        sel++;
    }
    return num;
}

const int INF = 1001001001;

//mint�p�̒萔 (10��9�� + 7)
const int mod = 1000000007;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream & is, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }

int main() {
    int x;
    string s;
    cin >> x;
    if (x >= 30) {
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No";
    return 0;
}

/*���C�u�����ő����*/
//���[�O���b�h�̌ݏ��@
ll gcd(ll x, ll y) {
    ll num[3];
    num[0] = (x > y) ? x : y;
    num[1] = (x <= y) ? x : y;
    num[2] = num[0] % num[1];

    while (num[2]) {
        num[0] = num[1];
        num[1] = num[2];
        num[2] = num[0] % num[1];
    }

    return num[1];
}

/*�f��������*/
//���색�C�u����
//i����ɑf���ɂ��Ă����Ȃ��Ƃ��܂��ł��Ȃ�&&�v�Z�ʃ��o�C
//�G�X�g���l�X��⿂őf����U����Ă����K�v�������肻��
int fac(ll n, vector<int> num) {
    ll kazu = n;
    for (int i = 2; i <= sqrt(n); i++) {
        while (1) {
            if (kazu % i != 0) break;

            kazu /= i;
            num[i]++;
        }
    }
    if (kazu == n && n != 1) return 1;
    int ans = 0;
    if (kazu != 1) ans++;
    for (int i = 2; i <= sqrt(n); i++) {
        for (int j = 1; j <= num[i]; j++) {
            num[i] -= j;
            ans++;
        }
    }
    return ans;
}

Measured memory_bytes: 3720
import java.util.Scanner;
public class Main {
@SuppressWarnings("resource")
public static void main(String[] args) {
	Scanner sc =new Scanner(System.in);
	String S=sc.next();
	String[] S2=S.split("");
	if(S2[0].equals(S2[1])&&!S2[0].equals(S2[2])&&S2[2].equals(S2[3])) {
		System.out.println("Yes");
	}else if(S2[0].equals(S2[2])&&!S2[0].equals(S2[1])&&S2[1].equals(S2[3])) {
		System.out.println("Yes");
	}else if(S2[0].equals(S2[3])&&!S2[0].equals(S2[2])&&S2[2].equals(S2[1])) {
		System.out.println("Yes");
	}else {
		System.out.println("No");
	}
}
}

Measured memory_bytes: 21844
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <limits>
#include <queue>
#include <iomanip>
#include <set>
//#include <bits/stdc++.h>
template<typename T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}
using namespace std;
#define ALL(X) X.begin(),X.end()
using ll = long long int;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
const int MOD=1000000007;
//const int MOD=998244353;
const int INTMAX=2147483647;
const ll LLMAX=9223372036854775807;

ll modadd(ll a,ll b,ll mod=MOD){
    return (a%mod+b%mod)%mod;
}

ll modsub(ll a,ll b,ll mod=MOD){
    a%=mod;
    b%=mod;
    if(a>=b) return a-b;
    else return mod-b+a;
}

ll modmul(ll a,ll b,ll mod=MOD){
    return ((a%mod)*(b%mod))%mod;
}

ll modpow(ll a, ll n,ll mod=MOD) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

ll moddiv(ll a,ll b,ll mod=MOD) {
    return modmul(a, modpow(b, mod-2));
}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll N;
    cin>>N;
    vll T(N),A(N);
    for(ll i=0;i<N;i++)cin>>T[i];
    for(ll i=0;i<N;i++)cin>>A[i];
    
    vvll h(N,vll(2));
    for(ll i=0;i<N;i++){
        h[i][0]=1;
        h[i][1]=LLMAX;
    }
    
    for(ll i=0;i<N;i++){
        if(i==0){
            h[0][0]=T[0];
            h[0][1]=T[0];
        }else{
            if(T[i]==T[i-1]){
                h[i][0]=1;
                h[i][1]=T[i];
            }else{
                h[i][0]=T[i];
                h[i][1]=T[i];
            }
        }
    }
    
    for(ll i=N-1;i>=0;i--){
        if(i==N-1){
            if(h[i][0]>A[i]||h[i][1]<A[i]){
                cout<<0<<endl;
                return 0;
            }
            h[i][0]=A[i];
            h[i][1]=A[i];
        }else{
            if(A[i]==A[i+1]){
                if(h[i][0]>A[i]){
                    cout<<0<<endl;
                    return 0;
                }
                h[i][1]=min(A[i],h[i][1]);
            }else{
                if(h[i][0]>A[i]||h[i][1]<A[i]){
                    cout<<0<<endl;
                    return 0;
                }
                h[i][0]=A[i];
                h[i][1]=A[i];
            }
        }
    }
    
    ll ans=1;
    for(ll i=0;i<N;i++){
        if(h[i][1]-h[i][0]+1<=0){
            cout<<0<<endl;
            return 0;
        }
        ans=modmul(ans,h[i][1]-h[i][0]+1);
    }
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 7296
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
  int d,t,s;
  cin>>d>>t>>s;
  if(d<=(t*s))
  {
    cout<<"Yes\n";
  }
  else
  {
    cout<<"No\n";
  }
}

Measured memory_bytes: 3636
#include <iostream>
#include <set>
#include <cstring>
#include <vector>
using namespace std;

//int node[101][101];
int visit[101];
int ans,last;
int die[101];
int flag;

void dfs(int now, int cnt, int *st, vector<vector<int> >& vv){
	if( cnt>ans ){
		ans=cnt;
		last = now;
		flag = 1;
	}
	for(int next=0; next<vv[now].size(); next++)if( !visit[vv[now][next]] ){
		int k = vv[now][next];
		visit[k] = die[k] = 1;
		st[cnt] = k;
		dfs(k,cnt+1,st,vv);
		visit[k] = 0;
	}
	return ;
}

int main(){
	int n;
	while(cin>>n,n){
		set<int> s;
		vector<vector<int> > vv(101);
		ans = 0;
		//memset(node,0,sizeof(node));
		memset(visit,0,sizeof(visit));
		memset(die,0,sizeof(die));
		for(int i=0; i<n; i++){
			int a,b; cin>>a>>b;
			//node[a][b] = node[b][a] = 1;
			vv[a].push_back(b);
			vv[b].push_back(a);
			s.insert(a);
			s.insert(b);
		}
		int tmp[101];
		/*
		for(int i=0; i<vv.size(); i++){
			printf("vv[%d].size = %d\n",i,vv[i].size());
			for(int j=0; j<vv[i].size(); j++)
				printf("%d ",vv[i][j]);
			puts("");
		}
		*/
		for(set<int>::iterator it=s.begin(); it!=s.end(); it++)if( !die[*it] ){
			flag = 0;
			
			visit[*it]=1;
			tmp[0] = *it;
			dfs(*it,1,tmp,vv);
			visit[*it]=0;
			
			die[last] = 0;
			//printf("*it:%d\n",*it);

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

Measured memory_bytes: 928
package main

import (
	"fmt"
	"math"
)

func main() {
	var x int
	fmt.Scan(&x)

	result := 1
	for i := 2; i < x; i++ {
		for j := 2; j < x; j++ {
			now := int(math.Pow(float64(i), float64(j)))
			if now > x {
				break
			} else if result < now {
				result = now
			}
		}
	}

	fmt.Println(result)
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  int N=stoi(s);
  int d1=N/100;
  int d2=N%100;
  string a="NA";
  
  if(0<d1&&d1<=12&&0<d2&&d2<=12){
    a="AMBIGUOUS";
  }
  else if(0<d1&&d1<=12){
    a="MMYY";
  }
  else if(0<d2&&d2<=12) {
    a="YYMM";
  }
  cout<<a<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

long long f(long long a, long long x)
{
    if (a == -1)
        return 0;
    return a / x + 1;
}

int main()
{
    long long a, b, x;
    scanf("%lld %lld %lld", &a, &b, &x);
    if (f(b, x) - f(a - 1, x) < 0)
        printf("0");
    else
        printf("%lld\n", f(b, x) - f(a - 1, x));
}

Measured memory_bytes: 128
import Control.Monad
import Control.Applicative
import Data.List

main = do
    n <- readLn
    when (n /= 0) $ do
        xs <- input n read
        print $ solve xs
        main

solve :: [Int] -> Int
solve = maximum . scanl1 accumMax
    where
    accumMax a b = max (a+b) b

input :: Int -> (String -> a) -> IO [a]
input n f = map f <$> replicateM n getLine

Measured memory_bytes: 5768
#include <cstdio>

#if LOCAL
#include <ctime>
#endif
int findFactor(int x)
{
    int i,count=0;
    for(i=1;i<=x;i+=2)
    {
        if(x%i==0){
            count++;
        }
    }
    return count;
}

int main()
{
#if LOCAL
    clock_t startTime=clock();
#endif
    int i,N,count;
    scanf("%d",&N);
    count=0;
    for(i=1;i<=N;i+=2)
    {
        
        if(findFactor(i)==8){
           
            count++;
        }
    }
    printf("%d\n",count);

#if LOCAL
    printf("[Runtime=%3d ms.\n",clock()-startTime);
#endif
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);(i)--)
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);(i)--)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T> inline istream& operator>>(istream& input, vector<T>& v) { for (auto& elemnt : v)input >> elemnt; return input; }

int main() {
    init();

    int n; ll K;
    cin >> n >> K;
    VL a(n); cin >> a;


    string k = "";
    while (K) {
        k += to_string(K % 2);
        K /= 2;
    }
    while (k.length() < 40)k += '0';
    reverse(all(k));
    int len = k.length();

    VI bit(40, 0);
    FOR(i, 0, n) {
        ll b = a[i];
        for (int j = 0; b; j++) {
            bit[j] += b % 2;
            b /= 2;
        }
    }
    reverse(all(bit));

    vector<VL> dp(41, VL(2, -1));
    dp[0][0] = 0;
    FOR(i, 0, 40)FOR(small, 0, 2) {
        if (dp[i][small] == -1)continue;
        eFOR(x, 0, (small ? 1 : k[i] - '0')) {
            ll num = (1LL << (40 - i - 1)) * (ll)(x ? n - bit[i] : bit[i]);
            chmax(dp[i + 1][small || x < k[i] - '0'], dp[i][small] + num);
        }
    }
    cout << max(dp[40][0], dp[40][1]) << "\n";
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define pb push_back
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[200010];
struct edge{int to,cost;};
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
bool prime(int a){
	if(a==1)return false;
	for(int i=2;i*i<=a;i++){
		if(a%i==0)return false;
	}
	return true;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
	double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
	double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
	double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
	double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
	return tc*td<0&&ta*tb<0;
}
void init_fact(int n){
	kaijo[0]=1;
	for(int i=1;i<=n;i++){
		kaijo[i]=kaijo[i-1]*i;
		kaijo[i]%=MOD;
	}
}
int modpow(int a,int b){
	if(b==0)return 1;
	if(b%2)return modpow(a,b-1)*a%MOD;
	int memo=modpow(a,b/2);
	return memo*memo%MOD;
}
int comb(int a,int b){
	return kaijo[a]*modpow(kaijo[a-b],MOD-2)%MOD*modpow(kaijo[b],MOD-2)%MOD;
}
int inv(int x){
	x=modpow(x,MOD-2);
	return x;
}
double a,b,x;
signed main(){
	cin>>a>>b>>x;
	if(x<=a*a*b/2){
		double c=x/a/b*2.0;
		double d=sqrt(b*b+c*c);
		double e=acos(c/d);
		printf("%.12lf\n",e*180.0/M_PI);
	}
	else{
		
		x=a*a*b-x;
		double c=x/a/a*2.0;
		double d=sqrt(a*a+c*c);
		double e=acos(a/d);
		printf("%.12lf\n",e*180.0/M_PI);
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long int n;
  cin>>n;
  string a="";
  while(n){
    n-=1;
    long long int z=(n%(long long int)26);
    char x=z+'a';
    a+=x;
    n/=26;
  }
  reverse(a.begin(),a.end());
  cout<<a;
}

Measured memory_bytes: 3588
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
typedef pair<int, int> P;
typedef pair<int, P> PP;
int d[1010][1010];
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, W;
    cin >> H >> W;
    string S[1010];
    rep(i, H) cin >> S[i];
    priority_queue<PP, vector<PP>, greater<PP>> que;
    rep(i, H) rep(j, W) d[i][j] = INF;
    rep(i, H)  {
        rep(j, W) {
            if(S[i][j] == '#') {
                que.push({0, {i, j}});
                d[i][j] = 0;
            }
        }
    }
    int ans = 0;
    while(que.size()) {
        PP p = que.top(); que.pop();
        int x = p.second.first;
        int y = p.second.second;
        if(p.first > d[x][y]) continue;
        rep(k, 4) {
            int xx = x + dx[k];
            int yy = y + dy[k];
            if(xx < 0 || xx >= H || y < 0 || y >= W) continue;
            if(d[xx][yy] > p.first + 1) {
                d[xx][yy] = p.first + 1;
                ans = max(ans, d[xx][yy]);
                que.push({d[xx][yy], {xx, yy}});
            }
        }
    }
    cout << ans << endl;



    return 0;
}


Measured memory_bytes: 18668
import math


a, b, h, m = map(int, input().split())

theta_a_deg = (360/60) * (1/12) * m + (360/12) * h
theta_b_deg = (360/60) * m
theta_deg = abs(theta_a_deg - theta_b_deg)

cc = (a - b*math.cos(math.radians(theta_deg)))**2  + (b*math.sin(math.radians(theta_deg)))**2
print(abs(cc**0.5))

Measured memory_bytes: 9524
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char c;
  cin >> c;
  if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o'){
    cout << "vowel" << endl;
  }
  else {
    cout << "consonant" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<map>
using namespace std;

int main() {
    int n; scanf("%d",&n);
    map<string, int> mp;
    for(int i=1;i<=n;i++){
        string s; cin >> s;
        mp[s]++;
    }  
    printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d", mp["AC"], mp["WA"], mp["TLE"], mp["RE"]);
    return 0;
}

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

const long long INF = 1LL << 60;
int MOD = 1000000007;
double PI = 3.14159265358979323846;
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; }

typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define For(i,s,n) for (int i=s;i<(int)(n);i++)
#define vi vector<int>
#define vii vector< vector<int> >
#define vs vector<string>
#define All(c) (c).begin(), (c).end()
#define Print(x) cout<<(x)<<"\n"



int main() {

	string S;
	cin >> S;

	rep(i, 12) {
		if (i == 4) cout << ' ';
		cout << S[i];
	}
	cout << endl;

}

Measured memory_bytes: 256
import math
import copy
from copy import deepcopy
import sys
import fractions
# import numpy as np
from functools import reduce
# import statistics
import decimal
import heapq
import collections
import itertools
from operator import mul

sys.setrecursionlimit(100001)


# input = sys.stdin.readline
# sys.setrecursionlimit(10**6)

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum


def getInputListInt():
    outputData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) - 1 for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===

while True:
    n, x = map(int, input().split())
    if n == 0 and x == 0:
        break

    ans = 0
    for i in range(1, n+1):
        for j in range(i+1, n+1):
            if i+j > x:
                break
            for k in range(j+1, n+1):
                tmp = i+j+k
                if tmp==x:
                    ans+=1
                if tmp>=x:
                    break

    print(ans)




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

int main()
{
    int n,k,temp,s=0; cin>>n>>k;
    for(int i=0;i<n;++i) 
    {
        cin>>temp; if(temp>=k) s++;
    }
    cout<<s;
    return 0;
}

Measured memory_bytes: 256
a,b,c=map(int,input().split())
temp=max(a,b,c)*3-a-b-c
if (a%2==0 and b%2==0 and c%2==0) or (a%2!=0 and b%2!=0 and c%2!=0):
  print(int(temp/2))
else:
  if temp%2==0:
    print(int(temp/2))
  else:
    print(1+int((temp+1)/2))

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cstring>
#include <functional>
#include <cmath>
#include <complex>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define fs first
#define sc second
#define pb push_back
#define show(x) cout << #x << " " << x << endl
int a(char c){
	if(isdigit(c)) return c-'0';
	if(c=='T') return 10;
	if(c=='J') return 11;
	if(c=='Q') return 12;
	if(c=='K') return 13;
	if(c=='A') return 14;
}
int main(){
	while(true){
		char c;
		cin>>c;
		if(c=='#') break;
		string s[4][13];
		rep(i,4) rep(j,13) cin>>s[i][j];
		int ew=0,ns=0;
		int l=0;
		rep(i,13){
			bool t=false;
			rep(j,4){
				if(!t&&s[j][i][1]==c){
					t=true;
					l=j;
				}else if(!t&&s[j][i][1]==s[l][i][1]&&a(s[j][i][0])>a(s[l][i][0])){
					l=j;
				}else if(t&&s[j][i][1]==c&&a(s[j][i][0])>a(s[l][i][0])){
					l=j;
				}
			}
			if(l%2) ew++;
			else ns++;
		}
		if(ew>ns) cout<<"EW "<<ew-6<<endl;
		else cout<<"NS "<<ns-6<<endl;
	}
}

Measured memory_bytes: 1188
import java.util.*;
public class Main{

  
  public static void main(String[] args){
  
    Scanner s=new Scanner(System.in);
    int n=s.nextInt();
    int k=s.nextInt();
    int ss=s.nextInt();
    if(k%n==0 || ss%n==0){System.out.println("OK" );}
    else if(  (int)(k/n) == (int)(ss/n)  ){
    System.out.println("NG");}
    else{System.out.println("OK");}
  
  }
  
}

Measured memory_bytes: 27036
#include <bits/stdc++.h>
#pragma once
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
#define endn "\n"
typedef pair<int,int> P;
const int MOD = 1000000007;
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 


////////////////////////////////////////////////////////////////////
///////////////////////___modpow___////////////////////
ll modpow(ll a,  ll n, const ll &MOD = MOD){
  ll ret = n == 0 ? 1 : modpow(a, n/2, MOD);
  (ret *= ret) %= MOD;
  if(n%2)((ret *= a) %= MOD);
  return ret;
}
///////////////////////___modinv___////////////////////
ll modinv(ll d, const ll &MOD = MOD){
  return modpow(d, MOD-2, MOD);
}
////////////////////////////////////////////////////////////////////

int n, x[110000];
signed main(){
  cin>>n;rep(i,n)cin>>x[i];
  int ans = 0, a = 1, f;
  repd(i,2,n)a = (a*i)%MOD;
  f = a;
  rep(i,n-1){
    int l = (x[i+1] - x[i])%MOD, t = a*l%MOD;
    ans = (ans + t)%MOD;
    a = (a + f*modinv(i+2)%MOD)%MOD;
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	static Scanner scanner;

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

	    int n=gi();
	    //int r=gi();
	    //int c=gi();

	    //System.out.print(String.valueOf(c));

        if (n%2==0) {
        	System.out.print(n/2);
        }else {
        	System.out.print((n+1)/2);
        }


	}
	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35616
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using VI = vector<int>;
using VVI = vector<VI>;

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int a, b; cin >> a >> b;
  if (a * b == 15) {
    cout << "*" << '\n'; 
  } else if (a + b == 15) {
    cout << "+" << '\n';
  } else {
    cout << "x" << '\n';
  }
  return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main(){
	var n,m,temp int
	fmt.Scan(&n,&m)
	for i:=0; i<m; i++ {
		fmt.Scan(&temp)
		n -= temp
	}
	if 0 <= n {
		fmt.Println(n)
	} else {
		fmt.Println("-1")
	}
}


Measured memory_bytes: 2356
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;//T

Node treeMinimum(Node x){
  while(x->left != NIL){
    x = x->left;
  }
  return x;
}

Node treeSearch(Node u, int k){
  while((u != NIL) && (k != u->key)){
    if (k < u->key){
    u = u->left;
    } 
    else u = u->right;
  }
  return u;
}

Node treeSuccessor(Node x){
  Node y;

  if(x->right != NIL)
    return treeMinimum(x->right);
  y = x->parent;

  while(y != NIL && x == y->right){
    x = y;
    y = y->parent;
  }
  return y;
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y

  if(z->left == NIL || z->right ==NIL)
    y = z;
  else y = treeSuccessor(z);

  if(y->left != NIL)
    x = y->left;
  else x = y->right;

  if(x != NIL)
    x->parent = y->parent;
  if(y->parent == NIL)
    root = x;
  else if(y == y->parent->left)
    y->parent->left = x;
  else y->parent->right = x;

  if(y != z)
    z->key = y->key;
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
  
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  
  /*場所を探している*/
  while(x != NIL){
    y = x;
    if (z->key < x->key)
    x = x->left;
    else x = x->right;
  }
  z->parent = y;
  if (y == NIL)
  root = z;
  else if(z->key < y->key)
    y->left = z;
  else y->right = z;
}

void inorder(Node u){
  if(u != NIL) {
    if(u->left != NIL) inorder(u->left);
    printf(" %d",u->key);
    if(u->right != NIL) inorder(u->right);
  }
}
void preorder(Node u){ 
  if(u != NIL) {
    printf(" %d",u->key);
    if(u->left != NIL) preorder(u->left);
    if(u->right != NIL) preorder(u->right);
  }
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}

Measured memory_bytes: 19364
#include <iostream>
#include <iomanip>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define POWER9 1000000000
#define MOD POWER9+7
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483647
#define INT_MAX 2147483647
#define LL_MIN (LL)-9223372036854775807
#define LL_MAX (LL)9223372036854775807
#define PI 3.14159265359
LL a[200000];
LL wa[200000];
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << setprecision(9);

	int N;
	cin >> N;
	
	cin >> a[0];
	wa[0] = a[0];
	for(int i=1; i<N; i++){
		cin >> a[i];
		wa[i] = wa[i-1] + a[i];
	}
	LL ans = LL_MAX;
	for(int i=0; i<N-1; i++){
		ans = min(ans, abs(wa[N-1]-2*wa[i]));
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3328
import numpy as np

A = np.zeros((3,3),int)
for i in range(3):
    A[i,:] = np.array([int(x) for x in input().split()])
    
N = int(input())

for _ in range(N):
    b = int(input())
    A[A==b] = 0

ans = 'No'
if np.sum(A[0,:])==0 or np.sum(A[1,:])==0 or np.sum(A[2,:])==0 or np.sum(A[:,0])==0 or np.sum(A[:,1])==0 or np.sum(A[:,2])==0 or np.sum(A[0,0]+A[1,1]+A[2,2])==0 or np.sum(A[0,2]+A[1,1]+A[2,0])==0:
   ans = 'Yes'

print(ans)


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

int main()
{
	int top;
	int a, b, c;
	int N;

	cin >> N;

	for (int i = 0; i < N; i++){

		cin >> a >> b >> c;

		if (a > b)
			top = a;
		else top = b;

		if (c > top)
			top = c;

		if (top == a){
			if ((a * a) == ((b * b) + (c * c)))
				cout << "YES" << endl;
			else cout << "NO" << endl;
		}
		else if (top == b){
			if ((b * b) == ((a * a) + (c * c)))
				cout << "YES" << endl;
			else cout << "NO" << endl;
		}
		else {
			if ((c * c) == ((b * b) + (a * a)))
				cout << "YES" << endl;
			else cout << "NO" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1156