akhauriyash/Code-Regression huggingface dataset:
(let* ((h (read))
       (w (read))
       (lst (loop repeat h
                  collect (read-line)))
       (lst2 lst)
       (lst3 (loop for i in lst
                   for j in lst2
                   collect (cons i (cons j nil)))))

  (format t "~{~{~A~%~}~}" lst3))


Measured memory_bytes: 24628
def solve(n):

    while len(n) > 4:
        if n[-5:] == "dream":
            n = n[:-5]
        elif n[-7:] == "dreamer":
            n = n[:-7]
        elif n[-5:] == "erase":
            n = n[:-5]
        elif n[-6:] == "eraser":
            n = n[:-6]
        else:
            break

    return "YES" if len(n) == 0 else "NO"

if __name__ == "__main__":
    n = input()
    print(solve(n))


Measured memory_bytes: 3316
import sys
import math
import collections
import bisect
import itertools

# import numpy as np

sys.setrecursionlimit(10 ** 7)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline().rstrip())
ns = lambda: map(int, sys.stdin.readline().rstrip().split())
na = lambda: list(map(int, sys.stdin.readline().rstrip().split()))
na1 = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().rstrip().split()))


# ===CODE===

def main():
    w, b = ns()
    l = 100
    mat = [["#" for _ in range(l)] for __ in range(l)]

    if w == 1 and b == 1:
        mat[0][0] = "."

    cnt = 0
    breakflg = False
    tmp = 1 if b > 1 else 0
    flg = False
    for i in range(0, l - 3, 3):
        for j in range(0, l - 3, 3):
            if not flg:
                if cnt < w - tmp:
                    around = "#"
                    center = "."
                else:
                    flg = True
                    break

            if flg:
                if cnt < w - tmp + b - 1:
                    around = "."
                    center = "#"
                else:
                    breakflg = True
                    break




            for n in range(3):
                for m in range(3):
                    mat[i + n][j + m] = center if n == 1 and m == 1 else around
            cnt += 1
        if breakflg:
            break

    print(l, l)
    for mi in mat:
        print(*mi, sep="")


if __name__ == '__main__':
    main()


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

int main() {
    string s1,s2;
    while (cin >> s1 >> s2)
    {
        if(s1==s2){
            cout << "IDENTICAL" << endl;
            continue;
        }

        vector<string> ss1(1, "");
        int cnt=0;
        bool flg1=0;
        for (int i = 0; i < s1.size(); i++)
        {
            if(flg1==0){
                if (s1.at(i)=='"'){
                    ++cnt;
                    ss1.push_back("");
                    flg1=1;
                }
                ss1.at(cnt)+=s1.at(i);
            }else{
                ss1.at(cnt)+=s1.at(i);
                if (s1.at(i)=='"'){
                    ++cnt;
                    ss1.push_back("");
                    flg1=0;
                }
            }
        }
        vector<string> ss2(1, "");
        cnt=0;
        flg1=0;
        for (int i = 0; i < s2.size(); i++)
        {
            if(flg1==0){
                if (s2.at(i)=='"'){
                    ++cnt;
                    ss2.push_back("");
                    flg1=1;
                }
                ss2.at(cnt)+=s2.at(i);
            }else{
                ss2.at(cnt)+=s2.at(i);
                if (s2.at(i)=='"'){
                    ++cnt;
                    ss2.push_back("");
                    flg1=0;
                }
            }
        }

        if(ss1.size()!=ss2.size()){
            cout << "DIFFERENT" << endl;
            continue;
        }
        bool flg=0;
        for (int i = 0; i < ss1.size(); i+=2)
        {
            if(ss1.at(i) != ss2.at(i)){
                cout << "DIFFERENT" << endl;
                flg=1;
                break;  
            }
        }
        if(flg==1) continue;

        cnt=0;
        for (int i = 1; i < ss1.size(); i+=2)
        {
            if(ss1.at(i) != ss2.at(i)){
                ++cnt;
            }
        }
        if(cnt<=1){
            cout << "CLOSE" << endl;
        }else{
            cout << "DIFFERENT" << endl;
        }
               
    }
}
//g++ -o b.exe b.cpp


Measured memory_bytes: 3136
import collections
import math

n = int(input())
str_L = []

for val in range(n):
    s = input()
    s_L = [i for i in s]
    s_L.sort()
    s = "".join(s_L)
    str_L.append(s)


c = collections.Counter(str_L)

str_L = list(set(str_L))


ans = 0
r = 2

def combinations_count(n, r):
    try:
        return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
    except:
        return 0

for val in str_L:
    n = c[val]
    #print(n,r)
    ans = ans + combinations_count(n,r) #comb(n, r, exact=True)

print(ans)

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

int main() {
    int n,k,b[200010]={};
    // 配列の初期化
    for(int i=0;i<200010;i++){
        b[i] = 0;
    }    
    cin >> n >> k;
    //入力 + 初めて登場(?)した数があれば種類(cnt)をインクリメント
    int tmp;
    int cnt = 0;
    for(int i=0;i<n;i++){
		cin >> tmp;
        if(b[tmp] == 0){
            cnt++;
        }
        b[tmp]++;
	}
    // ボールの数が少ない順にソート
	sort(b,b+200010);
    // もともとK種類以下なら0を出力
	if(cnt<=k){
		cout << 0 << endl;
		return 0;
	}
	int sum=0;
    // cntがKになるまでb[i]の値をsumに足していく
    int j = 0;
	while(cnt > k){
        //b[j] == 0の時ボールの種類(=cnt)は減らない
        if(b[j] != 0){
            sum += b[j];
            cnt--;
        }
        j++;
    }
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 1532
#include <stdio.h>

int main(){
  char str[20], str2[20];
  int i=0, j=0;
  scanf("%s", str);
  while( str[i] != '\0'){
    i++;
  }

  while( i >= 0){
    str2[j] = str[i-1];
    //printf("%c", str[i]);
    i--;
    j++;
  }
  str[j] = '\0';
  printf("%s\n", str2);

  return 0;
}

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

bool acgt(char c){
  return c=='A'||c=='C'||c=='G'||c=='T';
}

int main() {
  string S;cin>>S;
  int l=0,r=0,m=0;
  while(r<S.size()){
    if(acgt(S[r])){m=max(m,r-l+1);r++;}
    else {l=r+1;r=l;}
  }
  cout<<m<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
int max=0, ans=0;
string s;
cin>>s;
for(int i=0; i<s.length(); i++)
{
if(s[i]=='R')
max++;
else if(s[i]=='S')
max=0;
if(max>ans)
ans=max;
}
cout<<ans<<endl;
return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if ((abs(a-b)<=d&&abs(b-c)<=d)||abs(a-c)<=d) {
        cout<<"Yes"<<endl;
    } else {
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<queue>

using namespace std;

#define REP(i,e,s) for(register int i=(e); i<=(s); i++)
#define DREP(i,e,s) for(register int i=(e); i>=(s); i--)
#define ll long long
#define DE(...) fprintf(stderr,__VA_ARGS__)
#define DEBUG(a) DE("DEBUG: %d\n",a)
#define file(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout)
int read() {
	int x=0,f=1,ch=getchar();
	while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

const int MAXN=400+10;

int n,m;

char a[MAXN][MAXN];

queue<pair<int,int> > q;

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

int bfs(int x,int y) {
	int dis[25][25];
	REP(i,1,n) REP(j,1,m) dis[i][j]=1000;
	q.push(make_pair(x,y));
	dis[x][y]=0;
	while(!q.empty()) {
		int x=q.front().first,y=q.front().second;
		q.pop();
		REP(i,1,4) {
			int xx=dx[i]+x,yy=dy[i]+y;
			if(xx<1||xx>n||yy<1||yy>m||a[xx][yy]=='#') continue;
			if(dis[xx][yy]>dis[x][y]+1) {
				dis[xx][yy]=min(dis[xx][yy],dis[x][y]+1);
				q.push(make_pair(xx,yy));
			}
		}
	}
	int ans=0;
	REP(i,1,n) REP(j,1,m) if(dis[i][j]!=1000) ans=max(ans,dis[i][j]);
	return ans;
}

int main() {
	n=read(),m=read();
	REP(i,1,n) {REP(j,1,m) a[i][j]=getchar();getchar();}
	int ans=0;
	REP(i,1,n) REP(j,1,m) if(a[i][j]!='#') ans=max(ans,bfs(i,j));
	
	printf("%d\n",ans);
	return 0;
}



Measured memory_bytes: 256
import itertools
def resolve():
    n=int(input())
    p=tuple(map(int,input().split()))
    q=tuple(map(int,input().split()))
    l=list(range(1,n+1))
    chk=list(itertools.permutations(l))
    a=chk.index(p)
    b=chk.index(q)
    print(abs(a-b))

resolve()

Measured memory_bytes: 45168
#include <cstdio>
#include <algorithm>
using namespace std;
int main() {
	int X, ans = 0;
	scanf("%d", &X);
	ans += X / 500 * 1000;
	X %= 500;
	ans += X / 5 * 5;
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <chrono>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define eps 1e-9

typedef long long ll;

using namespace std;

const int N = 1e5;
int a[N+5];

int main()

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

    int n, sum = 0;

    cin >> n;

    n*=2;

    int arr[n];

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

        cin >> arr[i];
    }

    sort(arr, arr+n);

    for (int i = 0; i < n; i+=2) {

        sum+=arr[i];
    }

    cout << sum;

    return 0;
}


Measured memory_bytes: 256
// G++ MACro.cpp -std=c++14
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
 
#define dump(x)  cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
 
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
 
#define FOREACH(x,a) for(auto& (x) : (a) )
 
#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j])
 
#define SCOUT(x) cout<<(x)<<" "
#define ENDL cout<<endl
 
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i]
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<endl
 
#define ALL(obj) (obj).begin(),(obj).end()
 
#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())
#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)
 
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision; // cpp_int
 
#define P pair<int,int>
#define V vector<int>
#define M map<int,int>
#define S set<int>
#define L list<int>
 
#define pb(a) push_back(a)
#define mp make_pair

int main(){
  CIN(n);V v(n*2);VECCIN(v);
  sort(ALL(v));
  reverse(ALL(v));
  ll ans=0;
  REP(i,n){
    ans+=min(v[i*2],v[i*2+1]);
  }
  COUT(ans);

  return 0;
}


Measured memory_bytes: 256
/* while(!success_achieved())
      work_hard();

   code by:aman_ayush
  */
#include <bits/stdc++.h>
using namespace std;

#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define ll long long
#define ldb long double 
#define db double
#define str string

#define fr first
#define se second
#define lb lower_bound 
#define ub upper_bound 
#define pb push_back
#define mp make_pair

#define pi pair<int,int>
#define pll pair<ll,ll>
#define pdb pair<db,db>
#define pldb pair<ldb,ldb>

#define vi vector<int>
#define vll vector<ll>
#define vdb vector<db>
#define vldb vector<ldb>
#define vpi vector< pi >
#define vpll vector< pll >

#define mi map<int,int>
#define mll map<ll,ll>
#define mdb map<db,db>
#define mldb map<ldb,ldb>


#define forr(a,b) for (int i = (a); i < (b); ++i)
#define rrof(a,b) for (int i = (b)-1; i >= (a); --i)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)

const int MOD = 1e9+7;
const int MX = 2e5+5;
const ll INF = 1e18; 
const ldb PI = 4*atan((ldb)1);

ll power(ll a,ll n)
{
 ll res=1;
 while(n)
{
 if(n%2)
  res*=a;
  a*=a;
  n/=2;
}
return res;
}

ll abst(ll a)
{
 return ((a<0)?(-1*a):(a));
}

int main()
{
     int m,k;
     cin>>m>>k;
     int p=power(2,m);
     if(k>=p)
      cout<<-1<<"\n";
      else
      {
          if(m==0)
           cout<<0<<" "<<0<<"\n";
           else if(m==1)
           {
               if(k==0)
                cout<<0<<" "<<0<<" "<<1<<" "<<1<<"\n";
               else 
                cout<<-1<<"\n";
           }
           else
           {
               for(int i=0;i<p;i++)
               {
                   if(i!=k)
                    cout<<i<<" ";
               }
               cout<<k<<" ";
               for(int i=p-1;i>=0;i--)
               {
                   if(i!=k)
                    cout<<i<<" ";
               }
                cout<<k<<" ";
                cout<<"\n";
           }
      }
     return 0;
}

Measured memory_bytes: 1920
def modpow(val, n, mod):
    ret = 1
    while n:
        if n & 1:
            ret = (ret * val) % mod
        val = (val * val) % mod
        n = n >> 1
    return ret

n = int(input())
a_list = list(map(int, input().split()))

a_list.sort()

if n % 2 != 0:
    if a_list[0] != 0:
        print(0)
        exit()
    else:
        a_list = a_list[1:]

if n % 2 == 0:
    for i in range(len(a_list)):
        if a_list[i] != ((i // 2) + 1) * 2 - 1:
            print(0)                                                                                        
            exit() 
else:    
    for i in range(len(a_list)):
        if a_list[i] != ((i // 2) + 1) * 2:
            print(0)
            exit()

print(modpow(2, len(a_list) // 2, (10 ** 9) + 7))



Measured memory_bytes: 52300
n=int(input())
l=[[j for j,k in enumerate(input())if k=="1"]for i in range(n)]
class UnionFind:
    #def   -> foo=UnionFind(n,1)  <- 1-based index, default is 0
    #method -> foo.hoge(huga)
    __slots__ = ["_size", "_first_idx", "_parents"]
    def __init__(self, size: int, first_index: int = 0) -> None:
        self._size = size
        self._first_idx = first_index
        self._parents = [-1] * (size + first_index)
    def find(self, x: int) -> int:
        if self._parents[x] < 0:
            return x
        self._parents[x] = self.find(self._parents[x])
        return self._parents[x]
    def same(self, x: int, y: int) -> bool:
        return self.find(x) == self.find(y)
    def unite(self, x: int, y: int) -> bool:
        x, y = self.find(x), self.find(y)
        if x == y:
            return False
        if self._parents[x] > self._parents[y]:
            x, y = y, x
        self._parents[x] += self._parents[y]
        self._parents[y] = x
        return True
    def size(self, x: int) -> int:
        return -self._parents[self.find(x)]
    def group_count(self) ->int:
        return sum(1 for i in  self._parents if i<0)-self._first_idx
    def connected(self) ->bool:
        return self._parents[self.find(self._first_idx)]==-self._size
uf=UnionFind(2*n)
for i in range(n):
    for ne in l[i]:
        uf.unite(i,ne+n)
        uf.unite(i+n,ne)

if uf.same(0,n):
    print(-1)

else:
    class WarshallFloyd:
        #O(V^3)で任意２頂点の最短距離
        def __init__(self,n,_first_index=0):
            self.v = n
            self._first_idx=_first_index
            self.d = [[float("INF")]*(n) for _ in range(n)]
            for i in range(n):
                self.d[i][i] = 0
    
        def path(self,x,y,c):
            if x == y:
                return False
            f=self._first_idx
            self.d[x-f][y-f] = c
            self.d[y-f][x-f] = c
            return True
    
        def build(self):
            for k in range(self.v):
                for i in range(self.v):
                    for j in range(self.v):
                        self.d[i][j] = min(self.d[i][j], self.d[i][k] + self.d[k][j])
            return self.d
    w=WarshallFloyd(n)
    for x in range(n):
        for j in l[x]:
            w.path(x,j,1)
    d=w.build()
    ans=0
    for i in range(n):
        ans=max(ans,max(d[i]))
    print(ans+1)


Measured memory_bytes: 57688
#include <atcoder/twosat>
#include <bits/stdc++.h>

using namespace std;

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

    atcoder::two_sat sat(n * 2);
    vector<int> x(n), y(n);

    for (int i = 0; i < n; i++) {
        cin >> x[i] >> y[i];
        sat.add_clause(i, false, n + i, false);
        sat.add_clause(i, true, n + i, true);
    }

    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            if (i == j) continue;
            if (abs(x[i] - x[j]) < d) {
                sat.add_clause(i, false, j, false);
            }
            if (abs(x[i] - y[j]) < d) {
                sat.add_clause(i, false, n + j, false);
            }
            if (abs(y[i] - x[j]) < d) {
                sat.add_clause(n + i, false, j, false);
            }
            if (abs(y[i] - y[j]) < d) {
                sat.add_clause(n + i, false, n + j, false);
            }
        }
    }

    bool b = sat.satisfiable();

    if (b) {
        cout << "Yes\n";
        auto ans = sat.answer();
        for (int i = 0; i < n; i++) {
            if (ans[i]) {
                cout << x[i] << "\n";
            } else {
                cout << y[i] << "\n";
            }
        }
    } else {
        cout << "No\n";
    }
    return 0;
}

Measured memory_bytes: 3760
# pythonでスタック、キューを実現するためにdequeをimport
from collections import deque

N, M = map(int, input().split())

# 辺集合EとグラフGの構築
G = [[] for _ in range(N)]
E = []
for _ in range(M):
    a, b = map(int, input().split())
    # 入力は1-indexedだがこれを扱いやすいように0-indexedに変更
    a -= 1
    b -= 1
    E.append((a, b))
    G[a].append(b)
    G[b].append(a)
# print(G)

# 橋を数えるための変数cntを用意
cnt = 0
for edge_to_remove in E:
    # 橋であるか判定したい辺を取り除いてみる
    i, j = edge_to_remove
    G[i].remove(j)
    G[j].remove(i)

    # 深さ優先探索
    seen = [False] * N
    todo = deque()
    # 適当な頂点から深さ優先探索をスタート（ここでは頂点0をスタートに選んだ）
    todo.append(0)
    seen[0] = True
    seen_nodes_num = 0
    while todo:
        here = todo.popleft()
        seen_nodes_num += 1
        for neighbor in G[here]:
            if seen[neighbor] == False:
                seen[neighbor] = True
                todo.append(neighbor)
    # print(seen)
    # もし訪問できていない頂点があれば連結でないというなので今着目している辺は橋であった！
    if seen_nodes_num != N:
        cnt += 1

    # 次の辺について調べるために今取り除いた辺を再びGに戻しておく
    G[i].append(j)
    G[j].append(i)
print(cnt)


Measured memory_bytes: 3316
#include <vector>
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>

using namespace std;


int main(void){
  
  long long X,ans=0,money=100;


  cin >> X;
  while(1){
    ans++;
    money*=1.01;
    if(money>=X){
      break;
    }
  }
 
  cout << ans << endl;

  return 0;
}




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

int main() {
	string o, e;
	cin >> o >> e;
	for (int i = 0; i < e.size(); i++)
		cout << o[i] << e[i];
	if (o.size() != e.size())
		cout << o[o.size() - 1];
	return 0;
}

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

using namespace std;

int main() {
	int N, K;
	cin >> N >> K;

	string buf;
	getline(cin, buf);

	cout << ceil((float)(N - 1) / (float)(K - 1)) << endl;
	return 0;
}

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

ll keta(ll n) {
    ll res = 0;
    ll p = 1;
    while(n >= p) {
        p *= 10;
        res++;
    }
    return res;
}

int main() {
    int h, w;
    cin >> h >> w;
    vector<vector<char> > a(h, vector<char>(w));
    rep(i, h) rep(j, w) cin >> a[i][j];
    rep(i, w + 2) cout << '#';
    cout << endl;
    rep(i, h) {
        rep(j, w + 2) {
            if(j == 0 || j == w + 1) cout << '#';
            if(j == w + 1) cout << endl;
            if(1 <= j && j <= w) cout << a[i][j - 1];
        }
    }
    rep(i, w + 2) cout << '#';

    cout
        << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<iomanip>
#include<map>
#include<utility>
#include<string>
#include<unordered_map>
#include<queue>

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

using namespace std;

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

int gcd(int a, int b){return b ? gcd(b, a%b) : a;}

int main(){
    int a, b, m;
    int fridge_min = 1000000, microwave_min = 1000000;
    cin >> a >> b >> m;
    vector<int> fridge(a), microwave(b), x(m), y(m), c(m);
    for(int i = 0; i < a; i++){
        cin >> fridge[i];
        fridge_min = min(fridge_min, fridge[i]);
    }
    for(int i = 0; i < b; i++){
        cin >> microwave[i];
        microwave_min = min(microwave_min, microwave[i]);
    }
    int ans = 1000000007;
    for(int i = 0; i < m; i++){ //割引券使った時の最小値
        int x, y, c;
        cin >> x >> y >> c;
        int use_ticket = fridge[x-1]+microwave[y-1]-c;
        ans = min(ans, use_ticket);
    }
    ans = min(ans, fridge_min+microwave_min);
    cout << ans << endl;
    return 0;
}


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

int main() {
    int w, h, n;
    cin >> w >> h >> n;
    int x[110], y[110], a[110];
    int right = 0, left = w, down = 0, up = h;
    for(int i = 0; i < n; ++i) {
        cin >> x[i] >> y[i] >> a[i];
        if(a[i] == 1) right = max(x[i], right);
        if(a[i] == 2) left = min(x[i], left);
        if(a[i] == 3) down = max(y[i], down);
        if(a[i] == 4) up = min(y[i], up);
    }
    
    cout << max(left - right, 0) * max(up - down, 0) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define N 22
#define LL long long
const LL inf=5e18;
int n,a[N];
LL solve(int l,int r,LL x,LL y){
	if (l+1>=r) return 0;
	LL res=inf;
	for (int i=l+1;i<=r-1;++i){
		res=min(res,solve(l,i,x,x+y)+solve(i,r,x+y,y)+a[i]*(x+y));
	}
	return res;
}
signed main(){
	scanf("%d",&n);
	for (int i=1;i<=n;++i) scanf("%lld",&a[i]);
	cout<<a[1]+a[n]+solve(1,n,1,1)<<endl;
}

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

int main(){
  int h,w;
  cin>>h>>w;
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++){
      string str;
      cin>>str;
      if(str=="snuke") cout<<(char)('A'+j)<<i+1<<endl;
    }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int INF = 100000000;
int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++){
    cin >> a[i];
  }
  int ans = INF;
  for (int i = -100; i <= 100; i++){
    int tmp = 0;
    for (int j = 0; j < N; j++){
      tmp += (a[j] - i) * (a[j] - i);
    }
    ans = min(ans, tmp);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm> 
#include <cstdlib>
#include <map>
#include <queue>
#include <vector>
#include <utility>
#include <climits>
#include <numeric>
#define ll long long
#define INF INT_MAX 
using namespace std;
int main(){
    string s;
    cin >> s;
    int r=0,b=0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='0'){
            r++;
        }else{
            b++;
        }
    }
    cout << min(r,b)*2 << endl;
}

Measured memory_bytes: 512
n,m=map(int,input().split())
h=list(map(int,input().split()))
flag=[1]*n
for i in range(m):
    a,b = map(int,input().split())
    a-=1
    b-=1
    if h[a] == h[b]:
        flag[a] =0
        flag[b] =0
    elif h[a] > h[b]:
        flag[b] = 0
    else:
        flag[a] = 0
print(sum(flag))

Measured memory_bytes: 20096
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <memory.h>
using namespace std;

int h,w,n,a[10005],ans[105][105],id=1,dir=1,row=1;

void paint(int i){
	while(a[i]){
		if(dir==1){
			ans[row][id]=i;
			a[i]--;
			id++;
			if(id>w){
				row++;
				id--;
				dir=-1;
			}
		}
		else if(dir==-1){
			ans[row][id]=i;
			a[i]--;
			id--;
			if(id<1){
				row++;
				id++;
				dir=1;
			} 
		}
	}
}

int main(){
	scanf("%d%d%d",&h,&w,&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		paint(i);
	}
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			if(j>1) printf(" ");
			printf("%d",ans[i][j]); 
		}
		printf("\n");
	}
return 0;
} 

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t K, A, B;
  cin >> K >> A >> B;
  if(A >= K){
    cout << 1 << endl;
  }
  else{
    if(A <= B){
      cout << -1 << endl;
    }
    else{
      K -= A;
      int64_t ans = (K+(A-B-1)) / (A-B);
      cout << ans*2 + 1 << endl;
    }
  }
}

Measured memory_bytes: 3564
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	n = readline() |> parseInt
	a = Tuple{Int,Int,Int}[(0,0,0) for i in 1:n]
	for i in 1:n
		p,q = readline() |> split |> parseMap
		a[i] = (p,q,p+q)
	end
	a = sort(a,by=x->x[3],rev=true)
	x = 0
	y = 0
	for i in 1:n
		if i%2==1
			x+=a[i][1]
		else
			y+=a[i][2]
		end
	end
	println(x-y)
end

main()

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

using namespace std;

using ll = long long;
using ull = unsigned long long;

template <typename T> inline void print(T val) { cout << val << '\n'; }

template <typename Iterator> inline void print(Iterator begin, Iterator end) {
  for (auto it = begin; it != end; it = next(it)) {
    cout << *it << ' ';
  }
  cout << '\n';
}

template <class T> inline T square(T x) {
  T result;
  result = x * x;
  return result;
};

#ifdef LOCAL
#define DBG_MACRO_NO_WARNING
#include <dbg.h>
#else
#define dbg(...) 0
#endif

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

int main() {
#ifdef LOCAL
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);

  auto start = chrono::steady_clock::now();
#endif

  int x, y, a, b, c;
  cin >> x >> y >> a >> b >> c;

  vector<int> p(a), q(b), r(c);

  for (auto &i : p) {
    cin >> i;
  }
  for (auto &i : q) {
    cin >> i;
  }
  for (auto &i : r) {
    cin >> i;
  }

  sort(p.rbegin(), p.rend());
  sort(q.rbegin(), q.rend());

  copy(p.begin(), p.begin() + x, back_inserter(r));
  copy(q.begin(), q.begin() + y, back_inserter(r));

  sort(r.rbegin(), r.rend());

  ll ans = 0;

  ans = accumulate(r.begin(), r.begin() + x + y, ans);

  print(ans);

#ifdef LOCAL
  auto end = chrono::steady_clock::now();
  auto diff = end - start;

  cout << "Duration: " << chrono::duration<double, milli>(diff).count() << " ms"
       << '\n';
#endif

  return 0;
}


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

#define mod 1000000007

using namespace std;
 
int main(void){
	
	int N;
	
	cin >> N;
	
	int d[N], K;
	
	for(int i=0; i<N; i++)
		cin >> d[i];
	
	sort(d, d+N);
	
	cout << d[N/2] - d[(N/2)-1];
	
	return 0;
}

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

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

  int n,a,d;
  cin >> n >> a >> d;

  int m;
  cin >> m;
  vector<int> x(m),y(m),z(m);
  for(int i=0;i<m;i++){
    cin >> x[i] >> y[i] >> z[i];
  }

  int k;
  cin >> k;

  stack<int> task;
  for(int i=m-1;i>=0;i--){
    if(y[i] <= k && k <= z[i]){
      if(x[i] == 0){
	int dif = z[i] - k;
	k = y[i] + dif;
      }else{
	task.push(x[i]);
      }
    }
  }

  int val = a + d*(k-1);
  while(!task.empty()){
    if(task.top() == 1){
      val++;
    }else{
      val /= 2;
    }
    task.pop();
  }
  cout << val << endl;
}

Measured memory_bytes: 5244
# maspyさんの見て書いた。
# 最初自分で書いたけど、改善していたらほぼ写経になってしまった。。。

from collections import defaultdict

n = int(input())
m = 10**9+7

dp = [defaultdict(int) for i in range(n+1)]
dp[0]['']=1

def check(s):
    if 'AGC' in s:
        return False
    for i in range(len(s)-1):
        l = list(s)
        l[i],l[i+1]=l[i+1],l[i]
        t = ''.join(l)
        if 'AGC' in t:
            return False
    return True

for i in range(n):
    for k,v in dp[i].items():
        for x in 'AGCT':
            y = k[-3:]+x
            if check(y):
                dp[i+1][y]+=v

print(sum(dp[n].values())%m)



Measured memory_bytes: 48860
N, K = [int(v) for v in input().split()]

kcnt = [0] * K

for i in range(1, N + 1):
    kcnt[i % K] += 1

ans = 0
for a in range(1, K + 1):  # aを固定
    b = K - (a % K)
    c = K - (a % K)
    if (a + b) % K == 0 and (a + c) % K == 0 and (b + c) % K == 0:
        ans += kcnt[a%K] * kcnt[b%K] * kcnt[c%K]

print(ans)

Measured memory_bytes: 4596
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define scan(n) scanf("%d",&n)
#define ls(n) scanf("%lld",&n)
#define print(n) printf("%d",n)
#define pln(n) printf("%d\n",n)
#define lpln(n) printf("%lld\n",n)
#define rep(i,a,n) for(int i=a;i<n;i++)
#define rev(i,a,n) for(int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define tc           ll t1; cin>>t1; while(t1--)
#define inp         ll n; cin>>n; ll arr[n]; rep(i,0,n) cin>>arr[i];
#define vect vector<ll>
#define sortv(v)       sort(v.begin(),v.end())
#define lower(v,n)    lower_bound(v.begin(),v.end(),n)-v.begin()
#define upper(v,n)    upper_bound(v.begin(),v.end(),n)-v.begin()
#define all(v)        v.begin(),v.end()
#define bitcount(n) __builtin_popcount(n)
#define ln <<endl
#define inf          1e12+5
#define ninf         -1e17
#define fast()         ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
const   ll mod=1e9+7;
const ll N=1e6+5;
int minp[N];
int counter[N];

void fun(){
    for (int i = 2; i * i < N; ++i) {
      if (minp[i] == 0) { 
          for (int j = i * i; j < N; j += i) {
              if (minp[j] == 0) {
                  minp[j] = i;
              }
          }
      }
  }
  for (int i = 2; i < N; ++i) {
      if (minp[i] == 0) {
          minp[i] = i;
      }
  }
}




int main() 
{ 
          fast();
         
          fun();
          int n;
          cin >> n;
          bool f=0;
          int a[n];
          rep(i,0,n)
          cin >> a[i];
          rep(i,0,n) {
            int temp=a[i];
            set<int> s;
            while(temp>1){
             // cout<<minp[temp]<<endl;
              s.insert(minp[temp]);
              temp/=minp[temp];
            }

            for(auto i=s.begin(); i!=s.end();i++){
             // cout<<*i<<" ";
              counter[*i]++;
            }
           // cout<<endl;
          }

          rep(i,0,N)
          if(counter[i]>1)
            f=1;
          if(f==0){
            cout<<"pairwise coprime";
            return 0;
          }

          int hcf=a[0];
          rep(i,1,n)
          hcf=gcd(hcf,a[i]);
          if(hcf==1){
            cout<<"setwise coprime";
            return 0;
          }
          cout<<"not coprime";

          

          
           return 0; 

} 

Measured memory_bytes: 15184
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N;
  cin >> N;
  vector<int> ws(N);
  int sum = 0;
  F0R(i, N) {
    cin >> ws[i];
    sum += ws[i];
  }
  int result = sum;
  int a = 0;
  F0R(i, N) {
    a += ws[i];
    sum -= ws[i];
    chmin(result, abs(sum - a));
  }
  cout << result;
}
#endif


Measured memory_bytes: 3600
k,q = map(int,input().split())
dbase = list(map(int,input().split()))
for _ in range(q):
  n,x,m = map(int,input().split())
  x %= m
  dls = [d%m for d in dbase]
  q,r = divmod(n-1,k)
  end = x
  minus = 0
  for i in range(k):
    if i < r:
      end += dls[i]*(q+1)
      if dls[i] == 0:
        minus += q+1
    else:
      end += dls[i]*q
      if dls[i] == 0:
        minus += q
  minus += end//m
  print(n-minus-1)

Measured memory_bytes: 64860
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod
#define N 100010
ll n,m;
vector<ll> g[N];
ll col[N],cnt[2];
bool dfs(ll x,ll c){
	if(~col[x]){
		return c==col[x];
	}
	col[x]=c;
	cnt[c]++;
	for(auto y:g[x]){
		if(!dfs(y,c^1))return 0;
	}
	return 1;
}
ll val[N],dp[N],dq[N];
int main(){
	cin>>n>>m;
	rep(i,m){
		ll a,b; cin>>a>>b;
		a--,b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	rep(i,N)val[i]=0;
	rep(i,n)col[i]=-1;
	bool ok=1;
	ll base=0;
	rep(i,n){
		if(col[i]==-1){
			rep(k,2)cnt[k]=0;
			if(!dfs(i,0))ok=0;
			if(cnt[0]>cnt[1])swap(cnt[0],cnt[1]);
			base+=cnt[0];
			val[cnt[1]-cnt[0]]++;
		}
	}
	rep(i,N)dp[i]=0; dp[0]=1;
	for(ll d=1;d<N;d++)if(val[d]>0){
		rep(i,N)dq[i]=(dp[i]>0);
		rep(i,N){
			if(i-d>=0){
				dp[i]=dp[i-d]+dq[i];
				ll id=i-d*(val[d]+1);
				if(id>=0)dp[i]-=dq[id];
			}
			else{
				dp[i]=dq[i];
			}
		}
	}
	ll ans=0;
	rep(i,N)if(dp[i]>0){
		ll x=i+base;
		chmax(ans,x*(n-x)-m);
	}
	if(ok==0)ans=-1;
	cout<<ans<<endl;
}




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

#define rep(ver,n) rep2(ver,0,n)
#define rep2(ver,m,n) for(int ver=m;ver<(n);ver++)
#define loop while(true)
#define dup(x,y) (((x)+(y)-1)/(y))
#define all(v) (v).begin(), (v).end()
#define debug(x) std::cerr<<#x<<": "<<x<<"\n"
#define debug2(x,y) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<"\n"
#define debug3(x,y,z) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<", "<<#z<<": "<<z<<"\n"

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

int main(){
  int n;
  char c[300000];
  
  cin>>n;
  scanf("%s",c);
  
  int rc=0;
  
  rep(i,n){
    if(c[i]=='R')rc++;
  }
  
  if(rc==0){
    cout<<0;
    return 0;
  }
  
  int wc=0;
  rep(i,n){
    char now=c[i];
    if(now=='R')rc--;
    else wc++;
    if(rc==wc)break;
  }
  
  cout<<wc;
  
  return 0;
}


Measured memory_bytes: 3856
#include<stdio.h>
int main(void)
{
  long long int count=0,min,max,try;
  scanf("%lld%lld",&min,&max);
  try=min;
  while(try<=max)
  {
    count++;
    try=try*2;
  }
  printf("%lld",count);
  return 0;
}

Measured memory_bytes: 128
x = input()
x = x[::-1]

while True:
  if x[:5] == "maerd":
    x = x[5:]
  elif x[:7] == "remaerd":
    x = x[7:]
  elif x[:5] == "esare":
    x = x[5:]
  elif x[:6] == "resare":
    x = x[6:]
  else:
    break
    
if len(x) == 0:
  print("YES")
else:
  print("NO")

Measured memory_bytes: 3188
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String T = sc.next();
        String S = sc.next();
 
        int res = (int)1e9;
        int legth = (T.length() - S.length()) + 1;
        for (int index = 0; index < legth; index++) {
            int count = 0;
            for (int j = 0; j < S.length(); j++) {
                if (S.charAt(j) != T.charAt(index + j)) {
                    count++;
                }
            }
            if(count < res) {
                res = count;
            }
        }
        System.out.println(res);
    }
}

Measured memory_bytes: 35584
#include <iostream>
  #include <cstdio>
  #include <cstring>
  #include <cmath>
  #include <cstring>
  #include <chrono>
  #include <complex>
  #define endl "\n"
  #define ll long long int
  #define vi vector<int>
  #define vll vector<ll>
  #define vvi vector < vi >
  #define pii pair<int,int>
  #define pll pair<long long, long long>
  #define mod 1000000007
  #define inf 1000000000000000001;
  #define all(c) c.begin(),c.end()
  #define mp(x,y) make_pair(x,y)
  #define mem(a,val) memset(a,val,sizeof(a))
  #define eb emplace_back
  #define f first
  #define s second
  
  using namespace std;
  int main()
  {
    std::ios::sync_with_stdio(false);
    float a,b,c;
    cin>>a>>b>>c;
    float d=a/c;
    if(a/c<=b)
      cout<<"Yes";
    else cout<<"No";
    return 0;
  }


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

using namespace std;

typedef long long ll;

#define REP(i,p,q) for(ll i = p; i < q; i++)

int main(void){
    ll n;
    cin >> n;
    vector<ll> a = vector<ll>(n);
    REP(i,0,n) cin >> a[i];
    sort(a.begin(),a.end());
    ll amax = a[n-1];
    vector<ll> isPrime = vector<ll>(amax + 1,1);
    REP(i,0,n){
        //if(a[i] > sqrt(amax) + 1) break;
        if(isPrime[a[i]]){
            for(ll j = a[i]*2; j <= amax; j += a[i]){
                isPrime[j] = 0;
            }
        }
    }
    REP(i,0,n - 1){
        if(a[i] == a[i+1]) isPrime[a[i]] = 0;
    }
    ll ans = 0;
    REP(i,0,n) if(isPrime[a[i]]) ans++;
    cout << ans << endl;
}

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


int main(){
    ll n;
    cin >> n;
    REP(i, n){
        ll ai;
        cin >> ai;
        if(ai % 2 == 0 && ai % 3 != 0 && ai % 5 != 0){
            cout << "DENIED" << endl;
            return 0;
        }
    }
    cout << "APPROVED" << endl;
    return 0;
}


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

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

  map<int, int> p;

  for (int x = 1; x < 100; x++){
    int x2 = x*x;
    for (int y = 1; y < 100; y++){
      int y2 = y*y;
      for (int z = 1; z < 100; z++){
	int z2 = z*z;
	int n = x2+y2+z2 + x*y + y*z + z*x;
	p[n] += 1;
      }
    }
  }

  for (int n = 1; n <= N; n++){
    if (p.count(n)){
      cout << p[n] << endl;
    }else{
      cout << "0" << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 5312
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
ll dp[20][2][10][10];
ll recur(ll small, ll idx, vector<ll>v, ll cur, ll first)
{
  if(idx==v.size())
  {
      if(first==0) return 0;
      else
      return 1;
  }
        if(dp[idx][small][cur][first]!=-1)
            return dp[idx][small][cur][first];
  ll limit;
  if(small==true)
    limit=9;
  else
  {
      limit=v[idx];
  }
  ll ret=0;

  for(ll j=0;j<=limit;j++)
  {

        if (!first)
            {
          ll news= small || (j<(v[idx]));
      ret+=recur(news, idx+1, v, j,j);
            }

          else if(abs(j-cur)<=1)
          {

            ll news= small || (j<(v[idx]));
      ret+=recur(news, idx+1, v, j,first);
          }


  }
  dp[idx][small][cur][first]=ret;
  return ret;
}
bool check(ll mid)
{
    bool flag=false;
    ll prev;
    bool ans=true;
    while(mid>0)
    {
        ll d=mid%10;
        mid/=10;
        if(flag==true)
        {
            if( abs(d-prev)>1)
            {
                ans=false;
                break;
            }
            else prev=d;
        }
        else
        {
            flag=true;
            prev=d;
        }
    }
    return ans;
}
int main()
{
    ll k;
    cin>>k;
    ll low=1;

    ll high=10000000000000;
    ll ans=-1;
    while(low<=high)
    {
        ll mid=(low+high)/2;
        vector<ll>v;
        ll st=mid;
        while(st>0)
        {
            v.push_back(st%10);
            st/=10;
        }
        reverse(v.begin(),v.end());
        memset(dp,-1,sizeof(dp));
        ll temp=recur(0,0,v,0,0);
        if(temp==k)
        {
            if(check(mid))
            {
                ans=mid;
                break;
            }
            else
            {
                high=mid-1;

            }
        }
        else if(temp<k)
            low=mid+1;
        else high=mid-1;

    }

    cout<<ans<<endl;

}


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

Measured memory_bytes: 128
using System;
using System.Linq;

namespace a
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = Console.ReadLine().Split().Select(s => Convert.ToChar(s.Substring(0,1))).Select(c => char.ToUpper(c));
            Console.WriteLine(string.Join("",a));
        }
    }
}


Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
long long int MOD = 1e9+7;
int main(){
    int n,m;
    char x;
    cin>>n>>m;
    long long int adj[n][m];
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin>>x;
            if(x=='.') adj[i][j]=0;
            else adj[i][j]=-1;
        }
    }
    if(adj[n-1][m-1]==0){
    adj[n-1][m-1]=1;
    for(int i=n-1;i>=0;i--){
        for(int j=m-1;j>=0;j--){
            if(adj[i][j]==-1) adj[i][j]=0;
            else{
                if(i+1<n) adj[i][j] = adj[i+1][j];
                if(j+1<m) adj[i][j] += adj[i][j+1];
            }
            adj[i][j] = adj[i][j]%MOD;
            //cout<<adj[i][j]<<" ";
        }
        //cout<<endl;
    }
    cout<<adj[0][0]%MOD;
    }
    else cout<<"0";
}

Measured memory_bytes: 11348
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll mod=1e9+7;

int main(){
  int a,b;
  string s;
  cin>>a>>b>>s;
  int size=s.size();
  if (size!=a+b+1){
    cout << "No" << endl;
    return 0;
  }
  for (int i(0);i<size;i++){
    if (i==a&&s[i]!='-'){
      cout << "No" << endl;
      return 0;
    }
    if (i!=a){
      if (s[i]-'0'<0||s[i]-'0'>9){
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);
		//入力表示

		int N = sc.nextInt();
		int h[] = new int[N];

		for (int i = 0; i < N; i++) {
			h[i] = sc.nextInt();
		}
		int ans = 0;
		int count = 0;
 	
		for (int i = 0; i < N - 1; i++) {
			if (h[i] >= h[i + 1]) {
				count++;
			} else {
				count = 0;
			}
			if (ans < count) {
				ans = count;
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 49204
from functools import reduce

n, s = map(int, input().split())
xl = [abs(int(i) - s) for i in input().split()]

def gcd_(a, b):
    while b:
        a, b = b, a%b
    return a
def gcd(*numbers):
    return reduce(gcd_, numbers)

print(gcd(*xl))

Measured memory_bytes: 14596
N = int(input())
D,X = map(int,input().split())
A = [int(input())for _ in range(N)]
cnt = 0
#print(A)

for i in A:
    if D%i ==0:
        cnt += D//i
    else:
        cnt += (D//i + 1)
    #print(cnt)
print(cnt+X)

Measured memory_bytes: 8980
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>> cpp_dec_float_1000;

constexpr char CRLF = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;

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; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }

void solve(void)
{
  map<char, ui> res{};
  char a; cin >> a;
  char b; cin >> b;
  char c; cin >> c;
  ++res[a];
  ++res[b];
  ++res[c];

  auto ans = res['a'] == 1 && res['b'] == 1 && res['c'] == 1;
  cout << (ans ? "Yes" : "No") << CRLF;
  return;
}

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

  solve();

  return 0;
}


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

#define mk make_pair
#define pb push_back

typedef long long lld;
typedef pair<lld,lld> pr;
typedef priority_queue <lld> max_heap;
typedef priority_queue <lld, vector<lld>, greater<lld> > min_heap;
lld const mod = 1e9+7;

lld power(lld x, lld y)
{
    lld res = 1;
    while (y > 0) {
        if (y & 1)
            res = res * x;
        y = y >> 1;
        x = x * x;
    }
    return res;
}

lld power_mod(lld base, lld y)
{
    lld t = 1;
    while (y > 0)
    {

        if (y % 2 != 0)
            t = (t * base) % mod;
        base = (base * base) % mod;
        y /= 2;
    }
    return t % mod;
}

lld nCrModp(lld n, lld r, lld p)
{
    if (r > n - r)
        r = n - r;
    lld C[r + 1]={0};
    C[0] = 1;

    for (lld i = 1; i <= n; i++)
    {
      for (lld j = min(i, r); j > 0; j--)
      {
        C[j] = (C[j] + C[j - 1]) % p;

      }
    }
    return C[r];
}

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  lld x,n;
  cin>>x>>n;
  if(n==0)
  {
    cout<<x<<endl;
    exit(0);
  }
  lld p[n];
  lld i;
  lld hash[105]={0};
  for(i=0;i<n;i++)
  {
    cin>>p[i];
    hash[p[i]]++;
  }
  lld ans = 0;
  lld diff = abs(0-x);
  for(i=0;i<=105;i++)
  {
    if(hash[i]==0)
    {
      if(abs(i-x)<diff)
      {
        diff = abs(i-x);
        ans = i;
      }
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;

bool check(vector<bool> honest, vector<vector<pair<int, int>>> say) {
  for (int i = 0; i < honest.size(); ++i) {
    if(!honest[i]) continue;
    for(auto p : say[i]) {
      int x = p.first;
      int y = p.second;
      if (honest[x-1] && y == 0) return false;
      if (!honest[x-1] && y == 1) return false;
    }
  }
  return true;
}

int main() {
  int ans = 0;
  int n;
  cin >> n;
  vector<vector<pair<int, int>>> say(n);
  for(int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    for(int j = 0; j < a; j++) {
      int x, y;
      cin >> x >> y;
      say[i].push_back(make_pair(x, y));
    }
  }

  for(int bit = 0; bit < (1<<n); ++bit) {
    vector<bool> honest(n, false);
    for(int i = 0; i < n; ++i) {
      if (bit & (1<<i)) {
        honest[i] = true;
      }
    }
    if(!check(honest, say)) continue;
    int count = 0;
    for (int i = 0; i < honest.size(); i++) {
      if(honest[i]) count++;
    }
    ans = max(ans, count);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
vector<long long int> v;
vector<long long int> mem;
long long int dp(long long int n)
{
	if(mem[n]!=-1)
	{
		return mem[n];
	}
	if(n==1)
	{
		mem[n]=0;
		return 0;
	}
	if(n==2)
	{
		mem[n]=abs(v[1]-v[2]);
		return abs(v[1]-v[2]);
	}
	else
	{
		mem[n]=min(dp(n-1)+abs(v[n]-v[n-1]),dp(n-2)+abs(v[n]-v[n-2]));
		return min(dp(n-1)+abs(v[n]-v[n-1]),dp(n-2)+abs(v[n]-v[n-2]));
	}
}
int main()
{
	
	long long int n;
	cin>>n;
	v.clear();
	v.assign(n+5,0);
	mem.assign(n+5,-1);
	for(long long int i=1;i<=n;i++)
	{
		cin>>v[i];
	}
	long long int ans=dp(n);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4992