akhauriyash/Code-Regression huggingface dataset:
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

vector<int> naive(const int M_, const int K) {
	// M <= 2
	const int M = M_ + 1;

	vector<int> res(1LL << M);
	for (int i = 0; i < (1LL << (M - 1)); i++) {
		res[2 * i] = res[2 * i + 1] = i;
	}

	do {

		//DMP(res);
		vector<int> res_xor((1LL << M) + 1);
		for (int i = 0; i < (1LL << M); i++) res_xor[i + 1] = res_xor[i] ^ res[i];

		bool is_K = true;
		for (int i = 0; i < (1LL << (M - 1)); i++) {
			auto it1 = find(res.begin(), res.end(), i);
			auto it2 = find(it1 + 1, res.end(), i);

			if ((res_xor[it1 - res.begin()] ^ res_xor[it2 - res.begin() + 1]) != K) {
				is_K = false;
				break;
			}

		}

		if(is_K) return res;

	} while (next_permutation(res.begin(), res.end()));

	return vector<int>{-1};

}

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int M, K;
	cin >> M >> K;

	if (M == 1) {
		if (K == 0) cout << "0 0 1 1" << "\n";
		else cout << -1 << "\n";
	}
	else {
		if (K < (1 << M)) {

			cout << K << " ";
			for (int i = 0; i < (1 << M); i++) if (i != K) cout << i << " ";
			cout << K << " ";
			for (int i = (1 << M) - 1; i >= 0; i--) if (i != K) cout << i << " ";

		}
		else cout << -1 << "\n";
	}

	return 0;
}

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

int num_count[10];
int ans;
uint64_t limit;

void dfs(uint64_t n)
{
  static const int64_t nums[] {3, 5, 7};

  if (n > limit) return;
  if (num_count[3] > 0 && num_count[5] > 0 && num_count[7] > 0) ans++;

  for (int i = 0; i < 3; i++) {
    num_count[nums[i]]++;
    dfs(n * 10 + nums[i]);
    num_count[nums[i]]--;
  }
}

int main()
{
  cin >> limit;
  dfs(0);
  cout << ans << endl;
}


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

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) throws Exception {
		while (true) {
			int N = sc.nextInt();
			if (N == 0) break;
			HashMap<Character, Character> map = new HashMap<Character, Character>();
			for (int i = 0; i < N; ++i) {
				char key = sc.next().charAt(0);
				char val = sc.next().charAt(0);
				map.put(key, val);
			}
			int M = sc.nextInt();
			StringBuilder sb = new StringBuilder();
			for (int i = 0; i < M; ++i) {
				char c = sc.next().charAt(0);
				if (map.containsKey(c)) {
					sb.append(map.get(c));
				} else {
					sb.append(c);
				}
			}
			System.out.println(sb);
		}
	}
}

Measured memory_bytes: 13000
#include <iostream>

using namespace std;

long long int GCD(long long int x, long long int y) {
    if(x<y) {
        swap(x, y);
    }
    if(y==0) {
        return x;
    }
    return GCD(y, x%y);
}

long long int LCM(long long int x, long  long int y) {
    return x/GCD(x, y)*y;
}

int main() {
    long long int N, M;
    cin >> N >> M;
    string S, T;
    cin >> S >> T;
    bool flag=true;
    for(long long int i=0; i<GCD(N, M); i++) {
        flag = (S[i*N/GCD(N, M)]==T[i*M/GCD(N, M)]);
        if(!flag) {
            break;
        }
    }

    if(flag) {
        cout << LCM(N, M) << endl;
    } else {
        cout << -1 << endl;
    }

    return 0;
    
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define N 200005
#define chmax(a,b) a=max(a,b)

string s;
int dp[N][2];

int main()
{
	ios_base::sync_with_stdio(0);
	
	cin>>s;
	memset(dp,-1,sizeof(dp));
	dp[0][0]=dp[1][1]=0;
	for(int i=0;i<s.size();i++)
	{
		if(dp[i][1]!=-1) chmax(dp[i+1][0],dp[i][1]+1);
		if(dp[i][1]!=-1 && (s[i-1]!=s[i+1] || s[i]!=s[i+2])) chmax(dp[i+2][1],dp[i][1]+1);
		if(dp[i][0]!=-1 && s[i]!=s[i+1]) chmax(dp[i+1][0],dp[i][0]+1);
		if(dp[i][0]!=-1) chmax(dp[i+2][1],dp[i][0]+1);
	}
	cout<<max(dp[s.size()][0],dp[s.size()][1]);
	
	return 0;
}

Measured memory_bytes: 2704
#include <bits/stdc++.h>
using namespace std;
int a,b,c,ans;
int main(){
	cin>>a>>b>>c;
	for(int i=a;i<=b;i++){
	    if(c%i==0)ans++;
	}cout<<ans<<endl;
}
/*for(初期化式;条件式;終了のときの式)
  for(int i=a;i<=b;i++){
     cout<<i<<endl;
  }*/



Measured memory_bytes: 3112
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cassert>
#include <utility>
#include <numeric>
#include <cstring>
#include <map>
#include <set>
#include <cmath>
#define rep(i,n) for (int i=0; i<(n); ++i)

using namespace std;
using ll = long long;

int main (){
    int N;
    cin >> N;
    char S[N];
    for (int i=0;i<N;i++){
        cin >> S[i];
    }
    if (N%2 !=0){
        cout << "No";
    }
    else{
        for (int i=0;i<N/2;i++){
            if (S[i] == S[N/2+i]){
                //cout << S[i];
                continue;
            }
            else{
                //cout << S[i];
                cout << "No";
                return 0;
            }
        }
        cout << "Yes";
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int mod=998244353;
int k[1000000];
int p(int A,int B){
  if(!B)return 1;
  if(B%2)return p(A,B-1)*A%mod;
  int C=p(A,B/2);
  return C*C%mod;
}
int c(int n,int m){
  return k[n]*p(k[n-m]*k[m]%mod,mod-2)%mod;
}
signed main(){
  k[0]=1;
  for(int i=1;i<1000000;i++)k[i]=k[i-1]*i%mod;
  int N,M,K,ans=0;
  cin>>N>>M>>K;
  for(int i=0;i<=K;i++)ans=(ans+c(N-1,i)*M%mod*p(M-1,N-i-1)%mod)%mod;
  cout<<ans<<endl;
}

Measured memory_bytes: 11420
#include <stdio.h>

int	main(void)
{
	int	a, b, c;
	scanf("%d %d %d", &a, &b, &c);

	int count = 0;
	for (int i = a; i <= b; i++)
	{
		if (c % i == 0)
			count++;
	}
	printf("%d\n", count);
	return (0);
}



Measured memory_bytes: 2120
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = Integer.parseInt(sc.next()); 
		int b = Integer.parseInt(sc.next()); 
		int c = Integer.parseInt(sc.next()); 
		int count = 0;
		for (int i = a ; i <= b ;i++  ) {
			if (c % i ==0) {
				count++;
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 26168
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;

class Main {
  public static int cnt = 0;
  
  public static void main(String[] args) {
  	Scanner sc = new Scanner(System.in);
  	int n = sc.nextInt();
  	int[] a = new int[n];
  	for(int i = 0; i < n; ++i) {
  		a[i] = sc.nextInt();
  	}

  	//insertionSort(a, 1);
  	shellSort(a);
  	System.out.println(cnt);
  	for(int i = 0; i < n; ++i) {
  		System.out.println(a[i]);
  	}
  }
  
  public static void insertionSort(int[] a, int g){
  	for(int i = g; i < a.length; ++i) {
  		int v = a[i];
  		int j = i - g;
  		while(j >= 0 && a[j] > v) {
  			a[j + g] = a[j];
  			j = j - g;
  			cnt += 1;
  		}
  		a[j + g] = v;
  	}
  }
  
  public static void shellSort(int[] a) {
  	List<Integer> g = new ArrayList<Integer>();
  	for(int t = 1; t < a.length; t = 4*t + 1){
  		g.add(0, t);
  	}
  	
	if(g.size() == 0){
		g.add(0, 1);
	}
  	
  	int m = g.size();
  	System.out.println(m);
	
	for(int i = 0; i < m; ++i) {
		System.out.print(i == 0 ? "" : " ");
		System.out.print(g.get(i));
	}
  	System.out.println();
  	
  	for(int i = 0; i < m; ++i) {
  		insertionSort(a, g.get(i));
  	}
  }
}

Measured memory_bytes: 300384
#include <iostream>
using namespace std;
#include<string.h>
#include<set>
#include<stdio.h>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
#include <cstdio>
#include <cstdlib>
#include<stack>
#include<vector>
int main()
{
    int a,b;
    cin>>a>>b;
    if(a<=b)
        cout<<b+(b-a)<<endl;
    else
        cout<<b-(a-b)<<endl;
    return 0;
}


Measured memory_bytes: 256
#![allow(non_snake_case)]

use std::io::{stdin, Read};
use std::str::FromStr;
fn read_option<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok()
}
fn read<T: FromStr>() -> T {
    let opt = read_option();
    opt.expect("failed to parse token")
}

fn main() {
    let N: usize = read();
    let A: Vec<usize> = (0..N).map(|_| read()).collect();
    let mut pairs = vec![];
    let mut max = None;
    let mut before = A[0];
    let mut min = before;
    for &v in A.iter().skip(1) {
        // 増えてる
        if before <= v {
            max = Some(v);
        } else {
            // 減ってる
            if max.is_some() {
                pairs.push((min, max.unwrap()));
                max = None;
            }
            min = v;
        }
        before = v;
    }
    if max.is_some() {
        pairs.push((min, max.unwrap()));
    }
    let mut now = 1000;
    for (min, max) in pairs {
        let count = now / min;
        now -= count * min;
        now += count * max;
    }
    println!("{}", now)
}


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

int main() {
  string S;
  cin >> S;
  long long K;
  cin >> K;

  for (long long i = 0; i < K; i++){
    if (S.at(i) != '1') {
      cout << S.at(i) - '0' << endl;
      return 0;
    }
  }

  cout << 1 << endl;
}

Measured memory_bytes: 256
C1 = list(map(int,input().split()))
C2 = list(map(int,input().split()))
C3 = list(map(int,input().split()))

if C1[0]-C1[1]==C2[0]-C2[1]==C3[0]-C3[1] and C1[1]-C1[2]==C2[1]-C2[2]==C3[1]-C3[2] and C1[0]-C2[0]==C1[1]-C2[1]==C1[2]-C2[2] and C2[0]-C3[0]==C2[1]-C3[1]==C2[2]-C3[2]: 
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9208
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#define _USE_MATH_DEFINES
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
ll inf = llmax / 2;

bool dp[50][100010];
vector<int> take;

int main() {
    int N;
    cin >> N;
    for (int i = 0; i < 50; i++) {
        fill(dp[i], dp[i] + N + 1, false);
    }
    take.push_back(0);
    take.push_back(1);
    int num = 6;
    while (num <= N) {
        take.push_back(num);
        num *= 6;
    }
    num = 9;
    while (num <= N) {
        take.push_back(num);
        num *= 9;
    }
    dp[0][N] = true;
    int ans = 0;
    int len = take.size();
    for (int i = 0; i < 50; i++) {
        if (dp[i][0]) {
            break;
        }
        for (int j = 0; j <= N; j++) {
            if (dp[i][j]) {
                for (int k = 0; k < len; k++) {
                    if (j - take[k] >= 0) {
                        dp[i + 1][j - take[k]] = true;
                    }
                }
            }
        }
        ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 5120
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	var t, x, y int
	pt, px, py := 0, 0, 0
	for i := 0; i < n; i++ {
		fmt.Scan(&t, &x, &y)

		dt := abs(pt - t)
		dl := abs(px-x) + abs(py-y)
		if dt < dl || dt%2 != dl%2 {
			fmt.Println("No")
			return
		}

		pt, px, py = t, x, y
	}

	fmt.Println("Yes")
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}


Measured memory_bytes: 5504
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int r = Integer.parseInt(sc.next());
        sc.close();

        // 主処理
        double result = 2 * r * Math.PI;

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 35868
N, M = map(int, input().split())

flags = [False] * N
p_ary = [0] * N

penalty = 0
score = 0
for _ in range(M):
    p_num, result = input().split()
    p_num = int(p_num) - 1
    if result == 'AC':
        if flags[p_num] is False:
            score += 1
        flags[p_num] = True
    elif result == 'WA' and flags[p_num] is False:
        p_ary[p_num] += 1

for p, flag in zip(p_ary, flags):
    if flag is True:
        penalty += p

print(score, penalty)

Measured memory_bytes: 4596
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

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

	public static void ALDS1_4_A() {
		Scanner sc = new Scanner(System.in);
		int ans = 0;
		int n = sc.nextInt();
		int[] S = new int[n];
		for(int i = 0; i < n; i++) {
			S[i] = sc.nextInt();
		}
		int q = sc.nextInt();
		int[] T = new int[n];
		for(int i = 0; i < q; i++) {
			T[i] = sc.nextInt();
			for(int j = 0; j < n; j++) {
				if(T[i] == S[j]) {
					ans++;
					break;
				}
			}
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 40560
n = int(input())
a = list(map(int,input().split()))

count={}
for ak in a:
    if ak not in count:
        count[ak] = 0
    count[ak] += 1

sum=0
for key in count:
    sum += count[key]*(count[key]-1) // 2

for ak in a:
    print(sum-(count[ak]-1))


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

int main() {
    int N, K;
    string S, T;
    cin >> N >> S >> K;
    T = S.substr(K - 1, 1);
    cout << regex_replace(S, regex("[^" + T + "]"), "*") << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))

ll n;
int main(){
	scanf("%lld",&n);
	printf("%lld\n",n/11*2+!!(n%11)*(n%11<=6?1:2));
}

Measured memory_bytes: 128
#include <vector>
#include <iostream>
using namespace std;
#define MAX 100000
#define INF __INT_MAX__

struct edge{
    // 始点,終点,重み
    int s,t,w;
};

vector<edge> edges;
int d[MAX];

void BellmanFord(int startVertex,int vNum,int eNum){
	fill(d,d + MAX,INF);
	d[startVertex] = 0;
	
	// 頂点分回すことで、最後のサイクルは負のサイクルを確認するプロセスになる
	for(int i=0;i < vNum;++i){
		bool update = false;
		for(int j = 0;j < eNum;++j){
			edge e = edges[j];
			if(d[e.s] != INF && d[e.t] > d[e.s] + e.w){
				d[e.t] = d[e.s] + e.w;
				update = true;
				// 頂点分更新されていれば、負のサイクルがあることがわかる
				if(i == vNum - 1){
					cout << "NEGATIVE CYCLE" << endl;
					return;
				}
			}
		}
		if(!update)break;
	}

	for(int i = 0;i < vNum;++i){
		if(d[i] == INF){
		    cout << "INF"<< endl;
		}
		else cout<< d[i] << endl;
	}
}

int main(){
    int v,e,r;
	cin >> v >> e >> r;
	for(int i = 0;i < e;++i){
		int s,t,w;
		cin >> s >> t >> w;
		edges.push_back({s,t,w});
	}
	BellmanFord(r,v,e);
}


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

/*
   AtCoder contest code
   coder : yoichidon
 */
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N1 = sc.nextInt();
        int N2 = sc.nextInt();
        int N3 = sc.nextInt();
        int N4 = sc.nextInt();

        if(   (N1==1 || N2==1 || N3==1 || N4==1)
           && (N1==9 || N2==9 || N3==9 || N4==9)
           && (N1==7 || N2==7 || N3==7 || N4==7)
           && (N1==4 || N2==4 || N3==4 || N4==4)
        ) System.out.println("YES");
        else System.out.println("NO");

    }
}


Measured memory_bytes: 22100
#include<cstdio>
using namespace std;
int main(){
   int S[13],H[13],C[13],D[13];
   for(int i=0;i<13;i++){
     S[i]=-1;
     H[i]=-1;
     C[i]=-1;
     D[i]=-1;
   }
   int num;
   scanf("%d",&num);
   int n;
   char m;
   for (int j=0;j<num;j++){
    scanf(" %c %d",&m,&n);
    if (m=='S'){
        S[n-1]=1;
    }
    else if (m=='H'){
        H[n-1]=1;
    }
    else if (m=='C'){
        C[n-1]=1;
    }
    else if (m=='D'){
        D[n-1]=1;
    }
   }




   for (int i=0;i<4;i++){
       for(int j=0;j<13;j++){
           if(i==0){
               if(S[j]==-1){
                   printf("S %d\n",j+1);
               }
           }
           else if(i==1){
               if(H[j]==-1){
                   printf("H %d\n",j+1);
               }
           }
           else if(i==2){
               if(C[j]==-1){
                   printf("C %d\n",j+1);
               }
           }
           else if(i==3){
               if(D[j]==-1){
                   printf("D %d\n",j+1);
               }
           }
       }
   }

}






Measured memory_bytes: 2672
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < n; i++)
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

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

    ll cnt[32];
    rep (i, 32) cnt[i] = 0;
    rep (i, n) {
        ll k;
        cin >> k;
        rep (j, k) {
            ll a;
            cin >> a;
            a--;
            cnt[a] ++; 
        }
    }

    ll ans = 0;
    rep (i, m) {
        if (cnt[i] == n) ans++;
    }

    cout << ans << endl;
}

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

#define MAPSIZE 1048576

int cmpmin(int a, int b) {
	return a-b;
}

int cmpmax(int a, int b) {
	return b-a;
}

typedef struct {
	int n, arr[200000];
	int (*cmp)(int, int);
} heap;

void hpush(heap *h, int x) {
	int i = h->n++;
	h->arr[i] = x;

	while (i > 0) {
		int p = (i-1)/2;
		if (h->cmp(h->arr[p], h->arr[i]) > 0) {
			int t = h->arr[p];
			h->arr[p] = h->arr[i];
			h->arr[i] = t;
			i = p;
		} else break;
	}
}

int hpop(heap *h) {
	int ret = h->arr[0];
	h->arr[0] = h->arr[--h->n];

	int i = 0, c;
	while ((c = i*2 + 1) < h->n) {
		if (c+1 < h->n && h->cmp(h->arr[c], h->arr[c+1]) > 0) {
			c++;
		}

		if (h->cmp(h->arr[i], h->arr[c]) > 0) {
			int t = h->arr[c];
			h->arr[c] = h->arr[i];
			h->arr[i] = t;
			i = c;
		} else break;
	}

	return ret;
}

int hpeek(const heap *h) {
	return h->arr[0];
}

heap left = {.cmp = cmpmax}, right = {.cmp = cmpmin};

int main(void) {
	int q;
	scanf("%d", &q);

	long long int y = 0, d = 0;

	while (q--) {
		int t;
		scanf("%d", &t);
		if (t == 1) {
			int a, b;
			scanf("%d%d", &a, &b);
			int px = hpeek(&left);
			y += abs(px-a);
			d += b;

			if (a < px) hpush(&left, a);
			else hpush(&right, a);

			int diff = left.n - right.n;
			if (diff == 2) {
				hpush(&right, hpop(&left));
				diff = 0;
			} else if (diff == -1) {
				hpush(&left, hpop(&right));
				diff = 1;
			}

			int x = hpeek(&left);
			if (x != px) {
				if (x > px) diff -= 2;
				y += (long long int) (x-px) * diff;
			}
		} else {
			printf("%d %lld\n", hpeek(&left), y+d);
		}
	}
}


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

using namespace std;

int main() {
	int n; cin>>n;
	int a[n+1];
	long long ans = 0;
	map<int, int> m;

	for(int i=1; i<=n; i++) {
		cin>>a[i];
		m[i+a[i]]++;
	}

	for(int i=1; i<=n; i++) {
		ans += m[i-a[i]];
	}

	cout<<ans<<endl;

	return 0;
}

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

int main() {
    int n;
    cin >> n;
    map<int, int> d;
    rep(i,n) {
        int x;
        cin >> x;
        d[x]++;
    }
    int m;
    cin >> m;
    map<int, int> t;
    rep(i,m) {
        int x;
        cin >> x;
        t[x]++;
    }
    string ans = "YES";
    for(auto itr = t.begin(); itr != t.end(); itr++) {
        if (itr->second > d[itr->first]) ans = "NO";
    }
    cout << ans << endl;
}

Measured memory_bytes: 18944
/*
 * Problem Description: Stack
 * Category:
 * Author: Khan
 * Date: 12th October, 2017
 */

#include <stdio.h>
#include <string.h>
#define LEN 100005

typedef struct{
    char name[100];
    int t;
}Task;

Task Queue[LEN];
int head, tail, n;

void enqueue(Task x)
{
    Queue[tail] = x;
    tail = (tail + 1) % LEN;
}

Task dequeue()
{
    Task x = Queue[head];
    head = (head + 1) % LEN;
    return x;
}

int min(int a, int b)
{
    return a < b ? a : b;
}

int main(int argc, char const *argv[])
{
    //freopen("sample.txt", "r", stdin);
    int elaps = 0, c;
    int q;
    Task u;
    scanf("%d %d", &n, &q);
    
    for (int i = 1; i <= n; ++i)
    {
        scanf("%s", Queue[i].name);
        scanf("%d", &Queue[i].t);
    }
    head = 1;
    tail = n + 1;

    while(head != tail)
    {
        u = dequeue();
        c = min(q, u.t);
        u.t -= c;
        elaps += c;
        if(u.t > 0)
            enqueue(u);
        else
        {
            printf("%s %d\n", u.name, elaps);
        }
    }
    return 0;
}

Measured memory_bytes: 11824
package main

import (
	"fmt"
)

func main() {
	var k, n int
	fmt.Scan(&k, &n)
	min := k
	first := -1
	last := -1
	for n > 0 {
		n--
		var a int
		fmt.Scan(&a)
		if first < 0 {
			first = a
		} else {
			if k-a+last < min {
				min = k - a + last
			}
		}
		last = a
		if n == 0 {
			if a-first < min {
				min = a - first
			}
		}
	}
	fmt.Printf("%d\n", min)
}


Measured memory_bytes: 7552
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main(){
  ll n,count = 0;
  cin>>n;
  ll a[n],b[n];
  for(ll i=0;i<n;i++){
    cin>>a[i]>>b[i];
  }
  for(ll i=0;i<n;i++){
    if((a[i]==b[i])&&(a[i+1]==b[i+1])&&(a[i+2]==b[i+2])){
      count = count + 1;
      break;
    }
  }
  if(count == 1) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

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

int main(){
    int n;
    cin>>n;
    vector<vector<int> > a(3, vector<int>(10, 0)), b(3, vector<int>(10, 0)), c(3, vector<int>(10, 0)), d(3, vector<int>(10, 0)); //a[階数][部屋番号]
    
    int e, f, g, h;
    for(int i=0;i<n;i++){
        cin>>e >>f >>g >>h;
        f--;
        g--;
        if(e==1){
            a[f][g]+=h;
        }else if(e==2){
            b[f][g]+=h;
        }else if(e==3){
            c[f][g]+=h;
        }else{
            d[f][g]+=h;
        }
    }
    
    for(int i=0;i<3;i++){
        for(int j=0;j<10;j++){
            cout<<" "<<a[i][j];
        }
        cout<<endl;
    }
    
    for(int i=0;i<20;i++)cout<<'#';
    cout<<endl;
    
    for(int i=0;i<3;i++){
        for(int j=0;j<10;j++){
            cout<<" "<<b[i][j];
        }
        cout<<endl;
    }
    
    for(int i=0;i<20;i++)cout<<'#';
    cout<<endl;
    
    for(int i=0;i<3;i++){
        for(int j=0;j<10;j++){
            cout<<" "<<c[i][j];
        }
        cout<<endl;
    }
    
    for(int i=0;i<20;i++)cout<<'#';
    cout<<endl;
    
    for(int i=0;i<3;i++){
        for(int j=0;j<10;j++){
            cout<<" "<<d[i][j];
        }
        cout<<endl;
    }
    return 0;
}



Measured memory_bytes: 3160
import java.util.*;

public class Main {
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        while(true) {
            double a = 0;
            try {
                a = sc.nextDouble();
            }catch(Exception e) {
                break;
            }
            double sum = a;
            for(int i = 2; i <= 10; i++) {
                if(i % 2 == 0) {
                    sum += a * 2;  
                    a *= 2;
                }
                if(i % 2 == 1) {
                    sum += a / 3;
                    a /= 3;
                }
            }
            System.out.println(sum);
        }
    }
}



Measured memory_bytes: 27916
require 'pp'

n = gets.chomp!.to_i
v_n = gets.chomp!.split(' ').map(&:to_i)

even = v_n.select.with_index(0) {|_, i| i % 2 == 0 }.sort
odd = v_n.select.with_index(0) {|_, i| i % 2 == 1 }.sort

even_nums = {
    10 ** 6 => 0
}
odd_nums = {
    10 ** 6 => 0
}

even.each do |v|
    even_nums[v] ||= 0
    even_nums[v] += 1
end

odd.each do |v|
    odd_nums[v] ||= 0
    odd_nums[v] += 1
end

even_sorted_count = even_nums.sort{|x, y| y[1] <=> x[1]}.to_h
odd_sorted_count = odd_nums.sort{|x, y| y[1] <=> x[1]}.to_h

if even_sorted_count.first[0] != odd_sorted_count.first[0]
    puts even.length - even_sorted_count.first[1] + odd.length - odd_sorted_count.first[1]
else
    e1, v1 = even_sorted_count.first
    o2, v2 = odd_sorted_count.first
    even_sorted_count.delete(e1)
    odd_sorted_count.delete(o2)

    num1 = even.length - v1 + odd.length - odd_sorted_count.first[1]
    num2 = even.length - even_sorted_count.first[1] + odd.length - v2
    puts [num1, num2].min
end


Measured memory_bytes: 27348
N, Q = map(int, input().split())
S = input()
t=[0]*(N+1)
for i in range(N):
  t[i + 1] = t[i] + (1 if S[i : i + 2] == 'AC' else 0)
for i in range(Q):
  l, r = map(int, input().split())
  print(t[r-1] - t[l-1])

Measured memory_bytes: 7748
#include<iostream>
using namespace std;
int main(){
	int m, f, r, hasi;
	char seiseki[100];
	for (int i = 0; i < 100; i++){
		cin >> m;
		cin >> f;
		cin >> r;
		if (m == -1 && f == -1 && r == -1){
			break;
		}
		if (m == -1 || f == -1){
			seiseki[i] = 'F';
		}
		else if (m + f >= 80){
			seiseki[i] = 'A';
		}
		else if (m + f >= 65){
			seiseki[i] = 'B';
		}
		else if (m + f >= 50){
			seiseki[i] = 'C';
		}
		else if (m + f >= 30){
			if (r >= 50){
				seiseki[i] = 'C';
			}
			else{
				seiseki[i] = 'D';
			}
		}
		else{
			seiseki[i] = 'F';
		}
		hasi = i;
	}
	for (int i = 0; i <= hasi; i++){
		cout << seiseki[i] << endl;
	}
	return 0;
}

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

int main()
{
  int H, W;
  string odd = "";
  string even = "";
  cin >> H >> W;
  while (H != 0 && W != 0)
  {
    for (int i = 0; i < W; i++)
    {
      if(i%2==0){
        odd += "#";
      }
      if(i%2==1){
        odd += ".";
      }
    }
    for (int i = 0; i < W; i++)
    {
      if(i%2==0){
        even += ".";
      }
      if(i%2==1){
        even += "#";
      }
    }

    for (int i = 0; i < H; i++)
    {
      if(i%2==0){
        cout << odd << endl;
      }
      if(i%2==1){
        cout << even << endl;
      }
    }
    printf("\n");
    odd = "";
    even = "";
    cin >> H >> W;
  }
}


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

#pragma GCC optimize("O3")
using namespace std;
#define ll long long
#define ull unsigned long long
#define rep(i,n,N) for(ll i=n;i<=N;++i)
#define rap(i,n,N) for(ll i=n;i>=N;--i)
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define ff fi.fi
#define fs fi.se
#define sf se.fi
#define ss se.se
#define lc (id<<1)
#define rc ((id<<1)|1)
#define db(x) cout << ">>>>>> " << #x << " -> " << x << endl;
#define all(x) x.begin(),x.end()
#define pii pair<int,int> 
#define pll pair<ll,ll>
#define piii pair<int,pii>
#define piiii pair<pii,pii>
#define psi pair<string,int>
//#define endl "\n"
const int MAX = 3e5+5;
const ll MAX2 = 11;
const ll MOD = 1000000007;
const ll INF = 2e18;
const int dr[]={1,0,-1,0,1,1,-1,-1,0};
const int dc[]={0,1,0,-1,1,-1,1,-1,0};
const double pi = acos(-1);
const double EPS = 1e-9;
const int block = 450;

int n;
string a,b,ta,tb,s;
bool st;

int main(){
//	cout<<fixed<<setprecision(15);
//    freopen("input.txt", "r", stdin);
//	freopen("output.txt","w",stdout);
//    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin>>n;
    while(1){
    	if(st){
    		ta = '.'+a, tb = '.'+b;
			cout<<ta<<endl<<tb<<endl;
			cin>>s;
			if(s=="end")break;
			else if(s=="T"){a = ta, b = tb; continue;}
    		ta = '.'+a, tb = '#'+b;
			cout<<ta<<endl<<tb<<endl;
			cin>>s;
			if(s=="end")break;
			else if(s=="T"){a = ta, b = tb; continue;}
    		ta = '#'+a, tb = '.'+b;
			cout<<ta<<endl<<tb<<endl;
			cin>>s;
			if(s=="end")break;
			else if(s=="T"){a = ta, b = tb; continue;}
    		ta = '#'+a, tb = '#'+b;
			cout<<ta<<endl<<tb<<endl;
			cin>>s;
			if(s=="end")break;
			else if(s=="T"){a = ta, b = tb; continue;}
		}
		else {
			ta = a+'.', tb = b+'.';
			cout<<ta<<endl<<tb<<endl;
			cin>>s;
			if(s=="end")break;
			else if(s=="T"){a = ta, b = tb; continue;}
			ta = a+'.', tb = b+'#';
			cout<<ta<<endl<<tb<<endl;
			cin>>s;
			if(s=="end")break;
			else if(s=="T"){a = ta, b = tb; continue;}
			ta = a+'#', tb = b+'.';
			cout<<ta<<endl<<tb<<endl;
			cin>>s;
			if(s=="end")break;
			else if(s=="T"){a = ta, b = tb; continue;}
			ta = a+'#', tb = b+'#';
			cout<<ta<<endl<<tb<<endl;
			cin>>s;
			if(s=="end")break;
			else if(s=="T"){a = ta, b = tb; continue;}
			st = 1;
		}
	}
	return 0;
}//

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

int main(void){
  int w, h, n;
  cin >> w >> h >> n;
  int in_x, in_y, in_a;
  int up_x = w, dw_x = 0, up_y = h, dw_y = 0;
  for(int i = 0;i<n;i++){
    cin >> in_x >> in_y >> in_a;
    switch (in_a)
    {
      case 1:
          dw_x = max(dw_x, in_x);
        break;
      case 2:
          up_x = min(up_x, in_x);
        break;
      case 3:
          dw_y = max(dw_y, in_y);
        break;
      case 4:
          up_y = min(up_y, in_y);
        break;
    }
  }

  cout << max(up_x - dw_x, 0) * max(up_y - dw_y, 0) << endl;
  return 0;
}

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

int main(){
  int N;
  cin >> N;
  string Ans;
  
  for(int i=0;i<N;i++){
    string A;
    cin >> A;
    if(A=="Y"){
      Ans="Four";
      break;
    }
    Ans="Three";
  }
  
  cout << Ans << endl;
}

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

int main(){
    string S, T;
    int ans = 0;
    cin >> S >> T;
    rep(i,0,3){
        if (S[i] == T[i]){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3520
#include<cstdio>
#include<cstring>
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
typedef long long ll;
template<typename T>inline void rd(T&x){int fl=0,ch;while(ch=getchar(),ch<48||57<ch)fl^=!(ch^45);x=(ch&15);while(ch=getchar(),47<ch&&ch<58)x=x*10+(ch&15);if(fl)x=-x;}
template<typename T>inline void pt(T x){if(x<0)putchar('-'),x=-x;if(x>9)pt(x/10);putchar(x%10+48);}
template<typename T>inline void pt(T x,int ch){pt(x),putchar(ch);}
template<typename T>inline T max(const T&x,const T&y){return x<y?y:x;}
template<typename T>inline T min(const T&x,const T&y){return x<y?x:y;}
const int N=200005,P=1000000007;
int n,c[N],f[N],ans[N];
int main(){
	rd(n);rep(i,1,n){
		rd(c[i]);
		if(c[i]==c[i-1]){--i,--n;continue;}
	}
	f[0]=1;
	rep(i,1,n){
		(ans[c[i]]+=f[i-1])%=P;
		f[i]=ans[c[i]];
	}
	printf("%d\n",f[n]);
	return 0;
}

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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = (1LL << 60);

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int N; cin >> N;
	vll arr (N);
	F0R(i, N) cin >> arr[i];

	vector<vll> dp (3, vll (N+2, -INF));
	F0R(i, 3) dp[i][i] = 0;
	F0R(i, N) {
		F0R(s, 3) dp[s][i] += arr[i], dp[s][i+2] = max(dp[s][i+2], dp[s][i]);
		F0R(s, 2) dp[s+1][i+3] = max(dp[s+1][i+3], dp[s][i]);
		dp[2][i+4] = max(dp[2][i+4], dp[0][i]);
	}
	print(max(dp[N%2][N-2], dp[1+(N%2)][N-1]));
}

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

#define MAX 1000000

long long cnt;
int l;
int A[MAX];
int n;
vector <int> G;

void insertionSort(int[], int, int);
void shellSort(int[], int);

int main(){
  int i;
  cin >> n;
  for(i = 0; i < n; i++){
    cin >> A[i];
    //scanf("%d",&A[i]);
  }
  cnt = 0;
  shellSort(A,n);
  cout << G.size() << endl;
  for(i = G.size() - 1 ; i >= 0; i--){
    cout << G[i];
    if(0 < i){
      cout << " ";
    }
  }
  cout << endl;
  cout << cnt << endl;
  for(i = 0; i < n; i++){
    cout << A[i] << endl;
  }
  return 0;
}

void insertionSort(int A[], int n, int g){
  int i,j,v;
  for(i = g; i < n; i++){
    v = A[i];
    j = i - g;
    while( j >= 0 && A[j] > v){
      A[j + g] = A[j];
      j = j - g;
      cnt++;
    }
    A[j + g] = v;
  }
}

void shellSort(int A[], int n){
  int i,h;
  for(h = 1;;){
    if(n < h){
      break;
    }
    G.push_back(h);
    h = 3*h + 1;
  }
  for(i = G.size() - 1; i >= 0; i--){
    insertionSort(A, n, G[i]);
  }
}

Measured memory_bytes: 6996
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

ll f[110][11];
ll p[110][11];

int main(){
#ifdef LOCAL_TEST
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif
    int n;
    cin >> n;
    rep(i, n) rep(j, 5) rep(k, 2) cin >> f[i][j*2+k];
    rep(i, n) rep(j, 11) cin >> p[i][j];

    ll ans = -1e18;
    REP(mask, 1, 1<<10) {
        ll tmp = 0LL;
        rep(i, n) {
            int cnt = 0;
            rep(j, 10) {
                if(mask&(1<<j)) {
                    if(f[i][j] == 1) cnt++;
                }
            }
            tmp += p[i][cnt];
        }
        ans = max(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int a,b,c;
  scanf("%d%d",&a,&b);
  if (a < b){
    a+=b;
    b=a-b;
    a-=b;
  }
  while(b != 0){
    c = a % b;
    a = b;
    b = c;
  }
  printf("%d\n",a);
  return 0;
}

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

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

typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//定数
#define INF 1000000000 //10^9:極めて大きい値,∞
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second　//pairの二つ目の要素

int gcd(int a,int b){
    int tmp, r;
  /* 自然数 a > b を確認・入替 */
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }

  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
    return b;
}

int main(){
    int n,wl;
    cin>>n>>wl;
    vector<int> w(n), v(n);
    ll v_max=0;
    rep(i,n){ 
        cin>>w[i]>>v[i];
        v_max+=v[i];
    }
   
    vector<ll> dp(v_max+1,INF);
    dp[0]=0;
    rep(i,n){
        vector<ll> dpt(v_max+1);
        for(int j=1;j<=v_max;j++){
            if(j-v[i]>=0) dpt[j]=min(dp[j],dp[j-v[i]]+w[i]);
            else dpt[j]=dp[j];
        }
        dp=dpt;
    }
    ll vl=v_max;
    while(1){
        if(dp[vl]<= wl) break;
        vl--;
    }
    cout<<vl<<endl;
    return 0;
}

Measured memory_bytes: 1792
def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    from collections import Counter
    c = Counter(A)
    mc = c.most_common()
    fi = mc[0]
    se = mc[1]
    if mc[0][1] < 2:
        return print(0)
    elif mc[1][1] < 2 and mc[0][1] < 4:
        return print(0)

    # 長方形作成可能
    four = [k for k, v in mc if v >= 4]
    two = [k for k, v in mc if v >= 2]
    ans1, ans2 = 0, 0
    if four:
        ans1 = max(four)**2
    two.sort()
    if len(two) >= 2:
        ans2 = two[-1]*two[-2]
    print(max(ans1, ans2))


if __name__ == '__main__':
    main()


Measured memory_bytes: 71960
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int N;
int res;
void doit(long long c, int mask){
  if(c > N){
    return;
  }
  if(mask==7){
    res++;
  }
  doit(10*c+3, mask | 1);
  doit(10*c+5, mask | 2);
  doit(10*c+7, mask | 4);
}
int main(){
  rd(N);
  doit(0, 0);
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190715-1

// --- original code ---
// int N;
// int res;
// 
// void doit(ll c, int mask){
//   if(c > N) return;
//   if(mask==7) res++;
//   doit(10c+3, mask | 1);
//   doit(10c+5, mask | 2);
//   doit(10c+7, mask | 4);
// }
// 
// {
//   rd(N);
//   doit(0, 0);
//   wt(res);
// }
// 


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>

using namespace std;

int main() {
  string S;
  cin >> S;
  bool bad = false;
  for (int i = 1; i < 4; ++i) {
    if (S[i] == S[i - 1]) bad = true;
  }
  if (bad) cout << "Bad" << endl;
  else cout << "Good" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  ll t;
  //cin>>t;
 // while(t--){
ll a,b,c=0,d=0,e=0;
cin>>a>>b>>c;
if(b*c>=a){cout<<"Yes"<<endl;}
else{cout<<"No"<<endl;}

 // }
  return 0;
}

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

int main(void){
  int N;
  cin>>N;
  double ans=0;
  for(int i = 0; i<N; i++){
    double x;
    string u;
    cin>> x>> u;
    //cout<<(u=="JPY")<<"\n";
    ans += x*((u=="JPY")?1:380000);
  }
  cout<<ans;
  return 0;
}

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

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  int n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
vb arr(200001);
int N ;
void Eratosthenes(){
	for(int i = 0; i <= 2*N; i++){
		arr[i] = true;
	}
	for(int i = 2; i < sqrt(2*N); i++){
      arr[0]=false;arr[1]=false;
		if(arr[i]){
			for(int j = 0; i * (j + 2) < 2*N; j++){
				arr[i *(j + 2)] = false;
			}
		}
	}

	for(int i = 2; i < 2*N; i++){
		if(arr[i]){
			//cout << i << endl;
		}
	}
}
int main(){
  cin>>N;
  Eratosthenes();
  for(int i =N; N<=2*N; i++){
    if(arr[i]){ cout<<i<<endl; break;}
  }
}
  


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

int main(void)
{
  int N;
  long int sum=0;
  int i;

  scanf("%d",&N);

  for(i=1;i<=N;i++)
  {
    if(i%3 != 0 && i%5 != 0)
    {
      sum += i;
    }
  }

  printf("%ld\n",sum);

  return 0;
}

Measured memory_bytes: 1732
#include<iostream>
#include<string>
using namespace std;
int main(){
int First=0;
string S;
cin>>S;
for (int i = 0; i < 4; i++) {
  if(S[i]=='+'){
    First=First+1;
  }else{
    First=First-1;
  }
}


cout<<First<<endl;






}


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

using namespace std;

int solve(int X)
{
    switch (X) {
    case 1:
        return 300000;

    case 2:
        return 200000; 

    case 3:
        return 100000;
    }
 
    return 0;
}

int main()
{
    ios::sync_with_stdio(false);

    int X, Y;
    cin >> X >> Y;

    auto ans = solve(X) + solve(Y);

    if (X == 1 and Y == 1)
        ans += 400000;
 
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 764
#define _GRIBCXX_DEBUG
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <string>
#include <utility>
#include <vector>
using namespace std;

// ?????¬???????????¬??????
#define REP(i,n) for(int i=0; i<(int)n; ++i)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), c.end()

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<double> vd;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<long, long> pil;

// ??°?????????????????¬??????
typedef int Weight;

struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) {}
};

bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight :
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;


int main() {
  int x;
  int i = 1;
  while (true) {
    scanf("%d", &x);
    if (x==0) break;
    else {
      printf("Case %d: %d\n", i, x);
      i++;
    }
  }
  return 0;
}

Measured memory_bytes: 3160
N, K = map(int, input().split())
P = list(map(int, input().split()))

E = [0] * N

for i, p in enumerate(P):
  E[i] = (1 + p) * p / 2 / p
  
# 初期化  
sum_exp = sum(E[0:K])
max_exp = sum_exp

for head, e in enumerate(E[K:], 0):
  sum_exp = sum_exp - E[head] + e
  max_exp = max(max_exp, sum_exp)
  
print(max_exp) 

Measured memory_bytes: 73400
#include<iostream>
using namespace std;
int main()
{
  int n=0,ans;
  cin >>n;
  while(n!=-1){
    ans=0;
    if(n>30){
      ans+=(n-30)*160;
      n=30;
    }
    if(n>20){
      ans+=(n-20)*140;
      n=20;
    }
    if(n>10)
      ans+=(n-10)*125;
    cout <<4280-(ans+1150)<<endl;
    cin>> n;
  }
  return 0;
}



Measured memory_bytes: 3012
// i hope i get better                                                           
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int sz=2e5+9;
int n,p;
string s;
ll ans;
ll cnt[sz];
ll w[sz];
ll mod;
ll mul(ll a,ll b){return (a%mod*b%mod)%mod;}
ll add(ll a,ll b){return ((a%mod+b%mod)%mod+mod)%mod;}

int main(){
	cin>>n>>p>>s;
	if(p==2||p==5){
		for(int i=0;i<n;i++){
			int v=s[i]-'0';
			if(v%p) continue;
			ans+=i+1;
		}
		cout<<ans;
		return 0;
	}
	mod=p;
	w[0]=1;
	for(int i=1;i<sz;++i) w[i]=mul(w[i-1],10);
	ll val=0;
	cnt[0]=1;
	for(int i=0;i<n;++i){
		int idx=n-i;
		int v=s[i]-'0';
		val=add(val,mul(w[idx],v));
		ans+=cnt[val];
		cnt[val]++;
	}
	cout<<ans;
    return 0;
}

Measured memory_bytes: 2180
#include <bits/stdc++.h>
#include <set>
using namespace std;
using ll = long long;
using P = pair<int,int>;

#define rep(i, n) for(int i=0;i<(int)n;i++)
#define rep2(i, s, n) for(int i=(s);i<(int)n;i++)
int INF=1e9+7;

int main() {
  ll N,K;
  cin >> N >> K;
  vector<int> A(N);
  rep(i,N) {
    cin >> A[i];
    A[i]--;
  }
  vector<int> tr(1);
  set<int> s;
  s.insert(0);
  set<int>::iterator ite;;
  int last=0,start=0;
  while(true) {
    int to=A[last];
    last=to;
    ite=s.find(to);
    if(ite!=s.end()) break;
    tr.push_back(to);
    s.insert(to);
  }
  rep(i,N) {
    if(tr[i]==last) {
      start=i;
      break;
    }
  }
  if(K<start) cout << tr[K]+1 << endl;
  else {
    K-=start;
    K%=tr.size()-start;
    cout << tr[K+start]+1 << endl;
  }
}

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

int isEqualTo7(int op1,int op2,int op3,string num){
	int ans = 0;
	if(op1 == 0) ans = num[0]-'0' + num[1] - '0';
	else ans = num[0]-'0' - (num[1]-'0');
	if(op2 == 0) ans += num[2] - '0';
	else ans -=  (num[2] - '0');
	if(op3 == 0) ans += num[3] - '0';
	else ans -= (num[3] - '0');  
	return ans == 7;
}


string outFunc(int i){
	if(i == 0) return "+";
	else return "-"; 
}

int main(){
	string s;
    cin >> s;
	for(int op1=0;op1<2;op1++)
		for(int op2=0;op2<2;op2++)
			for(int op3=0;op3<2;op3++)
				if(isEqualTo7(op1,op2,op3,s)){
					cout << s[0] << outFunc(op1) << s[1] << outFunc(op2) << s[2] << outFunc(op3) << s[3] << "=7" << endl;
					return 0;
				}
}

Measured memory_bytes: 256