akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;

ll mod = 1e9+7 ;
const ld error = 1e-9;
const ld PI = acosl(-1); //const ld PI = acosl(-1)

#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define eq(x, y) (fabs((x)-(y))<error)
#define bt(i) (1LL<<(i))

#define debug(x) cerr<<#x<<" = "<<(x)<<"\n"
#define hoise cerr<<"hoise - "<<__LINE__<<"\n"
#define tham getchar()
mt19937 rng((unsigned)chrono::system_clock::now().time_since_epoch().count()); //mt199937_64 for ll

inline ll MOD(ll x, ll m = mod){
    ll y = x % m;
    return (y >= 0) ? y: y+m;
}

const int inf = 1e9;
const ll infl = 1e18+1;
const int nmax = 1e6+10;
///===========================================  template  =======================================================

int arr[nmax];

int pairity(int n, int r){
    if((~n)&r) return 0;
    else return 1;
}

int main(){
    FASTIO;

    int n;
    cin>>n;
    n--;
    string s;
    cin>>s;
    for(int i = 0; i<n; i++){
        arr[i] = abs(s[i+1]-s[i]);
    }

//    for(int i = 0; i<n; i++) debug(arr[i]);


    int res = 0;
    for(int i = 0; i<n; i++){
        res = ((res + pairity(n-1, i)*arr[i])&1);
    }

    if(res == 1){
        cout<<1<<endl;
        return 0;
    }

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

    for(int i = 0; i<n; i++){
        arr[i] /= 2;
    }

    res = 0;
    for(int i = 0; i<n; i++){
        res = ((res + pairity(n-1, i)*arr[i])&1);
    }
    if(res == 0) cout<<0<<endl;
    else cout<<2<<endl;
    return 0;
}


Measured memory_bytes: 5276
N = int(input())
S = list(input())

R = [0] * N
G = [0] * N
B = [0] * N

for i in range(N):
    if S[i] == 'R':
        R[i] = 1
    elif S[i] == 'G':
        G[i] = 1
    else:
        B[i] = 1

sumR = sum(R)
sumG = sum(G)
sumB = sum(B)

cnt = 0
for i in range(N):
    sumR -= R[i]
    sumG -= G[i]
    sumB -= B[i]
    sum_r = sumR
    sum_g = sumG
    sum_b = sumB
    for j in range(i + 1, N):
        sum_r -= R[j]
        sum_g -= G[j]
        sum_b -= B[j]
        check_index = j + (j - i)
        if S[j] == 'R':
            if S[i] == 'B':
                cnt += sum_g
                if check_index < N:
                    cnt -= G[check_index]
            if S[i] == 'G':
                cnt += sum_b
                if check_index < N:
                    cnt -= B[check_index]
        elif S[j] == 'G':
            if S[i] == 'R':
                cnt += sum_b
                if check_index < N:
                    cnt -= B[check_index]
            if S[i] == 'B':
                cnt += sum_r
                if check_index < N:
                    cnt -= R[check_index]
        else:
            if S[i] == 'R':
                cnt += sum_g
                if check_index < N:
                    cnt -= G[check_index]
            if S[i] == 'G':
                cnt += sum_r
                if check_index < N:
                    cnt -= R[check_index]
print(cnt)


Measured memory_bytes: 69296
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N=I()
    T=LI()
    M=I()
    PX=LLIN(M)
    ans = sum(T)
    for i,(p,x) in enumerate(PX):
        print(ans - (T[p-1] - x))
if __name__ == '__main__':
    main()

Measured memory_bytes: 3572
n = int(input())
a = [input() for i in range(n)]

c0, c1, c2, c3 = 0, 0, 0, 0

for output in a:
    if output == 'AC':
        c0 += 1
    elif output == 'WA':
        c1 += 1
    elif output == 'TLE':
        c2 += 1
    elif output == 'RE':
        c3 += 1
        
        
print('AC x {}'.format(c0))
print('WA x {}'.format(c1))
print('TLE x {}'.format(c2))
print('RE x {}'.format(c3))

Measured memory_bytes: 16252
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#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 all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
vvi ta;
int n,m,out;
bool F(){
	bool h=true;
	rep(i,n-1)rep(j,m-1){
		int a=ta[i][j],b=ta[i+1][j],c=ta[i][j+1],d=ta[i+1][j+1];
		if(a*b*c*d==0)break;
		if(a==b||a==c||a==d||b==c||b==d||c==d);
		else h=false;
	}
	return h;
}
void f(int d,int a,int b){
	if(a==n){out+=F();return;}
	if(b==m){f(d,a+1,0);return;}
	
	if(ta[a][b]){f(d,a,b+1);return;}
	//tate
	if(a!=n-1&&ta[a+1][b]==0){
		ta[a][b]=ta[a+1][b]=d;
		if(F())f(d+1,a,b+1);
		ta[a][b]=ta[a+1][b]=0;
	}
	//yoko
	if(b!=m-1&&ta[a][b+1]==0){
		ta[a][b]=ta[a][b+1]=d;
		if(F())f(d+1,a,b+2);
		ta[a][b]=ta[a][b+1]=0;	
	}
}
int main(){
	while(cin>>n>>m,n+m){
		ta=vvi(n,vi(m));
		out=0;
		f(1,0,0);
		cout<<out<<endl;
	}
}

Measured memory_bytes: 1240
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
        ll n,w,temp;
        cin>>n>>w;
        ll weights[n+1];
        weights[0]=0;
        ll values[n+1];values[0]=0;
        for(ll i=1;i<=n;i++){
            cin>>weights[i]>>values[i];

        }

        ll dp[n+1][w+1];
        for(ll i=0;i<=n;i++){
            for(ll j=0;j<=w;j++){
                if(i==0||j==0)dp[i][j]=0;
                    else if(weights[i]<=j){
                        dp[i][j]=max(values[i]+dp[i-1][j-weights[i]],dp[i-1][j]);


                    }
                    else{
                        dp[i][j] = dp[i-1][j];
                    }



            }



        }
       cout<<dp[n][w];

    return 0;
}


Measured memory_bytes: 79104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<ll,ll> P;
#define M 1000000007
#define F first
#define S second
#define PB push_back
#define INF 100000000000000000
struct mono{
	ll x;
	void init(void){
		x=(1LL<<31)-1;
	}
};
mono func(mono a,mono b){
		mono res;
		res.init();
		res.x=min(a.x,b.x);
		return res;
}
struct segtree{
	mono seg[1<<20];
	int sz;
	void init(int n){
		sz=1;
		while(sz<n)sz*=2;
		for(int i=0;i<sz*2;i++)seg[i].init();
	}
	void set(int a,mono x){
		a+=sz-1;
		seg[a]=x;
	}
	void build(int k,int l,int r){
		if(l==r)return;
		build(k*2+1,l,(l+r-1)/2);
		build(k*2+2,(l+r+1)/2,r);
		seg[k]=func(seg[k*2+1],seg[k*2+2]);
	}
	void up(int a,mono x){
		a+=sz-1;
		seg[a]=x;
		while(a>0){
			a=(a-1)/2;
			seg[a]=func(seg[a*2+1],seg[a*2+2]);
		}
	}
	mono query(int a,int b,int l,int r,int k){
		if(a<=l&&r<=b)return seg[k];
		mono res;
		res.init();
		if(r<a||b<l)return res;
		return func(query(a,b,l,(l+r-1)/2,k*2+1),query(a,b,(l+r+1)/2,r,k*2+2));
	}
};
int main(void){
    int n,q;
    scanf("%d%d",&n,&q);
    segtree seg;
    seg.init(n);
    while(q--){
		ll t,a,b;
		scanf("%lld%lld%lld",&t,&a,&b);
		if(t==0)seg.up(a,mono{b});
		else{
			printf("%lld\n",seg.query(a,b,0,seg.sz-1,0).x);
		}
	}
    
}



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

const int MAX_N = 1e5+10;
int N;
int a[MAX_N];

void solve()
{
	int ans = 0;
	for(int i=0;i<N;++i)ans^=a[i];
	if(!ans) cout << "Yes\n";
	else cout << "No\n";
}

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

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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  int n; cin >> n;
  vector<int> b(n); for(int i = 1;i<=n-1;i++) cin >> b[i];

  int ans = b[1];
  for(int i = 1;i<n-1;i++){
    ans += min(b[i],b[i+1]);
  }
  ans += b[n-1];
  /*ans = b[0]*2;
    for(int i = 1;i<n-1;++i) ans += b[i];*/

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


Measured memory_bytes: 3580
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;

public class Main {
	private static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	public static void main(String[] args) throws Exception {
		int n = Integer.parseInt(br.readLine());
		Map<String, Object> map = new HashMap<>();
		for (int i = 0; i < n; i++) {
			String[] commands = br.readLine().split(" ");
			String command = commands[0];
			String target = commands[1];
			
			switch(command){
			case "insert":
				map.put(target, null);
				break;
			case "find":
				if(map.containsKey(target)){
					System.out.println("yes");
				}else{
					System.out.println("no");
				}
				break;
			}
		}
	}
}


Measured memory_bytes: 190024
#include <bits/stdc++.h>
using namespace std;
                                                                 
int main(void) {
    stack<int> S;
    string s;
    int x,y;
    while(cin>>s) {
        if(s=="+") {
            x=S.top();
            S.pop();
            y=S.top();
            S.pop();
            S.push(x+y);
        } else if (s == "-") {
            x = S.top();
            S.pop();
            y = S.top();
            S.pop();
            S.push(y-x);
        } else if (s == "*") {
            x = S.top();
            S.pop();
            y = S.top();
            S.pop();
            S.push(x*y);
        } else {
            S.push(atoi(s.c_str()));
            }
    }                                                             
  cout << S.top() << endl;                                      
}  

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

using ll=long long;
const ll MOD=1000000007;

int main() {
  int n;
  cin >> n;
  bool c=1;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  for(int i=0;i<n;i++){
    if(a[i]%2==0){
      if(a[i]%3!=0&&a[i]%5!=0)
        c=0;
    }
  }
  if(c)
    cout << "APPROVED" << endl;
  else
    cout << "DENIED" << endl;
}

Measured memory_bytes: 256
n=int(input())
ans=[]
for i in range(n):
    s,p=input().split()
    ans.append([s,int(p),i+1])

anspoint=sorted(ans,key=lambda x:x[1], reverse=True)
anscity=sorted(anspoint,key=lambda x:x[0])

for i in anscity:
    print(i[2])

Measured memory_bytes: 9120
# include <cstring>
# include <cstdio>
# include <iostream>
# include <queue>
# define N 100050 //N为顶点个数 
# define M 200050 //N为顶点个数 
# define WQD 0x7f7f7f7f//无穷大 
int n;//图的顶点个数
int m;//图的边数 
struct Edge{int next,to, w;}  e[M<<1];//不用0号单元 
int head[N+1]; 
int dis[N+1];//存放源点到其他点的路径
bool vis[N+1];
bool book[N+1];
bool spfa(int s);//差分约束判断 
using namespace std;
int main()
{
	ios::sync_with_stdio ( false ) ;
	int u,v,w;
	memset(head,-1,sizeof(head));
	cin>>n>>m;
	for(int i=1; i<=m; i++)  //本题约束关系为=，要添加两条边 
	{
		cin>>u>>v>>w;//输入第i条边 ,i为编号 
		e[i]=(Edge){head[u],v,w};head[u]=i;
		e[m+i]=(Edge){head[v],u,-w};head[v]=m+i;
	}
	memset(book,0,sizeof(book));
	memset(dis,0x7f,sizeof(dis));
	for(int i=1; i<=n; i++)//每一片的连通区域都要判断 
		if(!vis[i]) 
		{
			vis[i]=1;
			if(spfa(i)==false)  {cout<<"No";return 0;}//有约束自相矛盾 
		}
	cout<<"Yes";//所以的点都符合条件 
	return 0;
}
bool spfa(int s)
{
 	queue<int>q;
 	//memset(book,0,sizeof(book));
	memset(dis,0x7f,sizeof(dis));
	dis[s]=0;
	q.push(s);book[s]=1;	
	//如果没松弛就松弛，如果松弛过就判断是否符合约束条件，如果自相矛盾就是不可能的数据
	while(q.size()>0) 
	{
		int k=q.front();q.pop();//对头元素出队 
		book[k]=0;
		for(int i=head[k]; i!=-1; i=e[i].next)
		{
			int v=e[i].to;
			if(dis[v]==WQD && dis[k]<WQD)//如果v点没松弛过，就松弛更新dis[v]的值 				
			{	//题目的约束条件是= 			
				dis[v]=dis[k]+e[i].w;//更新 
				if(book[v]==0)	{q.push(v);	book[v]=1;}//入队标记
				vis[v]=1;//标记该点已经松弛过 
			}
			//据题意理解差分系统约束条件，不相等，自相矛盾 
			else if(dis[v]<WQD && dis[k]<WQD && dis[v]!=dis[k]+e[i].w)	return false;
		}		
    }
	return true;//别掉了这句 
}

Measured memory_bytes: 6400
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<deque>
#include<functional>
#include<iterator>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;
template<class T> inline bool chmin(T& a, T b){if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a=b;return true;}return false;}
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll digsz(ll x){if(x==0) return 1;else{ll ans=0;while(x){x/=10;ans++;}return ans;}}
ll digsum(ll x){ll sum=0;while(x){sum+=x%10;x/=10;}return sum;}
vector<ll> pw2(62,1);vector<ll> pw10(19,1);


int main(){
    {rep1(i,61) pw2[i]=2*pw2[i-1];}
    {rep1(i,18) pw10[i]=10*pw10[i-1];}
    ll N; cin>>N;
    vector<string> S(N);
    rep(i,N) cin>>S[i];
    vector<ll> X(5,0);
    rep(i,N){
        if(S[i][0]=='M') X[0]++;
        else if(S[i][0]=='A') X[1]++;
        else if(S[i][0]=='R') X[2]++;
        else if(S[i][0]=='C') X[3]++;
        else if(S[i][0]=='H') X[4]++;
    }
    ll ans=0;
    rep(i,3)FOR(j,i+1,4)FOR(k,j+1,5){
        ans+=X[i]*X[j]*X[k];
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 6408
from collections import Counter,defaultdict,deque
import sys
import bisect
import math
import itertools
import string
import queue
import copy
#import numpy as np
# import scipy
from itertools import permutations, combinations
from heapq import heappop, heappush
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
 
def inp(): # n=1
    return int(input())
def inpm(): # x=1,y=2
    return map(int,input().split())
def inpl(): # a=[1,2,3,4,5,...,n]
    return list(map(int, input().split()))
def inpls(): # a=['1','2','3',...,'n']
    return list(input().split())
def inplm(n): # x=[] 複数行
    return list(int(input()) for _ in range(n))
def inpll(n): # [[1,1,1,1],[2,2,2,2],[3,3,3,3]]
    return [list(map(int, input().split())) for _ in range(n)]

def main():
    n=inp()
    f=[]
    for _ in range(n):
        f.append(inpl())
    p=[]
    for _ in range(n):
        p.append(inpl())
    ans=-10**10
    for i in range(1,11):
        for j in combinations(range(10),i):
            do = [0 for _ in range(10)]
            for k in j:
                do[k]=1
            benefit = 0
            for l in range(n):
                s=0
                for u in range(10):
                    s+=f[l][u]*do[u]
                benefit += p[l][s]
            ans=max(ans,benefit)
    print(ans)

if __name__ == "__main__":
    main()

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

int main()
{
    int H,A;
    scanf("%d%d",&H,&A);

    if(H%A==0)
    {
          printf("%d",H/A);
    }
    else
    {
         printf("%d",(H+A)/A);
    }




    return 0;
}


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

int main() {
  int a,b;
  cin >> a >> b;
  
  if(a>=13){
    cout << b << endl;
  }
  else if(6<=a && a<=12){
    cout << b/2 << endl;
  }
  else{
    cout << 0 << endl;
  }
}

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

int main() {
  string s;
  int count;
  cin >> s[0];
  if(s[0]=='o') ++count;
  cin >> s[1];
  if(s[1]=='o') ++count;
  cin >> s[2];
  if(s[2]=='o') ++count;
  cout << 700+count*100 << endl;
}


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

int n, k;
int a[1000000], f[1000000];

bool check(int x){
  
  int K = k;
  
  for(int i=0;i<n;i++){
    
    int to_a = x / f[i];
    
    if( to_a < a[i] ){
      
      int num = a[i] - to_a;
      
      if( num > K ) return false;
      
      K -= num;
      
    }
    
  }
  
  return true;
}

signed main(){
  
  cin>>n>>k;
  
  for(int i=0;i<n;i++) cin>>a[i];
  
  for(int i=0;i<n;i++) cin>>f[i];
  
  sort(a,a+n);

  sort(f,f+n,greater<int>());
  
  int L = -1, R = 1e12+1;
  
  while(L+1<R){
    
    int M = (L+R)/2;
    
    if(check(M)) R = M;
    else L = M;
    
  }
  
  cout<<R<<endl;
  
  return 0;
}


Measured memory_bytes: 5888
x, k, d = map(int, input().split())

x = abs(x)

# 0をまたがないなら0の方向にk回移動下座標が答え
if x - k * d > 0:
    print(x - k * d)
    exit()

# 0をまたぐ瞬間の移動回数
step_num = x // d + 1

remain_steps = k - step_num

if remain_steps % 2 == 0:
    ans = abs(x - step_num * d)
else:
    ans = x - (step_num - 1) * d

print(ans)

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

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


int main() {
    int N; cin >> N;
    map<ll,int> A;
    REP(i,N){
        int a; cin >> a;
        A[a]++;
    }
    ll max1 = 0;
    ll max2 = 0;
    for(auto a: A){
        if(a.second>=2 && a.second<4){
            max2 = max1;
            max1 = a.first;
        }else if(a.second>=4){
            max1 = a.first;
            max2 = a.first;
        }
    }
    cout << max1*max2 << endl;
    return 0;
}

Measured memory_bytes: 9780
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<vector>
#include<set>
#include<list>
#include<queue>
#include<cmath>
#include<functional>
#include<algorithm>
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;


int n;
int a[300];
int s[301];
int dp[301][301];


int sum(int a,int b){
	return s[b-1]-s[a-1];
}
int cost(int x,int y){
	int res=0,c=0;
	while(x||y){
		res+=(x%10)*(y%10)+c;
		c=(10<=x%10+y%10+c);
		x/=10;
		y/=10;
	}
	return res+c;
}
int dfs(int s,int e){
	if(e-s==1)return 0;
	if(dp[s][e]!=-1)return dp[s][e];
	int res=INF;
	for(int i=s+1;i<e;i++){
		res=min(res,cost(sum(s,i),sum(i,e))+dfs(s,i)+dfs(i,e));
	}
	return dp[s][e]=res;
}

int main(){
	memset(dp,-1,sizeof(dp));
	cin>>n;
	rep(i,n)cin>>a[i];
	rep(i,n)s[i+1]+=s[i]+a[i];
	cout<<dfs(1,n+1)<<endl;
	return 0;
}

Measured memory_bytes: 1552
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
int main()
{
	SPEED
	int n;
	cin >> n;
	int arr[n];
	for (int i = 0; i < n; ++i)
	{
		cin >> arr[i];
	}
	int sum = 0;
	for (int i = 0; i < n; ++i)
	{
		for (int j = i+1; j < n; ++j)
		{
			sum += (arr[i]*arr[j]);
		}
	}
	cout << sum;
	return 0;
}

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

using namespace std;

typedef long long ll;

//#include<ext/pb_ds/assoc_container.hpp>
//#nclude<ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>pb_ds;

#define pii pair<int,ll>
#define pi pair<int,int>
#define F first
#define S second
#define pb push_back
#define pp pop_back
#define eps 10E-10
#define mod 1000000007
#define pai acos(-1)
#define mx 1000000000
#define N 2005


int main ()
{
//    ios_base::sync_with_stdio(false);
//    cin.tie(NULL);
//    freopen("in.txt","r",stdin);
//    freopen("out.txt","w",stdout);
    int t,l,r,n,m,id=0;
   cin>>l>>r>>n;
        swap(l,r);
        swap(l,n);
        cout<<l<<" "<<r<<" "<<n<<endl;
    return 0;
}



Measured memory_bytes: 256
// g++ -std=c++11 temp.cpp
#include <bits/stdc++.h>
using namespace std;

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define EACH(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

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

#define INF INT_MAX/3

#define MAX_N 1000

int n;
int a[100];

int main(){
	cin>>n;
	REP(i,n)cin>>a[i];
	int res=INF;
	FOR(i,-100,101){
		int sum=0;
		REP(j,n){
			sum+=pow(a[j]-i,2);
		}
		res=min(res,sum);
	}
	cout<<res<<endl;
	return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <iomanip>
#define sz(a) (int)(a).size()

using namespace std;

typedef vector<int> vi;
typedef long long ll;



int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	vector<double> p(n+1);
	vector<vector<double>> dp(n+1);
	for(int i=1;i<=n;i++){
		dp[i]=vector<double>(i+1);
//		p[i].resize(i+1);
//		p[i][0]=1;
		cin>>p[i];
//		for(int j=2;j<=i;j++){
//		p[i][j]=p[i][j-1]*p[i][1];
//		}
	}
	
	dp[1][0]=1-p[1];
	dp[1][1]=p[1];
	for(int i=2;i<=n;i++){
			for(int k=0;k<=i-1;k++){
				dp[i][k]=dp[i-1][k]*(1-p[i]);
				if(k!=0)
					dp[i][k]+=dp[i-1][k-1]*p[i];
			}
			dp[i][i]=dp[i-1][i-1]*p[i];
	}
	double loss=0;
	for(int i=0;i<=n/2;i++){
		loss+=dp[n][i];
	}
	cout<<setprecision(10)<<1-loss<<"\n";
	
}


Measured memory_bytes: 35584
#include <bits/stdc++.h>
#include <cassert>
typedef long long int ll;
using namespace std;

template<typename T>
bool on_a_line(T err, const complex<T>& z1, const complex<T>& z2,
	       const complex<T>& z3) {
  complex<T> v1 = z1 - z3;
  complex<T> v2 = z2 - z3;
  return abs(v1.real() * v2.imag() - v1.imag() * v2.real()) < err;
}

template<typename T>
complex<T> conjdiff(const complex<T>& z1, const complex<T>& z2) {
  return z1 * conj(z2) - conj(z1) * z2;
}

// Intersection of two lines, using a real parameter t
//    z = v1 t + u1
//    z = v2 t + u2
template<typename T>
complex<T> line_inter(const complex<T>& v1, const complex<T>& u1,
		      const complex<T>& v2, const complex<T>& u2) {
  return conjdiff(u1 - u2, v1) / conjdiff(v2, v1) * v2 + u2;
}

// circumcenter --- 外心
template<typename T>
complex<T> circumcenter(const complex<T>& z1, const complex<T>& z2,
			const complex<T>& z3) {
  return line_inter((z1 - z3) * complex<T>(0, 1), (z1 + z3) / T(2),
		    (z2 - z3) * complex<T>(0, 1), (z2 + z3) / T(2));
}

using Complex = complex<double>;

int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  double err = 1e-6;

  ll N; cin >> N;
  vector<Complex> z;
  for (ll i = 0; i < N; i++) {
    double x, y; cin >> x >> y;
    z.emplace_back(x, y);
  }

  auto check = [&](Complex c, double d) -> bool {
    for (ll i = 0; i < N; i++) {
      if (abs(z.at(i) - c) > d + err) return false;
    }
    return true;
  };

  double ans = 1e10;
  for (ll i = 0; i < N; i++) {
    for (ll j = i + 1; j < N; j++) {
      double d = abs(z.at(i) - z.at(j)) / 2;
      if (check((z.at(i) + z.at(j)) / 2.0, d)) ans = min(ans, d);
      for (ll k = j + 1; k < N; k++) {
	if (on_a_line(1e-10, z.at(i), z.at(j), z.at(k))) continue;
	Complex cc = circumcenter(z.at(i), z.at(j), z.at(k));
	double d2 = abs(cc - z.at(i));
	if (check(cc, d2)) ans = min(ans, d2);
      }
    }
  }
  cout << ans << endl;

  return 0;
}



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

bool ub(string s, int a, int b){
  vector<char> chr(1,s.at(a-1));
  vector<int> cnt(1,1);
  for(int i = a; i < b; i++){
    for(int j = 0; j < chr.size(); j++){
      if(s.at(i) == chr.at(j)){
        cnt.at(j) ++;
      }
      else if(j = chr.size()-1){
        chr.push_back(s.at(i));
        cnt.push_back(1);
      }
    }
  }
  sort(cnt.begin(), cnt.end());
  if(2*cnt.at(cnt.size()-1) > b-a+1)
    return true;
  else
    return false;
}

int main(){
  string s;
  cin >> s;
  int n = s.size();
  int a = -1;
  int b = -1;
  bool bk = false;
  for(int i = 1; i < 4; i++){
    for(int j = 1; j+i <= n; j++){
      if(ub(s,j,j+i)){
        a = j;
        b = j+i;
        bk = true;
        break;
      }
    }
    if(bk)
      break;
  }
  cout << a << " " << b << endl;
}

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

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

int main()
{
    int H1,M1,H2,M2,K;
    cin>>H1>>M1>>H2>>M2>>K;

    int X,Y;
    X=H1*60+M1;
    Y=H2*60+M2;

    cout<<Y-X-K<<endl;

    return 0;
}

Measured memory_bytes: 3648
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int L = sc.nextInt();
        boolean check = false;
        int a[] = new int[N];
        int an[] = new int[N - 1];
        int ans = 0;
        for (int i = 0; N > i; i++) {
            a[i] = sc.nextInt();
        }
        for (int j = 0; j < N - 1; j++) {
            if (a[j] + a[j + 1] >= L) {
                ans = j;
                check = true;
                break;
            }
        }
        if (check == false) {
            System.out.println("Impossible");
        } else {
            if (ans == 0) {
                System.out.println("Possible");
                while (N-1> ans) {
                    System.out.println(N-1);
                    N--;
                }
            } else if (ans == N - 2) {
                System.out.println("Possible");
                N = 1;
                while (N < ans + 2) {
                    System.out.println(N);
                    N++;
                }

            } else {
                System.out.println("Possible");
                for (int k = 1; k < ans + 1; k++) {
                    System.out.println(k);
                }
                for (int l = N - 1; l > ans; l--) {
                    System.out.println(l);
                }
            }
        }
    }

}

Measured memory_bytes: 65596
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main(){
    ll a,b,c;
    cin >> a >> b >> c;
    if(c < a + b){
        cout << "No" << endl;
        return 0;
    }
    if(4 * a * b < c * c - 2 * c * (a + b) + (a + b) * (a + b)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[n];
    int count=0;
    int min=n+1;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        if(a[i]<=min)
        {
            min=a[i];
            count++;
        }
    }
    cout<<count;
}

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

typedef long long ll;

int main() {
	ll A, B, C;
	cin >> A >> B >> C;
	if(A%2 == 0 || B%2 == 0 || C%2 == 0)
		cout << 0 << endl;
	else
		cout << min(A*B, min(B*C, C*A)) << endl;
}


Measured memory_bytes: 256
def solve(V,E,r,edges):
    cost=[float('inf')]*V
    cost[r]=0
    for _ in range(V-1):
        for edge in edges:
            s=edge[0]
            t=edge[1]
            d=edge[2]
            if cost[t]>cost[s]+d:
                cost[t]=cost[s]+d
    for edge in edges:
        s=edge[0]
        t=edge[1]
        d=edge[2]
        if cost[t]>cost[s]+d:
            return []
    return cost
            
V,E,r=map(int,input().split())
edges=[]
for _ in range(E):
    s,t,d=map(int,input().split())
    edges.append(tuple((s,t,d)))
ans=solve(V,E,r,edges)
if len(ans)==0:
    print("NEGATIVE CYCLE")
else:
    for i in range(len(ans)):
        if ans[i]==float('inf'):
            print("INF")
        else:
            print(ans[i])


Measured memory_bytes: 6008
<?php

$num = trim(fgets(STDIN));
$c = 0;
while(true){
    $c++;
    if(isset($map[$num])){
        echo $c;
        exit;
    }
    $map[$num] = true;
    if($num % 2 == 0){
        $num /= 2;
    }else{
        $num = $num * 3 + 1;
    }
}


Measured memory_bytes: 4856
#include<vector>
#include<algorithm>
#include<stdio.h>
using namespace std;
const double EPS=1e-8;
typedef vector<double>vec;
typedef vector<vec>mat;
inline double ABS(double a){return max(a,-a);}
vec gauss_jordan(const mat &A,const vec &b){
	int n=A.size();
	mat B(n,vec(n+1));
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)B[i][j]=A[i][j];
	for(int i=0;i<n;i++)B[i][n]=b[i];
	for(int i=0;i<n;i++){
		int pivot=i;
		for(int j=i;j<n;j++){
			if(ABS(B[j][i])>ABS(B[pivot][i]))pivot=j;
		}
		swap(B[i],B[pivot]);
		if(ABS(B[i][i])<EPS)return vec();
		for(int j=i+1;j<=n;j++)B[i][j]/=B[i][i];
		for(int j=0;j<n;j++){
			if(i!=j){
				for(int k=i+1;k<=n;k++)B[j][k]-=B[j][i]*B[i][k];
			}
		}
	}
	vec x(n);
	for(int i=0;i<n;i++)x[i]=B[i][n];
	return x;
}
double p[12][120];
double dp[110000];
int main(){
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);

	if(a<0)a=-a;
	if(b==1){
		if(a%c!=0){
			printf("-1\n");return 0;
		}else{
			a/=c;c=1;
		}
	}
	p[0][0]=1;
	for(int i=0;i<c;i++){
		for(int j=0;j<100;j++){
			for(int k=1;k<=b;k++){
				p[i+1][j+k]+=p[i][j]/b;
			}
		}
	}
	int n=b*c;
	mat A(n,vec(n));
	vec B(n);
	for(int i=0;i<n;i++){
		A[i][i]=1;
		
		if(i==0)continue;
		B[i]=1;
		for(int j=c;j<=b*c;j++){
			int to=i-j;
			if(to<0)to=-to;
			A[i][to]-=p[c][j];
		}
	}
	vec x=gauss_jordan(A,B);
	for(int i=0;i<n;i++)dp[i]=x[i];
	for(int i=n;i<=100000;i++){
		dp[i]=1;
		for(int j=c;j<=b*c;j++){
			dp[i]+=dp[i-j]*p[c][j];
		}
	}
	if(a<=100000)printf("%.12f\n",dp[a]);
	else{
		double M=(c+b*c)*0.5;
		printf("%.12f\n",dp[100000]+(a-100000)/M);
	}
}

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

int x[10][10];
int N, D;

bool isInt(int a, int b) {
    int s = 0;
    for (int i = 0; i < D; ++i) {
        s += (x[a][i] - x[b][i]) * (x[a][i] - x[b][i]);
    }

    for (int i = 1; i < 200; ++i) {
        if ((i * i) == s) {
            return true;
        }
    }

    return false;
}

int main() {
    std::cin >> N >> D;

    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < D; ++j) {
            std::cin >> x[i][j];
        }
    }

    int cnt = 0;
    for (int i = 0; i < N - 1; ++i) {
        for (int j = i + 1; j < N; ++j) {
            if (isInt(i, j)) {
                ++cnt;
            }
        }
    }
        
    std::cout << cnt << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int h,w;
	cin>>h>>w;
	vector< vector<char> > arr(h);
	vector< vector<int>  > score(h);
	for(int i=0;i<h;i++)
	for(int j=0;j<w;j++)
	{
		char c;
		cin>>c;
		arr[i].push_back(c);
		score[i].push_back(0);
	}
	bool dot;
	if(arr[h-1][w-1]=='.')
	dot=true;
	else
	{
		dot=false;
		score[h-1][w-1]=1;
	}
	for(int j=w-2;j>=0;j--)
	{
		if(arr[h-1][j]=='.')
		{
			score[h-1][j]=score[h-1][j+1];
		}
		else if(arr[h-1][j+1]=='#')
 		{
			score[h-1][j]=score[h-1][j+1];
		}
		else
		score[h-1][j]=score[h-1][j+1]+1;
	}
	for(int i=h-2;i>=0;i--)
	{
		if(arr[i][w-1]=='.')
		{
			score[i][w-1]=score[i+1][w-1];
		}
		else if(arr[i+1][w-1]=='#')
 		{
			score[i][w-1]=score[i+1][w-1];
		}
		else
		score[i][w-1]=score[i+1][w-1]+1;
	}
	
	
	for(int i=h-2;i>=0;i--)
	{
		for(int j=w-2;j>=0;j--)
		{
			if(arr[i][j]=='.')
			score[i][j]=min(score[i+1][j],score[i][j+1]);
			else
			{
				if(arr[i+1][j]=='#'&&arr[i][j+1]=='#')
				score[i][j]=min(score[i+1][j],score[i][j+1]);
				else if(arr[i][j+1]=='#')
				{
					score[i][j]=min(score[i+1][j]+1,score[i][j+1]);
				}
				else if(arr[i+1][j]=='#')
				{
					score[i][j]=min(score[i][j+1]+1,score[i+1][j]);
				}
				else
				score[i][j]=min(score[i][j+1]+1,score[i+1][j]+1);
			}
		}
	}
	cout<<score[0][0];
}
  

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using vl = vector<ll>;
using vvl = vector<vl>;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

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

long long lcm(long long a, long long b) {
    long long temp = gcd(a, b);
    return temp ? (a / temp * b) : 0;
}

vector<int> E[101010];
int D[101010][2]; //互いの距離
void dfs(int cur, int pre, int d, int id) {
    D[cur][id] = d;
    for(auto e : E[cur]) {
        if(e != pre) {
            dfs(e, cur, d + 1, id);
        }
    }
}
int main() {
    int N, A, B;
    cin >> N >> A >> B;
    A--;
    B--;
    REP(i, N - 1) {
        int x, y;
        cin >> x >> y;
        E[x - 1].push_back(y - 1);
        E[y - 1].push_back(x - 1);
    }
    dfs(A, A, 0, 0);
    dfs(B, B, 0, 1);
    int ma = 0;
    REP(i, N) {
        if(D[i][0] < D[i][1]) {
            //後者のほうが遠い点
            ma = max(ma, D[i][1] - 1);
        }
    }
    cout << ma << endl;
    return 0;
}

Measured memory_bytes: 11648
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <climits>
#include <cstring>
#include <string>
#include <map>
#include <set>
#include <vector>
#include <queue>


using namespace std;
#define INF 0x3f3f3f3f3f
#define ll long long
#define pr(x) (cerr << #x << ' ' << x << ' ')
#define prln(x) (cerr << #x << ' ' << x << endl)


int main()
{
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
    #endif // LOCAL

    int n;
    scanf("%d", &n);
    if (n == 0) {
        puts("0");
        return 0;
    }
    string ans;
    while (n) {
        int t = n % -2;
        n /= -2;
        if (t == -1) {
            ans = '1' + ans;
            ++n;
        }else {
            ans = char(t + '0') + ans;
        }
        // n /= -2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<queue>
#include<cmath>

using namespace std;
int helper(int N);
int main(){
    int n;
    cin >> n;
    for(int N=1;N<=n;N++){
        cout << helper(N) << endl;
    }

    return 0;
}



int helper(int N){
    int cnt=0;

    for(int x=1;x<=58;x++){
        for(int y=x;y<=100;y++){
            if(x*x+y*y+x*y > N){break;}
            for(int z=y;z<=100;z++){
                if(x*x + y*y + z*z + x*y + y*z + z*x == N){
                    if(x == y && y == z){
                        cnt += 1;
                    }else if(x == y || y == z || z == x){
                        cnt += 3;
                    }else{
                        cnt += 6;
                    }
                }
            }
        }
    }
    return cnt;

}


Measured memory_bytes: 3548
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1e18) + 1;

int main(void)
{
    int a, b;

    cin >> a >> b;

    if (a - 2 * b >= 0)
    {
        cout << a - 2 * b << endl;
    }
    else
    {
        cout << 0 << endl;
    }
}

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

#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(),(x).end()
#define MSG(x) cout << x << endl;
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
using ll = long long;

int main(int argc, char *argv[]) {
    ll a, b, c;
    cin >> a >> b >> c;
    MSG(min(min(a+b, b+c), a+c))
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
	long long l,r,min=2020;
  scanf("%lld%lld",&l,&r);
  if(r-l>2019){
  	printf("0");
    return 0;
  }
  for(int i=l;i<=r-1;i++){
  	for(int j=i+1;j<=r;j++){
    	min=(min>(i%2019)*(j%2019)%2019)?(i%2019)*(j%2019)%2019:min;
    }
  }
  printf("%lld",min);
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<set>

using namespace std;

int main() {
	int N;
	cin >> N;
	vector<string> S(N);
	set<string> l;
	for (int i = 0; i < N; i++) {
		cin >> S[i];
		l.insert(S[i]);
	}
	cout << (l.size() == 4 ? "Four" : "Three") << endl;
	system("pause");
	return 0;
}

Measured memory_bytes: 504
n = int(input())
mem = [{} for i in range(n + 1)]

first3s = []
for c in 'ACGT':
	for c2 in 'ACGT':
		for c3 in 'ACGT':
			first3s.append(c + c2 + c3)

ans = 0
for three in first3s:
  mem[3][three] = 0 if three in ['AGC', 'ACG', 'GAC'] else 1
  ans += mem[3][three]

def check4(four):
  if 'AGC' in four:
    return False
  for i in range(3):
    if 'AGC' in four[:i] + four[i+1] + four[i] + four[i+2:]:
      return False
  return True

if n > 3:
  for i in range(4, n + 1):
    ans = 0
    for three in first3s:
      for c in 'ACGT':
        four = c + three
        if check4(four):
          ans = (ans + mem[i - 1][three]) % (10**9 + 7)
          mem[i][(c + three)[:3]] = (mem[i].get((c + three)[:3], 0) + mem[i - 1][three]) % (10**9 + 7)
print(ans)

Measured memory_bytes: 3804
#include <stdio.h>
 
int main()
{
  int n, i,max, min;
  int a[10000];
  long int sum = 0;
 
  scanf("%d", &n);
 
  for(i = 0; i < n; i++){
      scanf("%d ", &a[i]);
  }

  max = a[0];
  min = a[0];

  for(i = 0; i < n; i++){
      sum = sum + a[i];
      if(a[i] >= max){
          max = a[i];
      }else if(a[i] <= min){
          min = a[i];
      }
    }
 
  printf("%d %d %ld\n", min, max, sum);
 
  return 0;
}

Measured memory_bytes: 2744
n = int(input())
A = list(map(int, input().split()))

tmp = 1
A.sort()
#print(A)
if A[0] == 0:
    print(0)
    exit()
for i in range(n):
    tmp *= A[i] 
    if tmp > 10**18:
            tmp = -1
            print(tmp)
            exit()
print(tmp)

Measured memory_bytes: 21476
def main():
    n=int(input())
    ac=0
    wa=0
    tle=0
    re=0
    for i in range(n):
        a=input()
        if a=="AC":
            ac+=1
        elif a=="WA":
            wa+=1
        elif a=="TLE":
            tle+=1
        elif "RE":
            re+=1
    print(f"AC x {ac}")
    print(f"WA x {wa}")
    print(f"TLE x {tle}")
    print(f"RE x {re}")
if __name__ == "__main__":
    main()

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

namespace AtCoder_Biginner_Contest_178__CSharp_
{
    class Program
    {
        static void Main(string[] args)
        {
            int x = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine(Convert.ToBoolean(x)?0:1);
        }
    }
}


Measured memory_bytes: 17680
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;

const ll MOD = (ll)1e9 + 7;


ll power(int n){
    if(n == 0) return 1;
    return 2 * power(n - 1) % MOD;
}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    VI hash(n, 0);
    REP(i, n){
        int a;
        cin >> a;
        if((n - a + 1) % 2 == 1){
            cout << 0 << "\n";
            return 0;
        }
        hash[a]++;
    }
    REP(i, n){
        if(hash[i] > 2){
            cout << 0 << "\n";
            return 0;
        }
    }
    if(n % 2 == 1 && hash[0] > 1){
        cout << 0 << "\n";
        return 0;
    }

    ll ans;
    if(n % 2 == 0) ans = power(n / 2);
    else ans = power((n - 1) / 2);
    cout << ans << "\n";

    return 0;
}


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

   typedef long long ll;
   typedef pair<ll, ll> Pii;
   typedef vector<ll> Vi;
   typedef vector<Vi> VVi;

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define RSORT(x) sort((x).rbegin(), (x).rend())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   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; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

   ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
   ll pow(ll a, ll b){if (b == 0) return 1; else if (b % 2 == 0) return pow(a * a, b / 2); else return pow(a * a, b / 2) * a;}
   ll pow(ll a, ll b, ll m){if (b == 0) return 1; else if (b % 2 == 0) return (pow(a * a, b / 2, m) % m); else return (pow(a * a, b / 2) * a) % m;}
   ll residue(ll a, ll m){return ((a % m) + m) % m;};

   ll dx[4]={1,0,-1,0};
   ll dy[4]={0,1,0,-1};
ll N, K;
int main(){
   cin >> N >> K;
   vector<Pii> v(N);
   ll sum = 0;
   REP(i, N){
      ll a, b;
      cin >> a >> b;
      v[i] = mp(a, b);
      sum += b;
   }
   sort(v.begin(), v.end(), [](const Pii& a, const Pii& b){return a.first < b.first;});
   ll temp = 0;
   REP(i, N){
      temp += v[i].second;
      if(temp >= K){
         cout << v[i].first << endl;
         break;
      }
   }


}


Measured memory_bytes: 1792
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif


using namespace std;

// #define int long long
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

const int MOD = 1e9 + 7;
const int INF = INT_MAX;

signed main() {
    Fast();

    int H, W, h, w;
    cin >> H >> W;
    cin >> h >> w;

    cout << H * W - (h * W) -  (H * w) + (h * w) << endl;

    return 0;
}








Measured memory_bytes: 256
#define _USE_NATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <random>
#include <tuple>


using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
#define EPS 1e-9
const int INF = 1050000000;
const long long LINF = 1LL << 60;
const ll MOD = 1e9 + 7;
const int MINF = -1050000000;

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


int main() {
	
	ll n;
	cin >> n;
	ll sum = 0;
	for (int i = 1; i <= n; i++) {
		if (i % 3 == 0 && i % 5 == 0) continue;
		else if (i % 3 == 0) continue;
		else if (i % 5 == 0) continue;
		else sum += i;
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 3636
#include<stdio.h>
int main()
{
  int n;
  scanf("%d",&n);
  int a[n+1],i;
  for(i=1;i<=n;i++)
  scanf("%d",&a[i]);
  int sum=0;
  for(i=1;i<=n;i+=2)
  if(a[i]%2==1)sum++;
  printf("%d",sum);
} 

Measured memory_bytes: 2152
#include <iostream>
#include <string.h>
using namespace std;

int n, wt;
int v[100], w[100], m[100], f[10001];
long a[10001], d[10001];

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

	for (int i = 0; i < n; i++)
		cin >> v[i] >> w[i] >> m[i];

	memset(a, 0, sizeof(a));
	memset(f, 0, sizeof(f));
	memset(d, 0, sizeof(d));

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < w[i]; j++) {
			int s = 0, t = 0;
			for (int k = 0; k * w[i] + j <= wt; k++) {
				int x = a[k * w[i] + j] - k * v[i];
				while (s < t && d[t - 1] <= x)
					t--;
				f[t] = k;
				d[t++] = x;
				a[k * w[i] + j] = d[s] + k * v[i];
				if (f[s] == k - m[i])
					s++;
			}
		}
	}

	cout << a[wt] << endl;

	return 0;
}


Measured memory_bytes: 3276
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>

using namespace std;

int func(int x){
	int cnt=0;
	for(int i=1;i<=x;i++){
		if(x%i==0){
			cnt++;
		}
	}
	return cnt;
}

int main(){
	int N;
	int ans=0;
	cin>>N;
	for(int i=1;i<=N;i++){
		if(i%2==0){
			continue;
		}else if(func(i)==8){
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){

  int a,b,c,d;
  scanf("%d %d %d %d", &a, &b, &c, &d);
  int start = a;
  if (c > a) {
    start = c;
  }
  int end = b;
  if (d < end) {
    end = d;
  }
  int answer = end-start;
  if (answer < 0) {
    answer = 0;
  }
  printf("%d\n", answer);

  return 0;
}

Measured memory_bytes: 128