akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
#include <climits>
#include <set>
#include <map>
#include <stack>
#include <iomanip>
#include <tuple>
#define ll long long
using namespace std;
struct all_init
{
    all_init()
    {
        cout << fixed << setprecision(12);
    }
} All_init;

int main()
{
    string s,ys;
    cin >> s;
    for (ll i = 0; i < s.size(); i++)
    {
        for (ll j = 0; j < s.size();j++){
            ys = s;
            ys.erase(i,j);
            if(ys=="keyence"){
                cout << "YES" << endl;
                exit(0);
            }
        }
    }
    cout << "NO" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) {if (a<b) { a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, const T &b) {if (b<a) { a=b; return 1;} return 0;}
struct init{init(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}}init_;

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 4e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//

int main() {
    ll N, Q;
    string S;
    cin >> N >> S >> Q;
    
    rep(_, Q){
        ll K;
        cin >> K;

        ll d = 0, m = 0, cnt = 0, ans = 0;
        rep(i, N){
            if(S[i] == 'D'){
                d++;
            }else if(S[i] == 'M'){
                m++, cnt += d;
            }else if(S[i] == 'C'){
                ans += cnt;
            }

            if(i - K + 1 >= 0 and S[i - K + 1] == 'D'){
                d--, cnt -= m;
            }else if(i - K + 1 >= 0 and S[i - K + 1] == 'M'){
                m--;
            }
        }

        cout << ans << '\n';
    }
}

Measured memory_bytes: 4228
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/rope>
#define VALHALLA cin.tie(0);ios_base::sync_with_stdio(false);cout<<fixed<<setprecision(13);
#define endl "\n"
#define pb push_back
#define all(v) v.begin(),v.end()
#define debug(x) std::cerr << #x << ": " << (x) << '\n';
#define sz(x) (int)x.size()
#define fast(map_name) map_name.reserve(1024);map_name.max_load_factor(0.25);
using namespace std;
using namespace __gnu_cxx;
typedef long long int ll;
typedef pair<int,int> ii;
typedef complex<double> point;
const double epsilon=1e-9;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int mod=1e9+7;
/* VARIABLE DECLARATION START */
/*  FUCNTION TEMPLATE STARTS  HERE */

double dot(point a,point b){ return (conj(a)*b).real() ; }
double cross(point a,point b){ return (conj(a)*b).imag() ; }
double dist(point a, point b){ return abs(a-b); }
struct neal {
static uint64_t splitmix64(uint64_t x)
 {
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
}
size_t operator()(uint64_t x) const
 {
    static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
}
};
struct HASH{
  size_t operator()(const pair<int,int>&x)const{
    return (size_t) x.first * 37U + (size_t) x.second;
  }
};
bool isprime(ll n) {
    if (n == 2 || n == 3) return true;
    if (n < 2 || n % 2 == 0 || n % 3 == 0) return false;
    for (ll i = 6; (i - 1) * (i - 1) <= n; i += 6) {
        if (n % (i - 1) == 0 || n % (i + 1) == 0) {
            return false;
        }
    }
    return true;
}
inline ll exp(ll a, ll b, ll mod) {
    ll n = 1;
    ll p = a;
    while (b > 0) {
        if (b % 2 == 1) {
            n *= p;
            n %= mod;
        }
        p *= p;
        p %= mod;
        b /= 2;
    }
    return n;
}

inline bool comp(double a,double b)
{
  return (fabs(a-b)<epsilon);
}
ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}


/*  FUCNTION TEMPLATE ENDS HERE */
int main()
{
   VALHALLA
    ll n;cin>>n;
    ll a,b;
    cin>>a>>b;
    for(ll i=1,x,y;i<n;++i)
    {
      cin>>x>>y;
      ll r1=a/x;
      ll r2=b/y;
      if(a%x!=0)
        r1++;
      if(b%y!=0)
        r2++;
      ll mul=max(r1,r2);
      x*=(mul);
      y*=(mul);
      a=x;
      b=y;
    }
    cout<<a+b<<endl;

}


Measured memory_bytes: 256
def reachable(graph, init):
    if init not in graph or graph[init] is None:
        return set()
    
    tmp,  graph[init] = graph[init], None

    return tmp.union(* [reachable(graph, i) for i in tmp])

def sugoroku(m, d):
    d = [0] + d + [0]
    start, goal = 0, len(d) - 1

    graph_to = {goal:{goal}}
    graph_from = {start:{start}}
    
    for init in range(len(d) - 1):
        for xi in range(1, 1 + m):
            pos = min(init + xi, goal)
            to = max(start, min(pos + d[pos],goal))
            try:
                graph_to[to].add(init)
            except KeyError:
                graph_to[to] = {init}
            try:
                graph_from[init].add(to)
            except KeyError:
                graph_from[init] = {to}
    
    unreachable_node = reachable(graph_from, start).difference(reachable(graph_to, goal))
    
    return 0 == len(unreachable_node)

import sys
f = sys.stdin

while True:
    m = int(f.readline())
    if m == 0:
        break
    d = [int(f.readline()) for _ in range(int(f.readline()))]
    print('OK' if sugoroku(m, d) else 'NG')

Measured memory_bytes: 7092
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <tuple>
#include <bitset>
#include <random>
#define REP(i,n) for(int i=0;i<n;i++)
#define INF 100000000000007
using namespace std;
using pii=pair<int,int>;
using LL=int64_t;


vector<int64_t> fac, finv, inv;

// テーブルを作る前処理
void COMinit(int MAX, int MOD) {
    fac=vector<int64_t>(MAX);/*n! modのデーブル　*/
    finv=vector<int64_t>(MAX);/*n!の逆元のテーブル*/
    inv=vector<int64_t>(MAX);/*nの逆元のテーブル*/

    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算 nCkを与える
int64_t COM(int MOD, int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}




int main(){
    int n,m,k;
    cin>>n>>m>>k;

    int MOD=998244353;
    COMinit(2*100000+10,MOD);

    int64_t ans=0;

    vector<int64_t> modpower(n+1,1);

    for(int i=1;i<=n;i++){
        modpower.at(i)=modpower.at(i-1)*(m-1);
        modpower.at(i)%=MOD;
    }

    REP(i,k+1){
        int64_t tmp;
        tmp=COM(MOD,n-1,i)*m;
        tmp%=MOD;
        tmp*=modpower.at(n-1-i);
        tmp%=MOD;
        ans+=tmp;
        ans%=MOD;
    }

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

Measured memory_bytes: 9088
package main

import "fmt"

var h, w int

func allWhiteColumn(board []string, col int) bool {
	for i := range board {
		if board[i][col] != '.' {
			return false
		}
	}
	return true
}

func allWhiteRow(board []string, row int) bool {
	for i := range board[row] {
		if board[row][i] != '.' {
			return false
		}
	}
	return true
}

func contains(arr []int, x int) bool {
	for i := range arr {
		if arr[i] == x {
			return true
		}
	}
	return false
}

func main() {
	fmt.Scan(&h, &w)

	board := make([]string, h)
	for i := range board {
		fmt.Scan(&board[i])
	}

	var lines, columns []int
	for i := range board {
		if allWhiteRow(board, i) {
			lines = append(lines, i)
		}
	}

	for i := range board[0] {
		if allWhiteColumn(board, i) {
			columns = append(columns, i)
		}
	}

	for i := range board {
		if contains(lines, i) {
			continue
		}
		for j := range board[i] {
			if contains(columns, j) {
				continue
			}
			fmt.Print(string(board[i][j]))
		}
		fmt.Println()
	}
}


Measured memory_bytes: 768
import math
N,D = map(int,input().split())
X = [0]*N
total = 0
cnt = 0
for i in range(N):
  X[i] = list(map(int,input().split()))
for i in range(N-1):
  for j in range(i+1,N):
    for k in range(D):
      total += abs(X[j][k]-X[i][k])**2
    if math.sqrt(total)%1==0:
      cnt += 1
    total=0
print(cnt)

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
      reader = new BufferedReader(new InputStreamReader(in));
      tokenizer = null;
    }

    public String next() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public String nextLine() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          return reader.readLine();
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }

      return tokenizer.nextToken("\n");
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = nextInt();
      return a;
    }

    public long[] nextLongArray(int n) {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = nextLong();
      return a;
    }
  }
  
  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    int n = sc.nextInt();
    int[] a = sc.nextIntArray(n);
    int result = 0;
    for (int ai: a) result += ai - 1;
    System.out.println(result);
  }
}

Measured memory_bytes: 33372
#include <stdio.h>

int main( void )
{
	int H, W, H_Cou, W_Cou;
	
	while(1)
	{
		scanf( "%d %d", &H, &W );
		
		if( H == 0 && W == 0 )
		{
			break;
		}
		else
		{
			for( H_Cou = 0; H_Cou < H; H_Cou++ )
			{
				for( W_Cou = 0; W_Cou < W; W_Cou++ )
				{
					printf( "#" );
				}
				
				printf( "\n" );
			}
			
			printf( "\n" );
		}
	}
	
	return 0;
}

Measured memory_bytes: 572
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

int main()
{
   long a,b;
   long i,j,k;
   long f;
   long n;
   long cnt = 0;
   long h;
   long left,right,mid;
   long ans = 0;
   static char str[102][1003];
   char s[9];
   char p[1003];
   char tmp;
   int end = 0;

   fgets(str[0],1002,stdin);
   scanf("%ld",&n);
   j = 1;
   for (i = 0; i < n;i++) {
      scanf("%s",s);
      scanf("%ld %ld",&a,&b);
      if (s[2] == 'p') {
         scanf("%s",p);
         for (k = 0; k < b-a+1; k++) 
            str[0][a+k] = p[k];
      }

      /* revserse */
      if (s[2] == 'v') {
         for (k = 0; k < (b-a+1)/2; k++) {
            tmp = str[0][a+k];
            str[0][a+k] = str[0][b-k];
            str[0][b-k] = tmp;
         }
      }

      /* print */
      if (s[2] == 'i') {
         for (k = 0; k < b-a+1; k++) {
            str[j][k] = str[0][a+k];
         }
         j++;
      }
   }
   for (i = 1; i < j; i++) 
      printf("%s\n",str[i]);

   return 0;
}

Measured memory_bytes: 1048
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
#include <set>
#include <vector>
#include <queue>
#define pb push_back
using namespace std;
typedef pair<int,int> pii;

int main(){
  string s;
  int w;
  cin>>s;
  cin>>w;
  for(int i=0;i<s.size();i+=w){
    cout<<s[i];
  }
  cout<<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);

            int HP;
            int attack;
            int need;

            HP = sc.nextInt();
            attack = sc.nextInt();

            need = (HP + attack -1) / attack;

            if(need == 0) {
                System.out.println(1);
            }
            else if ( HP == attack){
                System.out.println(1);
            }
            else {
                System.out.println(need);
            }

        }
    }

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;cin >> n;
  vector<ll> a(n),b(n),c(n-1);
  rep(i,n) cin >> a[i],--a[i];
  rep(i,n) cin >> b[i];
  rep(i,n-1) cin >> c[i];
  ll ans = 0;
  rep(i,n){
    ans+=b[a[i]];
    if(i&&a[i]==a[i-1]+1) ans+=c[a[i-1]];
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int way1(int money,int year, double percent, int minus)
{
	int x;
	for(x=0;x<year;x++){
		money=money*(1.0+percent)-minus;
	}
	return money;
}

int way2(int money, int year, double percent, int minus)
{
	int y;
	int plus=0;
	for(y=0;y<year;y++){
		plus+=money*percent;
		money=money-minus;
	}
	return money+plus;
}

int main(void)
{
	int m;
	int money;
	int year;
	int num_way;
	int way;
	double percent;
	int minus;
	int count1;
	int count2;
	
	scanf("%d",&m);
	for(count1=0; count1<m;count1++){
		int max=0;
		scanf("%d",&money);
		scanf("%d",&year);
		scanf("%d",&num_way);
		for(count2=0;count2<num_way;count2++){
			scanf("%d",&way);
			scanf("%lf",&percent);
			scanf("%d",&minus);
			if (way == 1) {
				if (max < way1(money, year, percent, minus))
					max = way1(money, year, percent, minus);
			}
			else {
				if (max < way2(money, year, percent, minus))
					max = way2(money, year, percent, minus);
			}
		}
		printf("%d\n",max);
	}
	return 0;
}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
using ll = long long;

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

    vector<ll> F(N + 1, 1);
    REP(i, 2, N + 1) {
        for (int j = i; j < N + 1; j += i) F[j]++;
    }

    ll ans = 0;
    REP(i, 1, N + 1) {
        ans += i * F[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 81396
#include<bits/stdc++.h>
using namespace std;
double d[1003];
long long x[1003],y[1004],r[1004],v[1004];
long long inf =1000000000000000000;
long long int mod=1000000007;
long long int j=mod-2;
long long int modpow (long long int a) {
	long long int res = 1;
	j=mod-2;
	while (j > 0)
		if (j & 1) {
			res = (res * a) % mod;
			--j;
		}
		else {
			a = (a * a) % mod;
			j >>= 1;
		}
	return res %mod;
}
double dist(int l,int e)
{
    double s=x[l]-x[e];
    double q=y[l]-y[e];
    s=s*s+q*q;
    s=sqrt(s);
    return s;
}
int main()
{
   long long int xs,ys,xt,yt;
   cin>>x[0]>>y[0]>>xt>>yt;
   long n;
   cin>>n;
   for(long i=1;i<=n;i++)
   {
       cin>>x[i]>>y[i]>>r[i];
       d[i]=inf;
   }
   d[0]=0;d[n+1]=inf;
   x[n+1]=xt;y[n+1]=yt;n++;
   set<pair< double ,int> >s;
   s.insert(make_pair(0,0));
   while(!s.empty())
   {
       double h=s.begin()->first;
       long f=s.begin()->second;
       v[f]=1;s.erase(s.begin());
      // cout<<f<<" "<<d[f]<<endl;
       if(f==n){  printf("%.12f\n", d[f]);return 0;}
       for(long i=1;i<=n;i++)
       {
           if(v[i]==0)
           {
               double w=dist(f,i);
               double p=r[i]+r[f];
               w=w-p;
               if(w<0)w=0;
               if(d[i]>d[f]+w){s.erase(make_pair(d[i],i));d[i]=d[f]+w;s.insert(make_pair(d[i],i));}

           }

       }
   }

}


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

sum = 0

for i in range(1, n + 1):
    if i % 15 == 0:
        sum += 0
    elif i % 3 == 0:
        sum += 0
    elif i % 5 == 0:
        sum += 0
    else:
        sum += i

print(sum)

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

using ll = long long;
#define REP(NAME, NUM) for (int NAME = 0; NAME < (NUM); ++NAME)
#define BREP(NAME, NUM) for (int NAME = (NUM)-1; NAME >= 0; --NAME)
#define VEC(TYPE, A, NAME, INIT) vector<TYPE> NAME(A, INIT)

ll proc( vector<ll>& q, vector<ll>& bl, int n )
{
    REP(i,n+1) bl[i] = 0;
    REP(i,n)
    {
        ll i_ = i + 1;
        if( q[i_] != 0 )
        {
            for( int j = i_; j > 0 && j > i_ - q[i_]; --j )
                bl[j]++;
        }
    }
    ll ans = 0;
    REP(i,n) if( bl[i+1]==0 ) ++ans;
    return ans;
}

int main()
{
    int n, m;
    cin >> n >> m;
    VEC(ll, n, a, 0);
    REP(i, n) cin >> a[i];
    VEC(ll, m, x, 0);
    VEC(ll, m, y, 0);
    REP(i, m) cin >> x[i] >> y[i];
    
    VEC(ll, n+1, q, 0);
    VEC(ll, n+1, bl, 1);
    REP(i,n)
    {
        q[a[i]]++;
    }
    
    ll ans = proc( q, bl, n );
    REP(i,m)
    {
        ll pre = a[x[i]-1];
        ll nex = y[i];
        a[x[i]-1] = nex;

        if( pre != nex )
        {
            ll hiku = pre - q[pre] + 1;
            ll tasu = nex - q[nex];

            if( hiku != tasu )
            {
                if( hiku > 0 && --bl[hiku] == 0 ) ans++;
                if( tasu > 0 && ++bl[tasu] == 1 ) ans--;
            }
        }
        
        q[pre]--;
        q[nex]++;

        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 10496
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  do {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
  } while (false);
  int n;
  cin >> n;
  vector<int> arr(n);
  vector<ll> s0(n), s1(n), s2(n), val(n);
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    s0[i] = arr[i];
    if (arr[i] % 2) {
      s1[i] = 0;
      s2[i] = 1;
    } else {
      s1[i] = 1;
      s2[i] = !arr[i] ? 2 : 0;
    }
  }
  partial_sum(s0.begin(), s0.end(), s0.begin());
  partial_sum(s1.begin(), s1.end(), s1.begin());
  partial_sum(s2.begin(), s2.end(), s2.begin());
  ll cur = 0, ans = s0[n - 1];
  for (int i = 0; i < n; i++) {
    ans = min(ans, s0[n - 1] - s0[i] + s2[i] + cur);
    cur = min(cur, s0[i] - s2[i]);
  }
  cur = 0;
  for (int i = 0; i < n; i++) {
    val[i] = cur;
    if (i) {
      val[i] += s2[i - 1] - s1[i - 1];
      val[i] = min(val[i], val[i - 1]);
    }
    cur = min(cur, s0[i] - s2[i]);
  }
  cur = LLONG_MAX;
  for (int i = n - 1; i >= 0; i--) {
    cur = min(cur, s2[i] - s0[i]);
    ans = min(ans, val[i] + s1[i] + s0[n - 1] - s2[i] + cur);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 7296
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define sorta(V) sort(V.begin(), V.end())
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end() 

using namespace std;

int main(){

    //各文字列の中に出現するアルファベットの回数を記録する
    //全文字列で出現回数が最小値になるものが答えとなる文字列に使える回数になる
    //O(N*|S|)

    int n;
    cin >> n;

    int count[50][26] = {};

    rep(i,n){
        string s;
        cin >> s;

        rep(j,s.size()){
            count[i][s[j] - 'a']++;
        }
    }

    string ans;

    rep(i,26){
        
        int c = INT_MAX;

        rep(j,n){
            c = min(c,count[j][i]);
        }

        string str(c, 'a' + i);

        ans = ans + str;
    }

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

typedef long long ll;

#define INF 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { debug(itr); }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

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

  int p = k - 1;
  for (int i = x-p; i < x + p+1; ++i) {
    cout << i << " ";
  }
  END;
}


Measured memory_bytes: 256
n = int(input())
l = list(map(int, input().split()))

cnt =0

for i in range(n):
    for j in range(i+1, n):
        for k in range(j+1, n):
            a = l[i]
            b = l[j]
            c = l[k]
            if a == b or b == c or c == a:
                continue
            if a + b > c and b + c > a and c + a > b:
                cnt +=1
print(cnt)

Measured memory_bytes: 9160
// 2012/12/10 Tazoe

#include <iostream>
using namespace std;

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

	int m;
	cin >> m;

if(n==0&&m==0)
break;

	int G[501][501];
	for(int i=1; i<=n; i++){
		for(int j=1; j<=n; j++){
			G[i][j] = 0;
		}
	}

	for(int i=0; i<m; i++){
		int a, b;
		cin >> a >> b;

		G[a][b] = G[b][a] = 1;
	}

	int F[501];
	for(int i=1; i<=n; i++){
		F[i] = 0;
	}

	for(int i=2; i<=n; i++){
		if(G[1][i]==1){
			F[i] = 1;
		}
	}

	for(int i=2; i<=n; i++){
		if(F[i]==1){
			for(int j=2; j<=n; j++){
				if(G[i][j]==1&&F[j]==0){
					F[j] = 2;
				}
			}
		}
	}

	int cnt = 0;
	for(int i=2; i<=n; i++){
		if(F[i]==1||F[i]==2){
			cnt++;
		}
	}

	cout << cnt << '\n';
}

	return 0;
}

Measured memory_bytes: 2140
c = [list(map(int,input().split())) for _ in range(3)]

e = c[0][1] - c[0][0]
f = c[0][2] - c[0][1]

if any(e != c[x][1]-c[x][0] for x in [1,2]) or any(f != c[x][2]-c[x][1] for x in [1,2]) :
    print('No')
else:
    print('Yes')

Measured memory_bytes: 3064
<?php

$length=trim(fgets(STDIN));
$str=trim(fgets(STDIN));
$count=0;

for ($i=0;$i<$length-2;$i++){

    if($str[$i]=="A"&&$str[$i+1]=="B"&&$str[$i+2]=="C"){
        $count++;
    }
}
echo $count;
?>

Measured memory_bytes: 4728
while True:
    a,op,b=input().split()
    if op == "+":
        print(int(a)+int(b))
    elif op =="-":
        print(int(a)-int(b))
    elif op =="*":
        print(int(a)*int(b))
    elif op =="/":
        print(int(a)//int(b))
    else:
        break


Measured memory_bytes: 5592
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
#include <time.h>
#include <chrono>
#ifdef _MSC_VER
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,a,b) for(ll i=a;i>b;i--)
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
#define ct(a) cout<<a<<endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define repl(i,l,r) for(int i=(1);i<(r);i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
static const double pi = 3.141592653589793;
using namespace std;
typedef long long ll;
const ll MOD = 998244353;
const ll INF = 1e9 + 7;
const ll mod = 1e9 + 7;

ll N, Q;
string S;
set<int> st[26];

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

	cin >> N >> S >> Q;
	FOR(i, 0, N) {
		int k = int(S[i]-'a');
		st[k].insert(i);
	}

	FOR(i, 0, Q) {
		int kind; cin >> kind;


		if (kind == 1) {
			int j; char c;
			cin >> j >> c;
			j--; c =int(c-'a');
			st[int(S[j]-'a')].erase(j);
			st[int(c)].insert(j);
			S[j] = char(c+'a');
		}
		else {
			int l, r; cin >> l >> r;
			l--; r--;
			int ans=0;
			FOR(j, 0, 26) {
				auto p = st[j].lower_bound(l);
				if (p != st[j].end()&& *p <= r)ans++;
			}
			cout << ans << endl;
		}
	}
	



	return 0;
}


Measured memory_bytes: 27156
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from itertools import chain
from functools import reduce
from collections import OrderedDict, Counter, deque
import operator

S = input()
N = len(S)

b1 = S[0::2].count('0')
w1 = (N // 2 + (N & 1)) - b1
b2 = S[1::2].count('0')
w2 = (N // 2) - b2

print(min(b1 + w2, w1 + b2))

Measured memory_bytes: 3800
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define MOD 1000000007
#define len(x) x.size()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define all(v) v.begin(), v.end()
#define alla(a,n) a, a + n
#define fo(i,n) for(int i =0;i<n;i++)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<string> vs;

int32_t main() {

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin) ;
    freopen("output.txt", "w", stdout) ;
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL) ; cout.tie(NULL) ;

    int t ;
    cin >> t ;

    cout <<  (-t % 1000 + 1000) % 1000;
    return 0 ;

}

Measured memory_bytes: 3668
#include<bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int (i)=0;(i) < (N); (i)++)
#define all(V) V.begin(), V.end()
using i64 = int_fast64_t;
using P = pair<i64,i64>;
using uset = unordered_set<int>;

int N;
int cnt[100100];
int color[100100];
vector<int> A;

void dfs(int i, int c){
    if(color[i] == c && cnt[i] >= 2) return;
    if(color[i] != 0 && color[i] != c) return;

    color[i] = c;
    cnt[i]++;

    dfs((i+A[i])%N, c);
    
    return; 
}

int main(){
    cin >> N;
    A.resize(N);
    rep(i,N) cin >> A[i];

    rep(i,N) if(!cnt[i]) dfs(i, N+i);

    int ans = 0;
    rep(i,N) ans += (cnt[i] >= 2);

    cout << ans << endl;
}


Measured memory_bytes: 4008
#include <stdio.h>
#include <string.h>
int main(void)
{
    int i,j,k,m,x;
    char n[200],n1[200];
    while(1){
        scanf("%s",n);
        if(n[0]=='-')break;
        x=strlen(n);
        scanf("%d",&k);
        for(m=0;m<k;m++){
            scanf("%d",&i);
            strncpy(n1,n,i);
            n1[i] = '\0';
            for(j=0;j<x-i;j++)n[j]=n[i+j];
            n[j] = '\0';
            strcat(n,n1);
        }
        printf("%s\n",n);
    }
    return 0;
}

Measured memory_bytes: 604
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
ll arr[] = {682498929LL, 632720431LL, 448943438LL, 116079221LL, 615142340LL, 6259027LL, 948197154LL, 145971945LL, 916800752LL, 202251309LL, 37983229LL, 837458921LL, 975495147LL, 518030386LL, 376072195LL, 622014712LL, 716809811LL, 934894288LL, 220366634LL, 464931331LL, 836796013LL, 577952413LL, 97313845LL, 283854312LL, 210437135LL, 88493197LL, 747521698LL, 110954347LL, 351437952LL, 531553513LL, 172279346LL, 633918352LL, 41789059LL, 743764606LL, 946214298LL, 462694068LL, 572856921LL, 493284479LL, 649230871LL, 878554427LL, 139060384LL, 73966192LL, 303719911LL, 720131873LL, 525952103LL, 497375585LL, 657945273LL, 935274198LL, 24382639LL, 490716262LL, 308431504LL, 321519436LL, 612968833LL, 593412210LL, 298137292LL, 622826075LL, 106009973LL, 824985246LL, 701967571LL, 239564185LL, 271700936LL, 900989749LL, 408066260LL, 484652396LL, 890515364LL, 950182975LL, 969238460LL, 498362772LL, 604180732LL, 550240872LL, 603837221LL, 139677594LL, 502054009LL, 924014287LL, 566254400LL, 71835811LL, 507367266LL, 497160223LL, 582441075LL, 592048491LL, 11579706LL, 322196210LL, 744436409LL, 359281663LL, 261077935LL, 391723090LL, 686167966LL, 732061422LL, 351968552LL, 384403496LL, 285632677LL, 858738739LL, 189667484LL, 482253650LL, 514650121LL, 78576211LL, 85412424LL, 498597530LL, 719338134LL, 799987210LL, 0LL, 87057359LL, 768138694LL, 794109565LL, 528998351LL, 170600929LL, 161280204LL, 557841721LL, 313174199LL, 899015368LL, 920674541LL, 660042853LL, 96753306LL, 247831107LL, 991211596LL, 913846238LL, 333086748LL, 582746625LL, 512764351LL, 136118538LL
};
struct BigCombination{
private:
    ll N;

public:
    BigCombination(ll n){
        N = n;
    }
    ll power(ll x, ll n){
        if(n == 0) return 1LL;
        ll res = power(x * x % MOD, n/2);
        if(n % 2 == 1) res = res * x % MOD;
        return res;
    }
    ll fac(ll n){
        ll v = 1;
        ll res = 1;
        ll cnt = 0;
        ll tt = 10000000;
        for(ll i = 1; (i+tt) <= n; i += tt){
            res *= arr[cnt];
            res %= MOD;
            v = i+tt;
            cnt++;
        }
        rep(i,v,n+1){
            res *= i;
            res %= MOD;
        }
        return res;
    }

    ll facinv(ll n){
        return power(fac(n), MOD-2);
    }

    ll nck(ll n, ll k){
        if(k == 0 || n == k) return 1LL;
        return fac(n) * facinv(k) % MOD * facinv(n-k) % MOD;      
    }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,A,B;
    cin >> N >> A >> B;
    BigCombination cb(200010);
    ll ans = (cb.power(2, N) - 1 + MOD) % MOD;
    ans = (ans - cb.nck(N, A) - cb.nck(N, B) + 2 * MOD) % MOD;
    print(ans);
}


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

struct Data{
    int idx;
    int l,r;
    Data* ptr;
};

void insert(int idx,int s,Data &data){
    if(s<=0) return;
    if(data.ptr==nullptr){
        data.ptr=new Data{idx,data.r,data.r+s,nullptr};
        return;
    }
    else if((data.ptr->l)-data.r>=1){
        Data *to=data.ptr;
        int buf=data.ptr->l-data.r;
        data.ptr=new Data{idx,data.r,data.r+min(s,buf),to};
        insert(idx,s-buf,*to);
        return;
    }
    else{
        insert(idx,s,*data.ptr);
    }
}
void erase(int idx,Data &data){
    if(data.ptr==nullptr) return;
    while(data.ptr->idx==idx){
        data.ptr=data.ptr->ptr;
        if(data.ptr==nullptr) return;
    }
    erase(idx,*data.ptr);
}
int search(int pos,Data& data){
    if(data.l<=pos && pos<data.r) return data.idx;
    else if(data.ptr==nullptr) return -1;
    else return search(pos,*data.ptr);
}
void solve(int n){
    Data base=Data{-1,-1,0,nullptr};
    for(int i=0;i<n;i++){
        char com;
        cin>>com;
        if(com=='W'){
            int idx,s;
            cin>>idx>>s;
            insert(idx,s,base);
        }
        if(com=='D'){
            int idx;
            cin>>idx;
            erase(idx,base);
        }
        if(com=='R'){
            int pos;
            cin>>pos;
            cout<<search(pos,base)<<endl;
        }
    }
    return;
}

int main(){
    int n;
    while(cin>>n,n){
        solve(n);
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 57164
import java.util.HashMap;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);

		int n = stdIn.nextInt();
		int[] score = new int[n];
		int[][] scan = new int[n][];
		for(int i=0;i<n;i++){
			scan[i] = new int[3];
			for(int j=0;j<3;j++){
				scan[i][j] = stdIn.nextInt();
			}
		}
		for(int i=0;i<3;i++){
			HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
			int[] input = new int[n];
			for(int j=0;j<n;j++){
				input[j] = scan[j][i];
				if(map.containsKey(input[j])){
					int value = map.get(input[j]);
					map.put(input[j], ++value);
				}
				else{
					map.put(input[j], 1);
				}
			}
			for(int j=0;j<n;j++){
				if(map.get(input[j])==1){
					score[j] += input[j];
				}
			}
		}
		for(int i=0;i<n;i++){
			System.out.println(score[i]);
		}
	}
}

Measured memory_bytes: 20972
/**
 *   author: Shubham Srivastava
 *   created: 07 September 2019  17:35:59
**/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
 
int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    ll n;cin>>n;
    vector <int> dish(n),wei(n),val(n-1);
    for(int i=0;i<n;i++)
        cin>>dish[i];
    int sum=0,sum2=0,maxi=0;
    for(int j=0;j<n;j++){
        cin>>wei[j];
        sum += wei[j];
    }
    for(int i=0;i<n-1;i++)
        cin>>val[i];
    for(int i=0;i<n-1;i++){
        if(dish[i]+1 == dish[i+1]){
            sum += val[dish[i]-1];
        }
    }
    cout<<sum;
return 0;
}

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

using namespace std;

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

    string s; cin >> s;
    if (s == "Sunny") {
        cout << "Cloudy";
    } else if (s == "Cloudy") {
        cout << "Rainy";
    } else {
        cout << "Sunny";
    }

    return 0;
}


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


int main(){
    ll n,p;
    string s;
    cin>>n>>p;
    cin>>s;

    ll ans=0;
    if(p==2||p==5){
        rep(i,n){
            int c = s[i]-'0';
            if(c%p==0){
                ans+=i+1;
            }
        }
    }else{
        map<ll,ll> mp;
        ll c=1;
        ll prev=0;
        rep(i,n){
            ll tmp=s[n-i-1]-'0';
            prev = (tmp*c+prev)%p;
            mp[prev]+=1;
            c=c*10%p;
        }
        for(auto v=mp.begin();v!=mp.end();v++){
            ans+= v->second*(v->second-1)/2;
        }
        ans+=mp[0];
    }

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

Measured memory_bytes: 1028
from collections import Counter
n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]
sc = Counter(s)
tc = Counter(t)
a = 0
for sck in sc.keys():
    a = max(a,sc.get(sck,0)-tc.get(sck,0))
if a>=1:
    print(a)
else:
    print(0)


Measured memory_bytes: 3316
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
using namespace std;
typedef long long ll;
int main(void){
	int d[]={111,222,333,444,555,666,777,888,999},n,i;
	cin>>n;
	for(i=0;i<9;i++){
		if(n<=d[i]){
			cout<<d[i]<<endl;
			return 0;
		}
	}
}
/*reveres begin end
cout<<"\n";
  m.insert(std::make_pair('c', 30));
*/


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <unordered_map> 
#include <map> 
#include <numeric>
#include <limits>
#include <utility>
#include <queue>
#include <random>
#include <bitset>
#include <memory>
#include <complex>
using namespace std;
typedef long long LL;

int main() {
	string s;
	cin >>s;
	int a=0;
	for (int i = 0; i < 3; i++) {
		if(s[i]=='1')a++;
	}
	cout <<a<<endl;
    return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

ll N;
pair<ll,ll> P[202020];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N) {
		cin>>P[i].second>>P[i].first;
	}
	sort(P,P+N);
	ll cur=0;
	FOR(i,N) {
		cur+=P[i].second;
		if(cur>P[i].first) return _P("No\n");
	}
	_P("Yes\n");
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 3456
import java.util.Scanner;

public class Main {

	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		int a = in.nextInt();
		int b = in.nextInt();
//		int c = in.nextInt();

		int c = (a < b) ? 0 : 10;
		System.out.println(c);
	}

}


Measured memory_bytes: 23892
#define _USE_MATH_DEFINES
#define INF 10000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>

using namespace std;

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

static const double eps = 1e-8;

int main(){

	bool table[1000001];
	fill((bool*)table,(bool*)table+1000001,true);

	table[0]=false;
	table[1]=false;
	for(int i=2;i*i<=1000000;i++){
		if(table[i]){
			for(int j=i+i;j<=1000000;j+=i){
				table[j]=false;
			}
		}
	}

	int n;
	while(~scanf("%d",&n)){
		if(n==0) break;

		int res=0;
		for(int i=n,j=0;j<=n/2;j++,i--){
			if(table[i] && table[j]) res++;
		}

		printf("%d\n",res);
	}
}

Measured memory_bytes: 0
#include<stdio.h>
#include<string.h>
int main(){
	int x,y,W,H,r;
	char s[4];
	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
	if(x+r<=W && x-r>=0){
		if(y+r<=H && y-r>=0){
		strcpy(s,"Yes");
		}
		else{
		strcpy(s,"No");
		}
	}
	else{
		strcpy(s,"No");
		}
	printf("%s\n",s);
	return 0;	
	
}

Measured memory_bytes: 584
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<string>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<cstring>
#include<stack>
using namespace std;
#define EPS 1e-10

struct Point{
    double x,y;
    Point(){}
    Point(double _x,double _y){
        x=_x; y=_y;
    }
    Point operator +(const Point p)const{
        return Point(x+p.x,y+p.y);
    }
    Point operator -(const Point p)const{
        return Point(x-p.x,y-p.y);
    }
	Point operator *(const double d)const{
		return Point(x*d,y*d);
	}
};

struct Line{
    Point a,b;
    Line(){}
    Line(Point _a,Point _b){
        a=_a; b=_b;
    }
};

double dot(Point p,Point q){
    return p.x*q.x+p.y*q.y;
}

double cross(Point p,Point q){
    return p.x*q.y-q.x*p.y;
}

int ccw(Point a,Point b,Point c){
    if(cross(b-a,c-b)>0) return +1;
    if(cross(b-a,c-b)<0) return -1;
    return 0;
}

bool intersectSS(Line l,Line m) {
    return ccw(l.a,m.a,l.b)*ccw(l.a,m.b,l.b)<=0 && ccw(m.a,l.a,m.b)*ccw(m.a,l.b,m.b)<=0;
}

bool pss(Line l,Line m,Point &p){
    if(intersectSS(l,m)==false) return false;
	Point a1,a2,b1,b2;
	a1 = l.b-l.a; a2 = m.b-m.a;
	b1 = m.a-l.a; b2 = m.b-l.a;
	double s1,s2;
	s1 = abs(cross(a1,b1)/2); s2 = abs(cross(a1,b2)/2);
	if(s1<EPS && s2<EPS) return false;
	p = Point(m.a.x+a2.x*s1/(s1+s2),m.a.y+a2.y*s1/(s1+s2));
	return true;
}

int main(){
	Line l[3];
	while(true){
		for(int i=0;i<3;i++){
			cin>>l[i].a.x>>l[i].a.y>>l[i].b.x>>l[i].b.y;
			if(l[i].a.x==0 && l[i].a.y==0 && l[i].b.x==0 && l[i].b.y==0) return 0;
		}
		Point p[3];
		bool kyo = false;
		for(int i=0;i<3;i++){
			if(pss(l[i],l[(i+1)%3],p[i])==false) kyo = true;
		}
		if(kyo==true){
			puts("kyo"); continue;
		}
		double s = abs(cross(p[1]-p[0],p[2]-p[0])/2);
		//printf("\t%lf\n",s);
		if(s<EPS) puts("kyo");
		else if(s<100000.0) puts("syo-kichi");
		else if(s<1000000.0) puts("kichi");
		else if(s<1900000.0) puts("chu-kichi");
		else puts("dai-kichi");
	}
    return 0;
}

Measured memory_bytes: 1176
#include <stdio.h>

int main(){
	int n;
	scanf("%d",&n);
	int p[5][4][11];
	for(int a=1;a<=4;a++){
		for(int b=1;b<=3;b++){
			for(int c=1;c<=10;c++){p[a][b][c]=0;}
		}
	}
	
	for(int i=0;i<n;i++){
		int b,f,r,v;
		scanf("%d %d %d %d",&b,&f,&r,&v);
		p[b][f][r]+=v;
	}
	
	for(int b=1;b<=4;b++){
		for(int f=1;f<=3;f++){
			for(int r=1;r<=10;r++){
				printf(" %d",p[b][f][r]);
			}
			printf("\n");
		}
		if(b<4){printf("####################\n");}
	}
	return 0;
}

Measured memory_bytes: 1040
#include<bits/stdc++.h>
using namespace std;
int main(){
  int m,ni,na,i,j,k,ans,idx;
  while(cin>>m>>ni>>na,m||ni||na){
    int p[m];
    for(i=0;i<m;i++) cin>>p[i];
    sort(p,p+m);
    ans=0;
    idx=ni;
    for(i=ni;i<=na;i++){
      //cout<<p[m-i]-p[m-i-1]<<endl;
      if(p[m-i]-p[m-i-1]>=ans){
	ans=p[m-i]-p[m-i-1];
	idx=i;
      }
    }
    cout << idx << endl;
  }
  return 0;
}

Measured memory_bytes: 3072
#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)

#define chmax(x,y) x = max(x,y)

// 定数宣言
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);
}

ll dp[200005][4];

int main()
{
    cout << fixed << setprecision(15);
    ll N;
    cin >> N;

    vector<ll> A(N);
    REP(i, N){
        cin >> A[i];
    }
    
    // 奇数なら2個偶数なら1個入れられる
    ll k = 1 + N%2;

    // dpテーブルの初期化
    REP(i, N+1){
        REP(j, k+1){
            dp[i][j] = -LINF;
        }
    }
    dp[0][0] = 0;

    REP(i,N) {
        REP(j,k+1) {
        chmax(dp[i+1][j+1], dp[i][j]);
        ll now = dp[i][j];
        if ((i+j)%2 == 0) now += A[i];
        chmax(dp[i+1][j], now);
        }
    }
    ll ans = dp[N][k];
    cout << ans << endl;
    return 0;
}

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

int main()
{
	ios::sync_with_stdio(false);
  	cin.tie(0);
  	int n;
  	cin >> n;
  	for(int i = 2; i < n; i++)
  		if(n % i == 0)
  		{
  			n++;
  			i = 2;
		}
	cout << n;
	return 0;
}



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

bool check(vector<int>& wolf, const string S) {
    int N = S.size();
    for (int i = 0; i < N; i++) {
        int prev = i - 1;
        if (prev < 0) prev = N - 1;
        int next = i + 1;
        if (next >= N) next = 0;
        if ((S[i] == 'o' && wolf[i] == 2) || (S[i] == 'x' && wolf[i] == 1)) {
            if (wolf[prev] != 0 && wolf[prev] == wolf[next]) continue;
            if (wolf[prev] == 0) {
                wolf[prev] = wolf[next];
                continue;
            } else if (wolf[next] == 0) {
                wolf[next] = wolf[prev];
                continue;
            } else {
                return false;
            }
        } else {
            if (wolf[prev] != 0 && wolf[next] != 0 && wolf[prev] != wolf[next]) continue;
            if (wolf[prev] == 0) {
                if (wolf[next] == 1) wolf[prev] = 2;
                else wolf[prev] = 1;
            } else if (wolf[next] == 0) {
                if (wolf[prev] == 1) wolf[next] = 2;
                else wolf[next] = 1;
            } else {
                return false;
            }
        }
    }
    return true;
}

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

    // 0: unknown 1: wolf 2:sheep
    vector<int> wolf(N);
    
    for (int j = 0; j < N; j++) wolf[j] = 0;
    wolf[0] = 1; wolf[1] = 1;
    if (check(wolf, S)) goto END;

    for (int j = 0; j < N; j++) wolf[j] = 0;
    wolf[0] = 1; wolf[1] = 2;
    if (check(wolf, S)) goto END;

    for (int j = 0; j < N; j++) wolf[j] = 0;
    wolf[0] = 2; wolf[1] = 1;
    if (check(wolf, S)) goto END;

    for (int j = 0; j < N; j++) wolf[j] = 0;
    wolf[0] = 2; wolf[1] = 2;
    if (check(wolf, S)) goto END;
    cout << -1 << endl;
    return 0;

END:
    for (int i = 0; i < N; i++) {
        if (wolf[i] == 1) cout << 'W';
        else cout << 'S';
    }
    cout << '\n';
}


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

public class Main {
    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int[] p = new int[N];

        for (int i=0; i<N; i++) {
            p[i] = scanner.nextInt();
        }


        for (int i=0; i<N; i++) {
            for (int j=0; j<N; j++) {
                int[] coPy = Arrays.copyOf(p, p.length);
                int tmp = coPy[i];
                coPy[i] = coPy[j];
                coPy[j] = tmp;
                if (isOrderedAsc(coPy)) {
                    System.out.println("YES");
                    return;
                }
            }
        }

        System.out.println("NO");
    }

    private static boolean isOrderedAsc(int[] p) {
        for (int i=0; i<p.length - 1; i++) {
            if (p[i] > p[i+1]) return false;
        }
        return true;
    }
}

Measured memory_bytes: 22996
// inputに入力データ全体が入る
function Main(input) {
  
   input = input.split("\n");
  var n= parseInt(input[0], 10);
 
   var tmp = input[1].split(" ");
     var a = [];
for (var i = 0; i <n ; i++){
  var r= parseInt(tmp[i], 10);

  a[i] = r;}
  
 //console.log(a);
 
 var f = 0;
 
 for( i = 1; i <n;i++){if (a[i] < a[i-1]  && a[i]>a[i+1]){f = f+1;
                                                      //   console.log(f);
                                                         }
                      else{if (a[i] > a[i-1]  && a[i]<a[i+1]){f = f+1;}
                           }
                      }
 
 console.log(f);
 
  
  
  
  
}

  
  //*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
  


Measured memory_bytes: 7372
#include<bits/stdc++.h>
using namespace std;
 
#define cinsc ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(0);
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define FOR(i,k,n)  for(int64 i=k;i<(int64)n;i++)
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert( B <= A && A <= C)
#define MP make_pair
#define PB push_back
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define read(type) readInt<type>()
#define SQ(x) ((x)*(x))
const double pi=acos(-1.0);
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;
 
//ONLINE_JUDGE   LOCAL
 
int64 powr(int64 x,int64 y,int64 p)  
{  
    int res = 1;    
    x = x % p; 
    if (x == 0) return 0;
    while (y > 0){   
        if (y & 1)  
            res = (res*x) % p;   
        y = y>>1; 
        x = (x*x) % p;  
    }  
    return res;  
} 
 
void  in_o(){
#ifndef LOCAL
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
	cinsc;
}


int main(){
	//in_o();
	int n,p;
	cin>>n>>p;
	int r0=0,r1=0;
	FOR(i,0,n){
		int x;
		cin>>x;
		if(x%2)
			r1++;
		else 
			r0++;
	}
	int64 ans=0;
	if(!r1)
		ans=1LL<<n;
	else
		ans=1LL<<(n-1);
	if(p)
		ans=(1LL<<n)-ans;
	cout<<ans<<endl;
	return 0;
}


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

using namespace std;
int main()
{
    long long int i , j , k , n , sum = 0 , g1 = 0;
    cin>>n;
    for( i = 1 ; i <= n ; i++)
    {
        for( j = 1 ; j <= n  ;j++)
        {   
            g1 = __gcd(i,j);
            for (k = 1 ; k <= n ; k++)
            {
                sum+=__gcd(g1,k);
            }
        }
    }
    cout<<sum<<endl;
    
}

Measured memory_bytes: 3596