akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF 1001001000000
#define MOD 1000000007
#define ALL(x) begin(x),end(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> vii;
typedef vector<ll> vll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}
struct edge{ ll to, cost; };
ll n, q, k, a[100005], b[100005], c[100005], d[100005];
vector<edge> g[100005];

void dfs(int p, int q, ll dist) {
  d[p] = dist;
  rep(i, 0, g[p].size()) {
    edge e = g[p][i];
    if (e.to == q) continue;
    dfs(e.to, p, e.cost + dist);
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> n;
    rep(i, 0, n-1) {
      cin >> a[i] >> b[i] >> c[i];
      a[i]--, b[i]--;
      g[a[i]].pb({b[i], c[i]});
      g[b[i]].pb({a[i], c[i]});
    }
    cin >> q >> k;
    k--;
    dfs(k, -1, 0);
    rep(i, 0, q) {
      int x, y;
      cin >> x >> y;
      x--, y--;
      cout << d[x] + d[y] << endl;
    }
    return 0;
}




Measured memory_bytes: 18176
import java.util.Scanner;

class Node{
	int parent = -1;
	String type = "";
	int left = -1;
	int right = - 1;
} 

public class Main {
	
	private static Scanner src;
	public static Node[] tree;
	public static void main(String[] args) {
		src = new Scanner(System.in);
		int n = src.nextInt();
		tree = new Node[n];
		for(int i = 0; i < n; i++) tree[i] = new Node(); 
		for(int i = 0; i < n; i++) {
			int id = src.nextInt(); 
			Integer lc = src.nextInt(), rc = src.nextInt();
				tree[id].left = lc;
				tree[id].right = rc;
				if(lc != -1) tree[lc].parent = id;
				if(rc != -1) tree[rc].parent = id;
		}
		for(int i = 0; i < n; i++) {
			if(tree[i].parent == -1) {
				treeWalk(i);
				break;
			}
		}
	}
	private static void treeWalk(int root) {
		System.out.println("Preorder");
		preorder(root); System.out.println();
		System.out.println("Inorder");
		inorder(root); System.out.println();
		System.out.println("Postorder");
		postorder(root); System.out.println();
	}
	private static void postorder(int root) {
		if(tree[root].left != -1) postorder(tree[root].left);
		if(tree[root].right != -1) postorder(tree[root].right);
		System.out.print(" " + root);
	}
	private static void inorder(int root) {
		if(tree[root].left != -1) inorder(tree[root].left);
		System.out.print(" " + root);
		if(tree[root].right != -1) inorder(tree[root].right);
	}
	private static void preorder(int root) {
		System.out.print(" " + root);
		if(tree[root].left != -1) preorder(tree[root].left);
		if(tree[root].right != -1) preorder(tree[root].right);
	}
}



Measured memory_bytes: 26192
#include <iostream>

using namespace std;

int n;
int a[5000];
int rate[9];

int rateToIndex(int x) {
  if (x < 400) {
    return 0;
  } else if (x < 800) {
    return 1;
  } else if (x < 1200) {
    return 2;
  } else if (x < 1600) {
    return 3;
  } else if (x < 2000) {
    return 4;
  } else if (x < 2400) {
    return 5;
  } else if (x < 2800) {
    return 6;
  } else if (x < 3200) {
    return 7;
  } else {
    return 8;
  }
}

void solve() {
  for (int i=0;i<n;i++) {
    rate[rateToIndex(a[i])]++;
  }
  int cnt = 0;
  for (int i=0;i<8;i++) {
    cnt += (rate[i] > 0);
  }
  cout << max(1, cnt) << " " << cnt + rate[8] << endl;
}

int main() {
  cin >> n;
  for (int i=0;i<n;i++) {
    cin >> a[i];
  }
  solve();
}


Measured memory_bytes: 256
from functools import reduce
from operator import xor

A, B = map(int,input().split())


def calc(A):
    A = A+1
    cnt = 0
    ans = 0
    for i in range(0,50):
        # i=0 2回周期で1が出現
        # i=1 4回周期で1が出現
        loop = pow(2,i+1)

        #端数を覗いた2の出現回数
        #Aが6 / iが1のときは loop=4
        # 7//4 = 1 * 2^1 = 2
        cnt = (A//loop)*pow(2,i)

        # 端数を計算
        # 7%4 - 4/2 = 3-2 = 1
        # 端数は1なので加算
        if((A%loop - loop//2) > 0):
            cnt = cnt + (A%loop - loop//2)

        # cntが奇数の場合は ans 2^iをに加算
        if(cnt%2 == 1):
            ans = ans + pow(2,i)

    return ans



def main():
    return calc(A-1)^calc(B)

print(main())


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

typedef long long int ll;
const int maxn = 1e5 + 10;
int de[maxn],win[maxn];
ll h[maxn];
void solved(){
	int n,m;cin>>n>>m;
	for(int i = 1; i <= n; i++)cin>>h[i];
	for(int i = 1; i <= m; i++){
		int a,b;cin>>a>>b;
		de[a]++;de[b]++;
		if(h[a] == h[b])continue;
		win[h[a] > h[b] ? a : b]++;
	}
	int cnt = 0;
	for(int i = 1; i <= n; i++){
		if(de[i] == 0)cnt++;
		else if(de[i] == win[i])cnt++;
	}
	cout<<cnt<<endl;
}
int main(){
	solved();
	return 0;
} 

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

int main(){
  string s;
  cin >> s;
  sort(s.begin(), s.end());
  if(s.at(1)!=s.at(2)){
  	if(s.at(0)==s.at(1) && s.at(2)==s.at(3)){
    	cout << "Yes";
    }else{
    	cout << "No";
    }
  }else{
  	cout << "No";
  }
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main {

	int INF = 1 << 28;

	void run() {
		Scanner sc = new Scanner(System.in);
		for(;;) {
			int res = sc.nextInt();
			if( res == 0 ) break;
			for(int i=0;i<9;i++) {
				res -= sc.nextInt();
			}
			System.out.println(res);
		}
	}

	public static void main(String[] args) {
		try{
			System.setIn(new FileInputStream("A.in"));
			System.setOut(new PrintStream(new FileOutputStream("A.out")));
			}catch(Exception e){
//			System.err.println("Using standard input output.");
			}
			// System.setOut(new PrintStream(new BufferedOutputStream(System.out
			
			new Main().run();
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}
}

Measured memory_bytes: 12000
while True:
    n = int(input())
    if n == 0:
        break
    s = list(map(int, input().split()))
    m = sum(s)/n
    a2 = 0.0
    for i in range(n):
        a2 += (s[i] - m)**2
    a = (a2/n)**0.5
    print(a)

Measured memory_bytes: 7740
//Nihal Mittal - nihal_47
//Strike First , Strike Hard , No Mercy !!

/**⠀⠀⠀⠀⠀⠀⣀⣤⣤⣄⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⣠⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⣀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣰⣿⣿⣿⣿⠿⠿⣿⣿⣿⣿⣿⣿⣿⣧⢀⠀⠀⠀⠀
⠀⠀⠀⣿⣿⣿⠋⠀⠀⠀⠀⠀⠙⠀⠙⣿⣿⣿⣷⢳⢀⠀⠀⠀
⠀⠀⣠⣿⣿⣿⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⢀
⠀⠀⣸⣿⣿⣿⠸⠀⠀⠀⠒⠒⠒⠐⠀⠀⢿⣿⣿⣿⣿⣿⠀⠀
⠀⣴⣿⣿⣿⡿⠀⠒⣋⣙⡒⢰⠀⠤⣖⠒⢾⣿⣿⣿⣿⣧⠀⠀
⢺⣿⣿⣿⣿⢀⠀⠀⠉⠉⠉⠸⠀⡇⠉⠉⠀⢿⣿⣿⣿⣄⠀⠀
⠀⠙⣿⣿⣧⢻⠀⠀⠀⠀⠀⠠⠀⠰⠀⠀⠀⣸⠸⣿⣿⠿⠰⠀
⠀⠀⠀⠹⣿⣿⣿⣷⠀⡠⠙⣲⣔⣅⢡⣰⣷⣿⣿⣿⣧⠀⠀⠀
⠀⠀⠀⣼⣿⣿⣿⣿⠀⡿⠭⠭⠭⠭⢿⠀⣿⢻⣿⣿⠃⠀⠀⠀
⠀⠀⠀⠙⠛⣿⢻⠹⣿⠐⠙⠛⠟⠉⢀⣴⡟⢿⣿⡏⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⡟⠀⠀⠻⣦⣤⣶⠾⠋⠀⠀⠁⡦⢄⢀⠀⠀⠀
⠀⠀⠀⠀⡠⠁⡇⠑⢄⠀⠀⠀⠀⠀⠀⠔⠀⠀⠁⠀⠀⠀⠉⠁
⠀⠔⠊⠁⠀⠀⣇⠀⠀⠀⠑⡤⠤⢎⠁⠀⠀⡘⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⢢⠠⠀⡠⢆⠀⠀⡠⠙⢄⠀⡸⠀
**/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define mk make_pair
#define pb push_back
#define in insert
#define se second
#define fi first
#define mod 1000000007
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define all(v) (v).begin(),(v).end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
#define pii pair<ll,ll>
#define vi(x) vector<x>
#define maxn 100005
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
using namespace std;
using namespace __gnu_pbds;
struct datu
{
	ll a,b,c,d;
};
ll q,ans;
datu br[100];
void solve(ll n, ll k, ll &len, ll arr[]) 
{ 

    if (len == k) 
    { 
    	ll score=0;
        for(ll j=0;j<q;j++)
        {
        	if((arr[br[j].b-1] - arr[br[j].a-1])==br[j].c) score += br[j].d;
        }
        ans = max(ans,score);
        return; 
    } 
    ll i = (len == 0)? 1 : arr[len-1]; 
  
    len++; 
  
    while (i<=n) 
    { 
        arr[len-1] = i; 
        solve(n, k, len, arr); 
        i++; 
    } 
    len--; 
} 
signed main()
{
    fast;
  
    ll n,m,i;
    cin>>n>>m>>q;
    for(i=0;i<q;i++)
    {
    	cin>>br[i].a>>br[i].b>>br[i].c>>br[i].d;
    }
    ll arr[n+2],le=0;
    solve(m,n,le,arr);
    cout<<ans;

}

Measured memory_bytes: 3652
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        int x=sc.nextInt();
        int n=0;
        if(400<=x&&x<=599){n=8;}
        if(600<=x&&x<=799){n=7;}
        if(800<=x&&x<=999){n=6;}
        if(1000<=x&&x<=1199){n=5;}
        if(1200<=x&&x<=1399){n=4;}
        if(1400<=x&&x<=1599){n=3;}
        if(1600<=x&&x<=1799){n=2;}
        if(1800<=x&&x<=1999){n=1;}
        System.out.println(""+n);
        }
}

Measured memory_bytes: 38660
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(N: int):
    n = str(N)
    if "7" in n:
        print(YES)
    else:
        print(NO)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9176
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		int a = cin.nextInt();
		int b = cin.nextInt();
		if(a<b) {
			System.out.println("a < b");
		}else if(a>b) {
			System.out.println("a > b");
		}else {
			System.out.println("a == b");
		}
	}
}


Measured memory_bytes: 26348
#include<bits/stdc++.h>
#define watch(x) cout<<(#x)<<" is "<<(x)<<endl
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define pb push_back
#define pq priority_queue
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define elif else if

using namespace std;
using ll=long long;
using ull=unsigned long long;
using ld=long double;
using pll=pair<ll,ll>;
using pss=pair<string,string>;
using pdd=pair<ld,ld>;
using graph=vector<vector<int>>;
using wgraph=vector<vector<pll>>;

const ll MOD=1000000007;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int ex[8]={1,1,0,-1,-1,-1,0,1};
const int ey[8]={0,1,1,1,0,-1,-1,-1};
const ld E=1e-9;

template<class T> void chmin(T &a, T b){a=min(a, b);}
template<class T> void chmax(T &a, T b){a=max(a, b);}

ll abs1(ll a){if(a>=0)return a;else return -a;}
ll pow1(ll a,ll b,ll p=LLONG_MAX){
  ll ret=1;
  while(b!=0){
    if((b&1)==1)ret*=a;a*=a;
    if(a>=p)a%=p;if(ret>=p)ret%=p;
    b=b>>1;
  }
  return ret;
}
int digit(ll a,ll b=10){int i=0;while(a!=0){a/=b;i++;}return i;}
ll gcd1(ll a,ll b){
  if(a==0 || b==0)return 0;
  ll n;while(a%b!=0){n=a%b;a=b;b=n;}return b;
}
ll solveLinear(ll n,ll m,ll c){
  if(n==0 && m==0)return 0;
  ll a[100],b[100];a[0]=n;b[0]=m;int i=1;
  while(b[i-1]!=0){a[i]=b[i-1];b[i]=a[i-1]%b[i-1];i++;}
  n=i;if(c%a[n-1]!=0)return 0;
  ll x=c/a[n-1],y=0;
  for(i=1;i<n;i++){ll cnt=x;x=y;y=cnt-(a[n-i-1]/b[n-i-1])*y;}
  return x;
}
ll modInv(ll a,ll p=MOD){
  a%=p;ll n=solveLinear(a,p,1);
  n%=p;if(n<0)return n+p;
  return n;
}
ll fact(ll n,ll p=MOD){
  if(n<0)return 0;
  ll ret=1;for(int i=1;i<=n;i++){ret=ret*i;if(ret>=p)ret%=p;}
  return ret;
}
ll perm(ll n,ll k,ll p=MOD){
  if(n<0 || k<0 || n<k)return 0;
  ll ret=1;rep(i,k){ret=ret*(n-i);if(ret>=p)ret%=p;}
  return ret;
}
ll binom(ll n,ll k,ll p=MOD){
  return (perm(n,k,p)*modInv(fact(k)))%p;
}
int bis(vector<int> v,int key){
  int left=-1,right=v.size();
  while(abs1(right-left)>1){
    int mid=left+(right-left)/2;
    if(v[mid]<=key)left=mid;
    else right=mid;
  }
  return left;
}

int main(){
  ll i,j,cnt=0;
  int h,w;
  cin>>h>>w;
  char s[h][w];
  rep(i,h){
      rep(j,w){
          cin>>s[i][j];
      }
  }
  bool seen[h][w];
  ll dist[h][w];
  queue<pll> q;
  ll ans=0;
  for(i=0;i<h;i++){
      for(j=0;j<w;j++){
        if(s[i][j]=='#')continue;
        rep(i,h){
            rep(j,w){
                seen[i][j]=0;
                dist[i][j]=INT_MAX;
            }
        }
        q.push({i,j});

        dist[i][j]=0;
        while(!q.empty()){
            int x=q.front().fi,y=q.front().se;
            q.pop();
            for(int i=0;i<4;i++){
                int nx=x+dx[i],ny=y+dy[i];
                if(nx<0 || nx>=h || ny<0 || ny>=w)continue;
                if(s[nx][ny]=='#')continue;
                if(seen[nx][ny])continue;
                if(dist[nx][ny]<=dist[x][y]+1)continue;
                dist[nx][ny]=dist[x][y]+1;
                q.push({nx,ny});

            }
        }
        rep(i,h){
            rep(j,w){
                if(s[i][j]=='#')continue;
                chmax(ans,dist[i][j]);
            }
        }
      }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
d = []
a = []
for _ in range(k):
    d.append(int(input()))
    a.append(list(map(int, input().split())))

bu = [0 for i in range(n)]
for a_ in a:
    for _ in a_:
        bu[_-1]+=1

s = 0
for i in range(n):
    if bu[i]==0:
        s+=1
print(s)

Measured memory_bytes: 9192
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    //https://atcoder.jp/contests/abc141/tasks/abc141_a
    public class QuestionA
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            //// 文字列の入力
            //string s = Console.ReadLine();

            //// 整数の入力
            //long n = long.Parse(Console.ReadLine());

            //// 文字列配列の入力
            //string[] inputStrArray = Console.ReadLine().Split(' ');

            //// 整数配列の入力
            //var inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

            var inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

            long r = inputLongArray[0];
            long g = inputLongArray[1];
            long b = inputLongArray[2];

            string result = "";

            var sum = r * 100 + g * 10 + b;

            if (sum % 4 == 0) {
                result = "YES";
            } else {
                result = "NO";
            }

            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 11348
#include <iostream>
#include <numeric>
#include <vector>

void solve() {
    int n, m;
    std::cin >> n >> m;

    std::vector<int> xs(n);
    for (auto& x : xs) std::cin >> x;
    int s = std::accumulate(xs.begin(), xs.end(), 0);

    int cnt = 0;
    for (auto x : xs) {
        if (x * m * 4 >= s) ++cnt;
    }

    std::cout << (cnt >= m ? "Yes" : "No") << std::endl;
}

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

    solve();

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=500000004;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
long long p[110];
int main(){
	int a;scanf("%d",&a);
	p[0]=2;
	p[1]=1;
	for(int i=2;i<=a;i++){
		p[i]=p[i-1]+p[i-2];
	}
	printf("%lld\n",p[a]);
}

Measured memory_bytes: 128
D, G = map(int, input().split())
P = [list(map(int, input().split())) for _ in range(D)]

res = 1000
for i in range(2**D):
    pts = 0
    num = 0
    hzero = False
    zd = -1
    for j in range(D):
        if (i >> j) & 1:
            pts += P[D-j-1][0]*(D-j)*100+P[D-j-1][1]
            num += P[D-j-1][0]
        else:
            if not hzero:
                zd = D-j-1
                hzero = True

    if pts >= G:
        res = min(res, num)
    else:
        if hzero:
            for j in range(1, P[zd][0]):
                pts += 100*(zd+1)
                num += 1
                if pts >= G:
                    res = min(res, num)
                    break

print(res)

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;

namespace ABC137
{
    class Program3
    {
        static void Main()
        {
            var N = int.Parse(Console.ReadLine());
            var s = new string[N];
            for (int i = 0; i < N; i++)
            {
                s[i] = Console.ReadLine();
            }

            var dic = new Dictionary<string, int>();
            foreach (var item in s)
            {
                var c = item.ToCharArray();
                Array.Sort(c);
                var ss = new string(c);
                if (dic.ContainsKey(ss))
                {
                    dic[ss]++;
                }
                else
                {
                    dic.Add(ss, 1);
                }
            }

            var ans = 0L;
            foreach (var i in dic)
            {
                if (i.Value <= 1)
                    continue;

                ans += (long)i.Value * ((long)i.Value - 1) / 2;
            }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 33236
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#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 mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  int n;
  while(cin>>n,n){
    vector<int>in(n);
    rep(i,n)cin>>in[i];
    int t=0,l=n-1;
    int co=0;
    int out;
    cin>>out;
    while(t<=l){
      int tmp=(t+l)/2;
      //tmp=in[tmp];
      co++;
      if(in[tmp]==out)break;
      if(in[tmp]<out)t=tmp+1;
      if(in[tmp]>out)l=tmp-1;
    }
    cout<<co<<endl;
  }

}

Measured memory_bytes: 1192
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;

const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll LINF = 1e18;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const int ddy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

int gcd(int a, int b) {
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

int lcm(int a, int b) { return a * b * gcd(a, b); }

bool compareP(pair<int, int> a, pair<int, int> b) {
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

int main() {
    int m1, d1, m2, d2;
    cin >> m1 >> d1 >> m2 >> d2;
    if (m1 == m2)
        cout << 0 << endl;
    else
        cout << 1 << endl;
}

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

int main()
{
    const int MAX = 20000;
    int a, b, res;
    char op;
    bool none;

    while (1) {   
        cin >> a >> op >> b;
        if (op == '?') break;

        none = false;

        if ((a >= 0 && a <= MAX) && (b >= 0 && b <= MAX)) {
            switch (op) {
            case '+': res = a + b; break;
            case '-': res = a - b; break;
            case '*': res = a * b; break;
            case '/': 
                if (b > 0) {
                    res = a / b;
                } else {
                    none = true;
                }
                break;
            default: none = true;
            }
            if (!none) cout << res << endl;
        }
    }
}


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

int main () {
  int N, D, X;
  cin >> N >> D >> X;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  int ans = X;
  for (int i = 0; i < N; i++) {
    ans += ((D-1)/A.at(i)+1);
  }
  cout << ans << endl;
}

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

using namespace std;

typedef long long ll;

const double pi = 3.14159265358979323846;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define MOD 1000000007LL
#define PS(p) cout << setprecision(15) << fixed << p << endl;
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
#define ALL(c) c.begin(), c.end()
#define CIN(v) cin >> v;
#define COUT(v) cout << v << "\n";

#define TG0 get< 0 >
#define TG1 get< 1 >
#define TG2 get< 2 >

#define HONEST '1'
#define UNKIND '2'

int N;
ll honest;

vector< tuple< ll, ll > > XY[15];

bool check(string s, ll honest) {
  ll x, y;

  for (ll i = 0; i < N; i++) {
    if (s[i] == HONEST) {
      auto v = XY[i];

      for (auto t : v) {
        x = TG0(t);
        y = TG1(t);

        if (s[x] != y) {
          return false;
        }
      }
    }
  }

  return true;
}

void dfs(ll len, string s, ll c_honest) {
  if (len == N) {
    if (check(s, c_honest)) {
      honest = max(honest, c_honest);
    }
    return;
  }

  dfs(len + 1, s + UNKIND, c_honest);
  dfs(len + 1, s + HONEST, c_honest + 1);
}

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

  CIN(N);

  ll j;
  ll x, y;
  for (int i = 0; i < N; i++) {
    cin >> j;

    for (ll k = 0; k < j; k++) {
      cin >> x >> y;

      XY[i].push_back(make_tuple(x - 1, y == 1 ? HONEST : UNKIND));
    }
  }

  dfs(0, "", 0);

  cout << honest << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
//
//    #pragma GCC optimize("unroll-loops")
//    #pragma GCC optimize("Ofast")
//    #pragma GCC optimize("-O3")
//    #pragma GCC optimize("no-stacnice_task-protector")
//    #pragma GCC optimize("fast-math")

#define fi first
#define f first
#define se second
#define s second
#define vi_a vector<int>a;
#define p_b emplace_back
////////////////////////////////???????????????CHECnice_task THIS OUT???????????????//////////////////////////////
#define ll long long
////////////////////////////////???????????????CHECnice_task THIS OUT???????????????//////////////////////////////
#define ld long double
#define pll pair<ll,ll>
#define pii pair<int,int>
#define m_p make_pair
#define fast_io cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
#define all(x) x.begin(),x.end()
#define getfiles    ifstream cin("input.txt");ofstream cout("output.txt");
#define pw(x) (1ll << x)
#define sz(x) (ll)x.size()
#define endl "\n"
#define rall(x) x.rbegin(),x.rend()
#define len(a) (ll)a.size()
#define rep(x,l,r) for(ll x=l;x<r;x++)
using namespace std;
//using namespace __gnu_pbds;
ld eps = (ld)1 / 1e6;
ll inf = 1e9, mod2 = 998244353, mod1 = 1e9 + 7;
ll sqr(ll a) { return a * a; }
ll binpow(ll a, ll b, ll mod) { return b ? (b % 2 ? (a * (sqr(binpow(a, b / 2, mod)) % mod)) % mod : sqr(binpow(a, b / 2, mod)) % mod) : 1; }
ll binmult(ll a, ll b, ll mod) { return b ? (b % 2 ? (2 * binmult(a, b / 2, mod) + a) % mod : (2 * binmult(a, b / 2, mod)) % mod) : 0; }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
const ll R=1e4;
const ll tx[4]={0,0,1,-1};
const ll ty[4]={1,-1,0,0};
const char rev_to[4]={'E','W','N','S'};
//const ll N
signed main(){
    fast_io;
    ll n;
    cin>>n;
    map<string,bool>mp;
    string s;
    for(ll i=0;i<n;i++){cin>>s;mp[s]=1;}
    cout<<sz(mp);
    return 0;
}
/*
    если WA , то чекер говно, поэтому почекай 18 строчку
    чекай для t>1 (выводишь ли ты  с endl))
*/


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

int main(){
    int N,W[110],S=0,S1=0,S2,dS,min=100000;
    cin>>N;
    for(int i=0;i<N;++i){
        cin>>W[i];
        S+=W[i];
    }

    for(int i=0;i<N-1;++i){
        S1+=W[i];
        S2=S-S1;
        dS=abs(S1-S2);
        if(dS<min)min=dS;

    }

    cout<<min<<endl;
    return 0;

}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#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(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<double,int,double> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf=sizeof(Def)==sizeof(long long)?2e18:1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int MOD;
int main(){
	int n,m;
	while(cin>>n>>m,n){
		vvi in;
		int a=0,b=0,c=0;
		rep(i,n+m){
			string s;
			cin>>s;
			int t=0,d=0;
			while(t<s.size()&&s[t]=='.')t++;
			in.pb(vi{t,a,b,c});
			while(t<s.size()){
				if(s[t]=='(')a++;
				if(s[t]==')')a--;
				if(s[t]=='{')b++;
				if(s[t]=='}')b--;
				if(s[t]=='[')c++;
				if(s[t]==']')c--;
				t++;
			}
		}
//		rep(i,n+m){rep(j,4)cout<<" "<<in[i][j];cout<<endl;}
		vector<set<int> >out(m);
		loop(i,1,21)loop(j,1,21)loop(k,1,21){
			bool h=true;
			rep(x,n)if(i*in[x][1]+j*in[x][2]+k*in[x][3]!=in[x][0])h=false;
			if(h)rep(x,m)out[x].insert(i*in[n+x][1]+j*in[n+x][2]+k*in[n+x][3]);
		}
		rep(i,m){
			if(i)cout<<" ";
			if(out[i].size()==1)cout<<*(out[i].begin());
			else cout<<-1;
		}
		cout<<endl;
	}
}

Measured memory_bytes: 3164
<?php
$S = trim(fgets(STDIN));
$pattern = '/(.).?\1/';

preg_match($pattern, $S, $matches, PREG_OFFSET_CAPTURE);

if(!isset($matches[0])){
    echo('-1 -1');
}else {
    echo ($matches[0][1] + 1) . ' ' . ($matches[0][1] + strlen($matches[0][0]));
}

Measured memory_bytes: 3064
// clang-format off
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
// clang-format on

template <int mod>
struct ModInt {
    int x;

    ModInt() : x(0) {}
    ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

    ModInt &operator+=(const ModInt &p) {
        if ((x += p.x) >= mod) x -= mod;
        return *this;
    }
    ModInt &operator-=(const ModInt &p) {
        if ((x += mod - p.x) >= mod) x -= mod;
        return *this;
    }
    ModInt &operator*=(const ModInt &p) {
        x = (int)(1LL * x * p.x % mod);
        return *this;
    }
    ModInt &operator/=(const ModInt &p) {
        *this *= p.inverse();
        return *this;
    }

    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }

    ModInt inverse() const {
        int a = x, b = mod, u = 1, v = 0, t;
        while (b > 0) {
            t = a / b;
            swap(a -= t * b, b);
            swap(u -= t * v, v);
        }
        return ModInt(u);
    }

    ModInt pow(int64_t n) const {
        ModInt ret(1), mul(x);
        while (n > 0) {
            if (n & 1) ret *= mul;
            mul *= mul;
            n >>= 1;
        }
        return ret;
    }

    friend ostream &operator<<(ostream &os, const ModInt &p) {
        return os << p.x;
    }

    friend istream &operator>>(istream &is, ModInt &a) {
        int64_t t;
        is >> t;
        a = ModInt<mod>(t);
        return (is);
    }

    static int get_mod() { return mod; }
};

const int mod = 1e9 + 7;
using mint = ModInt<mod>;

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

    vector<mint> dp(k + 1);
    mint ans = 0;
    for (int i = k; i > 0; --i) {
        dp[i] = mint(k / i).pow(n);
        for (int j = 2 * i; j <= k; j += i) dp[i] -= dp[j];

        ans += dp[i] * i;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3796
#include<bits/stdc++.h>
using namespace std;
int main()
{
    map<char,int>mp;
    string s ;
    cin >> s ;
    int n = s.length();
    for(int i = 0 ; i < n ; i++)
        mp[s[i]]++;
    for(char i = 'a'; i<='z'; i++)
    {
        if(!mp[i])
        {
            cout << i << '\n';
            return 0 ;
        }
    }
    puts("None");
}


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

const string YES = "Yes";
const string NO = "No";
long long sum=0;
void solve(long long H, long long N, std::vector<long long> A)
{
    if(H<=sum)
        cout<<YES<<endl;
    else
        cout<<NO<<endl;
}

int main()
{
    long long H;
    scanf("%lld",&H);
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]),sum+=A[i];
    }
    solve(H, N, std::move(A));
    return 0;
}


Measured memory_bytes: 1024
def resolve():
    N = int(input())
    T, A = [int(i) for i in input().split()]
    H = [int(i) for i in input().split()]
    absList = []
    for i in range(N):
        absList.append((abs(A - (T - (H[i] * 0.006))), i))
    print(min(absList)[1] + 1)


resolve()


Measured memory_bytes: 9156
fun main(args: Array<String>) {
    val a = readLine()!!.split(" ").map { it.toInt() }.first()
    val s = readLine()!!
    
    println(if (s.isPostalCode(a)) "Yes" else "No")
}

fun String.isPostalCode(pre: Int): Boolean =
        this[pre] == '-' &&
                this.subSequence(0, pre).all(isNumber) &&
                this.subSequence(pre + 1, this.length).all(isNumber)

val isNumber: (Char) -> Boolean = { it in '0'..'9' }


Measured memory_bytes: 37644
import java.util.*;

public class Main {

	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		int e = sc.nextInt();
		int f = sc.nextInt();
		double max = -1;
		int maxAll = 0;
		int maxSugar = 0;
		for (int ax = 0; ax * a * 100 <= f; ax++) {
			for (int bx = 0; ax * a * 100 + bx * b * 100 <= f; bx++) {
				for (int cx = 0; ax * a * 100 + bx * b * 100 + cx * c <= f; cx++) {
					for (int dx = 0; ax * a * 100 + bx * b * 100 + cx * c + dx * d <= f; dx++) {
						if ((ax * a + bx * b) * e < cx * c + dx * d) {
							continue;
						}
						double v = (double)(cx * c + dx * d) / (double)(ax * a * 100 + bx * b * 100 + cx * c + dx * d);
						if (max < v) {
							max = v;
							maxAll = ax * a * 100 + bx * b * 100 + cx * c + dx * d;
							maxSugar = cx * c + dx * d;
						}
					}
				}
			}
		}
		System.out.println(maxAll + " " + maxSugar);
	}
}


Measured memory_bytes: 23252
#include<stdio.h>

int main(){

    int i,j;
    int n,m;
    int ctr;
    int counter = 0;
    int tmp;

    //----input----
    scanf("%d %d", &n, &m);

    //----mainFunction----
    tmp = n*(n-1) + m*(m-1);
    counter = tmp / 2;

    //----output----
    
    printf("%d\n", counter);

    return 0;

}

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

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;
int n,a[3003],dp[3003][3003][2];
int sol(int l,int r,int f){
    if(l>r) return 0;
    if(dp[l][r][f]!=-1) return dp[l][r][f];
    int &ans=dp[l][r][f];
    if(f==0) return ans=max(sol(l+1,r,!f)+a[l],sol(l,r-1,!f)+a[r]);
    else return ans=min(sol(l+1,r,!f)-a[l],sol(l,r-1,!f)-a[r]);
}
void solve(){
    cin>>n;
    rep(i,1,n+1) cin>>a[i];
    memset(dp,-1,sizeof dp);
    cout<<sol(1,n,0)<<endl;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 141312
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e9+5;
const int mod = 998244353;

vector<int> fac(300001); //n!(mod M)
vector<int> ifac(300001); //k!^{M-2} (mod M)

long long fpow(long long a,long long n){
  long long ret=1;
  if(n==1) return a;
  if(n%2==0) {
      ret = fpow(a*a%mod, n/2) %mod ;
  }else {
      ret = (a%mod)*fpow(a*a%mod, n/2) %mod;
  }
  return ret %mod;
}
int comb(int a, int b){ //aCbをmod計算
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    int tmp = ifac[a-b]* ifac[b] % mod;
    return tmp * fac[a] % mod;
}
const double PI=3.14159265358979323846;
int dp[3002][3002];
signed main(){
    int a, b,h, m;
    cin >> a >> b >> h >> m;
    
    double hour = PI*2.0/12.0*h+ PI*2.0/12.0*m/60.0;
    double minute = PI*2.0/60.0*m;
    double kaku = fmin(abs(hour-minute), abs(2.0*PI-(hour-minute)));
    
    double ans = a*a + b*b - 2.0*cos(kaku)*a*b;

    cout << setprecision(15) << sqrt(ans) << endl;
    return 0;
}



Measured memory_bytes: 7864
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		for(int i=0;i<n;i++){
			String str=sc.next();
			String a,b;
			ArrayList<String> list = new ArrayList<String>();
			for(int j=0;j<str.length()-1;j++){
				a=str.substring(0,j+1);
				b=str.substring(j+1);
				StringBuilder rev_a=new StringBuilder(a);
				StringBuilder rev_b=new StringBuilder(b);
				String r_a=new String(rev_a.reverse());
				String r_b=new String(rev_b.reverse());

				list.add(a+b);
				list.add(r_a+b);
				list.add(a+r_b);
				list.add(r_a+r_b);
				list.add(b+a);
				list.add(r_b+a);
				list.add(b+r_a);
				list.add(r_b+r_a);
			}	
			Collections.sort(list);
			String tmp="";int ans=0;
			for (String string : list) {
				if(!string.equals(tmp)){
					ans++;
					tmp=string;
				}
				//System.out.println(string);
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 79024
#include<bits/stdc++.h>
#define  fuckit(){	\
	ios_base::sync_with_stdio(false); \
	cin.tie(NULL); \
}
using namespace std;
typedef long long ll;
int main()
{
	fuckit();
	ll n,x,i,cnt=0,t;
	cin>>n>>x;
	int ara[n];
	for(i=0;i<n;i++){
		cin>>ara[i];
	}
	for(i=0;i<n-1;i++){
		t=ara[i]+ara[i+1];
		if(t>x){
			t=t-x;
			cnt+=t;
			if(ara[i+1]<t){
				t-=ara[i+1];
				ara[i+1]=0;
			}
			else{
				ara[i+1]-=t;
			}
		}
	}
	cout<<cnt<<endl;
	return 0;	
}


Measured memory_bytes: 640
#include <bits/stdc++.h> 
#include <vector>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;
using Field=vector<vector<int>>;

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

int main(){
    int n,k;
    cin>>n>>k;
    string s;
    cin>>s;
    s[k-1]=s[k-1]+' ';
    cout<<s<<endl;
}

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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vi a(n + 1, 0);
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  vi b(n + 1, 0);
  for (int i = 1; i <= n; i++) {
    cin >> b[i];
  }
  vi c(n, 0);
  for (int i = 1; i <= n - 1; i++) {
    cin >> c[i];
  }
  int ans = 0;
  int prev = 0;
  for (int i = 1; i <= n; i++) {
    ans += b[a[i]];
    if (prev + 1 == a[i]) {
      ans += c[prev];
    }
    prev = a[i];
  }

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


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <regex>
#include <map>
#include <set>
#include <iomanip>

using namespace std;
#define int long long

signed main(){
    int N;
    cin >> N;
    
    cout << "ABC" << N << endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int main(){
    int x1,y1,x2,y2,dx,dy,a,b;
    cin >> x1 >> y1 >> x2 >> y2;
    dx = x2 - x1;
    dy = y2 - y1;
    a = x2 - dy;
    b = y2 + dx;
    cout << a << " " << b << " ";
    a = a - dx;
    b = b - dy;
    cout << a << " " << b << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    static long MOD = 1000000007;
    static long inv2 = 500000004;
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] array = new long[n];
        for (int i = 0; i < n; i++) {
            array[i] = sc.nextLong();
        }
        
        // ans: 数列の全ペア(i,j)の積の和
        // 言い換え:
        // ab ac ad bc bd cd
        // (a+b+c+d)^2 = a^2+...d^2 + 2(ab ac ad ... cd)
        // ans = ((a+b+c+d)^2 - (a^2+...d^2))/2 (inv2を掛ける)
        
        // parta: 総和の2乗
        long parta = 0;
        for (int i = 0; i < n; i++) {
            parta += array[i];
            parta %= MOD;
        }
        parta = (modpow(parta, 2)) % MOD;
        // System.out.println(parta);
        
        // partb: 各要素の2乗の和
        long partb = 0;
        for (int i = 0; i < n; i++) {
            partb += (modpow(array[i], 2)) % MOD;
            partb %= MOD;
        }
        // System.out.println(partb);
        
        long ans = parta - partb;
        if (ans < 0) ans += MOD;
        ans %= MOD;
        ans *= inv2;
        ans %= MOD;
        System.out.println(ans);
    }
    
    public static long modpow(long num, long n) {
        // ex. 3^10
        // 3^10 = 3^(0b1010)
        // = 3^8が1個 * 3^4が0個 * 3^2が1個 * 3^1が0個
        // (次の桁の値は(前の桁)^2になる)
        
        long res = 1;
        long digit = num;
        
        while (n > 0) {
            long lsb = n & 1;
            if (lsb == 1) {
                res *= digit;
                res %= MOD;
            }
            
            digit = digit * digit;
            digit %= MOD;
            n = n >> 1;
        }
        
        return res;
    }
}


Measured memory_bytes: 63092
#include<stdio.h>
int main(void)
    {
    int P,Q,R,a,b,c,Ans;
    scanf("%d%d%d",&P,&Q,&R);
    a=P+Q;
    b=Q+R;
    c=R+P;
    Ans=1000;
    if(a<Ans)
    {
        Ans=a;
    }
    if(b<Ans)
    {
        Ans=b;
    }
    if(c<Ans)
    {
        Ans=c;
    }
    printf("%d\n",Ans);
}        

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

int main(){
	int a[10];
	for(int i = 0; i < 10; i++){
		cin >> a[i];
	}
	sort(a, a+10, greater<int>());

	cout << a[0] << endl << a[1] << endl << a[2] << endl;
}

Measured memory_bytes: 1172
#include <bits/stdc++.h>
#define int long long int
using namespace std;
#define P pair<int,int>
signed main()
{
    int h,w,k;
    cin>>h>>w>>k;
    int x1,y1,x2,y2;
    cin>>x1>>y1>>x2>>y2;
    vector<vector<int>> dis(h+4,vector<int>(w+4,INT_MAX));

    vector<vector<char>> gra(h+4,vector<char>(w+4,'@'));

    for(int i=1;i<=h;i++)
    {
        for(int j=1;j<=w;j++)
        cin>>gra[i][j];
    }

    queue<P> Q;

    P s(x1,y1);

    Q.push(s);
    int x[4] = {0,1,0,-1};
    int y[4] = {1,0,-1,0};
    dis[x1][y1]=0;
    while(!Q.empty())
    {
        P top = Q.front();
        Q.pop();
        int xt = top.first;
        int yt = top.second;
        for(int i=0;i<=3;i++)
        {
            for(int j=1;j<=k;j++)
            {
                //cout<<xt + x[i]*j<<" "<<yt + y[i]*j<<endl;
                if(gra[xt + x[i]*j][yt + y[i]*j]=='@')
                break;
                else if(dis[xt + x[i]*j][yt + y[i]*j]<=dis[xt][yt])
                break;
                else if(dis[xt + x[i]*j][yt + y[i]*j]>dis[xt][yt]+1)
                {
                    dis[xt + x[i]*j][yt + y[i]*j] = dis[xt][yt]+1;
                    Q.push(make_pair(xt + x[i]*j,yt + y[i]*j));
                }
            }
        }
    }

    if(dis[x2][y2]==INT_MAX)
    cout<<-1;
    else
    cout<<dis[x2][y2];

    return 0;

    
}


Measured memory_bytes: 50148
#include<bits/stdc++.h>
using namespace std;
int counter,AKM;
int answer(int m,int n)
{
	int x,y;
	for(x=0;x<=m;x++)
    {
        for(y=0;y<=m;y++)
        {
        	AKM=n-x-y;
            if(AKM<=m && AKM>=0 ) counter++;
        }
    }
    return counter;
}
int main()
{
	int m,n;
    cin>>m>>n;
    cout<<answer(m,n)<<endl;
    return 0;
}
/*
草稿纸：
因为：
2 ≤ K ≤ 2500
0 ≤ S ≤ 3K 
如果
用O(N^3)的算法
3000的立方是27*10^9
计算机运行速度是10^8每秒
限制2秒会超时
所以
用O(N^2)的算法
3000的平方是9*10^6
好得多
*/ 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using ld = long double;
const ll ATCODER_AMARI = 1000000007; //10^9 + 7
const ll INF = 10000000000000;

//階乗関数　ATCODER_AMARIに注意
ll factorial(ll k){
  ll sum = 1;
  for(int i = 1 ; i < k + 1; i++) {
    sum *= i;
    //sum = sum % ATCODER_AMARI;
  }
  return sum;
}

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

  ll ans;

  ans = a + a * a + a * a * a;

  cout << ans << endl;
}


Measured memory_bytes: 3620
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
score = 0
for i in range(n):
    score += b[a[i] - 1]
    if i >= 1:
        if a[i] - a[i - 1] == 1:
            score += c[a[i - 1] - 1]
print(score)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

typedef long long ll;

#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define grt() greater<int>()
#define grtl() greater<long long>()

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

    ll ans = min(n, b - 1);

    std::cout << (a * ans) / b << endl;
}

Measured memory_bytes: 3596
// abc159_c
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    double L;
    cin >> L;

    double ans = (L/3) * (L/3) * (L - 2*L/3);
    print(ans);


    return 0;
}


Measured memory_bytes: 256
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;

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

		Set<String> set = new HashSet<>();
		Map<String, Integer> map = new HashMap<>();
		String[] s = new String[n];
		for (int i = 0; i < n; i++) {
			s[i] = sc.next();
			set.add(s[i]);
			map.put(s[i], 0);
		}

		for (int i = 0; i < n; i++) {
			int v = map.get(s[i]);
			map.put(s[i], ++v);
		}

		int max = 1;
		for (String key : map.keySet()) {
			if (map.get(key) > max) {
				max = map.get(key);
			}
		}

		Set<String> tSet = new TreeSet<>();
		for (String key : map.keySet()) {
			if (map.get(key) == max) {
				tSet.add(key);
			}
		}

		StringBuilder sb = new StringBuilder();
		for (String string : tSet) {
			sb.append(string);
			sb.append('\n');
		}

		System.out.println(sb.toString());
	}


}


Measured memory_bytes: 111904
#include<stdio.h>

static const int N = 1000;

void print(int *a, int n){
	int i;

	for(i = 0; i < n; i++){
		printf("%d", a[i]);
		if(i < n - 1)
			printf(" ");
	}
	puts("");

}

void sort(int *a, int n){
	int i, j, key;
	print(a, n);
	for(i = 1; i < n; i++){
		key = a[i];
		j = i - 1;

		while(a[j] > key  && j >= 0){
			a[j+1] = a[j];
			j--;
		}
		a[j+1] = key;
		print(a, n);
	}
}

int main(){
	int n, i;
	int A[N+1];

	scanf("%d", &n);

	for(i = 0; i < n; i++)
		scanf("%d", &A[i]);
	sort(A, n);
	return 0;

}

Measured memory_bytes: 620
#include<bits/stdc++.h>
using namespace std;
int main(){
long int A , B , C;
  long int K;
  cin>>A>>B>>C>>K;
  if(K<=A)cout<<K<<endl;
  else if(K<=A+B)cout<<A<<endl;
  else if(K<=A+B+C)cout<<A-(K-A-B)<<endl;
  else cout<<A-C<<endl;
}

Measured memory_bytes: 3520
a, b = map(int, input().split())

if a == b:
    print(a)
    exit()
cnt = b - a + 1
cnt -= (a % 2 == 1) + (b % 2 == 0)
a, b = a * (a % 2 == 1), b * (b % 2 == 0)
if cnt // 2 % 2 == 0:
    print(0 ^ a ^ b)
elif cnt // 2 % 2 == 1:
    print(1 ^ a ^ b)


Measured memory_bytes: 61888
import * as fs from "fs"
const process = (n: number): string => {
  return "" + n * n * n
}

const Main = (input: string): string => {
  const n: number = parseInt(input)
  const res = process(n) + ""
  console.log(res)
  return res
}
Main(fs.readFileSync("/dev/stdin", "utf8"))


Measured memory_bytes: 7372
#include<iostream>
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue> 
using namespace std;
int main() 
{int a,b,c,d,ans=0;
 cin>>a>>b>>c>>d;
 if (a>=b)
 ans+=b;
 else
 ans+=a;
 if (c>=d)
 ans+=d;
 else
 ans+=c;
 cout<<ans;                                           
 system("pause");
 return 0;
}        


Measured memory_bytes: 504
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

ll yey(ll a, ll b) {
  ll h = mod-2;
  ll two;
  ll tmp;
  while(h>0) {
    two = 1;
    tmp = b;
    while(2*two<h) {
      two *= 2;
      tmp *= tmp;
      tmp %= mod;
    }
    h -= two;
    a *= tmp;
    a %= mod;
  }
  return a;
}

int main() {
  int N;
  cin>>N;
  ll x[N];
  for(int i=0;i<N;++i) cin>>x[i];
  ll frac = 1;
  for(ll i=2;i<=N-1;++i) {
    frac *= i;
    frac %= mod;
  }
  ll ans = 0;
  ll sum = frac;
  for(ll i=1;i<=N-1;++i) {
    ans += sum*(x[i]-x[i-1])%mod;
    ans %= mod;
    sum += yey(frac,i+1);
    sum %= mod;
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 4404