akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#pragma GCC optimize ("trapv")
using namespace std;

#define pii pair<int, int>
#define pll pair<long long, long long>
#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define DEBUG 1
#define cerr if (DEBUG) cerr
#define test cerr << "hi\n";

//mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
//#define rand(l, r) uniform_int_distribution<long long>(l, r)(rng)
//using namespace __gnu_pbds;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> OST;

#define INF 0x3f3f3f3f3f3f3f3f
#define MAXN 200005
//#define MOD 998244353LL
#define MOD 1000000007LL

int n, m;
vector<pair<pii, int> > games;
int p[MAXN], col[MAXN];
vector<int> v[MAXN];

void join(int x, int y, int st) {
    x = p[x], y = p[y];
    if (x == y) return;
    if (v[x].size() < v[y].size())
        swap(x, y);

    // v[x] > v[y]

    int col_shift = col[x]+st+3-col[y];

    int src = p[y];
    for (int i = 0; i < v[src].size(); i++) {
        int q = v[src][i];
        p[q] = p[x];
        v[p[x]].pb(q);
        (col[q] += col_shift) %= 3;
    }
    v[src].clear();
}

int work(int go) {
    for (int i = 0; i < n; i++) {
        p[i] = i;
        v[i].clear();
        v[i].pb(i);
        col[i] = 0;
    }

    for (int i = 0; i < m; i++) {
        int u, v, st;
        u = games[i].fi.fi;
        v = games[i].fi.se;
        st = games[i].se;

        if (u == go or v == go)
            continue;

        if (p[u] != p[v]) {
            join(u, v, st);
        }
        else {
            if ((col[u]+st)%3 != col[v])
                return i;
        }
    }

    return -1;
}

int val[255];
int q;

void solve() {
    cin >> n >> q;
    iota(p+1, p+1+n, 1);
    for (int i = 0; i <= n; i++)
        v[i].pb(i);
    while (q--) {
        int t, u, v;
        cin >> t >> u >> v;
        if (t == 0) {
            join(u, v, 0);
        }
        if (t == 1) {
            cout << (p[u] == p[v]) << '\n';
        }
    }
}

int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    auto start_time = clock();
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int t = 1;
//    cin >> t;
    for (int no = 1; no <= t; no++) {
//        cout << "Case #" << no << ": ";
        solve();
    }

#ifdef LOCAL
    cerr << "TIME ELAPSED: " << double(clock() - start_time) / CLOCKS_PER_SEC << '\n';
#endif
}

Measured memory_bytes: 15928
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
string str(ll i) {
    return i < 0 ? "" : str((i / 26) - 1) + (char)(65 + i % 26);
}
int main()
{
   ll n,k;
   cin>>n;
   string sl=str(n-1);
   transform(sl.begin(), sl.end(), sl.begin(), ::tolower); 
   cout<<sl<<endl;
   
}

Measured memory_bytes: 3624
#include<iostream>
#include <algorithm>
using namespace std;
int main(){
  int a,b,c,d,tb[101];
  while(1){
    cin>>a>>b;
    for(int i=0;i<b;i++){
      tb[i]=b-i;
    }
    if(a==b&&b==0)break;
    for(int i=0;i<a;i++){
      for(int j=0;j<b;j++){
	cin>>c;
	if(c==1)tb[j]+=1000;
      }
    }
    
    sort(tb,tb+b);

    for(int i=0;i<b;i++){
      // cout<<" "<<tb[i]<<endl;
    }

    cout<<1+b-(tb[b-1]%1000);
    for(int i=b-2;i>=0;i--){
      cout<<" "<<1+b-(tb[i]%1000);
    }
    cout<<endl;
  }
  return 0;
}

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

using namespace std;

int main(void) {
  int K; cin >> K;
  long long ans = 0;
  int gcd_pair[K+1][K+1];
  memset (gcd_pair, 0, sizeof(gcd_pair));

  for (int i = 1; i <= K; i++) ans += i;

  for (int i = 1; i < K; i++) {
    for (int j = i+1; j <= K; j++) {
      ans += 6 * (gcd_pair[i][j] = gcd(i, j));
    }
  }

  for (int i = 1; i < K-1; i++) {
    for (int j = i+1; j < K; j++) {
      for (int k = j+1; k <= K; k++) {
        ans += 6 * gcd_pair[gcd_pair[i][j]][k];
      }
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3676
/*Made by Shivam Solanki*/
#include<bits/stdc++.h>
#pragma GCC optimize ("Ofast")
using namespace std;
#define DEBUG(x) cerr << '>' << #x << ':' << x << endl;
#define ll long long int
#define endl '\n'
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<pii> vp;
typedef vector<pll> vpll;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef set<int> sii;
typedef set<ll> sll;
typedef queue<int> qii;
typedef priority_queue<int> pq;
typedef unordered_map<int,int> umii;
typedef unordered_map<ll,ll> umll;
#define all(x) x.begin(),x.end()
#define rep(i,k,n) for (int i = k; i < n; ++i) 
#define repr(i,k,n) for (int i = n; i>=k; --i)
#define repll(i,k,n) for (ll i = k; i < n; ++i) 
#define pb push_back
#define mp make_pair
#define gcd __gcd
#define F first
#define S second
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const int INF = 1e9+5;
const int MOD = 1e9+7;
double pi = 2 * acos(0.0); 

void solve(){
   int h,w,K;
   cin>>h>>w>>K;
   vector<string>a(h);
   rep(i,0,h) cin>>a[i];
   int ans=0,ctr=0;
   string s="";
   rep(i,0,h){
      s+=to_string(i);
   }
   set<string>s1,s2;
   rep(i,0,pow(2,s.size())){
      string x="";
      rep(j,0,s.size()){
         if(i&(1<<j)) x+=s[j];
      }
      //cout<<x<<endl;
      s1.insert(x);
   }
   s="";
   rep(i,0,w){
      s+=to_string(i);
   }
   rep(i,0,pow(2,s.size())){
      string x="";
      rep(j,0,s.size()){
         if(i&(1<<j)) x+=s[j];
      }
      //cout<<x<<endl;
      s2.insert(x);
   }
   for(string check1:s1){
      for(string check2:s2){      
         int ctr=0;
         rep(i,0,h){
            rep(j,0,w){
               string c1=to_string(i),c2=to_string(j);
               bool f1=1,f2=1;
               //cout<<c<<'\n';
               for(char cx:check1){
                  if(c1[0]==cx){
                     f1=0;
                     break;
                  }
               }
               for(char cx:check2){
                  if(c2[0]==cx){
                     f2=0;
                     break;
                  }
               }
               if(f1 and f2 and a[i][j]=='#') ctr++;
            }
         }
         //cout<<check<<' '<<ctr<<'\n';
         if(ctr==K) ans++;
      }
   }
   // for(string check:s2){
   //    int ctr=0;
   //    rep(i,0,h){
   //       rep(j,0,w){
   //          string c=to_string(j);
   //          bool f=1;
   //          for(char cx:check){
   //             if(c[0]==cx){
   //                f=0;
   //                break;
   //             }
   //          }
   //          if(f and a[i][j]=='#') ctr++;
   //       }
   //    }
   //    //cout<<check<<' '<<ctr<<'\n';
   //    if(ctr==K) ans++;
   // }
   cout<<ans;
}

int main(){ 
    // #ifndef ONLINE_JUDGE  
        // freopen("input.txt", "r", stdin); 
        // freopen("output.txt", "w", stdout); 
    // #endif 
   //  fastio;
    int t=1;
   //  cin>>t;
    while(t--)
        solve();
    return 0;
}


Measured memory_bytes: 4172
#include <stdio.h>
#define MAX 100000
#define VMAX 100000

int main(){
    int n, i, j, A[MAX], tmp, x ;

    //input
    scanf("%d", &n);
    for(i=0; i<n; i++) scanf("%d", &A[i]);
    x = A[n-1];
    //sort
    for(i=-1, j=0; j<n-1; j++){
	if(A[j] <= x){
	    i++;
	    tmp = A[i];
	    A[i] = A[j];
	    A[j] = tmp;
	}
    }
    tmp = A[i+1]; A[i+1] = A[n-1]; A[n-1] = tmp;
    //display
    for(j=0; j<n; j++){
	if(j == i+1) printf("[");
	printf("%d", A[j]);
	if(j == i+1) printf("]");
	if(j < n-1) printf(" ");
    }
    printf("\n");
    return 0;
}



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

using namespace std;

int main(){
    int n;
    unordered_map <string,int> m;
    int count = 0;
    cin >> n;
    
    for(int i = 0; i < n; i++){
        string s;
        cin >> s;
        if(m[s] == 0) count++,m[s] = 1;
    }
    
    cout << count;
    
    return 0;
}

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

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define fi first
#define sc second
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define ANS cout << ans << endl
#define RETURN(x)    \
  cout << x << endl; \
  return 0
clock_t CLOCK;
#define START_TIMER CLOCK = clock()
#define SHOW_TIMER cerr << "time: " << (ld)(clock() - CLOCK) / 1000000 << endl
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define debug(x) cerr << "[debug] " << #x << ": " << x << endl;
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << endl;
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using mll = map<ll, ll>;
using qll = queue<ll>;
using P = pair<ll, ll>;

constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

signed main() {
  init();
  ll N, M;
  cin >> N >> M;

  vector<P> key;

  rep(i, M) {
    ll a, b;
    cin >> a >> b;
    ll s = 0;
    rep(j, b) {
      ll c;
      cin >> c;
      --c;
      s |= 1 << c;
    }
    key.pb({s, a});
  }

  vll dp(1 << N, INF);
  dp[0] = 0;
  rep(s, 1 << N) {
    rep(i, M) {
      ll t = s | key[i].first;
      ll cost = dp[s] + key[i].second;
      dp[t] = min(dp[t], cost);
    }
  }

  ll ans = dp.back();
  if (ans == INF) {
    COUT(-1);
    return 0;
  }
  ANS;
  return 0;
}

Measured memory_bytes: 3656
#include <iostream>
using namespace std;
int k[100005];
bool fl[100005];
int main() {
	int a, b, c;
	cin >> a;
	for (int i = 2; i <= 100000; ++i) {
		if (!fl[i]) {
			for (int j = 2 * i; j <= 100000; j += i) {
				fl[j] = 1;
			}
		}
	}
	for (int i = 3; i <= 100000; i += 2) {
		if (!fl[i] && !fl[(i + 1) / 2]) {
			k[i]++;
		}
	}
	for (int i = 3; i <= 100000; ++i) {
		//るいせきわ
		k[i] += k[i - 1];
	}
	while (a--) {
		cin >> b >> c;
		cout << k[c] - k[b - 1] << endl;
	}
}

Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstring>

#define ll long long
const ll MOD = 1e9 + 7;

int main()
{
    std::ios::sync_with_stdio(false);
    int H, W;
    std::cin >> H >> W;

    int N = H * W;

    char graph[H][W];
    ll dp[H][W];
    memset(dp, 0, sizeof(dp));

    for (int h=0; h<H; h++)
    {
        for (int w=0; w<W; w++)
        {
            std::cin >> graph[h][w];
        }
    }

    dp[0][0] = 1;

    // 右、下へと走査
    for (int h=0; h<H; h++)
    {
        for (int w=0; w<W; w++)
        {
            // 右と接続
            if (w < W - 1 && graph[h][w+1] == '.')
            {
                dp[h][w+1] += dp[h][w];
                dp[h][w+1] %= MOD;
            }
            // 下と接続
            if (h < H - 1 && graph[h+1][w] == '.')
            {
                dp[h+1][w] += dp[h][w];
                dp[h+1][w] %= MOD;
            }
        }
    }

    /*
    for (int h=0; h<H; h++)
    {
        for (int w=0; w<W; w++)
        {
            std::cout << dp[h][w] << ", ";
        }
        std::cout << std::endl;
    }
    */

    std::cout << dp[H-1][W-1];
}

Measured memory_bytes: 9088
import java.io.*;
import java.util.*;

public class Main {
  private static String solve(char[] cs) {
    char cFirst = cs[0];
    char cLast = cs[cs.length - 1];
    return (cFirst == cLast) == (cs.length % 2 != 0) ? "Second" : "First";
  }
  
  private static void execute(ContestReader reader, PrintWriter out) {
    char[] cs = reader.nextCharArray();
    out.println(solve(cs));
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
  
  public String[] next(int n) {
    String[] array = new String[n];
    for (int i = 0; i < n; i++) {
      array[i] = next();
    }
    return array;
  }
  
  public int[] nextInt(int n) {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  }
  
  public long[] nextLong(int n) {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  }
  
  public double[] nextDouble(int n) {
    double[] array = new double[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextDouble();
    }
    return array;
  }
  
  public char[] nextCharArray() {
    return next().toCharArray();
  }
  
  public int[][] nextInt(int n, int m) {
    int[][] matrix = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextInt();
      }
    }
    return matrix;
  }
  
  public long[][] nextLong(int n, int m) {
    long[][] matrix = new long[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextLong();
      }
    }
    return matrix;
  }
  
  public double[][] nextDouble(int n, int m) {
    double[][] matrix = new double[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextDouble();
      }
    }
    return matrix;
  }
  
  public char[][] nextCharArray(int n) {
    char[][] matrix = new char[n][];
    for (int i = 0; i < n; i++) {
      matrix[i] = next().toCharArray();
    }
    return matrix;
  }
}


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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;

Node root,NIL;
Node treeMinimum(Node x){


}

Node treeMaximum(Node x){


}

Node treeSearch(Node u, int k){
  while(u != NIL && k != u->key){
    if(k < u->key)
      u=u->left;
    else u=u->right;
  }
  return u;
}

Node treeSuccessor(Node x){


}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y



}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y=x;
    if(z->key < x->key){
      x=x->left;
    }
    else{
      x=x->right;
    }
  }
  z->parent=y;
  if(y == NIL)
    root=z;
  else{
    if(z->key < y->key)
      y->left=z;
    else y->right=z;
  }
}

void inorder(Node u){
  if(u==NIL)
    return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node u){
  if(u==NIL)
    return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}

int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}




Measured memory_bytes: 20444
#include <stdio.h>

int n;
int x;
int i;
int hoge[256];
main(){
	scanf("%d",&n);
	for(i=0; i<n; i++){
		scanf("%d",&x);
		hoge[i]=x;
	}
	for(i= n-1; i>0; i--){
		printf("%d ",hoge[i]);
	}
	printf("%d\n",hoge[0]);
	return 0;
}

Measured memory_bytes: 596
//agc024_b.cpp
//Thu Jul  9 22:33:11 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007

using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

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

	int count = 1;
	int ans = 1;
	for (int i=1;i<n;i++){
		if (q[i]>q[i-1]){
			count++;
		}else {
			count = 1;
		}
		ans = max(ans,count);
	}


	cout << n-ans << endl;
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 5168
s = list(input())
k = int(input())
n = len(s)
for i in range(n-1):
    d = (ord('z')-ord(s[i])+1)%26
    if d<=k:
        s[i] = 'a'
        k -= d

x = ord(s[-1])+k%26
if x>ord('z'):x-=26
s[-1] = chr(x)


print(''.join(s))


Measured memory_bytes: 4152
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;
typedef long long ll;

int N;
char buf[3][110];

int main(void) {
  scanf("%d", &N);
  REP(i, 3) {
    scanf("%s", buf[i]);
  }
  int res = 0;
  REP(i, N) {
    if(buf[0][i] == buf[1][i] && buf[1][i] == buf[2][i]) {
      res += 0;
    } else if(buf[0][i] == buf[1][i] || buf[1][i] == buf[2][i] ||  buf[2][i] == buf[0][i]) {
      res += 1;
    } else {
      res += 2;
    }
  }
  cout << res << endl;
  return 0;
}


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

int main()
{
	int n,l; string s;
  cin >> n >> s;
  l= s.length();
  rep(i,l){
    if((s[i]+n)>90){
    	int k=n-(90-s[i])-1;
      	s[i]=65+k;
    }
    else
    s[i] = int(s[i])+n;
  }
  cout << s;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
#include <time.h>


using namespace std;

int main(void) {



	int H = 0, W = 0;
	string res = "Yes";
	cin >> H >> W;
	char cam[50][50] = {};

	for (int j = 0; j < H; j++)
		for (int i = 0; i < W; i++)
			cin >> cam[j][i];
	int ci = 0, cj = 0;
	for (cj = 0; cj < H;cj++) {
		for (ci = 0; ci < W;ci++) {
			if (cam[cj][ci] == '#') {

				if (cj == 0 && ci == 0) { if (cam[cj + 1][ci] != '#' && cam[cj][ci + 1] != '#') { res = "No"; break; } }
				else if (cj == H - 1 && ci == W - 1) { if (cam[cj - 1][ci] != '#' && cam[cj][ci - 1] != '#') { res = "No"; break; } }
				else if (cj == 0 && ci == W - 1) { if (cam[cj + 1][ci] != '#' && cam[cj][ci - 1] != '#') { res = "No"; break; } }
				else if (cj == H - 1 && ci == 0) { if (cam[cj - 1][ci] != '#' && cam[cj][ci + 1] != '#') { res = "No"; break; } }
				else if (ci == 0) { if (cam[cj - 1][ci] != '#' && cam[cj + 1][ci] != '#' &&cam[cj][ci + 1] != '#') { res = "No"; break; } }
				else if (ci == W - 1) { if (cam[cj - 1][ci] != '#' && cam[cj + 1][ci] != '#' &&cam[cj][ci - 1] != '#') { res = "No"; break; } }
				else if (cj == 0) { if (cam[cj][ci - 1] != '#' && cam[cj][ci + 1] != '#' &&cam[cj + 1][ci] != '#') { res = "No"; break; } }
				else if (cj == W - 1) { if (cam[cj][ci - 1] != '#' && cam[cj][ci + 1] != '#' &&cam[cj - 1][ci] != '#') { res = "No"; break; } }
				else { if (cam[cj][ci - 1] != '#' && cam[cj][ci + 1] != '#' &&cam[cj - 1][ci] != '#' && cam[cj + 1][ci] != '#') { res = "No"; break; } }






			}
		}
		
	}


	cout << res << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		long c = sc.nextLong();
		if(a == b && b == c) {
          if(a%2==0) System.out.println(-1);
          if(a%2==1) System.out.println(0);
			return;
		}
		int ans = 0;
		while(a % 2 == 0 && b % 2 == 0 && c % 2 == 0) {
			ans++;
			long x = a / 2 + b / 2;
			long y = b / 2 + c / 2;
			long z = c / 2 + a / 2;
			a = y;
			b = z;
			c = x;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 23124
import java.util.Scanner;
import java.util.Arrays;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(), tmp = 0;
		long A[] = new long[N], ans = 0;
		for (int i = 0; i < N; ++i) A[i] = sc.nextLong();
		sc.close();
		Arrays.sort(A);
		for (int i = N - 1; i > 0 && tmp != 2; --i) {
			if (A[i - 1] == A[i]) {
				if (tmp == 0) {
					ans = A[i];
					tmp = 1;
				}
				else {
					ans *= A[i];
					tmp = 2;
				}
				--i;
			}
		}
		if (tmp == 2) System.out.print(ans);
		else System.out.print(0);
	}
}

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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

// ====================================================================

int main() {
  ll r, g, b, n;
  cin >> r >> g >> b >> n;
  // RとGについて考える
  ll ans = 0;
  for (int i = 0; i * r <= n; i++) {
    for (int j = 0; i * r + j * g <= n; j++) {
      if ((n - (i * r + j * g)) % b == 0) {
        ans++;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
/*
    HARSHAD VAGHASIYA

        @DAIICT
        
          H_M_Vaghasiya

            */
#include<bits/stdc++.h>
using namespace std;
#define FS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define INF 10000000000
#define ld long double
#define pb push_back
#define mp make_pair
#define pu push
#define vsz(v) cout<<v.size()<<endl; 
#define printv(v) for(ll i=0;i<v.size();i++)cout<<v[i]<<" "; cout<<endl;
#define printvpair(v) for(ll i=0;i<v.size();i++)cout<<v[i].first<<" "<<v[i].second<<endl;
#define sz size()
#define ff first
#define ss second
#define setpri(x) cout<<setprecision(x);
#define all(v) v.begin(),v.end()
ll gcd(ll a,ll b){return __gcd(a,b);}
ll fact(ll n){ll s=1; for(ll i=1;i<=n;i++)s*=i; return s;}
ll pow1(ll n,ll k,ll mm){
    if(k==0)return 1;
    if(k%2==0)return (pow1((n%mm)*(n%mm),k/2,mm))%mm;
    return ((n%mm)*(pow1((n%mm)*(n%mm),k/2,mm)%mm))%mm;
}
ll pow2(ll n,ll k,ll m){ll ans=1;
    while(k>0){if(k%2==1)ans=ans*n;
        n=n*n;k/=2;
    }return ans;
}
bool func(pair<ll,ll> &a,pair<ll,ll> &b ){
	return a.first > b.first;
}
void solve(){
	FS;
    ll i,j,k,q,n,m,x,y,z;
	cin>>n;
	vector<pair<ll,ll>> a(n);
	for(i=0;i<n;i++){
		cin>>x;
		a[i]={x,i+1};
	}
	sort(all(a));
	for(i=0;i<n;i++){
		cout<<a[i].ss<<" ";
	}
	
}
int main(){
	ll i,j,k,n,m,x,y,z;
	n=1;
	//cin>>n;
	while(n--)solve();
	return 0;
}

Measured memory_bytes: 2432
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <map>
#define div 1000000000+7 
using namespace std;
typedef long long ll;

int main(){
  ll w, h, n;
  ll x, y, a;
  ll o = 0, q = 0;
  cin >> w >> h >> n;
  for(int i = 0; i < n; i++){
    cin >> x >> y >> a;
    if(a == 1 && o < x){
      o = x;
    }else if(a == 2 && x < w){
      w = x;
    }else if(a == 3 && q < y){
      q = y;
    }else if(a == 4 && y < h){
      h = y;
    }
  }
  ll result = (w-o) * (h-q);
  //cout << o << " " << q << " " << endl;
  if(result < 0){
    cout << 0 << endl;
  }else if(w-o < 0 && h-q < 0){
    cout << 0 << endl;
  }else{
    cout << result << endl;
  }
  return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	A, B, C, D := ReadInt(), ReadInt(), ReadInt(), ReadInt()
	p := cnt(A, B, C)
	q := cnt(A, B, D)
	r := cnt(A, B, LCM(C, D))
	fmt.Println(B - A + 1 - p - q + r)
}

func cnt(l, r, m int) int {
	return r/m - (l-1)/m
}

func LCM(a, b int) int { return a * b / GCD(a, b) }
func GCD(a, b int) int {
	if b == 0 {
		return a
	}
	return GCD(b, a%b)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int) { Scan(&i); return }


Measured memory_bytes: 1840
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>
#include <iomanip>
#include <functional>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define MAXMIN(a,b,c) std::max(a,min(b,c))
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

lli mod197 = 1000000007LL;
lli INF = 10000000000000;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}

	return d;
}

lli ans[200000] = {};

int main(void) {

	string s;
	cin >> s;

	lli n = s.size();

	for (int i = 0; i < n; i++) {
		if (s[i] == 'R' && s[i + 1] == 'L') {
			//rをカウントする
			for (int j = i; j >= 0 && s[j] == 'R'; j--) {
				if (j % 2 == i % 2) {
					ans[i]++;
				}
				else {
					ans[i + 1]++;
				}
			}
			//lをカウントする
			for (int j = i + 1;j < n &&  s[j] == 'L'; j++) {
				if (j % 2 == (i + 1) % 2) {
					ans[i + 1]++;
				}
				else {
					ans[i]++;
				}
			}
		}
	}


	for (int i = 0; i < n; i++) {
		cout << ans[i] << " ";
	}
	cout << endl;



	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2,t3;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;

int main(){
  ll a,b,c,d;
  cin >> a >> b >> c >> d;
  t1 = c / b;
  if(c % b != 0){
    t1++;
  }
  t2 = a / d;
  if(a % d != 0){
    t2++;
  }
  if(t1 > t2){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 3624
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す
  if n==1
    return Array.new(size){init}
  else
    return Array.new(n).map{Array.new(size){init}}
  end
end

n,q=get_i
a=get_i
X=get_i
X.each do|x|
  tail=0
  s=0
  ans=0
  n.times do|head|
    while tail<n and s+a[tail]<=x
      s+=a[tail]
      tail+=1
    end
    ans+=tail-head
    if tail==head
      tail+=1
    else
      s-=a[head]
    end
  end
  puts ans
end


Measured memory_bytes: 15884
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
int main() {
	int n;
	std::cin >> n;
	int sum = 0;
	for (auto i = 0; i < n; ++i) {
		int a;
		std::cin >> a;
		sum += a - 1;
	}
	std::cout << sum << std::endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
Int f(Int X, Int C, Int D) {
    Int E = C/__gcd(C,D)*D;
    Int ans = X - X/C - X/D + X/E;
    return ans;
}
int main()
{
    Int A, B, C, D; cin >> A >> B >> C >> D;
    cout << f(B, C, D) - f(A-1, C, D) << '\n';
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cmath>
#define int long long
using namespace std;
int n,a,b,c,d,cha1,cha2,s1,s2;
bool fl;
bool work(int cha,int bu){return cha2*bu>=cha;}
#undef int
int main()
#define int long long
{
    scanf("%lld%lld%lld%lld%lld",&n,&a,&b,&c,&d);
    n-=1;
    cha1=a-b>=0?a-b:b-a;
    cha2=d-c;
    //printf("cha1:%lld cha2:%lld\n",cha1,cha2);
    for(int i=1;i<=n;i++){
        s1+=c; s2+=d;
        if((n-i)%2==0&&work(min(abs(s1-cha1),abs(s2-cha1)),(n-i)/2)){
            //printf("s1:%lld s2:%lld bu:%lld cha:%lld\n",s1,s2,(n-i)/2,min(abs(s1-cha1),abs(s2-cha1)));
            puts("YES");return 0;
        }
    }
    puts("NO");
    return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) = IO().exec {
    val t = int()
    for (i in t) {
        val n = int()
        val d = int()
        println(if (n % 2 == 0) 127 * (n - 1) + (127 - d) else 127 * (n - 1) + d)
    }
}

// region template
operator fun Int.iterator() = 0.until(this).iterator()

class IO {
    val printable = 33..126
    val buffer = ByteArray(1024)
    var ptr = 0
    var buflen = 0
    val out = java.io.PrintWriter(System.out)
    fun hasNextByte(): Boolean = if (ptr < buflen) true else {
        ptr = 0
        buflen = System.`in`.read(buffer)
        buflen > 0
    }

    fun readByte(): Byte = if (hasNextByte()) buffer[ptr++] else -1
    fun hasNext(): Boolean {
        while (hasNextByte() && buffer[ptr] !in printable) ptr++
        return hasNextByte()
    }

    fun string(): String {
        if (!hasNext()) throw java.util.NoSuchElementException()
        val sb = StringBuilder()
        var b = readByte()
        while (b in printable) {
            sb.appendCodePoint(b.toInt())
            b = readByte()
        }
        return sb.toString()
    }

    fun long(): Long {
        if (!hasNext()) throw java.util.NoSuchElementException()
        var n = 0L
        var minus = false
        var b = readByte()
        if (b == '-'.toByte()) {
            minus = true
            b = readByte()
        }
        if (b !in '0'.toByte()..'9'.toByte()) {
            throw NumberFormatException()
        }
        while (true) {
            if (b in '0'.toByte()..'9'.toByte()) {
                n *= 10
                n += b - '0'.toByte()
            } else if (b == (-1).toByte() || b !in printable) {
                return if (minus) -n else n
            } else {
                throw NumberFormatException()
            }
            b = readByte()
        }
    }

    fun int(): Int {
        val nl = long()
        if (nl !in Integer.MIN_VALUE..Integer.MAX_VALUE) throw NumberFormatException()
        return nl.toInt()
    }

    fun double(): Double = string().toDouble()
    fun print(obj: Any) = out.print(obj)
    fun print(i: Int) = out.print(i)
    fun print(l: Long) = out.print(l)
    fun println(obj: Any) = out.println(obj)
    fun println(i: Int) = out.println(i)
    fun println(l: Long) = out.println(l)
    inline fun exec(block: IO.() -> Unit) {
        block()
        out.flush()
    }
}
// endregion

Measured memory_bytes: 31400
#include<bits/stdc++.h>
using namespace std;
using lint = long long;
template<typename T = lint>inline T in() { T x; cin >> x; return x; }
#define INF           1e9
#define INFL          static_cast<lint>(INF)
#define REP(i,n)      for(lint i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)     for(lint i=1,i##_len=(n);i<=i##_len;++i)
#define REPI(i,ini,n) for(lint i=(ini),i##_len=(n);i<i##_len;++i)
#define REPC(i,obj)   for(auto i:obj)
#define R_UP(a,b)     (((a)+(b)-1)/(b))
#define ALL(obj)      (obj).begin(),(obj).end()
int main()
{
	int n = in();
	vector<int>a(n);
	REP(i, n)a[i] = in();
	int q = in();
	REP(i, q)
	{
		int com = in();
		int b, e;
		switch (com)
		{
		case 0:
			cin >> b >> e;
			cout << *min_element(a.begin() + b, a.begin() + e) << endl;
			break;
		case 1:
			cin >> b >> e;
			cout << *max_element(a.begin() + b, a.begin() + e) << endl;
			break;
		}
	}
}


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

int main(void){
    string s, t;
    cin >> s >> t;
    for (int i=0; i<s.size(); i++){
        s = s[s.size()-1] + s;
        s.pop_back();
        if (s == t){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3548
#include<cstdio>
#define maxn 2005
#define mod 1000000007
int n,m,k,ans,dp[maxn*2][maxn*2],pre[maxn*2][maxn*2];
int main()
{
	scanf("%d%d%d",&n,&m,&k);
	dp[0][0]=1;
	for(int i=1;i<n+m;i++)
		for(int j=0;j<=m;j++)
		{
			pre[i][j]=(dp[i-1][j]+(j?pre[i][j-1]:0))%mod;
			dp[i][j]=(pre[i][j]-(j>=k?pre[i][j-k]:0)+mod)%mod;
		}
	for(;m>0;m-=k-1) ans=(ans+dp[(n+m-1)/(k-1)][m])%mod;
	printf("%d\n",ans);
}


Measured memory_bytes: 124928
#include <iostream>

int main(void){
  int N;
  std::string S;
  std::cin >> N;
  std::cin >> S;
  int N2=N*0.5;
  if(N%2!=0){
    std::cout<<"No";
    return 0;    
  }
  for(int i=0;i<N2;i++){
    if(S[i]!=S[N2+i]){
      std::cout<<"No";
      return 0;
    }
  }
  std::cout<<"Yes";
  return 0;
}


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

int main()
{
    long long h, n;
    cin >> h >> n;
    bool isPossible = false;
    long long sum = 0;
    for (long long i = 0; i < n; ++i)
    {
        int input;
        cin >> input;
        sum += input;
        if (sum >= h)
        {
            isPossible = true;
            break;
        }
    }
    cout << (isPossible ? "Yes" : "No") << endl;
}

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

int main(){
	string s, s1;
	int n;
	while(cin >> n, n){
		cin >> s;
	for(int i = 0;i < n;i++){
	for(int j = 0;j < s.size();j++){
		char c[10];int max = 0;
		while(s[j] == s[j + 1])j++, max++;
		//cout << max << endl;
		sprintf(c, "%d", max + 1);
		s1 += c;
		s1 += s[j];
	}
	s = s1;s1 = "";
	}
	cout << s << endl;
	}
	
	/*string s = "Hel", s1 = "Hello";
	s = s1;
	cout << s;*/
	
	return 0;
}

/*
1
3738893538469830671731701877825276800557025400476040953219197257965542184086336386458481140639477995
*/

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

using namespace std;
typedef long long ll;

int n;
vector<int> loc[30];
char str[200100];
int par[200100];
int lloc[200100];
int bit[200100];

void upd(int idx, int val) {
    idx++;
    while(idx) {
        bit[idx] += val;
        idx -= idx&-idx;
    }
}

int getv(int idx) {
    idx++; int res = 0;
    while(idx<=n) {
        res += bit[idx];
        idx += idx&-idx;
    }
    return res;
}

int main() {
    int i, j;

    scanf("%s",str); n =strlen(str);
    for (i=0;i<n;i++) loc[str[i]-'a'].push_back(i);
    int c = 0;
    for (i=0;i<26;i++) c += loc[i].size()%2;
    if (c>=2) {
        printf("-1\n");
        return 0;
    }
    for (i=0;i<26;i++) for (j=0;j<loc[i].size();j++) par[loc[i][j]] = loc[i][(int)loc[i].size()-1-j];
    ll res = 0; int p = 0;
    for (i=0;i<n;i++) {
        if (i<par[i]) {lloc[p] = i; lloc[n-1-p] = par[i]; p++;}
        else if (i==par[i]) lloc[n/2] = i;
    }
    for (i=0;i<n;i++) {
        res += 1LL*lloc[i] + getv(lloc[i]) - i;
        upd(lloc[i],1);
    }
    printf("%lld\n",res);

    return 0;
}


Measured memory_bytes: 3832
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1001001001
#define LINF 1001001001001001001
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

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

int main() {
  
  int N;
  cin >> N;
  vector<ll> A(N);
  rep(i,N) cin >> A[i];
  
  ll maximum = 0;
  ll ans = 0;

  rep(i,N) {
    maximum = max(maximum, A[i]);
    ans += maximum - A[i];
  }
  
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 4788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;
#define rep(i, n)  for (int i = 0; i <  (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(x) (x).begin(), (x).end()

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

    ll S,W;
    cin >> S;
    cin >> W;
    if(S <= W){
        cout << "unsafe";
    }
    else{
        cout << "safe";
    }
}

Measured memory_bytes: 3604
#include <iostream>

using namespace std;

int main() {
	int n, money = 100000;
	cin >> n;
	for (int i = 0; i < n; i++) {
		money += int((double)money * 0.05 / 1000 + 0.999) * 1000;
	}
	cout << money << endl;
	return 0;
}

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

int main() {
    int N, K, Q; cin >> N >> K >> Q;
    vector<int> answers(N+1, 0);
    for(int i=0; i < Q; i++) {
        int A; cin >> A;
        answers[A] += 1;
    }
    for (int i=1; i < N+1; i++) {
        if (K - Q + answers[i] > 0) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
}


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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)

const int MAXN = 301, MAXM = 101;
const int INF = 1000000 ;
const int TIME = 1, COST = 0;

int cost[2][MAXM][MAXM] = {};
int d[MAXM] = {};
bool used[MAXM] = {};

int n, m ,a, b, c, t, k;

int p, q, r;

int main()
{
    while(cin >> n >> m && n)
    {
        memset(cost, INF, sizeof(cost));

        REP(n)
        {
            cin >> a >> b >> c >> t;
            a--;
            b--;
            cost[COST][a][b] = cost[COST][b][a] = c;
            cost[TIME][a][b] = cost[TIME][b][a] = t;
        }
        cin >> k;

        rep(s,k)
        {
            cin >> p >> q >> r;
            p--;
            q--;
            memset(d, INF, sizeof(d));
            memset(used, false, sizeof(used));
            d[p] = 0;

            while(true)
            {
                int v = -1;
                rep(i,m)if(!used[i] && (v==-1 || d[i] < d[v])) v = i;
    
                if(v == -1) break;
                used[v] = true;
                rep(i,m)d[i] = min(d[i], d[v] + cost[r][v][i]);
            }
            cout << d[q] << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 944
#include<bits/stdc++.h>
#define to edge[i].v
#define mp make_pair
#define rint register int
#define debug(x) cerr<<#x<<"="<<x<<endl
#define fgx cerr<<"-------------"<<endl
#define N 200010
#define T n+n+1
#define add(x,y,z) addedge(x,y,z),addedge(y,x,0)
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
int head[N],tot=1,cur[N],vis[N],dis[N],n,p[N],fa[N],s; vector<int> v[N];
struct Edge{int v,next,f,w;}edge[N*10]; queue<int> q;
inline void addedge(int x,int y,int z){edge[++tot]=Edge{y,head[x],0,z};head[x]=tot;}
inline int bfs()
{	memset(vis,0,sizeof(vis)); memcpy(cur,head,sizeof(cur)); q.push(0); vis[0]=1;
	while(!q.empty())
	{	int x=q.front(); q.pop();
		for(rint i=head[x];i;i=edge[i].next)
		if(!vis[to]&&edge[i].f<edge[i].w) dis[to]=dis[x]+1,vis[to]=1,q.push(to);
	}
	return vis[T];
}
int dfs(int x,int res)
{	if(x==T||!res) return res; int flow=0,f;
	for(rint &i=cur[x];i;i=edge[i].next)
	if(dis[to]==dis[x]+1&&(f=dfs(to,min(res,edge[i].w-edge[i].f))))
	{edge[i].f+=f;edge[i^1].f-=f;res-=f;flow+=f;if(!res)break;}
	return flow;
}
inline int dinic(){int A=0;while(bfs())A+=dfs(0,INT_MAX);return A;}
void dfs(int x){vis[x]=1;s++;for(auto y:v[x])if(!vis[p[y]])fa[y]=x,dfs(p[y]);}
int main()
{	int m,x; cin>>n; for(rint i=1;i<=n;i++) add(n+i,T,1);
	for(rint i=1;i<n;add(0,i,1),i++)
	for(scanf("%d",&m);m--;){scanf("%d",&x),v[x].push_back(i);if(x!=1)add(i,n+x,1);}
	if(dinic()!=n-1) return !printf("-1");
	for(rint j=1;j<n;j++)
	for(rint i=head[j];i;i=edge[i].next) if(n<to&&to<=n+n&&edge[i].f) p[j]=to-n;
	dfs(1); if(s!=n) return !printf("-1");
	for(rint i=1;i<n;i++) printf("%d %d\n",fa[i],p[i]);
	return 0;
}


Measured memory_bytes: 30848
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

signed main()
{
    int k, x;
    cin >> k >> x;
    if (500 * k >= x) {
        cout << "Yes" << "\n";
    }
    else {
        cout << "No" << "\n";
    }
}

Measured memory_bytes: 764
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>


using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

class ARatedForMe {
public:
void solve(std::istream& cin, std::ostream& cout) {
    int a;
    //int ans = 0;
    string ans = "AGC";
    cin >> a;

    if(a<1200){
        ans = "ABC";
    }else if (a <2800){
        ans = "ARC";
    }

    cout << ans << endl;
}
};


int main() {
	ARatedForMe solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

int main2() {
  int N = nextInt();
  int K = nextInt() -1;
  REP(i, N) nextInt();
  cout << (N+K-2)/K << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


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

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

    int maxX = 1000000;
    int candBeg = max(x - (k-1), maxX * (-1));
    int candEnd = min(x + (k-1), maxX);

    for (int i=candBeg; i<=candEnd; i++) {
        cout << i;
        if (i!=candEnd) {
            cout << " ";
        }
    }
    cout << endl;

    return 0;
}

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    ll H, W, A, B;
    cin >> H >> W >> A >> B;

    REP(i, H){
        REP(j, W){
            if(i<B){
                if(j<A){
                    cout << 1;
                }
                else{
                    cout << 0;
                }
            }
            else{
                if(j<A){
                    cout << 0;
                }
                else{
                    cout << 1;
                }
            }
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0)
#define endl '\n'
const int maxn =1000;

map<string,int> ma;
set<string> s;
int main(){
    IOS;
    int n,m;
    string str;
    cin>>n;
    rep(i,n){
        cin>>str;
        ma[str]++;
        s.insert(str);
    }
    cin>>m;
    rep(i,m){
        cin>>str;
        ma[str]--;
    }
    int ans=0;
    for(auto ss:s){
        ans=max(ans,ma[ss]);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

sumA = [0 for _ in range(N + 1)]
sumB = [0 for _ in range(N + 1)]

for i in range(1, N + 1):
    sumA[i] = sumA[i - 1] + A[i - 1]
    sumB[i] = sumB[i - 1] + B[i - 1]

ans = 0
for middle in range(1, N + 1):
    sub = sumA[middle] + (sumB[N] - sumB[middle - 1])
    ans = max(ans, sub)

print(ans)

Measured memory_bytes: 3064
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func main() {
	sc.Split(bufio.ScanWords)
	n := next()
	if n[0] == '9' || n[1] == '9' {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 640
N = gets.to_i
x, y = N.times.map{gets.split.map(&:to_i)}.transpose

hash = Hash.new

N.times do |i|
  N.times do |j|
    next if i == j
    new_x = x[i] - x[j]
    new_y = y[i] - y[j]
    hash["#{new_x},#{new_y}"] ||= 0
    hash["#{new_x},#{new_y}"] += 1
  end
end

puts N - (hash.values.max || 0)

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

#define ll long long
#define Fi first
#define Se second
#define Pb push_back

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

#define all(v) v.begin(),v.end()
#define output_s(a) printf("%s\n",(a).c_str())

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m) for(int i=(int)(n);i<(int)(m);i++)
#define RepS(i,n,m) for(int i=(int)(n);i<=(int)(m);i++)
#define RRepS(i,n,m) for(int i=(int)(n);i>=(int)(m);i++)
#define RepA(x) for(auto &item:(x))

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 LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

//library----------------------------------------------



int main() {
    CIN(N);
    vector<string> s(N);
    map<string,int> mp;
    rep(i,N){
        cin>>s[i];
        mp[s[i]]++;
    }
    int max=0;
    RepA(mp){
        int num=item.second;
        if(num>max)max=num;
    }
    RepA(mp){
        if(max==item.second) output_s(item.first);
    }
    return 0;
}

Measured memory_bytes: 26752