akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const int maxn=2e5+10;
const int mod=1e9+7;
ll f[maxn];
ll p[maxn];
ll pows(ll a,ll b)
{
     ll re=1;
     while(b)
     {
        if(b&1)
        re=re*a%mod;
            a=a*a%mod;
            b/=2;
     }
     return re%mod;
}
void inint()
{
    f[0]=p[0]=1;
    for(int i=1;i<=maxn;i++)
        f[i]=f[i-1]*i%mod,p[i]=pows(f[i],mod-2)%mod;
}
ll C(ll n,ll m)
{
    ll ans=(ll)f[n]*p[n-m]%mod*p[m]%mod;
 //   cout<<f[n]<<' '<<p[n-m]<<' '<<p[m]<<' '<<ans<<endl;
 //cout<<ans<<endl;
     return ans;
}
ll solve(ll n,ll m,ll k)
{
       ll ans=0;
       for(int i=1;i<n  ;i++)
       {
           ans=(ans+C(n*m-2,k-2)*(n-i)%mod*m%mod*m%mod*i%mod)%mod;
          // cout<<ans<<endl;
       }

       return ans%mod;
}
int main()
{
    ll n,m,k;
     cin>>n>>m>>k;
     inint();
     ll ans=(solve(n,m,k)+solve(m,n,k))%mod;
     printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define mp make_pair
#define pb push_back
#define vll vector<ll>
#define endl "\n"
#define pll pair<ll,ll>
#define all(x) (x).begin() , (x).end()
#define f first
#define s second
#define pr(x) cout<<x<<endl;
#define pr2(x,y) cout<<x<<" "<<y<<endl;
#define pr3(x,y,z) cout<<x<<" "<<y<<endl;
#define prv(v) for(auto x:v) cout<<x<<" ";
#define ffs fflush(stdout);
using namespace std;
 
const ll N =(2e5+5);
const ll MOD = 998244353;
const ll INF = LLONG_MAX;
const ll LOG = 29;
 
long long binpow(long long a, long long b) {
    // a%=MOD;    
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = (res * a);
        a = (a * a) ;
 
        
        b >>= 1;
    }
    //res;
    return res;
} 

void solve(){
    
    ll a[3];
    cin>>a[0]>>a[1]>>a[2];
    sort(a,a+3);
    // a*b*c%2==0
    if(a[0]%2==0||a[1]%2==0||a[2]%2==0){
        cout<<0<<endl;
        return;
    }
    cout<<a[0]*a[1]<<endl;
}
 
 
 
 
int main(){
    ios_base::sync_with_stdio(0);
     cin.tie(NULL);
     
    ll t=1;
    while(t--){
        solve();
    }
     
 
 
    return 0;     
    
        
}


Measured memory_bytes: 256
n=int(input())

def rot(d, r):
    if r == 'N':
        return (d[1], d[5], d[2], d[3], d[0], d[4])
    if r == 'E':
        return (d[3], d[1], d[0], d[5], d[4], d[2])
    if r == 'W':
        return (d[2], d[1], d[5], d[0], d[4], d[3])
    if r == 'S':
        return (d[4], d[0], d[2], d[3], d[5], d[1])
    return d

def gen_all( d1 ):
    ds = { d1 }
    while 1:
        ds2 = { rot(d, r) for d in ds for r in list('NEWS') }.union(ds)
        if ds == ds2: break
        ds = ds2
    return ds

ds = {}

for i in range(n):
    d=tuple(map(int,input().split()))
    ds[i] = (d, gen_all(d))

dep=any ([ ds[i][0] in ds[j][1] for i in range(n) for j in range(i+1,n) ])
    
print('No' if dep else 'Yes')

Measured memory_bytes: 8228
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <deque>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define rep(i, up) for (ll i = 0; i < up; ++i)
#define repp(i, up) for (ll i = 0; i <= up; ++i)
#define rrep(i, lo, up) for (ll i = lo; i < up; ++i)
#define rrepp(i, lo, up) for (ll i = lo; i <= up; ++i)

#define rdi(i) ll i; scanf("%lld", &i)
#define rds(s) string s; cin >> s
#define rdc(c) char c; cin >> c

#define INF 10000000000
#define MOD 1000000007

ll gcd(ll a, ll b)
{
    if (a < b) {
        return gcd(b, a);
    }
    ll r;
    while (r = a % b) {
        a = b;
        b = r;
    }
    return b;
}

int main()
{
    ull x;
    cin >> x;
    ull a = 100;
    ull cnt = 0;
    while (a < x) {
        a = a + a / 100;
        ++cnt;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
const int N=2000005;
set<int> a[2];
int n,m,k,flag1[N],flag2[N];
char s1[N],s2[N];
void solve(int x,int y){
	int p0=*a[0].upper_bound(x),p1=*a[1].upper_bound(x);
	int p=min(p0,p1);
	if (x+k-y<p){
		p=x+k-y;
		a[0].insert(p);
		a[1].insert(p);
		return;
	}
	int v=p,t=p1==p;
	a[t^1].insert(v);
	while (a[t].find(v)!=a[t].end()){
		a[t].erase(v);
		v++;
	}
	if (a[t^1].find(v)!=a[t^1].end()){
		a[t^1].erase(v);
		solve(v,p-x+y);
	}
	else a[t].insert(v);
}
int main(){
	scanf("%d%d%d",&n,&m,&k);
	scanf("%s",s1);
	scanf("%s",s2);
	reverse(s1,s1+n);
	reverse(s2,s2+m);
	for (int i=m;i<n;i++)s2[i]='0';
	for (int i=n;i<m;i++)s1[i]='0';
	n=max(n,m);
	a[0].insert(1e9);
	a[1].insert(1e9);
	for (int i=n-1;i>=0;i--)
		if (s1[i]=='1'&&s2[i]=='1')solve(i,0);
		else if (s1[i]=='1')a[0].insert(i);
		else if (s2[i]=='1')a[1].insert(i);
	int Max1=0,Max2=0;
	for (set<int>::iterator iter=a[0].begin();iter!=a[0].end();iter++)
		if ((*iter)!=1e9){
			Max1=max(Max1,*iter);
			flag1[*iter]=1;
		}
	for (set<int>::iterator iter=a[1].begin();iter!=a[1].end();iter++)
		if ((*iter)!=1e9){
			Max2=max(Max2,*iter);
			flag2[*iter]=1;
		}
	for (int i=Max1;i>=0;i--)printf("%d",flag1[i]);
	puts("");
	for (int i=Max2;i>=0;i--)printf("%d",flag2[i]);
	puts("");
}


Measured memory_bytes: 51968
from itertools import combinations
N=int(input())
d={}
for _ in range(N):
  s=input()
  if not s[0] in ["M","A","R","C","H"]:continue 
  if not s[0] in d:
    d[s[0]]=1
  else:
    d[s[0]]+=1
res=0
for i in combinations(d.keys(),3):
  res+=d[i[0]]*d[i[1]]*d[i[2]]
print(res)

Measured memory_bytes: 3064
import bisect,sys
from itertools import *
n=range(50001);a=list(n);a[1]=0
for i in range(2,224):a[i*2::i]=[0]*len(a[i*2::i])
p=list(compress(n,a))
for x in map(int,sys.stdin):
 if x:print(sum(1 for d in p[:bisect.bisect(p,x//2)]if a[x-d]))


Measured memory_bytes: 8448
#include <bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define MAXN 100001
#define MOD -1
#define INF 1e9+5
#define FastCin	ios_base::sync_with_stdio(false); cin.tie(NULL);

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef long long ll;

void swap(int *a, int *b){
    int t = *a;
    *a = *b; *b = t;
}

vii v(MAXN); // F -> weight || s -> value
ll memo[MAXN][200];

ll knapsack(int W, int pos){
    if(pos < 0  || W == 0)
        return 0;
    if(memo[W][pos]) return memo[W][pos];
    
    if(v[pos].F > W)
        return knapsack(W, pos-1);
    else{
        ll a = (ll)v[pos].S + knapsack( W - v[pos].F, pos - 1);
        ll b = knapsack(W, pos-1);
        return memo[W][pos] = max(a, b);
    }
}

int main(){   
    memset(memo, 0, sizeof(memo));
    int n, w;
    scanf("%d %d", &n, &w);
    for(int i = 0; i < n; i++){
        scanf("%d %d", &v[i].F, &v[i].S );
    }
    ll ans = 0;    
    cout << knapsack(w, n-1) << endl;
    return 0;
}



Measured memory_bytes: 157312
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
using namespace std;
int main(){
	int H,W;
	cin>>H>>W;
	int yu2,yu1;//2こ、1この文字が許される種類数
	if(H%2==0){
		if(W%2==0){
			yu2=0;
			yu1=0;
		} else {
			yu2=H/2;
			yu1=0;
		}
	} else {
		if(W%2==0){
			yu2=W/2;
			yu1=0;
		} else {
			yu2=(H+W)/2-1;
			yu1=1;
		}
	}
	int co[256];
	REP(i,200){
		co[i]=0;
	}
	REP(i,H){
		string moji;
		cin>>moji;
		REP(j,W){
			co[moji[j]]++;
		}
	}
	bool OK=true;
	REP(i,200){
		if(co[i]%2!=0){
			yu1--;
		} else if(co[i]%4!=0){
			yu2--;
		}
		if(yu1<0 || yu2 < 0){
			OK=false;
			break;
		}
	}
	if(OK){
		cout<<"Yes"<<endl;
	} else {
		cout<<"No"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var a,b int
	fmt.Scan(&a,&b)
	
	origin := a
	cnt := b
	if a > b {
		origin = b
		cnt = a
	}

	for i := 0; i < cnt; i++ {
		fmt.Printf("%d",origin)
	}
	
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for (int i = 0; i < n; i++)
#define IREP(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(a, b) for (int i = a; i < b + 1; i++)
#define all(v) v.begin(), v.end()
#define SENTINEL 2000000000
#define NIL -1
using namespace std;
typedef long long ll;

const ll INF = 1LL << 60;
const ll MOD = 1000000007;
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;}


int main()
{
    ll x;
    cin >> x;
    ll ans=(x/500)*1000;
    x -= (x / 500)*500;
    ans+=(x/5)*5;
    cout << ans << endl;
}

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

int main() {
  int n;
  cin >> n;
  map<int, int> mp;
  for (int i = 0; i < n; i++) {
    int d;
    cin >> d;
    mp[d]++;
  }

  int m;
  cin >> m;
  bool ok = true;
  for (int i = 0; i < m; i++) {
    int t;
    cin >> t;
    if (mp.count(t) && mp[t] > 0) {
      mp[t]--;
    } else {
      ok = false;
      break;
    }
  }

  if (ok)
    puts("YES");
  else
    puts("NO");

  return 0;
}

Measured memory_bytes: 9728
import sys

int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

class Top2:
    def __init__(self,x=-1,y=-1):
        if x<y:x,y=y,x
        self.val=[x,y]

    def __add__(self, other):
        self.val=sorted(self.val+other.val,reverse=True)[:2]
        return self

n=II()
aa=LI()
dp=[Top2(a) for a in aa]

for i in range(n):
    for j in range((1<<n)-1,-1,-1):
        if j>>i&1:continue
        dp[j|1<<i]+=dp[j]

mx=-1
for j in range(1,1<<n):
    mx=max(mx,sum(dp[j].val))
    print(mx)


Measured memory_bytes: 233000
#include <stdio.h>
#define FOR(i,a,n) for(i=a;i<n;i++)
#define MAX(a,b) (((a)>(b))?(a):(b))
#define ll long long

int heap[100001];
int num=0;
void push(int a){
 	int i=num++;
 	while(i>0){
 		int p=(i-1)/2;
 		if(heap[p]<=a) break;
 		heap[i]=heap[p];
 		i=p;
 	}
 	heap[i]=a;
 	return;
}
int pop(void){
 	int data=heap[0];
 	int n=heap[--num];
 	int pos=0;
 	while(pos*2+1<num){
 		int a=pos*2+1;
 		int b=pos*2+2;
 		if(b<num&&heap[a]>heap[b]) a=b;
 		if(n<=heap[a]) break;
 		heap[pos]=heap[a];
 		pos=a;
 	}
 	heap[pos]=n;
 	return data;
}
int a[300000];
ll k[100001];
int main(void)
{
     int n,p,size,i;
     ll sum=0,res;
     scanf("%d",&n);
     size=3*n;
     FOR(i,0,size) scanf("%d",&a[i]);
     FOR(i,0,n){
     	sum+=a[i];
     	push(a[i]);
     }
     k[0]=sum;
     FOR(i,1,n+1){
     	push(a[i+n-1]);
     	p=pop();
     	sum+=(a[i+n-1]-p);
     	k[i]=sum;
     }
     sum=num=0;
     FOR(i,0,n){
     	sum+=a[size-i-1];
     	push(-a[size-i-1]);
     }
     res=k[n]-sum;
     FOR(i,1,n+1){
     	push(-a[2*n-i]);
     	p=-pop();
     	sum+=(a[2*n-i]-p);
     	res=MAX(res,k[n-i]-sum);
     }
     printf("%lld\n",res);
 	return 0;
}


Measured memory_bytes: 2560
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int S = sc.nextInt();
		int h = (int) Math.floor(S / 3600);
		int m = (int) Math.floor((S % 3600) / 60);
		int s = (int) Math.floor((S % 3600) % 60);
		System.out.println(h + ":" + m + ":" + s);
	}
}


Measured memory_bytes: 26228
import java.io.IOException; 
import java.io.InputStream; 
import java.io.PrintWriter; 

class Main{ 

	static void solve(){ 
		int n = ni(), m=ni(), d=ni();
		double exp = (d==0 ? 1.0 : ((n-2*d)*2.0 + (2*d)*1.0)/(double)n);
		out.println(exp*(m-1)/(double)n);
	} 
 
 
 
 
	public static void main(String[] args){ 
		 solve(); 
		 out.flush(); 
	 } 
	 private static InputStream in = System.in; 
	 private static PrintWriter out = new PrintWriter(System.out); 
 
	 private static final byte[] buffer = new byte[1<<15]; 
	 private static int ptr = 0; 
	 private static int buflen = 0; 
	 private static boolean hasNextByte(){ 
		 if(ptr<buflen)return true; 
		 ptr = 0; 
		 try{ 
			 buflen = in.read(buffer); 
		 } catch (IOException e){ 
			 e.printStackTrace(); 
		 } 
		 return buflen>0; 
	 } 
	 private static int readByte(){ if(hasNextByte()) return buffer[ptr++]; else return -1;} 
	 private static boolean isSpaceChar(int c){ return !(33<=c && c<=126);} 
	 private static int skip(){int res; while((res=readByte())!=-1 && isSpaceChar(res)); return res;} 
 
	 private static double nd(){ return Double.parseDouble(ns()); } 
	 private static char nc(){ return (char)skip(); } 
	 private static String ns(){ 
		 StringBuilder sb = new StringBuilder(); 
		 for(int b=skip();!isSpaceChar(b);b=readByte())sb.append((char)b); 
		 return sb.toString(); 
	 } 
	 private static int[] nia(int n){ 
		 int[] res = new int[n]; 
		 for(int i=0;i<n;++i)res[i]=ni(); 
		 return res; 
	 } 
	 private static long[] nla(int n){ 
		 long[] res = new long[n]; 
		 for(int i=0;i<n;++i)res[i]=nl(); 
		 return res; 
	 } 
	 private static int ni(){ 
		 int res=0,b; 
		 boolean minus=false; 
		 while((b=readByte())!=-1 && !((b>='0'&&b<='9') || b=='-')); 
		 if(b=='-'){ 
			 minus=true; 
			 b=readByte(); 
		 } 
		 for(;'0'<=b&&b<='9';b=readByte())res=res*10+(b-'0'); 
		 return minus ? -res:res; 
	 } 
	 private static long nl(){ 
		 long res=0,b; 
		 boolean minus=false; 
		 while((b=readByte())!=-1 && !((b>='0'&&b<='9') || b=='-')); 
		 if(b=='-'){ 
			 minus=true; 
			 b=readByte(); 
		 } 
		 for(;'0'<=b&&b<='9';b=readByte())res=res*10+(b-'0'); 
		 return minus ? -res:res; 
	} 
} 



Measured memory_bytes: 21204
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7;
const ll MAX= 1000001;
ll gcd(ll a, ll b) {
	if (a<b) { return gcd(b, a); }
	else if (a%b) { return gcd(b, a%b); }
	else { return b; }
}
ll lcm(ll a, ll b){
	return a/gcd(a,b)*b;
}
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,m;
	cin>>n>>m;
	string s,t;
	cin>>s>>t;
	ll x=lcm(n,m);
	bool flag=true;
	if(s[0]!=t[0]){
		flag=false;
	}
	vector<int>a,b;
	ll y=lcm(x/n,x/m);
	for(int i=0; i<=n-1; i++){
		if(i*(x/n)%y==0){a.push_back(i);}
	}
	for(int i=0; i<=m-1; i++){
		if(i*(x/m)%y==0){b.push_back(i);}
	}
	for(int i=0; i<a.size(); i++){
		if(s[a[i]]!=t[b[i]]){
			flag=false;
			break;
		}
	}
	if(flag)cout<<x<<endl;
	else cout<<-1<<endl;
}

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

int main(){
  	int x = 0;
  	int y = 0;
    bool flg = true;
	while (flg) {
    	cin >> x >> y;
    	
      if (x == 0 && y == 0) {
      	flg = false;
        break;
      }
      
      for (int i = 0; i < x; i ++) {
      	for (int j = 0; j < y; j++) {
          if (i == 0 && j + 1 == y) {
          	cout << "#" << endl;
          } else if (i == 0) {
            cout << "#";
          } else if (j == 0) {
          	cout << "#";
          } else if (j + 1 == y) {
          	cout << "#" << endl;
          } else if (i + 1 == x && j + 1 == y) {
            cout << "#" << endl;
          } else if(i + 1 == x) {
            cout << "#";
          } else {
            cout << ".";
          }
        }
      }
      
      cout << endl;
    }
  	
    return 0;
}




Measured memory_bytes: 3044
def extract(a, i):
  return (a>>(i+1) << i) | (a&((1<<i)-1))

def space(a, i):
  return ((a>>i) << (i+1)) | (a&((1<<i)-1))

def compose(n, a, b):
  if n==1:
    return [a, b]
  for i in range(n):
    if (a>>i&1) ^ (b>>i&1):
      x = i
      a_bool = (a>>i & 1) << i
      b_bool = a_bool ^ (1 << i)
      a_dash = extract(a, i)
      b_dash = extract(b, i)
      c = a_dash ^ 1
      break
  Q = compose(n-1, a_dash, c)
  R = compose(n-1, c, b_dash)
  n_Q = [space(i, x)|a_bool for i in Q]
  n_R = [space(i, x)|b_bool for i in R]
  return n_Q + n_R
  
n, a, b = map(int, input().split())
cnt = 0
c = a^b
for i in range(n):
  cnt += c>>i & 1
if cnt&1:
  print("YES")
  print(*compose(n, a, b))
else:
  print("NO")

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

int main() {
  int N,M;
  int a=0;
  cin >> N >> M;
  vector <int> vec(M);
  for (int i=0;i<M;i++){
    cin >> vec.at(i);
  }
  for (int i=0;i<M;i++){
    a += vec.at(i);
    //cout << vec.at(i);
  }
  if (a>N){
    cout << "-1" << endl;
  }
  else cout << N-a << endl;
}

Measured memory_bytes: 3644
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define INF 1 << 30
#define EPS 1e-10

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int n;
char k, s[2048];

bool cmp(const pair<string, int> &a, const pair<string, int> &b){
  if(a.S != b.S) return a.S > b.S;
  return a.F < b.F;
}

int main(){
  while(scanf("%d", &n) && n){
    vector<pair<string, int> >c;
    scanf("\n");
    rep(i, n){
      fgets(s, sizeof(s), stdin);
      s[strlen(s)-1] = '\0';
      char *tp;

      tp = strtok(s, " ");
      int p;
      string ss = string(tp);
      for(p = 0; p < c.size(); p++) if(c[p].F == ss){ c[p].S++; break;}
      if(p == c.size()) c.PB(MP(ss, 1));
      while(tp != NULL){
	tp = strtok(NULL, " ");
	//	fprintf(stderr, "error %d\n", i);
	if(tp != NULL){
	  ss = string(tp);
	  //	  cout << ss << endl;
	  for(p = 0; p < c.size(); p++) if(c[p].F == ss){ c[p].S++; break;}
	  if(p == c.size()) c.PB(MP(ss, 1));
	  //	  printf("%d\n", p);
	}
      }
    }
    
    scanf("%s", s);
    k = s[0];
    //    printf("%d\n", (int)c.size());
    rep(i, c.size()) if(c[i].F[0] != k){ c.erase(c.begin()+i); i--;}
    //    printf("%d\n", (int)c.size());
    //    rep(i, c.size()) cout << c[i].F.size() << " " << c[i].F << " " << c[i].S << endl;
    sort(c.begin(), c.end(), cmp);
    if(c.size()){
      rep(i, 5<c.size()?5:c.size()) cout << (i?" ":"") << c[i].F;
      puts("");
    }else{
      puts("NA");
    }
  }
  return 0;
}

Measured memory_bytes: 1228
import java.util.*;

public class Main{
    public static void main(String [] args){
        Scanner sc = new Scanner(System.in);
        long A = sc.nextLong();
        long B = sc.nextLong();
        long C = sc.nextLong();
        long cnt = 0, a, b, c;
        while(((A & 1) == 0) && ((B & 1) == 0) && ((C & 1) == 0)){
            if((A == B) && (B == C)){
                System.out.println(-1);
                return;
            }

            a = A; b = B; c = C;
            A = (b + c) / 2;
            B = (a + c) / 2;
            C = (a + b) / 2;
            cnt++;
        }
        System.out.println(cnt);
        return;
    }
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = ll(1e9) + 1;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, n) for(int i = 1; i <= (int)(n); i++)
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 main()
{
  double l;
  cin >> l;

  double p = l / 3;
  printf("%.12lf\n", p * p * p);

  return 0;
}


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

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

    int n, k;
    string s;
    cin >> n>> k;
    cin >>s;
    int ans = 0;
    int i = 0, j = 0;
    while(i < n)
    {
        if(s[i] == '0'){
            if(k == 0){
                while(s[j] == '1') ++j;
                while(s[j] == '0') ++j;
                ++k;
            }
            while(i < n - 1 && s[i] == '0') ++i;
            --k;
        }
        //cout << i << " **  "<< j << endl;
        ans = max(ans, i - j + 1);
        ++i;
    }
   // cout << i << " "<< j << endl;
    cout<<ans <<endl;
}




Measured memory_bytes: 512
#include <stdio.h>
int main(){
  int a,b,k,i;
  scanf("%d%d%d",&a,&b,&k);
  for(i=0;i<k;i++)if(b>=a+i)printf("%d\n",a+i);
  for(i=1;i<=k;i++)if(b-k+i>=a+k)printf("%d\n",b-k+i);
  return 0;
}

Measured memory_bytes: 128
#![allow(unused_imports)]
#![allow(unused_macros)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

//
// Macro debug!
//

#[cfg(debug_assertions)]
include! {"./procon/debug.rs"}

#[cfg(not(debug_assertions))]
macro_rules! debug {
    ($($arg:expr),*) => {};
}

//
// Macro input!
//

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

//
// IteratorExt
//

trait IteratorExt: Iterator + Sized {
    fn vec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

impl<T: Iterator> IteratorExt for T {}

//
// Main
//

fn main() {
    input! {
        a: isize,
        b: isize,
    }

    let ans = max(a + b, max(a - b, a * b));
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

ll a[16][16],dp[65536],p[16],d[17];

int main(void){
	int n,m,i,j,k,st;
	for(i=0; i<=16; ++i){
		d[i] = (1<<i);
	}
	scanf("%d",&n);
	for(i=0; i<n; ++i){
		for(j=0; j<n; ++j){
			scanf("%lld",&a[i][j]);
		}
	}
	for(k=0; k<d[n]; ++k){
		for(i=0; i<n; ++i){
			for(j=0; j<i; ++j){
				if((k&(1<<i)) && (k&(1<<j))){
					dp[k] += a[i][j];
				}
			}
		}
	}
	for(i=0; i<d[n]; ++i){
		m = 0;
		for(j=0; j<n; ++j){
			if(i&(1<<j)){
				p[m] = j;
				++m;
			}
		}
		if(!m){
			continue;
		}
		for(k=0; k<d[m-1]; ++k){
			st = 0;
			for(j=0; j<m; ++j){
				if(k&(1<<j)){
					st += (1<<p[j]);
				}
				dp[i] = max(dp[i],dp[st]+dp[i-st]);
			}
		}
	}
	printf("%lld\n",dp[d[n]-1]);
	return 0;
}


Measured memory_bytes: 768
# -*- coding: utf-8 -*-
N = int(raw_input())
a_arr = map(int, raw_input().split())

a_arr_sort = sorted(a_arr, reverse=True)

sum_val = 0
for idx in range(0, N):
  temp_val = a_arr_sort[2*idx+1]
  sum_val += temp_val

print(sum_val)

Measured memory_bytes: 28776
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<set>
#include<map>
#include<utility>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

#define MOD 1000000007;

int main(){
	int n;
	cin >> n;
	vector<pair<int, int> > odd(1e5+1), even(1e5+1);
	for(int i=0; i<n/2; i++){
		int a, b;
		cin >> a >> b;
		odd[a].first=a;
		odd[a].second++;
		even[b].first=b;
		even[b].second++;
	}
	sort(odd.begin(), odd.end(), [](pair<int, int> x, pair<int, int> y){
		return x.second>y.second;
	});
	sort(even.begin(), even.end(), [](pair<int, int> x, pair<int, int> y){
		return x.second>y.second;
	});
	if(odd[0].first != even[0].first)
		cout << n-odd[0].second-even[0].second << endl;
	else
		cout << n-max(odd[0].second+even[1].second, odd[1].second+even[0].second) << endl;
	return 0;
}

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

#define ll long long int
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define all(A) A.begin(), A.end()
#define sz(A) (int)A.size()
typedef vector <int> vi;
typedef vector <ll> vl;
typedef pair <int, int> pii;
typedef tuple <int, int, int> tii;
const ll mod = 1e9 + 7;
//const ll mod = 998244353;
const int inf = 1e9;
//const ll inf = 1e18;
const int N = 2e5;

void solve () {
	int n;
	cin >> n;
	if (n % 1000 == 0) 
		cout << 0 << "\n";
	else cout << 1000 - n % 1000 << "\n";
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
  #endif
	int t = 1;
	while (t--) {
		solve();
	}
 	return 0;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
const int m=1000000007;
int fnc(int i,int j,int di,int dj,char a[][1000], int dp[][1000])
{
    //cout<<i<<" "<<j<<endl;
  if(i==di && j==dj)
    dp[i][j]=1;
 else if(dp[i][j]==-1)
 {
   if(i+1<=di && j+1<=dj && a[i][j+1]=='.' && a[i+1][j]=='.')
     dp[i][j]=(fnc(i,j+1,di,dj,a,dp)%m+fnc(i+1,j,di,dj,a,dp)%m)%m;
   else if(i+1<=di && j+1>dj && a[i+1][j]=='.')
     dp[i][j]=fnc(i+1,j,di,dj,a,dp)%m;
   else if(i+1>di && j+1<=dj && a[i][j+1]=='.')
     dp[i][j]=fnc(i,j+1,di,dj,a,dp)%m;
   else if(i+1<=di && j+1<=dj && a[i][j+1]=='#' && a[i+1][j]=='.')
     dp[i][j]=fnc(i+1,j,di,dj,a,dp)%m;
   else if(i+1<=di && j+1<=dj && a[i][j+1]=='.' && a[i+1][j]=='#')
     dp[i][j]=fnc(i,j+1,di,dj,a,dp)%m;
   else 
     dp[i][j]=0;
 }
  return dp[i][j]%m;
}
int main()
{
    //cout<<"MNM"<<endl;
  int h,w;
  cin>>h>>w;
  char a[1000][1000];
  int i=0;
  int j=0;
  //cout<<"LKL"<<endl;
   int dp[1000][1000];
  while(i<h)
  {
   j=0;
   while(j<w)
   {
    cin>>a[i][j];
     j++;
   }
    
    i++;
  }
  i=0;
  while(i<1000)
  {
      memset(dp[i],-1,sizeof(dp[i]));
      i++;
  }
  i=0;
  j=0;
  //cout<<"LOL"<<endl;
  cout<<fnc(i,j,h-1,w-1,a,dp)<<endl;
  return 0;
}

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

int main(){
  int n,k,i,j,s;
  cin >> n >> k;
  vector<int> y(n,1);
  int d,a;
  for(i=0;i<k;i++){
    cin >> d;
    for(j=0;j<d;j++){
      cin >> a;
      y.at(a-1)=0;
    }
  }
  
  s=0;
  for(i=0;i<n;i++){
    s+=y.at(i);
  }
  cout << s << endl;
}

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

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int N;
cin>>N;
vector<int>value(N),cost(N);
int tmp;
rep(i,N){
    cin>>value[i];
}
rep(i,N){
    cin>>cost[i];
}
ll total=0;
rep(i,N){
    int X=value[i]-cost[i];
    if(X<=0)continue;
    total+=X;
}
cout<<total<<endl;
//system("pause");
return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {


	static int MAXN= 3005;

	static long dp[][];
	static long as [];
	static long min(long a, long b) {
		return Math.min(a, b);
	}
	static long max(long a, long b) {
		return Math.max(a, b);
	}
	static long calc(int inicio, int fin, int p){
	    if(dp[inicio][fin]!=-1){
	        return dp[inicio][fin];
	    }
	    if(p==0){
	        return dp[inicio][fin]=max(as[inicio]+calc(inicio+1,fin,1),as[fin]+calc(inicio,fin-1,1));
	    }
	    return dp[inicio][fin]=min(calc(inicio+1,fin,0),calc(inicio,fin-1,0));
	}

	public static void main(String[] args) throws Exception{
	    int n;
	    long suma =0,X,rta;
	    dp = new long[MAXN][MAXN];
	    as  = new long [MAXN];
	    BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
	    n = Integer.parseInt(bf.readLine());
	    String[] data = bf.readLine().split(" ");
	    for(int i =0; i<MAXN; i++){
	        for(int j =0; j<MAXN; j++){
	            dp[i][j]=-1;
	        }
	    }
	    for(int i=0; i<n; i++){
	        as[i] = Long.parseLong(data[i]);
	        suma+=as[i];
	        if(n%2==1){
	            dp[i][i]  = as[i];
	        }
	        else{
	            dp[i][i] = 0;
	        }
	    }
	    X = calc(0,n-1,0);
	    rta = 2*X-suma;
	    System.out.println(rta);
	}
	
}


Measured memory_bytes: 130732
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> P;
#define INF 10000000000000
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for(ll i = 1; i < (ll)(n); i++)
#define repN_1(i, n) for(ll i = 0; i < (ll)(n - 1); i++)
#define repM(i, n) for(ll i = (ll)(n - 1); i >= 0; i--)
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 main()
{
	cout << fixed << setprecision(18);
	ll k, a, b;

	cin >> k >> a >> b;

	for (ll i = a; i <= b; i++)
	{
		if (i % k == 0)
		{
			cout << "OK" << endl;
			return 0;
		}
	}

	cout << "NG" << endl;

	return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1000000007;
const int INF = 1001001001;

ll f(ll a, ll b) {
  return pow(a, 5) - pow(b, 5);
}

int main() {
  ll x;
  cin >> x;
  
  for (ll i = -1000; i <= 1000; ++i) {
    for (ll j = -1000; j <= 1000; ++j) {
      ll value = f(i, j);
      if (value == x) {
        cout << i << " " << j << endl;
        return 0;
      }
    }
  }
  // rep(i, 1001) {
  //   cout << pow(i, 5) - pow(i - 1, 5) << endl;
  // }

}

Measured memory_bytes: 4048
use proconio::input;

const LIMIT: i64 = 1_000_000_000_000_000_000;

fn main() {
    input! {
        n: usize,
        a: [i64; n],
    }

    if a.iter().any(|x| *x == 0) {
        println!("0");
        return;
    }

    let ans = a.iter().copied().fold(Some(1i64), |acc, x| acc.and_then(|y| y.checked_mul(x)));
    let ans = match ans {
        Some(x) => if x <= LIMIT { Some(x) } else { None },
        None => None,
    };
    let ans = ans.unwrap_or(-1);
    println!("{}", ans);
}


Measured memory_bytes: 4608
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int long long

template <class T>
bool INRANGE(T x, T a, T b) { return a <= x && x <= b; }
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 (a > b){ a = b; return 1;}return 0;}
template <class T>
void printv(vector<T> v) {for (T t : v) {cout << t << " ";}cout << '\n';}

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" <<endl;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

unsigned GetDigit(unsigned num){
    return log10(num);
}

signed main()
{
    int x;
    cin >> x;

    int keta = GetDigit(x);

    for (int i=keta; i>=1; i--) {
        int tg = x % (int)pow(10,i);
        int num = x - tg;
        if ((num % 100) != 0) break;
        num /= 100;
        // debug(tg)
        // debug(num)
        for (int d=5; d>=1; d--) {
            int dn = tg / d;
            tg = tg % d;
            num -= dn;
            if (num < 0) break;
            if (tg == 0) {
                cout << 1 << endl;
                return 0;
            }
        } 
    }

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


Measured memory_bytes: 384
from collections import deque
N=int(input())
A=[0 for i in range(N-1)]
B=[0 for i in range(N-1)]
G=[[] for i in range(N)]
for i in range(N-1):
    a,b=map(int,input().split())
    a-=1;b-=1
    A[i],B[i]=a,b
    G[a].append(b)
    G[b].append(a)
j=0
for i in range(N):
    if len(G[i])>len(G[j]):
        j=i
c=sorted([int(i) for i in input().split()])
M=sum(c)-max(c)
d=[-1 for i in range(N)]
q=deque([j])
while(len(q)>0):
    r=q.popleft()
    d[r]=c.pop()
    for p in G[r]:
        if d[p]==-1:
            q.appendleft(p)
print(M)
print(" ".join([str(i) for i in d]))


Measured memory_bytes: 50136
#include<stdio.h>
int main(){
  int H,W,i,j;
  for(;;){
    scanf("%d %d",&H,&W);
    if(H==0&&W==0)break;
    for(j=0;j<H;j++){
      for(i=0;i<W;i++){
	if(i==0||i==W-1||j==0||j==H-1){
	  printf("#");
	}else{
	  printf(".");
	}
      }printf("\n");
    }printf("\n");
  }
  return 0;
}

Measured memory_bytes: 572
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;
import java.util.Scanner;


public class Main {

	static char[][] grid = new char[1000][1000];
	static int[][] dist = new int[1000][1000];
	static int H;
	static int W;
	static int sx, sy, ex, ey;
	static Deque<Integer> xQ = new ArrayDeque<Integer>();
	static Deque<Integer> yQ = new ArrayDeque<Integer>();

	public int numMagic() {
		int res = 0;
		for (int i = 0; i < H; i++) {
			Arrays.fill(dist[i], Integer.MAX_VALUE);
		}
		dist[sx - 1][sy - 1] = 0;
		xQ.addFirst(sx - 1);
		yQ.addFirst (sy - 1);
		while (!xQ.isEmpty()) {
			
			int curX = xQ.poll();
			int curY = yQ.poll();
			//System.out.println("curX: "+curX + " curY: "+ curY);
			if (curX == ex - 1 && curY == ey - 1) {
				if(dist[curX][curY] < Integer.MAX_VALUE) {
					return dist[curX][curY];
				} else {
					return -1;
				}
			}

			int[] dx = { 0, 1, 0, -1 };
			int[] dy = { -1, 0, 1, 0 };

			for (int i = 0; i < 4; i++) {
				
					int x = curX + dx[i];
					int y = curY + dy[i];
					if (valid(x, y)) {
						if (dist[x][y] > dist[curX][curY]) {
							//System.out.println("adding ("+x+","+y+")");
							xQ.addFirst (x);
							yQ.addFirst(y);
							dist[x][y] = dist[curX][curY];
						}
					}
				
			}
			//System.out.println("After immediate curX: "+curX+ "  cury:  "+curY);
			for (int x = -2; x <= 2; x++) {
				for (int y = -2; y <= 2; y++) {
					if (valid(curX + x, curY + y)) {
						if (dist[curX + x][curY + y] > dist[curX][curY] + 1) {
							//System.out.println("adding ("+(curX + x)+","+(curY + y)+")");
							xQ.addLast(curX + x);
							yQ.addLast(curY + y);
							dist[curX + x][curY + y] = dist[curX][curY] + 1;
						}
					}
				}
			}

		}
		if(dist[ex-1][ey-1] < Integer.MAX_VALUE) {
			return dist[ex-1][ey-1];
		} else {
			return -1;
		}
	}

	public boolean valid(int x, int y) {
		boolean retVal = false;
		if (x < 0 || x >= H || y < 0 || y >= W || grid[x][y] == '#') {
			retVal =  false;
		} else {
			retVal =  true;
			//System.out.println("isValid: x: "+x + " y: "+y + " "+ retVal);
		}
		
		
		return retVal;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		H = sc.nextInt();
		W = sc.nextInt();
		sx = sc.nextInt();
		sy = sc.nextInt();
		ex = sc.nextInt();
		ey = sc.nextInt();

		String gridPts;
		for (int i = 0; i < H; i++) {
			gridPts = sc.next();
			grid[i] = gridPts.toCharArray();
		}
		Main sol = new Main();
		System.out.println(sol.numMagic());
	}
}

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

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin >> A.at(i);
  }
  sort(A.begin(),A.end());
  reverse(A.begin(),A.end());
  long long sum=0;
  for(int i=0;i<N-1;i++){
    sum+=A.at((i+1)/2);
  }
  cout << sum << endl;
}

Measured memory_bytes: 4044
/**
 *    author:  tourist
 *    created: 25.01.2020 20:24:55       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  n *= 2;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  int ans = 0;
  for (int i = n % 2; i < n; i += 2) {
    ans += a[i];
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
function Main(input){
  var num = parseInt(input);

  // 与えられる数から順に１ずつ引いていき、平方根が整数になる値を求める
  for(var i = num; i >= 1; i--){ 
    if(Math.sqrt(i) % 1 === 0){
      console.log(i);
      break;
    }
  }
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (int i = (int)a; i < (int)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MOD 1000000007
#define INF 1000000000
#define PI 3.14159265359
#define EPS 1e-12

int main(void)
{
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;

  //1
  REP(i, ty-sy) cout << "U";
  REP(i, tx-sx) cout << "R";
  //2
  REP(i, ty-sy) cout << "D";
  REP(i, tx-sx) cout << "L";
  //3
  cout << "L";
  REP(i, ty-sy+1) cout << "U";
  REP(i, tx-sx+1) cout << "R";
  cout << "D";
  //4
  cout << "R";
  REP(i, ty-sy+1) cout << "D";
  REP(i, tx-sx+1) cout << "L";
  cout << "U";

  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int d_num,cur_d;
	int y,m,d;
	int count;
	scanf("%d",&d_num);
	for(cur_d=0;cur_d<d_num;cur_d++) {
		scanf("%d%d%d",&y,&m,&d);
		for(count=0;y<1000;count++) {
			d++;
			if(d>20 || (d==20 && y%3!=0 && m%2==0)) {
				d=1;
				m++;
				if(m>10) {
					m=1;
					y++;
				}
			}
		}
		printf("%d\n",count);
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <cstring>
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef unsigned long long ll;

int main(){
	int N; cin >> N ;
	vector<int> A(N);
	rep(i,N) cin >> A[i];
	vector<int> B(N);
	B = A;
	sort(B.rbegin(),B.rend());
	rep(i,N){
		if(A[i] == B[0]){
			cout << B[1] << endl;
		}
		else
		{
			cout << B[0] << endl;
		}
		
	}

}

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

int main()
{
	map<int,int> numbers;

	numbers[1] = 0;
	numbers[2] = 2;
	numbers[3] = 0;
	numbers[4] = 1;
	numbers[5] = 0;
	numbers[6] = 1;
	numbers[7] = 0;
	numbers[8] = 0;
	numbers[9] = 1;
	numbers[10] = 0;
	numbers[11] = 1;
	numbers[12] = 0;

	int a, b;
	cin >> a >> b;

	if( numbers[a] == numbers[b] ) cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;	
}

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

#define lp(i,n) for(int i=0;i<n;i++)
#define lpin(a,i,n) for(int i=0;i<n;i++){cin>>a[i];}
using namespace std;
int a[10][5],check[10][5];
int main(){
  while(1){
    int n;
    cin>>n;
    if(n==0) break;
    lp(i,10){
      lp(j,5){
	a[i][j]=-1;
	check[i][j]=0;
      }
    }
    
    for(int i=n-1;i>=0;i--){
      lp(j,5){
	cin>>a[i][j];
      }
    }
    int ans=0;
    while(1){
      int r=0;
      lp(i,n){
	lp(j,3){
	  if(a[i][j]!=-1&&a[i][j]==a[i][j+1]&&a[i][j+2]==a[i][j+1]){
	    check[i][j]=1;
	    check[i][j+1]=1;
	    check[i][j+2]=1;
	    r=1;
	  }
	}
      }
      if(r==0) break;
      
      lp(i,n){
	while(1){
	  int x=0;
	  lp(j,5){
	    if(check[i][j]==1){
	      ans+=a[i][j];
	      for(int k=i;k<n;k++){
		a[k][j]=a[k+1][j];
		a[k+1][j]=-1;
		check[k][j]=check[k+1][j];
		check[k+1][j]=0;
		x=1;
	      }
	    }
	  }
	  if(x==0) break;
	}
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}



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

using ll = long long int;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

#define pi 3.14159265358979323846

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




ll cnt_rep = 0;
ll powmod(ll N, ll P, ll M){
  cnt_rep++;
  if(P == 0) return 1;
  if(P%2 == 0){
    ll t = powmod(N, P/2, M);
    return t*t % M;
  }
  return (N * powmod(N, P-1, M)) % M;
}


ll gcd(ll a, ll b){
  ll resi, g, l;
  if(a > b){
    g = a; l = b;
  }else if(b > a){
    g = b; l = a;
  }else{
    return a;
  }
  resi = g % l;
  if(resi != 0){
    return gcd(l, resi);
  }else{
    return l;
  } 
}

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}

int ans = 0;
int N, M, Q;

template<typename T>
void showall(vector<T> v){
  rep(i, 0, v.size()){
    cout << v[i] << " ";
  }
  cout << endl;
}

template<typename T>
ll com(T n, T m, T mod){
  ll a = 1, b = 1, ans;
  if(n == m || m == 0){
    ans = 1;
  }else{
    for(ll i = 0;i < m; i++){
      a *= n-i;
      a %= mod;
      b *= i+1;
      b %= mod;
    }
    ans = (a * powmod(b, mod-2, mod)) % mod;
  }
  
  return ans;
}


 
int main() {
  string S;

  cin >> S;

rep(i, 0, S.length()){
  if(S[i] == '?'){
    S[i] = 'D';
  }
}
cout << S << endl;

}



Measured memory_bytes: 3756
#include<stdio.h>
int main(void){int N,l,i;scanf("%d",&N);int A[N],E[N+1];for(i=0;i<=N-1;i++){scanf("%d",&A[i]);E[A[i]]=i+1;}for(l=1;l<=N;l++)printf("%d ",E[l]);return 0;}

Measured memory_bytes: 1536
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>
#include <numeric>

using namespace std;

#define mod 1000000007

int main()
{
	// 桁数を求める
	int keta = -1;
	for(int i = 1; i <= 10; i++){
		cout << "? " << 1 << string(i - 1, '0') << endl;
		char ans;
		cin >> ans;
		if(ans == 'N'){
			keta = i - 1;
			break;
		}
	}
	if(keta == -1){
		// 1, 10, 100, ... のとき、ここにくる
		for(int i = 1; i <= 10; i++){
			cout << "? " << 2 << string(i - 1, '0') << endl;
			char ans;
			cin >> ans;
			if(ans == 'Y'){
				cout << "! " << 1 << string(i - 1, '0') << endl;
				return 0;
			}
		}
	}

	int l = (int)pow(10, keta - 1);
	int r = (int)pow(10, keta) - 1;
	while(r - l > 1){
		int m = (l + r) / 2;
		cout << "? " << m << "0" << endl;
		char ans;
		cin >> ans;
		if(ans == 'Y') r = m;
		else l = m;
	}
	cout << "! " << r << endl;

}

Measured memory_bytes: 720
/*

Name: Krishan Kant Agnihotri
FROM: University school of information and technology

*/
#include<bits/stdc++.h>
#define ull unsigned long long int
#define ll long long
#define FOR(i,n) for(int i = 0;i<n ;i++)
#define ii pair<int,int>
#define vii vector<ii>
#define vi vector<int>
#define mii map<int,int>
#define uii unordered_map<int,int>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

#define pb push_back
#define MOD 1e9+7
#define INF 0x3f3f3f3f
#define print(x) cout<<x<<"\n";
using namespace std;
;
//use it with unordered_map<T,T,custom_hash> safe_map
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};

int main()
{
    int n;
    cin>>n;
    vi v(n);
    for(int i= 0 ;i<n ;i ++){
        cin>>v[i];
        
    }
    int cnt = 0 ; 
    for(int i = 0 ;i<n ;i+=2){
        if(v[i]&1)
        cnt++;
    }
    cout<<cnt<<endl;
    
}



Measured memory_bytes: 3548
S=input()
N=len(S)+1
A=[]
from itertools import groupby
if S[0]==">":
    S="<"+S
if S[-1]=="<":
    S+=">"
l=[len(list(g)) for k,g in groupby(S)]
ans=0
for i,j in zip(*[iter(l)] * 2):
    M=max(i,j)
    m=min(i,j)
    ans+=M*(M+1)//2 + m*(m-1)//2
print(ans)

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


class Node {
    public:
        char s;
        Node *prev;
        Node *next;
};


int main()
{
    int q;
    int rev;
    int i;
    int t, f;
    char c;

    char s[100000];

    Node *head;
    Node *tail;
    Node *temp;
    head = new Node;
    tail = head;

    cin >> s;
    head->s = s[0];
    head->prev = NULL;
    head->next = NULL;

    i = 1;
    while(s[i] != '\0'){
        temp = new Node;
        temp->s = s[i];
        tail->next = temp;
        temp->prev = tail;
        temp->next = NULL;
        tail = temp;
        i=i+1;
    }

    cin >> q;
    rev = 0;
    for(i=0;i<q;i++){
        cin >> t;

        if(t==1){
            temp = head;
            head = tail;
            tail = temp;
            if(rev == 0){
                rev = 1;
            }else{
                rev = 0;
            }
        }else{
            cin >> f;
            cin >> c;

            if(f == 1){
                temp = new Node;
                temp->s = c;
                if(rev == 0){
                    head->prev = temp;
                    temp->next = head;
                    temp->prev = NULL;
                    head = temp;
                }else{
                    head->next = temp;
                    temp->prev = head;
                    temp->next = NULL;
                    head = temp;
                }
            }else{
                temp = new Node;
                temp->s = c;
                if(rev == 0){
                    tail->next = temp;
                    temp->prev = tail;
                    temp->next = NULL;
                    tail = temp;
                }else{
                    tail->prev = temp;
                    temp->next = tail;
                    temp->prev = NULL;
                    tail = temp;
                }
            }
        }
    }

    temp = head;
    while(1){
        cout << temp->s;
        if(rev == 0){
            temp = temp->next;
        }else{
            temp = temp->prev;
        }
        if(temp == NULL){
            break;
        }
    }

    return 0;

}

Measured memory_bytes: 9984
#include<iostream>
#include<algorithm>
#include<climits>
#include<vector>
#include<utility>
#include<cmath>
#include<string>
#include<cstring>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) std::cout<<arg<<"\n"
#define prin2(arg1,arg2) std::cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) memset(arg,n,sizeof(arg))
using std::cin;
typedef long long ll;
typedef std::pair<int,int> pi;
typedef std::vector<int> vi;
const int INF=1e+9;
const ll INFLL=1e+17;
int Q;
ll A[110],B[110];
ll f(ll x){
  return (x+1)/2*(x+1-(x+1)/2);
}
ll bina(ll l,ll r,ll a,ll b){
  ll lb=l-1,ub=r+1;
  while(ub-lb>1){
    ll mid=(lb+ub)/2;
    if(f(mid)<a*b) lb=mid;
    else ub=mid;
  }
  return lb;
}
void solve(int i){
  if(A[i]==B[i]) prin(2*A[i]-2);
  else{
    ll x=bina(0,A[i]+B[i]-2,A[i],B[i]);
    prin(x-1);
  }
}
int main(){
  cin>>Q;
  rep(i,Q) cin>>A[i]>>B[i];
  rep(i,Q) solve(i);
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	Scanner sc = new Scanner(System.in);
	void run() {
		double arg = 0;
		double len = 0;
		double x = 0;
		double y = 0;
		while (true) {
			String[] str = sc.next().split(",");
			if (str[0].equals("0") && str[1].equals("0")) break;
			len = Double.parseDouble(str[0]);
			x += len * Math.sin(arg/180*Math.PI);
			y += len * Math.cos(arg/180*Math.PI);
			arg += Double.parseDouble(str[1]);
		}
		System.out.println((int)(x));
		System.out.println((int)(y));
	}
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 12000