akhauriyash/Code-Regression huggingface dataset:
import sys


def main():

    # Get Args
    args = _input_args()  # get arguments as an array from console/script parameters.

    # Call main Logic
    result = _main(args)

    # Export a result in a correct way.
    _export_result(result)


def _main(args):
    """Write Main Logic here for the contest.

    :param args: arguments
    :type args: list
    :return: result
    :rtype: depends on your logic.
    """
    # Extract arguments.
    R = int(args[0])
    G = int(args[1])

    # Write main logic here.
    X = (2 * G) - R

    # Return something.
    return X


def _input_args():
    # Comment-out appropriate pattern depends on subject.

    # arguments = sys.argv[1:]  # ptn1: get args from script parameters.
    # arguments = _input().split()  # ptn2: get args from 1 line console prompt with space separated.

    # for multi-line console input, use this.
    arguments = _get_args_from_multiple_lines(end_of_lines_char=[''])

    # Cast elements If you need.
    # arguments = list(map(int, arguments))  # cast elements to int for example.

    return arguments  # This will be array.


def _input():
    # If Subject requires interactive input, use this and patch mock in unittest.
    return input()  # Change if necessary.


def _get_args_from_multiple_lines(end_of_lines_char=['']):
    """Get arguments from multiple lines standard input.

    :param end_of_lines_char: Strings that indicate the end of lines.
    :type end_of_lines_char: list of str
    :return: args
    :rtype list of str
    """
    args = []
    while True:
        try:
            arg = _input()
            if arg in end_of_lines_char:
                break
            args.append(arg)
        except EOFError:  # Supports EOF Style. (Very Rare case)
            break
    return args


def _export_result(result):
    # Comment-out appropriate output pattern depends on subject.

    # sys.stdout.write(result)  # No Line Feed, and an result must be string (not useful). for single value output.
    # print(result)  # The result will cast to strings. Line feed will be appended to the end. for single value output.
    # print(result, end='')  # Same as above except Line Feed won't be appended. for single value output.
    # print(','.join(map(str, result)))  # Print array elements as comma separated strings. for multi-value.
    print('{}'.format(str(result)))  # Same as above, but more versatile.


if __name__ == '__main__':
    main()


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

#define ris   return *this
#define tmplt template<class T
#define dbgo  debug& operator<<
tmplt > struct rge { T b, e; };
tmplt > rge<T> range(T i, T j) { return rge<T>{i, j}; }
struct debug {
#ifdef LOCAL
~debug(){cerr<<endl;}
tmplt > dbgo(T x){cerr<<boolalpha<<x;ris;}
tmplt, class C > dbgo(pair<T, C> x){ris<<"("<<x.first<<", "<<x.second<<")";}
tmplt > dbgo(rge<T> x){*this<<"[";for(auto it=x.b;it!=x.e;it++){*this<<", "+2*(it==x.b)<<*it;}ris<<"]";}
tmplt > dbgo(vector<T> x){ris<<range(x.begin(),x.end());}
#else
tmplt > dbgo(const T&){ris;}
#endif
};
#define nav(...) << "[ " << #__VA_ARGS__ ": " << (__VA_ARGS__) << " ] "
using ll = long long;

#define forn(i, n) for(int i = 0; i < int(n); i++)
#define ford(i, n) for(int i = n-1; i >= 0; i--) 

template<typename T> 
void min_self(T& a, T b) { 
    a = min(a, b); 
}
template<typename T>
void max_self(T& a, T b) { 
    a = max(a, b); 
}

void merge(pair<pair<int,int>,pair<int,int>>& a, pair<int,int> b) {
    if(b == a.first) {
        return;
    }
    if(b > a.first) {
        a.second = a.first;
        a.first = b;
    } else if(b > a.second) {
        a.second = b;
    }
}

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

    int n;
    cin >> n;
    vector<pair<int,int>> a(1<<n);
    forn(i, 1<<n) {
        cin >> a[i].first;
        a[i].second = i;
    }
    vector<pair<pair<int,int>,pair<int,int>>> dp(1<<n);
    
    for(int i = 1; i < (1<<n); i++) {
        pair<int,int> x, y;
        x = a[i], y = a[0];
        if(x < y) swap(x, y);
        dp[i] = make_pair(x, y);
        for(int b = 0; b < n; b++) {
            if(i>>b&1) {
                int j = i ^ (1<<b);
                merge(dp[i], dp[j].first);
                merge(dp[i], dp[j].second);
            }
        }
    }
    
    vector<int> ans(1<<n);
    for(int i = 1; i < (1<<n); i++) {
        ans[i] = dp[i].first.first + dp[i].second.first;
        max_self(ans[i], ans[i-1]);
        cout << ans[i] << '\n';
    }
}













// Don't worry, you're getting better

// Read statement carefully
// Solve on paper first!
// Make your infinity big enough
// Overflows (long long)

// Author: blondie


Measured memory_bytes: 10240
#include<iostream>

using namespace::std;

long long int t,ar[3005],dp[3005][3005];

int main(){
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>ar[i];
    for(int i=0;i<n;i++)
        dp[i][0]=ar[i];
    for(int j=1;j<n;j++)
        for(int i=0;i<n-j;i++)
            dp[i][j]=max(ar[i+j]-dp[i][j-1],ar[i]-dp[i+1][j-1]);
            
    cout<<dp[0][n-1]<<'\n';
}

Measured memory_bytes: 70016
//#include <boost/multiprecision/cpp_dec_float.hpp>
//#include <boost/multiprecision/cpp_ll.hpp>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
#include <bitset>
using namespace std;
//namespace mp = boost::multiprecision;
//using llll = mp::cpp_ll;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
//using Real = mp::number<mp::cpp_dec_float<1024>>;
using ll = long long;
const double EPS = 1e-10;
const ll MOD = 7+(1e+9);

ll ans=0;
ll zzz=0;
ll n,k;

vector<vector<ll> > graph;   //graph[v]には頂点v につながっている
                            //頂点の集合が入っているとする
vector<bool> vec;

void dfs(int v){              //v に関して深さ優先探索(vは頂点の番号)
  vec[v]=true;              //v に訪問済みの印を付ける
  ll ii=0;
  ll num=k-2;
  for(int i : graph[v]){    //v に接続している各頂点i に対し
      if(vec[i]==false){    //i が未訪問なら
        ans=ans*(num)%MOD;
        num--;
        dfs(i);           //i に関して深さ優先探索
        ii++;
      }
  }
}

int main(){
  cin>>n>>k;
  vec.assign(n,false);
  graph.assign(n,vector<ll>());
  ll aa,bb;
  for(ll i=0;i<n-1;i++){
    cin>>aa>>bb;
    aa--;
    bb--;
    graph[bb].push_back(aa);
    graph[aa].push_back(bb);

  }
  if(n==1){
    cout<<k<<endl;
    return 0;
  }
  if(n==2){
    cout<<k*(k-1)%MOD<<endl;
    return 0;
  }
  for(ll i=0;i<n;i++){
    if(graph[i].size()==1){
      zzz=i;
      break;
    }
  }
  ll p=graph[zzz][0];
  ans=k*(k-1)%MOD;
  vec[zzz]=true;
  dfs(p);
  cout<<ans<<endl;
}


Measured memory_bytes: 10368
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string l = "abcdefghijklmnopqrstuvwxyz";
  long a; cin >> a;
  vector<int> v;
  while(a!=0){
      long b = a%26;
      if(b == 0)b = 26;
      v.push_back(b);
      a = (a-b)/26;
  }
  //for(auto x:v)cout << x << " ";
  for(int i=v.size()-1;i>-1;i--)cout << l[v[i]-1];
  cout << endl;
}


Measured memory_bytes: 3596
import sys
sys.setrecursionlimit(200000)
n = int(input())
a = [int(input()) for i in range(n)]

switch = [False] * (n + 1)
def button(x,cnt):
    if switch[x]:
        print(-1)
        return -1
    if x == 2:
        print(cnt)
        return
    switch[x] = True
    button(a[x - 1], cnt + 1)
    return cnt

ans = button(1, 0)

Measured memory_bytes: 93788
S=input()
L=[0,0,0]
for i in range(len(S)):
    if S[i]=="a":
        L[0]+=1
    elif S[i]=="b":
        L[1]+=1
    else:
        L[2]+=1
        
L.sort()
if L[2]-L[0]<=1:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 9168
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<list>
#include <array>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807
#define INF I64_MAX
#define MOD 1000000007



void solve(void)
{
  int N;
  cin>>N;
  vector<vector<pair<int,int> > > vec(N);
  vector<int> data(N,0);//true or false

  for (int i = 0; i < N; i++)
  {
    int M;
    cin>>M;
    for (int j = 0; j < M; j++)
    {
      pair<int,int> A;
      cin>>A.first>>A.second;
      A.first--;
      vec[i].push_back(A);
    }
  }




  vector<vector<int> > ANS;

    for (int bit = 0; bit < (1<<N); ++bit)
    {
        /* bit で表される集合の処理を書く */


        /* きちんとできていることを確認してみる */
        // bit の表す集合を求める
        vector<int> S(N,0);
        for (int i = 0; i < N; ++i) {
            if (bit & (1<<i)) { // i が bit に入るかどうか
                S[i] = 1;
            }
        }

        // for (int i = 0; i < S.size(); i++)
        // {
        //   cout<<S[i]<<" ";
        // }
        // cout<<endl;


        int check = 1;
        for (int i = 0; i < N; i++)
        {
          for (int j = 0; j < vec[i].size(); j++)
          {
            int Person = vec[i][j].first;
            int TF = vec[i][j].second;

            if(S[i] == 0)
            {
              continue;
              if(TF == 1) TF = 0;
              else TF = 1;
            } 

            if(TF != S[Person]) check = 0;
          }
        }

    if(check == 1)ANS.push_back(S);
    }
    int ANS_NUM = 0;
    for (int i = 0; i < ANS.size(); i++)
    {
      int C = 0;
      for (int j = 0; j < ANS[i].size(); j++)
      {
        if(ANS[i][j] == 1)C++;
      }
      ANS_NUM =max(ANS_NUM,C);
      
    }
    cout<<ANS_NUM;

}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  // std::cout << std::fixed;
  // std::cout << std::setprecision(8);

  solve();

 
  return 0;
}

Measured memory_bytes: 5176
import sys
input = lambda : sys.stdin.readline().rstrip()

import heapq
h = []
heapq.heapify(h)

n, m, s = list(map(int, input().split()))
a, b = [[None] * m for _ in range(2)]
c, d = [[None] * n for _ in range(2)]

ns = {u: [] for u in range(n)}
uv2e = {}
for i in range(m):
    u,v,a[i],b[i] = list(map(int, input().split()))
    ns[u-1].append(v-1)
    ns[v-1].append(u-1)
    uv2e[u-1,v-1] = i
    uv2e[v-1,u-1] = i
for i in range(n):
    c[i], d[i] = list(map(int, input().split()))

maxs = max(a)*(n-1)
s = min(s, maxs)
state = (0, 0, s) # (距離, ノード, 銀貨枚数)
ans = [[None] * (maxs+1) for _ in range(n)]
heapq.heappush(h, state)
count = 0
while h:
    count += 1
    dd, u, ss = heapq.heappop(h)
#     print(dd, u, ss)
    if ans[u][ss] is not None and ans[u][ss] <= dd:
        continue
    ans[u][ss] = dd
    
    # グラフの隣接点
    for v in ns[u]:
        e= uv2e[u,v]
        if ss<a[e] or ans[v][ss-a[e]] is not None:
            continue
        heapq.heappush(h, (dd + b[e], v, ss-a[e]))
    # 両替
    if ss+c[u] <= maxs:
        heapq.heappush(h, (dd + d[u], u, ss+c[u]))
    elif ss < maxs:
        heapq.heappush(h, (dd + d[u], u, maxs))

for item in ans[1:]:
    print(min(item))


Measured memory_bytes: 124904
#include<cstdio>
#include<cmath>
using namespace std;
int a[100005];
int main(){
    int n,i;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    int t=0,ans=0;
    for(i=1;i<n;i++){
        if(a[i]>a[i-1]){
            if(t==1){
                ans++;t=0;
            }
            else if(t==0){
                t=2;
            }
        }
        else if(a[i]<a[i-1]){
            if(t==2){
                ans++;t=0;
            }
            else if(t==0){
                t=1;
            }
        }
    }
    ans++;
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 512
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T> using vv=vector<vector<T>>;
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
const ll MOD=1e9+7;
struct UF{
  vector<int> data;
  UF(int size):data(size,-1){}
  bool unite(int x,int y){
    x=root(x); y=root(y);
    if(x!=y){
      if(data[y]<data[x]) swap(x,y);
      data[x]+=data[y]; data[y]=x;
    }
    return x!=y;
  }
  bool findSet(int x,int y){return root(x)==root(y);}
  int root(int x){return data[x]<0?x:data[x]=root(data[x]);}
  int size(int x) {return -data[root(x)];}
};

int main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
  int n,s,t;
  cin>>n>>s>>t;
  UF a(n),b(n);
  rep(i,s){
    int x,y;
    cin>>x>>y; --x; --y;
    a.unite(x,y);
  }
  rep(i,t){
    int x,y;
    cin>>x>>y; --x; --y;
    b.unite(x,y);
  }
  map<pii,int> cnt;
  rep(i,n) ++cnt[pii(a.root(i),b.root(i))];
  rep(i,n){
    if(i) cout<<" ";
    cout<<cnt[pii(a.root(i),b.root(i))];
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 13568
#include<stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
int main(){
	
	int R,G;
	scanf("%d %d",&R,&G);
	
	int a = G-R;
	
	R +=a*2;
	
	
	printf("%d\n",R);
	
	
	return 0;
}

Measured memory_bytes: 128
n = int(input())
points = [list(map(int, input().split())) for i in range(n)]
points.insert(0, [0, 0, 0])

flg = True

for i in range(n):
    dt = points[i + 1][0] - points[i][0]
    dist = abs(points[i + 1][1] - points[i][1]) + abs(points[i + 1][2] - points[i][2])
    if dt < dist:
        flg = False
        break
    if dist % 2 != dt % 2:
        flg = False
        break

if flg:
    print('Yes')
else:
    print('No')

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

int N, M, Q;

int dfs(vector<int> A, int n, vector<vector<int>> &Qu) {
    if (n == N-1) {
        int ret = 0;
        for (int i = 0; i < Q; i++) {
            if (A[Qu[i][1]-1] - A[Qu[i][0]-1] == Qu[i][2]) ret += Qu[i][3];
        }
        return ret;
    } else {
        int ret = 0;
        for (int i = A[n]; i <= M; i++) {
            A[n+1] = i;
            ret = max(ret, dfs(A, n+1, Qu));
        }
    return ret;

    }
}

int main() {
    cin >> N >> M >> Q;
    ll ans = 0;
    vector<int> A(N);
    vector<vector<int>> Qu(Q);

    for (int i = 0; i < Q; i++) {
        int a, b, c, d; cin >> a >> b >> c >> d;
        Qu[i] = vector<int>({a, b, c, d});
    }
    A[0] = 1;
    cout << dfs(A, 0, Qu) << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
typedef long long ll;
using namespace std;
const ll mod=1000000007,mod9=1000000009;
template <class T>inline T lcm(T a,T b){return (a*b/__gcd(a,b));}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    int n=s.length();
    int ans[n];
    memset(ans,0,sizeof(ans));
    int index;
    for(int i=n-1;i>=0;i--){
        if(s[i]=='L'){
            index=i;
        }
        else{
            if((index-i)%2){
                ans[index-1]++;
            }
            else{
                ans[index]++;
            }
        }
    }
    for(int i=0;i<n;i++){
        if(s[i]=='R'){
            index=i;
        }
        else{
            if((i-index)%2){
                ans[index+1]++;
            }
            else{
                ans[index]++;
            }
        }
    }
    for(int i=0;i<n;i++){
        cout <<ans[i]<<" ";
    }
    cout <<endl;
    return 0;
}



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

using namespace std;

int check(int N, vector<set<int>>& ts, vector<set<int>>& fs, int n) {
  int c = 0;
  for (int i = 0; i < N; i++) {
    if ((1 << i) & n) {
      c++;
      for (auto k : ts[i]) {
        if (!((1 << k) & n)) {
          return 0;
        }
      }
      for (auto k : fs[i]) {
        if ((1 << k) & n) {
          return 0;
        }
      }
    }
  }
  return c;
}

int solve(int N) {
  vector<set<int>> ts(N);
  vector<set<int>> fs(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;

      if (y == 1) {
        ts[i].insert(x - 1);
      } else {
        fs[i].insert(x - 1);
      }
    }
  }

  int ans = 0;
  for (int i = 1; i < (1 << N); i++) {
    int c = check(N, ts, fs, i);
    ans = max(ans, c);
  }
  return ans;
}

int main() {
  int N;
  cin >> N;
  cout << solve(N) << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int keta(long long n){
    int ret=0;
    while(n){
        ret++;
        n/=10;
    }
    return ret;
}
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long n,N,ans;
    cin>>n;
    bool b=false;
    N=n;
    vector<int>d(keta(n));
    for(int i=0;i<keta(n);i++){
        d[keta(n)-1-i]=N%10;
        N/=10;
    }
    for(int i=1;i<keta(n);i++){
        if(d[i]!=9){b=true;break;}
    }
    if(b){ans=d[0]-1+(keta(n)-1)*9;}
    else{ans=d[0]+(keta(n)-1)*9;}
    cout<<ans;
}

Measured memory_bytes: 256
class Dice
	TOP=0
	FRONT=1
	RIGHT=2
	LEFT=3
	BACK=4
	BOTTOM=5
	
	def initialize( nums )
		@face = nums
	end
	
	def rolltoTopIndex( faceindex )
		case faceindex
		when FRONT
			roll( "N" )
		when RIGHT
			roll( "W" )
		when LEFT
			roll( "E" )
		when BACK
			roll( "S" )
		when BOTTOM
			roll( "NN" )
		when TOP
		end
	end
	
	def roll( actions )
		for i in ( 0 ... actions.length )
			t = 0
			case actions[i]
			when "E"
				t =   @face[ TOP  ]
				@face[ TOP  ] =   @face[ LEFT  ]
				@face[ LEFT  ] =   @face[ BOTTOM  ]
				@face[ BOTTOM  ] =   @face[ RIGHT  ]
				@face[ RIGHT  ] = t
			when "N"
				t =   @face[ TOP  ]
				@face[ TOP  ] =   @face[ FRONT  ]
				@face[ FRONT  ] =   @face[ BOTTOM  ]
				@face[ BOTTOM  ] =   @face[ BACK  ]
				@face[ BACK  ] = t
			when "S"
				t =  @face[ TOP  ]
				@face[ TOP  ] =  @face[ BACK  ]
				@face[ BACK  ] =  @face[ BOTTOM  ]
				@face[ BOTTOM  ] =  @face[ FRONT  ]
				@face[ FRONT  ] = t	
			when "W"
				t =  @face[ TOP  ]
				@face[ TOP  ] =  @face[ RIGHT  ]
				@face[ RIGHT  ] =  @face[ BOTTOM  ]
				@face[ BOTTOM  ] =  @face[ LEFT  ]
				@face[ LEFT  ] = t	
			when "M"
				t =  @face[ FRONT  ]
				@face[ FRONT  ] =  @face[ RIGHT  ]
				@face[ RIGHT  ] =  @face[ BACK  ]
				@face[ BACK  ] =  @face[ LEFT  ]
				@face[ LEFT  ] = t				
			end
		end
	end
	attr_accessor :face
end

diceface = gets.split( " " ).map { |val| val.to_i }
dice1 = Dice.new( diceface )
diceface = gets.split( " " ).map { |val| val.to_i }
dice2 = Dice.new( diceface )

cnt = 0
catch ( :samedice ) do
	for i in ( 0 ... 6 )
		if dice1.face[Dice::TOP] == dice2.face[i]
			dice2.rolltoTopIndex( i )
			for j in ( 1 .. 4 )
				if dice1.face[Dice::FRONT] == dice2.face[Dice::FRONT]
					cnt = 0
					for k in ( 0 ... 6 )
						if dice1.face[k] == dice2.face[k]
							cnt += 1
						end
					end
					throw :samedice if cnt == 6
				end
				dice2.roll( "M" )
			end
		end
		dice2.face = diceface
	end
end

if cnt == 6
	puts( "Yes" )
else
	puts( "No" )
end

Measured memory_bytes: 6152
//long challenge
// This code is done by me.

#include<iostream>
#include<climits>
#include<bits/stdc++.h>
#include<algorithm>
#include<deque>
#include<set>
#include<cstdio>
#include<vector>
#include<string>
#include<cmath>
// some unique define keywords

#define fo(i,n) for(i=0;i<n;i++)
#define ll long long
#define mod 1000000007


// this code is prepared by deepakdpk
// please don't cheat
// code and improve
//All good.


using namespace std;

ll npow(ll base, ll exp) {
  int reaction=12345;
  base %= mod;
  ll ans = 1;
  while (exp > 0) {
    if (exp & 1) ans = ((ll)ans * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  int pract;
  int dact;
  return ans;
}

ll factorial(ll n)
{
    ll i = n;
    ll fact=1;
    while (n / i != n) {
        fact = fact * i;
        i--;
    }
    int dear=123;
    int say;
    return fact;
}



int main()
{
    ll b,c,x,ans;
    ll a[3];
    ll i;
    for(i=0;i<3;i++)
    {
        cin>>a[i];
    }
   sort(a,a+3);
   ans=a[2]*10+a[1]+a[0];
   cout<<ans<<endl;


    return 0;

    }








































Measured memory_bytes: 3636
import java.util.Scanner;

class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int cnt = 0;
        
        String W = sc.next();
        sc.nextLine();
        
        for(;;){
            String T = sc.next();
            if(T.equals("END_OF_TEXT")) break;
            T = T.toLowerCase();
            if(T.equals(W)) cnt++;
        }
        System.out.println(cnt);
    }
}


Measured memory_bytes: 26112
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;
using ll = long long;

int main()
{
  int N; cin >> N;
  vector<ll> A(N), B(N); REP(i, N) cin >> A[i] >> B[i];

  ll ans = 0;
  for (int i = N-1; i >= 0; --i) {
    A[i] += ans;
    ll k = (A[i] + B[i] - 1) / B[i];
    ans += k*B[i]-A[i];
  }

  cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a, b;
  int a2,b2;
  cin >> a >> b;
  a2 = a + 1;
  b2 = b + 1;
  a *= 100;
  b *= 100;
  a2 *= 100;
  b2 *= 100;
  int ei, ten;
  int eiend, tenend;
  ei = (a+7) / 8;
  ten = (b+9) / 10;
  eiend = (a2-1) / 8;
  tenend = (b2-1) / 10;
  if(eiend < ten || tenend < ei) cout << -1 << endl;
  else{
    cout << max(ei, ten) << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main() {
    int i, N, cnt[100] = {0}, ans = 0;
    char A[101], B[101], C[101];
    if (scanf("%d%*c%s%*c%s%*c%s", &N, A, B, C) == -1) return -1;
    for (i = 0; i < N; i++) {
        if (A[i] == B[i]) cnt[i]++;
        if (B[i] == C[i]) cnt[i]++;
        if (C[i] == A[i]) cnt[i]++;
        if (cnt[i] == 1) ans++;
        else if (cnt[i] == 0) ans += 2;
    }
    printf("%d\n", ans);
    return 0;
}

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


int main (void) {
  int R, G, B , N;
  std::cin >> R >> G >> B >> N;

  int Rmax = std::ceil(N/R);
  int Gmax = std::ceil(N/G);
  int Bmax = std::ceil(N/B);
  int ans = 0;
  for(int i=0; i<=Rmax; i++){
    for (int j=0; j<=Gmax; j++){
      int rg = R*i + G*j;
      if ( (N - rg) % B == 0 && N-rg >= 0 && (N-rg)/B <= Bmax ) ans++;
    }
  }

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

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

using namespace std;

#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void ZZ(const char* name, Arg1&& arg1){std::cerr << name << " = " << arg1 << endl;}
template <typename Arg1, typename... Args>void ZZ(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}

#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define endl '\n'
#define sz(a) int((a).size())

int n;
int a[1000];

signed main()
{
	IOS;
	cin >> n;
	for (int i = 0; i < n; i++) cin >> a[i];
	int res = 0;
	for (int i = 0; i < n - 1; i++) {
		for (int j = i + 1; j < n; j++) {
			res += a[i] * a[j];
		}
	}
	cout << res << endl;
	return 0;
}


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

typedef long long ll;
static const ll INF = 1ll<<60;

int main(){
    int N;
    cin>>N;
    vector<ll> dp(100000+10,INF);

    dp[0] = 0;

    for(int i=0; i<=N; i++){
        for(int six=1; six<=N; six *= 6){
            if(i-six < 0) continue;
            dp[i] = min(dp[i],dp[i-six]+1);
        }

        for(int nine=1; nine<=N; nine *= 9){
            if(i-nine < 0) continue;
            dp[i] = min(dp[i],dp[i-nine]+1);
        }
    }

    cout<<dp[N]<<endl;

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PI 4*atan(1.0)
typedef long long ll;
typedef long double ld;
using namespace std;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};
const int SIZE=200001;
//int arr[SIZE]={};
//ここまでテンプレ
int main(){
	ll A,B,C,D;
	cin>>A>>B>>C>>D;
	int N;
	cin>>N;
	ll ans=0;
	ans+=min(min(A*8,B*4),min(C*2,D))*(N/2);
	ans+=min(min(A*4,B*2),C)*(N%2);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <cstring>
#include <algorithm>
using namespace std;
/*#define fast ios_base::sync_with_stdio(0); cin.tie(0)*/
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
const double pi = acos(-1);
typedef long long ll;
int main()
{
	//fast;
	
	ll a,b,c,x;
	cin>>a>>b;
	((a*b)%2)?cout<<"Odd":cout<<"Even";
}

Measured memory_bytes: 3524
use std::io;
use std::str::FromStr;

fn input_int_tuple() -> (i32, i32) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<i32> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1])
}

fn main() {
    let (a, p) = input_int_tuple();
    println!("{}", (a * 3 + p) / 2);
}


Measured memory_bytes: 4352
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>

int main()
{
	char a[4], b[4], cat[99];
	int num, div;
	
	scanf("%s %s", a, b);
	
	strcpy(cat, a);
	strcat(cat, b);
	
	num = atoi(cat);
	div = (int)sqrt(num);
	
	if(div*div == num)
		puts("Yes");
	else
		puts("No");
	
	return 0;
}

Measured memory_bytes: 128
# abc112_b.py
# https://atcoder.jp/contests/abc112/tasks/abc112_b

# B - Time Limit Exceeded /
# 実行時間制限: 2 sec / メモリ制限: 1024 MB
# 配点 : 200点

# 問題文
# 外出している X さんは、ABC に参加するためにスマートウォッチで最適な帰宅経路を調べることにしました。
# スマートウォッチであるあなたは、N個の帰宅経路を見つけました。
# X さんが i番目の経路を使う場合、コスト ci かけて時間 tiで帰宅できます。
# 時間 T以内に帰宅できる経路のうち、コストが最小となる経路のコストを求めてください。

# 制約
#     入力はすべて整数である
#     1≤N≤100
#     1≤T≤1000
#     1≤ci≤1000
#     1≤ti≤1000
#     各 (ci,ti)の組は異なる

# 入力
# 入力は以下の形式で標準入力から与えられる。
# N T
# c1 t1
# c2 t2
# :
# cN tN

# 出力
# 時間 T以内に帰宅できる経路のうち、コストが最小となる経路のコストを出力せよ。
# ただし、どの経路を使っても時間 T以内に帰宅できない場合、TLE と出力せよ。

# 入力例 1
# 3 70
# 7 60
# 1 80
# 4 50

# 出力例 1
# 4

# 1番目の経路を使うと、コスト 7で帰宅できます
# 2番目の経路では時間 T=70以内に帰宅できません
# 3番目の経路を使うと、コスト 4で帰宅できます
# 従って、3番目の経路を使ったときのコスト 4が最小です。

# 入力例 2
# 4 3
# 1 1000
# 2 4
# 3 1000
# 4 500

# 出力例 2
# TLE

# どの経路を使っても時間 T=3以内に帰宅できません。

# 入力例 3
# 5 9
# 25 8
# 5 9
# 4 10
# 1000 1000
# 6 1

# 出力例 3
# 5


def calculation(lines):
    # N = int(lines[0])
    N, T = list(map(int, lines[0].split()))
    # n = lines[0]

    min_c = None

    for i in range(1, N+1):
        c, t = list(map(int, lines[i].split()))
        if t <= T:
            if min_c is None:
                min_c = c
            elif min_c > c:
                min_c = c

    if min_c is None:
        return ['TLE']
    else:
        return [min_c]


# 引数を取得
def get_input_lines():
    line = input()
    values = list(map(int, line.split()))
    N = values[0]
    lines = list()
    lines.append(line)
    for _ in range(N):
        lines.append(input())
    return lines


# テストデータ
def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['3 70', '7 60', '1 80', '4 50']
        lines_export = [4]
    if pattern == 2:
        lines_input = ['4 3', '1 1000', '2 4', '3 1000', '4 500']
        lines_export = ['TLE']
    if pattern == 3:
        lines_input = ['5 9', '25 8', '5 9', '4 10', '1000 1000', '6 1']
        lines_export = [5]
    return lines_input, lines_export


# 動作モード判別
def get_mode():
    import sys
    args = sys.argv
    if len(args) == 1:
        mode = 0
    else:
        mode = int(args[1])
    return mode


# 主処理
def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines()
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    # if mode > 0:
    #     print(f'lines_input=[{lines_input}]')
    #     print(f'lines_export=[{lines_export}]')
    #     print(f'lines_result=[{lines_result}]')
    #     if lines_result == lines_export:
    #         print('OK')
    #     else:
    #         print('NG')
    # finished = time.time()
    # duration = finished - started
    # print(f'duration=[{duration}]')


# 起動処理
if __name__ == '__main__':
    main()


Measured memory_bytes: 9292
#include <bits/stdc++.h>
 
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef int ftype;
typedef complex<ftype> point;
 
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second 
#define debug(x)  do{cerr<<#x<<": "<<x<<"\n";}while(0)
#define debugv(x) do{cerr<<#x<<": ";for(auto&e: (x))cerr<<e<<" ";cerr<<"\n";}while(0)
#define fori(i, n) for (int i = 0; i < (int)(n); ++i)
#define forn(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n); i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define FAIL0 {cout << "0\n"; return 0;}
#define FAIL1 {cout << "-1\n"; return 0;}
#define FAILNO {cout << "No\n"; return 0;}
#define YES {cout << "Yes\n"; return 0;}

const int MAXN = 1e3+3;
const int MOD = 1e9+7;

LL N;
int A[MAXN][MAXN];
int day[MAXN];
int idx[MAXN];
queue<pair<int,int>> qu;
int ans;

void push(int i, int j) {
    qu.push({min(i,j),max(i,j)});
}


int main() {
#ifdef OJ
    freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin >> N;
    fore(i,1,N) fore(j,1,N-1) cin >> A[i][j];
    fore(i,1,N) {
        idx[i] = 1;
        int j = A[i][1];
        if(A[j][1] == i) {
            if(i<j) push(i,j);
        }
    }

    while(qu.size()) {
        int i = qu.front().fi;
        int j = qu.front().se;
        qu.pop();
        if(day[i] == ans || day[j] == ans) ans++;
        day[i] = ans;
        day[j] = ans;

        idx[i]++;
        if(idx[i] <= N-1) {
            int v = A[i][idx[i]];
            if(A[v][idx[v]] == i) push(i,v);
        }

        idx[j]++;
        if(idx[j] <= N-1) {
            int v = A[j][idx[j]];
            if(A[v][idx[v]] == j) push(j,v);
        }
    }

    int ok = 1;
    fore(i,1,N) ok = idx[i] == N;
    if(!ok) ans = -1;

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


Measured memory_bytes: 4224
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;


int main()
{
	int n,k;
	cin>>n;
	cin>>k;
	int ans = 1;
	for(int i = 0; i < n; i++){
		if( k <= ans){
			ans = ans + k;
		}else{
			ans = ans + ans;
		}
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 3132
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def pf(s): return print(s, flush=True)

s = input()
K = I()
#  s = ''.join(['a' if i % 2 == 0 else 'b' for i in range(5000)])
#  K = 1

combis = []
for i in range(1, K+1):
    start = 0
    while start+i <= len(s):
        combi = s[start:start+i]
        combis.append(combi)
        start += 1
#  print(combis)
combis = list(set(combis))
combis = sorted(combis)
print(combis[K-1])


Measured memory_bytes: 66924
//OpÖðg¤
#include<stdio.h>
#include<math.h>

#define PI 3.1415926535898
int main(void){
	double x=0,y=0;
	double w,a,ah=90,rad;	//w=àAa=pxAah=»Ì_Åü¢Ä¢épx
	
	while(1){
		scanf("%lf,%lf",&w,&a);
		if(w==0 && a==0)
			break;
		rad=ah*PI/180;
		x+=cos(rad)*w;
		y+=sin(rad)*w;
		ah-=a;
	}
	printf("%d\n%d\n",(int)x,(int)y);
	
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#include<string>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
int main(void){
    // Your code here!
    string s,t;
    cin >> s;
    cin >> t;
    
    int count = 0;
    
    for(int i=0;i<s.size();i++){
        if(s[i] != t[i]){
            count++;
        }
    }
    
    cout << count << endl;
    
}


Measured memory_bytes: 3916
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public int[] Sarray() { return ReadLine().Split().Select(int.Parse).ToArray(); }
        static public List<int> Slist() { return ReadLine().Split().Select(int.Parse).ToList(); }

        static int N;
        static int[,] Move;
        static int[,] dp;
        static void Main(string[] args)
        {
            N = Slist()[0];
            Move = new int[N + 1, 3];
            dp = new int[N + 1, 3];

            for (var i = 0; i < N; ++i)
            {
                var t = Sarray();
                Move[i, 0] = t[0];
                Move[i, 1] = t[1];
                Move[i, 2] = t[2];
            }
            dp[0, 0] = Move[0, 0];
            dp[0, 1] = Move[0, 1];
            dp[0, 2] = Move[0, 2];

            WriteLine(Max(calchappy(N - 1, 0), Max(calchappy(N - 1, 1), calchappy(N - 1, 2))));
        }
        static int calchappy(int day, int move)
        {
            if (dp[day, move] != 0) return dp[day, move];
            return dp[day, move] = Max(calchappy(day - 1, (move + 1) % 3), calchappy(day - 1, (move + 2) % 3))
                                    + Move[day, move];
        }
    }
}


Measured memory_bytes: 22444
N = int(input())
Ai = [int(i) for i in input().split()]

leftSum = 0
rightSum = 0
K = N
L = 0

for i in range(0,N):
    if(leftSum < rightSum):
        leftSum = leftSum + Ai[L]
        L = L+1
    else:
        rightSum = rightSum + Ai[K-1]
        K = K-1
print(abs(leftSum-rightSum))

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

int main(){
  int A,B,C,D;
  cin>>A>>B>>C>>D;
  
  int ans=0;
  for(int a=A;a<=B;a++){
    for(int b=C;b<=D;b++){
      if((a<=b&&a!=C)&&(a>=b&&b!=A)){
        if(a==b)ans++;
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}

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

namespace ABC119 {
	class ABC119_B {
		static void Main(string[] args) {
			var N = int.Parse(Console.ReadLine());
			var dict = new Dictionary<string, double>() {
				["JPY"] = 0,
				["BTC"] = 0,
			};
			for (int i = 0; i < N; i++) {
				var input = Console.ReadLine().Split(' ').ToArray();
				var val = double.Parse(input[0]);
				var spc = input[1];
				dict[spc] += val;
			}

			Console.WriteLine(dict["JPY"] + ConvertBTCToJPY(dict["BTC"], 380000));
		}

		private static double ConvertBTCToJPY(double count, double rate) {
			return count * rate;
		}
		
	}
}


Measured memory_bytes: 13280
import collections
N, A = [int(_) for _ in input().split()]
X = [int(_) for _ in input().split()]
Y = X[:N // 2]
Z = X[N // 2:]


def calc(W):
    #dp[m][s]=m枚のカードの和がsとなるような選び方の総数
    M = len(W)
    dp = [collections.defaultdict(int) for _ in range(M + 1)]
    dp[0][0] = 1
    for i, w in enumerate(W):
        for j in range(i, -1, -1):
            for k, v in dp[j].items():
                dp[j + 1][k + w] += v
    return dp


dpy = calc(Y)
dpz = calc(Z)
ans = 0
for n in range(1, N + 1):
    B = A * n
    for l in range(n + 1):
        r = n - l
        if l >= len(dpy) or r >= len(dpz):
            continue
        for k, v in dpy[l].items():
            ans += v * dpz[r][B - k]
print(ans)


Measured memory_bytes: 10780
import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}
import Math.abs

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val H, W, D = in.next().toInt
  val A = Array.ofDim[Int](H+1, W+1)
  for(y <- 1 to H; x <- 1 to W) {
    A(y)(x) = in.next().toInt
  }

  val zahyo = new Array[(Int, Int)](H*W+1)
  for(y <- 1 to H; x <- 1 to W) {
    zahyo(A(y)(x)) = (x, y)
  }

  val dp = new Array[Int](H*W+1)

  for(i <- 1 to D) {
    val (ix, iy) = zahyo(i)
    dp(i) = 0

    var cnt = i + D
    var now = 0

    while(cnt <= W*H) {

      val (px, py) = zahyo(cnt - D)
      val (x, y) = zahyo(cnt)

      now += abs(x-px) + abs(y - py)
      dp(cnt) = now

      cnt += D
    }
  }

  val Q = in.next().toInt
  for(_ <- 1 to Q){
    val L, R = in.next().toInt
    val ans = dp(R) - dp(L)
    pw.println(ans.toString)
  }
  pw.flush()
}


class InputReader(stream: InputStream) {
  private val reader = new BufferedReader(new InputStreamReader(stream))
  private var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}


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

int main() {
	int n;
	int person[4][3][10] = {};
	int b, f, r, v;

	int temp;

	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> b >> f >> r >> v;
		person[b-1][f-1][r-1] += v;
	}

	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 10; k++) {
				printf(" %d", person[i][j][k]);
			}
			printf("\n");
		}
		if(i < 3)printf("####################\n");
	}
	return 0;
}

Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define REP(i, n) for(ll i=0; i<(ll)(n); i++)
#define REPD(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main(){
    ll n;   cin >> n;
    vector<ll> a(n);
    REP(i, n)   cin >> a[i];
    
    sort(ALL(a));
    vector<ll> isOk(a.back()+1, false);
    int i=0;
    REP(i, n){
        if(isOk[a[i]]) continue;
        if(0<i && a[i]==a[i-1]) isOk[a[i]] = true;
        for(ll k = 2*a[i]; k<=a.back(); k+=a[i]){

            isOk[k] = true;
        }
    }

    ll res=0;
    REP(i, n){
        if(!isOk[a[i]]) res += 1;

    }
    cout << res << endl;
}


Measured memory_bytes: 12672
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstdlib>

using namespace std;

template<class T> void gc(T &x)
{
    char c;
    int s = 0;
    x = 0;

    c = getchar_unlocked();

    if (c == '-') s = 1;
    else if ('0' <= c && c <= '9')  x = c - '0';

    while (true)
    {
        c = getchar_unlocked();

        if (c < '0' || c > '9') break;
        x = x * 10 + (c - '0');
    }

    if (s) x = -x;
}

int main()
{
    int N;

    gc(N);

    int nowT = 0;
    int nowX = 0;
    int nowY = 0;

    bool flg = true;
    for (int i = 0; i < N; i++)
    {
        int t, x, y;
        gc(t);
        gc(x);
        gc(y);

        int dx = abs(x - nowX);
        int dy = abs(y - nowY);

        if (t - nowT < dx + dy)
        {
            flg = false;
            break;
        }

        if (dx + dy == t - nowT)
        {
            nowT = t;
            nowX = x;
            nowY = y;
        }
        else if (
            ((dx + dy) % 2 == 0 && (t - nowT) % 2 == 0)
            || ((dx + dy) % 2 == 1 && (t - nowT) % 2 == 1))
        {
            nowT = t;
            nowX = x;
            nowY = y;
        }
        else
        {
            flg = false;
            break;
        }
    }

    if (flg) printf("%s\n", "Yes");
    else printf("%s\n", "No");

    return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;
typedef long long ll;
ll xor_sum(ll x){
	if(x==-1) return 0;
	if(x==0) return 0;
	if(x==1) return 1;
	if(x==2) return 3;
	ll k = 1;
	while(k<=x) k *= 2;
	if(k==x) return k;
	if(k==x+1) return 0;
	x -= k/2;
	ll ret = 0;
	if(!(x&1)) ret += k/2;
	return ret + xor_sum(x);
}

int main(){
	ll a,b;
	cin >> a >> b; a--;
	/*int i,k = 0;
	for(i=0;i<=32;i++){
		k = k^i;
		cout << xor_sum(i) << " " << k  << endl;
	}*/
	ll c = xor_sum(b)^xor_sum(a);
	cout << c << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;

const int N=100005;

struct E{
	int to,next;
}mem[N<<1];
int n,x,y,m,num,h,t,tag;
int head[N],q[N<<2];
bool vis[N];

void add(int x,int y){
	num++;
	mem[num].to=y; mem[num].next=head[x];
	head[x]=num;
}

int main(){
	int i,j,u;
	scanf("%d%d",&n,&m);
	for (i=1;i<=m;i++){
		scanf("%d%d",&x,&y);
		add(x,y); add(y,x);
	}
	h=t=100000; q[h]=1; vis[1]=1;
	while (1){
		x=q[h]; y=q[t]; tag=0;
		for (j=head[x];j;j=mem[j].next){
			u=mem[j].to;
			if (!vis[u]){
				q[--h]=u; vis[u]=1;
				tag=1;
				break;
			}
		}
		for (j=head[y];j;j=mem[j].next){
			u=mem[j].to;
			if (!vis[u]){
				q[++t]=u; vis[u]=1;
				tag=1;
				break;
			}
		}
		if (!tag) break;
	}
	printf("%d\n",t-h+1);
	for (i=h;i<=t;i++) printf("%d ",q[i]);
	return 0;
}

Measured memory_bytes: 3200
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1 << 28;
const double EPS = 1e-10;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

int main()
{
	int x;
	cin >> x;
	if (x == 3 || x == 5 || x == 7) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}


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

int main() {
  int64_t N, A[100];
  cin >> N;
  A[0] = 2;
  A[1] = 1;
  for(int i=2;i<100;i++) {
    A[i] = A[i-1] + A[i-2];
  }
  cout << A[N] << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define lld long double
#define fi first
#define se second
#define w(x) ll x;cin>>x;while(x--)
#define mod 1000000007
#define fio ios_base::sync_with_stdio(false);cin.tie(0);
using namespace std;

int main(){
    fio;
    string s;   cin>>s;
    ll sum=0;
    vector<int> v;
    for(int i=0;i<s.length();i++){
        if(s[i]=='B'){
            v.push_back(i);
        }
    }
    reverse(v.begin(),v.end());
    int size=s.length()-1;
    for(int i=0;i<v.size();i++){
        sum+=(size-v[i]);
        size-=1;
    }
    cout<<sum<<'\n';
    return 0;
}

Measured memory_bytes: 4244
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter,defaultdict
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)
# INF =  float("inf")
INF = 10**18
import bisect
import statistics
mod = 10**9+7
# mod = 998244353

N, X, T = map(int, input().split())

print(math.ceil(N/X)*T)























Measured memory_bytes: 11000
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int a[n];
    int ans=0;
    for(int i=0;i<n;i++){
        cin >> a[i];
        if(i%2==0 && a[i]%2==1)ans++;
    }
    cout << ans;
}

Measured memory_bytes: 3592
#include <cstdio>
#include <algorithm>
using namespace std;

int m,d,ans=0;

int main(void){
	scanf("%d %d",&m,&d);
	for(int i=1;i<=m;i++){
		int a,b;
		for(int j=1;j<=d;j++){
			a=j%10;
			b=j/10;
			if(a*b==i&&a>=2&&b>=2)ans++;
		}
	} 
	printf("%d",ans);
} 

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
/***********************************************/
/* Dear online judge:
 * I've read the problem, and tried to solve it.
 * Even if you don't accept my solution, you should respect my effort.
 * I hope my code compiles and gets accepted.
 *  ___  __     _______    _______      
 * |\  \|\  \  |\  ___ \  |\  ___ \     
 * \ \  \/  /|_\ \   __/| \ \   __/|    
 *  \ \   ___  \\ \  \_|/__\ \  \_|/__  
 *   \ \  \\ \  \\ \  \_|\ \\ \  \_|\ \ 
 *    \ \__\\ \__\\ \_______\\ \_______\
 *     \|__| \|__| \|_______| \|_______|
 */
const long long mod = 1000000007;

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

	string s;
	cin>>s;
	int res = INT_MAX;
	for(char c = 'a';c <= 'z';c++) {
		int cur = 0;
		int last = (int)s.size();
		for(int i = (int)s.size()-1;i >= 0;i--) {
			if(s[i] == c) {
				last = i;
				continue;
			}
			cur = max(cur,last - i);
		}
		res = min(res,cur);
	}
	cout<<res<<'\n';
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

int ans,Min;
int n,m,d;
int s[100001],k[10001];

int func(int x);

int main(){
	while (1) {
		cin>>d;
		if (d==0)break;
		cin>>n>>m;
		s[0]=0;
		for (int i=1; i<n; i++) {
			cin>>s[i];
		}
		s[n++]=d;
		sort(s, s+n);
		ans=0;
		for (int i=0; i<m; i++) {
			cin >> k[i];
			ans+=func(k[i]);
		}
		
		cout << ans << endl;
	}
}

int func(int x){
	int l=0,r=n;
	Min=1000000000;
	while(l<=r){
		int i=(l+r)/2;
		if (s[i]==x) {
			Min=0;
			
			break;
		}
		if (s[i]<x) {
			Min=min(Min,abs(s[i]-x));
			l=i+1;
		}
		else {
			Min=min(Min,abs(s[i]-x));
			r=i-1;
		}
	}
	return Min;
}

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

int main() {
	string d[50];
	char a[52][52];
	int h = 0;
	int w = 0;
	cin >> h >> w;
	for (int i = 0; i < h; ++i) {
		cin >> d[i];
	}

	for (int i = 0; i < 52; ++i) {
		for (int j = 0; j < 52; ++j) {
			a[i][j] = '.';
		}
	}

	for(int i = 0; i < h; ++i) {
		for (int j = 0; j < w; ++j) {
			a[i + 1][j + 1] = d[i][j];
		}
	}

	bool check = true;
	for (int i = 1; i < h + 1; ++i) {
		for (int j = 1; j < w + 1; ++j) {
			if (a[i][j] == '#') {
				if (a[i - 1][j] == '.' && a[i + 1][j] == '.' && a[i][j - 1] == '.' && a[i][j + 1] == '.') {
					check = false;
				}
			}
		}
	}

	if (check) {
		cout << "Yes\n";
	}
	else {
		cout << "No\n";
	}

	return 0;
}


Measured memory_bytes: 256