akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#ifdef LOCAL
#include <debug.hpp>
#else
#define debug(...) void()
#endif

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  int ans = 0;
  bool flag = true;
  for (int i = 1, a; i <= n; i++) {
    cin >> a;
    if (a == i) {
      if (flag) {
        ans++;
        flag = false;
      } else {
        flag = true;
      }
    } else {
      flag = true;
    }
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define mset(a, b) memset(a, b, sizeof(a))
#define mcpy(a, b) memcpy(a, b, sizeof(a))
#define rg register
using namespace std;
typedef long long LL;
const int MAXN = 1000005;
const int MOD = 1e9 + 7;

template <typename T> inline void read(T &AKNOI) {
	T x = 0, flag = 1;
	char ch = getchar();
	while (!isdigit(ch)) {
		if (ch == '-') flag = -1;
		ch = getchar();
	}
	while (isdigit(ch)) {
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	AKNOI = flag * x;
}

int n;
LL dp[MAXN], sum[MAXN];

inline void Inc(LL &x, LL y) {
	x += y; if (x >= MOD) x -= MOD;
}

void init() {
	read(n);
	dp[1] = 1;
	for (int i=1;i<=n;++i) {
		Inc(dp[i], dp[i-1]);
		if (i >= 3) Inc(dp[i], sum[i-3]);
		Inc(sum[i], sum[i-1]);
		Inc(sum[i], dp[i]);
	}
}

void solve() {
	LL ans = 0;
	for (int i=1;i<=n-1;++i) {
		ans = (ans + dp[i] * (n-1) % MOD * (n-1)) % MOD;
	}
	for (int i=1;i<=n-1;++i) {
		ans = (ans + dp[i] * min(i+1, n-1)) % MOD;
	}
	ans = (ans + dp[n] * n) % MOD;
	printf("%lld\n", ans);
}

int main() {
	init();
	solve();
	return 0;
}


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

using namespace std;
const int MAXN = 1e5 + 7;

int dp[MAXN], a[MAXN];

int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  dp[1] = 0;
  dp[2] = abs(a[2] - a[1]);
  for (int i = 3; i <= n; i++) {
    dp[i] = min(dp[i - 2] + abs(a[i - 2] - a[i]), dp[i - 1] + abs(a[i - 1] - a[i]));
  }
  cout << dp[n] << '\n';
  return 0;
}

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

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
bool chmin(T &a,T b){if(a>b){a=b;return true;}else return false;}
template<typename T>
bool chmax(T &a,T b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
ostream &operator<<(ostream &os, pair<ll, ll>&p){
  return os << p.first << " " << p.second;
}  
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll n;cin>>n;
  map<string,ll>mp;
  rep(i,0,n){
    string s;cin>>s;
    mp[s]++;
  }
  ll mx=0;
  for(auto z:mp)chmax(mx,z.se);
  for(auto z:mp){
    if(z.se==mx)cout<<z.fi<<endl;
  }
  return 0;
}

Measured memory_bytes: 23808
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f

#include <iostream>
#include <cstdio>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
  
using namespace std;
  
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;
  
static const double EPS = 1e-8;
  
int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};

int main(){
  int num_student;
  int num_min_pass;
  int num_max_pass;
  while(~scanf("%d %d %d", &num_student, &num_min_pass, &num_max_pass)) {
    if (num_student == 0) break;

    int score[10000];
    for (int student_i = 0; student_i < num_student; student_i++) {
      scanf("%d", &score[student_i]);
    }
    sort(score,score + num_student, greater<int>());
    int diff = -1;
    int res = 0;
    for (int pass_i = num_min_pass - 1; pass_i < num_max_pass; pass_i++) {
      int min_pass_score = score[pass_i];
      int max_fail_score = score[pass_i + 1];
      if (diff <= min_pass_score - max_fail_score) {
	diff = min_pass_score - max_fail_score;
	res = pass_i + 1;
      }
    }
    printf("%d\n",res);
  }
}

Measured memory_bytes: 3228
#include <bits/stdc++.h>
#define LL long long
using namespace std ;
void Read ( int &x, char c = getchar(), bool f = 0 ) {
	for ( x = 0 ; !isdigit(c) ; c = getchar() ) if (c == '-') f = 1 ;
	for ( ; isdigit(c) ; c = getchar() ) x = 10*x + c - '0' ;
	if (f) x = -x ;
}
const int maxn = 1e5+5 ;
int n, m, a[maxn] ;
int main() {
	Read(n) ; Read(m) ;
	int i, x = -1 ;
	for ( i = 1 ; i <= n ; i ++ )
		Read(a[i]) ;
	for ( i = 1 ; i < n ; i ++ )
		if (a[i] + a[i + 1] >= m) {
			x = i ;
			break ;
		}
	if (x == -1) goto no ;
	puts("Possible") ;
	for ( i = 1 ; i < x ; i ++ )
		printf ( "%d\n", i ) ;
	for ( i = n-1 ; i > x ; i -- )
		printf ( "%d\n", i ) ;
	printf ( "%d\n", x ) ;
	return 0 ;
	no :
	puts("Impossible") ;
	return 0 ;
}

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

int main(void) {
  int n;
  string event;

  cin >> n;
  while(n--) {
    int out = 3;
    int ret = 0;
    int runner = 0;
    
    while(out) {
      cin >> event;
      if(event == "HIT") runner++;
      if(event == "OUT") out--;
      if(event == "HOMERUN") {
	ret+=(runner+1);
	runner=0;
      }
      if(runner==4) { runner--; ret++; }
    }
    cout << ret << endl;
  }

  return 0;
}

Measured memory_bytes: 1208
N = int(input())
l = list(map(int, input().split()))

# リストを受け取り、すべてが偶数かどうかチェックする
def is_even(a):
    for i in a:
        if i % 2 != 0:
            return False
    return True

# リストを受け取り、すべてを÷2したリストを返却する
def divided_list(a):
    tmp_list = []
    for k in a:
        tmp_list.append(int(k / 2))
    return tmp_list

# リストを受け取り、すべてが偶数であればすべてを÷2したリストを返却し、それ以外の場合はFalseを返却する
def aaa(a):
    if is_even(l):
        return divided_list(l)
    else:
        return False

count = 0
while aaa(l):
    count += 1
    l = aaa(l)

print(count)

Measured memory_bytes: 3064
#![allow(unused)]

//入力マクロここから
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
//入力マクロここまで

//input
//use std::io::Read;

//collections
//use std::collections::BTreeMap;
//use std::collections::BTreeSet;
//use std::collections::HashMap;
//use std::collections::HashSet;
//use std::collections::VecDeque;

fn main() {
    input! {
        s: chars,
        k: usize,
    }

    for i in 0..k {
        if s[i] != '1' {
            println!("{}", s[i]);
            return;
        }
    }

    println!("1");
}


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

int main(){
  int n;
  cin >> n;
  int ans=0;
  for(int i=0; i<n; i++){
    int a;
    cin >> a;
    ans += a-1;
  }
  cout << ans << endl;
  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,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))

typedef long long ll;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;

typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);
const int mod=1000000007;
const int mod2=998244353;

ll powmod(ll a,ll b){ll c=1; while(b>0){ if(b&1){ c=a*c%mod; } a=a*a%mod; b>>=1; } return c;}
ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
  string s;cin>>s;

  if(s=="ABC")cout<<"ARC"<<endl;
  else cout<<"ABC"<<endl;
  
}

 
    

Measured memory_bytes: 3556
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;

public class Main {

	static PrintWriter out;
	static InputReader ir;

	static void solve() {
		int n=ir.nextInt();
		int ret=0;
		for(int i=0;i<n;i++)
			ret-=ir.nextInt()-ir.nextInt()-1;
		out.println(ret);
	}

	public static void main(String[] args) throws Exception {
		ir = new InputReader(System.in);
		out = new PrintWriter(System.out);
		solve();
		out.flush();
	}

	static class InputReader {

		private InputStream in;
		private byte[] buffer = new byte[1024];
		private int curbuf;
		private int lenbuf;

		public InputReader(InputStream in) {
			this.in = in;
			this.curbuf = this.lenbuf = 0;
		}

		public boolean hasNextByte() {
			if (curbuf >= lenbuf) {
				curbuf = 0;
				try {
					lenbuf = in.read(buffer);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return false;
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte())
				return buffer[curbuf++];
			else
				return -1;
		}

		private boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}

		private void skip() {
			while (hasNextByte() && isSpaceChar(buffer[curbuf]))
				curbuf++;
		}

		public boolean hasNext() {
			skip();
			return hasNextByte();
		}

		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (!isSpaceChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public int nextInt() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

		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 char[][] nextCharMap(int n, int m) {
			char[][] map = new char[n][m];
			for (int i = 0; i < n; i++)
				map[i] = next().toCharArray();
			return map;
		}
	}
}


Measured memory_bytes: 21204
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define INF 1e9;
using namespace std;
typedef long long ll;
int main() {
  int N, Q;
  cin >> N >> Q;
  string S;
  cin >> S;
  int c[N + 1];
  c[0] = 0;
  REP(i, N) {
    if (i + 1 < N && S[i] == 'A' && S[i + 1] == 'C') {
      c[i + 1] = c[i] + 1;

    } else {
      c[i + 1] = c[i];
    }
  }
  REP(i, Q) {
    int l, r;
    cin >> l >> r;
    --l, --r;
    cout << c[r] - c[l] << endl;
  }
  return 0;
}

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

//ソート用の判定関数
int compare_int(const void *a, const void *b){
  return *(long int*)b - *(long int*)a; // 降順
}

int main(int argc, char const *argv[]) {
  /* code */
  int n, k;
  int i;
  long int result=0;
  scanf("%d %d", &n, &k);
  
  long int h[n];
  for(i=0; i<n; i++){
    scanf("%ld", &h[i]);
  }
  
  qsort(h, n, sizeof(long int), compare_int);
  if(n>k){
    for(i=k; i<n; i++){
      result += h[i];
    }
  }
  printf("%ld", result);
  return 0;
}

Measured memory_bytes: 3324
process.stdin.resume();
process.stdin.setEncoding('utf8');
var lines = [];
var reader = require('readline').createInterface({
    input: process.stdin,
    output: process.stdout,
    terminal: false
});
reader.on('line', (line) => {
    lines.push(line);
});
reader.on('close', () => {
    let [S, W] = lines[0].split(" ").map(e => parseInt(e));
    console.log( S <= W ? "unsafe" : "safe" );
});

Measured memory_bytes: 30072
class Key
  attr_reader :a, :set

  def initialize(a, c)
    @a = a

    set = 0
    c.each do |num|
      num -= 1 # 0-index
      set |= 1 << num
    end
    @set = set
  end
end

INF = 1001001001

def get_everything(n, keys)
  dp = Array.new(1 << n, INF)
  dp[0] = 0

  (1 << n).times do |i|
    keys.each do |key|
      t = i | key.set
      cost = dp[i] + key.a
      dp[t] = [dp[t], cost].min
    end
  end
  
  dp.last == INF ? -1 : dp.last
end

n, m = gets.split.map(&:to_i)
keys = []
m.times do
  a, b = gets.split.map(&:to_i)
  c = gets.split.map(&:to_i)
  keys << Key.new(a, c)
end

puts get_everything(n, keys)


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

int main(void){
    int i, n, x=0;
    cin >> n;
    char s[n];
    for(i=0; i<n; i++)
        cin >> s[i];
    i=0;
    while(i<n){
        if(s[i]=='A'){
            i++;
            if(s[i]=='B'){
                i++;
                if(s[i]=='C')
                    x++;
            }
        }
        else
            i++;
    }
    cout << x << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define mrep(i,j,n) for(int i = j; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define mreps(i,j,n) for(int i = j; i <= n; i++)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define el cout << endl
#define sp(x) cout << setprecision(x);
#define cer(x) cerr << x <<endl
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(ALL(x), val), x.end())
#define vi vector<int> 
#define vvi vector<vector<int>> 
#define vpii vector<pair<int,int>> 
#define vl vector<ll> 
#define vvl vector<vector<ll>> 
#define vd vector<double> 
#define vvd vector<vector<double>> 
#define vb vector<bool> 
#define vvb vector<vector<bool>>
#define vs vector<string>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
ll mod = 1e9 + 7;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a * b / g; }
bool is_prime(ll x) { for (ll i = 2; i * i <= x; i++) { if (x % i == 0)return false; } return true; }

ll dfs(ll n)
{
	if (n == 1)return 1;
	else
	{
		ll h = n/2;
		return 2 * dfs(h) + 1;
	}
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll h; cin >> h;
	ll ans = dfs(h);
	co(ans);
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
class Main{

	public static void main(String[] args) {
		int[] a= new int[3];
		int t,i,flag=0;
		Scanner kbd = new Scanner(System.in);
		a[0] = kbd.nextInt();
		a[1] = kbd.nextInt();
		a[2] = kbd.nextInt();
		for(;;){
			flag = 0;
			for( i=0;i<2;i++){
				if(a[i] >a[i+1]) {
					t=a[i];a[i] = a[i+1];a[i+1]=t;flag = 1;
				}
			}
			if(flag == 1) continue;	else break;
		}
		for( i=0;i<2;i++){
			System.out.print(a[i] + " ");
		}
		System.out.println(a[2]);
	}

}

Measured memory_bytes: 26132
#include <iostream>
#include <cstdlib>

using namespace std;

int main(){
	int alpha[26];
	for(int i = 0; i < 26; i++) alpha[i] = 0;
	char c;
	while(cin >> c) if(isalpha(c)) alpha[tolower(c) - 'a'] ++;
	for(int i = 0; i < 26; i++) cout << (char)(i + 'a') << " : " << alpha[i] << '\n';
}



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

int main(){
    string s;
    cin >> s;

    if(s.substr(0,2) == "00" && s.substr(2,2) != "00" && s.substr(2,2) <= "12"){
        cout << "YYMM" << endl;
    }
    else if(s.substr(0,2) != "00" && s.substr(0,2) <= "12" && s.substr(2,2) == "00"){
        cout << "MMYY" << endl;
    }
    else if(s.substr(0,2) == "00" || s.substr(2,2) == "00"){
        cout << "NA" << endl;
    }
    else if(s.substr(0,2) <= "12" && s.substr(2,2) > "12"){
        cout << "MMYY" << endl;
    }
    else if(s.substr(0,2) > "12" && s.substr(2,2) <= "12"){
        cout << "YYMM" << endl;
    }
    else if(s.substr(0,2) <= "12" && s.substr(2,2) <= "12"){
        cout << "AMBIGUOUS" << endl;
    }
    else{
        cout << "NA" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <cmath>
using namespace std;
using ll = long long;

int main()
{
    int N, M;

    cin >> N;
    vector<string> S(N);
    for (int i = 0; i < N; i++) {
        cin >> S[i];
    }
    cin >> M;
    vector<string> T(M);
    
    for (int i = 0; i < M; i++) {
        cin >> T[i];
    }

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

    }

    int ans = 0;
    for (int i = 0; i < N; i++) {
        int tmp = 0;
        for (int j = 0; j < N; j++) {
            if (S[i] == S[j]) 
                tmp++;
        }
        for (int k = 0; k < M; k++) {
            if (S[i] == T[k])
                tmp--;
        }
        ans = max(ans, tmp);
    }

    cout << ans << endl;

    return 0;
}

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

int main(){
  int64_t A,B,K;
  cin >> A>>B>>K;
  if(K>A){
    K=K-A;
    A=0;
    B-=K;
    if(B<0)
      B=0;
  }
  else{
    A-=K;
  }
  cout<<A<<" "<<B<<endl;
}


Measured memory_bytes: 256
S = input()
T = input()
c =0
C = [0]
for i in range(len(S)):
  c = 0
  for j in range(len(T)):
    if S[i] == T[j] and i-j >= 0 and len(S)-i -1 >= len(T)-j -1:
      
      c = 1
      if not(i == len(S)-1 and j == len(T)-1):
        for k in range(len(T) - j-1):
          if S[i + k + 1] == T[j + k +1]:
            c += 1
        C.append(c)
        c = 0
      else:
        C.append(c)
print(len(T)-max(C))

Measured memory_bytes: 86668
// 解き直し.
// ABC 131解説.
// https://img.atcoder.jp/abc131/editorial.pdf
#include <bits/stdc++.h>
using namespace std;

int main() {
    
    // 1. 入力情報取得.
    int N, K;
    scanf("%d %d", &N, &K);
    
    // 2. 以下, 解説通り.
    // -> 解が存在しない場合は, 終了.
    int upper = (N - 1) * (N - 2) / 2;
    if(K > upper){
        printf("%d\n", -1);
        return 0;
    }
    
    // 3. 頂点 1 を中心とするスターを作成後, 
    // 頂点 2 ～ 頂点 N の間に, 必要な本数だけ, 辺を追加し, 出力.
    // -> 必要な本数は, (upper - K)本 とする.
    int M = (N - 1) + (upper - K);
    printf("%d\n", M);
    for(int i = 1; i < N; i++) for(int j = i + 1; j <= N; j++) if(M > 0) printf("%d %d\n", i, j), M--;
    
    // 4. 後処理.
    return 0;
    
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <utility>
using namespace std;
#define INF (1<<30)

int n,m;
bool linked[100] = {false};
vector<vector<pair<int,int> > > vec;

int main(){
	while(scanf("%d%d",&n,&m), n != 0){
		vec = vector<vector<pair<int,int> > >(n);
		for(int i = 0; i < m; i++){
			int a,b,cost;
			scanf("%d%d%d",&a,&b,&cost);
			vec[a].push_back(make_pair(b,cost));
			vec[b].push_back(make_pair(a,cost));
		}
		for(int i = 0; i < n; i++){
			linked[i] = false;
		}
		linked[0] = true;

		int ans = 0;
		for(int i = 1; i < n; i++){
			int mi = INF;
			int mic = INF;
			for(int j = 0; j < n; j++){
				if(linked[j]){
					int mj = INF;
					int mjc = INF;
					for(int k = 0; k < vec[j].size(); k++){
						if(vec[j][k].second < mjc && !linked[vec[j][k].first]){
							mj = vec[j][k].first;
							mjc = vec[j][k].second;
						}
					}
					if(mjc < mic){
						mi = mj;
						mic = mjc;
					}
				}
			}
			ans += mic;
			linked[mi] = true;
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 2632
s = input()
 
cnt = 1
l = len(s)
l1 = l//2
for i in range(l1):
  if s[i] != s[l-1-i]:
    cnt = 0
 
for i in range(l1//2):
  if s[i] != s[l1-1-i]:
    cnt = 0
 
for i in range(l1//2):
  if s[l1+1+i] != s[l-1-i]:
    cnt = 0
if cnt == 0:
  print("No")
else:
  print("Yes")

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

int n,m,s[26],q[26];
char c[100];
int main(){
	scanf("%d",&n);
	for (int i=0;i<26;i++) s[i]=51;
	while (n--){
		scanf("%s",c);
		for (int i=0;i<26;i++) q[i]=0;
		for (int i=0;c[i];i++) q[c[i]-'a']++;
		for (int i=0;i<26;i++) s[i]=min(s[i],q[i]);
	}
	for (int i=0;i<26;i++)
	while (s[i]--) putchar('a'+i);
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <math.h>
using namespace std;

int main(){
    long long n;
    long long big,small=1;
    cin >> n;
    big = n;
    for(int i = 1;i < sqrt(n)+1;i++){
        if(n % i == 0){
            big = n / i;
            small = i;
        }
    }

    cout << big + small - 2 << endl;

}



Measured memory_bytes: 256
#include <cstdio>
#define INF 2147483647
#define maxn 105
using namespace std;
 
int w[maxn];
 
int main(int argc, char** argv)
{	
	int n, ans = INF, sum = 0, tsum = 0;
	scanf("%d", &n);
	for(int i=1; i<=n; i++)
	{
		scanf("%d", w + i);
		tsum += w[i];
	}
	for(int i=1; i<=n; i++)
	{
		sum += w[i];
		int t = sum - (tsum - sum);
		t = t < 0? -t: t;
		if(ans > t) ans = t;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = 1; i <= (int)(n); i++)
#define drep(i, n) for(int i = (n)-1; i >= 0; i--)
#define ALL(x) (x).begin(), (x).end()
#define dup(x,y) (((x)+(y)-1)/(y))
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

// Mod int
const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
  ll x;
  mint():x(0){}
  mint(ll x):x((x%mod+mod)%mod){}
  // mint(ll x):x(x){}
  mint& fix() { x = (x%mod+mod)%mod; return *this;}
  mint operator-() const { return mint(0) - *this;}
  mint& operator+=(const mint& a){ if((x+=a.x)>=mod) x-=mod; return *this;}
  mint& operator-=(const mint& a){ if((x+=mod-a.x)>=mod) x-=mod; return *this;}
  mint& operator*=(const mint& a){ (x*=a.x)%=mod; return *this;}
  mint operator+(const mint& a)const{ return mint(*this) += a;}
  mint operator-(const mint& a)const{ return mint(*this) -= a;}
  mint operator*(const mint& a)const{ return mint(*this) *= a;}
  bool operator<(const mint& a)const{ return x < a.x;}
  bool operator==(const mint& a)const{ return x == a.x;}
};
istream& operator>>(istream&i,mint&a){i>>a.x;return i;}
ostream& operator<<(ostream&o,const mint&a){o<<a.x;return o;}
//



int main() {
  string s;
  cin >> s;
  int n = s.size();
  ll ans = 0;
  ll c = 0;
  rep(i, n) {
    if (s[i] == 'B') c++;
    else {
      ans += c;
    }
  }
  cout << ans << endl;
}

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

int main(){
  int a,b;
  char op;

  cin >> a >> op >> b;
  
  if(op == '+') cout << a+b;
  else if(op == '-') cout << a-b;
  cout << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unistd.h>
 
using namespace std;
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { -1,0, 1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
// #define mp make_pair
//#define endl '\n'

int main() {
  int n;
  cin >> n;
  int x = (n + 1) / 2;
  Sp((double)x / n);
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define M 998244353
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;
 
ll A(ll x){
    if(x>=0)return x;
    else return -x;
}
 
ll gcd(ll a, ll b) {
	if (b > a) {
		ll tmp = b;
		b = a;
		a = tmp;
	}
	if (a%b == 0)return b;
	else return gcd(b, a%b);
}

struct edge{
	ll to;
	ll cost;
};

vector<edge>g[110];

vector<P>used;

int main(void){
	string s,t;
	cin>>s>>t;
	int ans = 0;
	for(int i=0;i<s.length();i++){
		if(s[i]!=t[i])ans++;
	}
	cout<<ans<<endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll,ll> pii;

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

ll n;
ll k;
vector<ll> t;


bool ok(ll x){
  ll sb = 0;
  vector<ll> sq;
  for(ll i = 0 ; i < n; i ++ ){
    if(t[i] % x == 0) continue;
    sb += x-(t[i]%x);
    sq.push_back((t[i]%x)-(x-(t[i]%x)));
  }
  sort(sq.begin(), sq.end());
  if(sb%x != 0) return false;
  ll m = sb/x;
  for(int i = 0 ; i < m; i ++ ){
    if(i >= (ll)sq.size()) break;
    sb += sq[i];
  }
  sb /= 2ll;
  if(sb <= k) return true;
  return false;
}

int main(){
  fastIO;
  cin >> n >> k; 
  t.resize(n);
  ll sum = 0;
  for(int i = 0 ; i < n; i ++ ){
    cin >> t[i];
    sum += t[i];
  }
  ll ans = 1;
  for(ll i = 1; i * i <= sum; i ++ ){
    if(sum % i == 0){
      if(ok(i)) ans = max(ans, i);
      if(ok(sum/i)) ans = max(ans,sum/i);
    }
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long int
#define mod 998244353 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
int32_t main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output1.txt","w", stdout);
    #endif
    IOS;
    int n,d,ans=0;
    cin>>n>>d;
    while(n--)
    {
        int x,y;
        cin>>x>>y;
        if(x*x+y*y<=d*d)
        {
            ans++;
        }
    }
    cout<<ans<<"\n";
    #ifndef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif
    return 0;
}       

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

int main() {
	char d;
	int count1 = 0;
	int count2 = 0;
	for (int a, b, c; cin >> a >> d >> b >> d >> c;) {
		if (a * a + b * b == c * c) {
			++count1;
		}
		else if (a * a - c * c / 4 == b * b - c * c / 4) {
			++count2;
		}
	}
	cout << count1 << endl << count2 << endl;
	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define  forn(i, n)  for(int i=0; i < (int)n; i++)
#define  vi          vector<int>
// #define  pb          push_back
// #define  ap          append
// #define  mii         map<int, int> 
using namespace std ;

// vector<string> splitstring(string str, string delimiter) {
//     vector<string> v;
//     string token;
//     istringstream parse(str);
//     while(getline(parse, token, delimiter)) {
//     v.push_back(token);
//     }
//     return v;
// }
// int gcd (int a, int b) {
//     if (b == 0) return a;
//     else return gcd (b, a % b);
// }
// int lcm(int a, int b){
//   return a / gcd(a,b) * b;
// }
void solve() {
   float r ;
   cin >> r;
   cout << 2 * 3.141592653589793238 * r ;
}
int main() {
  int t=1;
  //cin >> t ;
  while(t--) solve() ;
  return 0 ;
}


Measured memory_bytes: 3788
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  string s;
  cin>>n>>k>>s;
  for(int i=0;i<n;i++){
    if(i+1==k) cout<<(char)(s.at(i)-'A'+'a');
    else cout<<s.at(i);
  }
  cout<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (((a)%mod) * ((b)%mod)) % mod
#define rollcall cout << "I'm Sucu." << endl;
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define fi first
#define se second
// debug
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p){
  os << "(" << p.first << "," << p.second << ")";return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  for (auto it = v.begin();it != v.end();++it){
    if(it != v.begin())os << " ";os << *it;
  }return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &mp){
  for(auto x: mp)os << "(" << x.first << "," << x.second << ")" << endl;
  return os;
}
template<typename T, int SIZE>
int array_length(const T (&)[SIZE]){return SIZE;}
template<typename T, int N>
void PRINTF(const T (&a)[N], int s = N, int t = -1, bool f = true){
	if(t == -1){rep(i,s){if(i)cout << " ";cout << a[i];}}
	else repi(i,s,t){if(i!=s)cout << " ";cout << a[i];}
	if(f)cout << "\n";
}
template<typename T, int N1, int N2>
void PRINTF(const T (&a)[N1][N2], int h = N1, int w = N2){
	rep(i,h){rep(j,w){cout << a[i][j] << " \n"[j==w-1];}}
}
string substr(const string &str, int S1, int S2 = -1){
  if(S2 == -1)return str.substr(S1);
  return str.substr(S1, S2-S1);
}
// typedef
typedef complex<double> Point;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;
// int sum = accumulate(a, a+n, 0LL);
// int mx = max_element(a, a+n);
// int mn = min_element(a, a+n);
// int cnt = count(a, a+n, k);

vector<P> v;
signed main(){
  int n, m;cin >> n >> m;
  rep(i,n){
    int a, b;cin >> a >> b;
    v.push_back(P(a, b));
  }
  sort(all(v));
  int ans = 0, cnt = 0;
  rep(i,n){
    int a = v[i].fi, b = v[i].se;
    if(cnt+b >= m){
      ans += a*(m-cnt);
      break;
    }
    ans += a*b;cnt += b;
  }
  cout << ans << endl;
  return 0;
}





Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(0);cin.tie();cout.tie();
#define ff first
#define ss second
#define pb push_back
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 9223372036854775807;
const ll mininf = -9223372036854775807;
const ll nax = 0;
ll n;
map<int, int>arr;
vector<int>vis(1000001, 0);

int main(){
	IOS
	cin >> n;
	for(int i=0;i<n;i++){
		int a;
		cin >> a;
		arr[a]++;
	}
	for(auto i:arr){
		for(int j=i.first*2;j<=1000000;j+=i.first){
			vis[j]++;
		}
	}
	ll ans=0;
	for(auto i:arr){
		if(!vis[i.first]&&i.second==1){
			ans++;
		}
	}
	cout << ans << '\n';
}

Measured memory_bytes: 16376
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>

int main(){
    std::vector<size_t> index;

    while(true){
        int32_t tmp;
        std::cin >> tmp;
        
        if(tmp == -1){
            break;
        }else{
            index.emplace_back(tmp);
        }
    }

    auto max = *std::max_element(index.begin(), index.end());
    std::vector<std::pair<double, double>> vertex = {{0.0, 1.0}, {1.0, 1.0}};

    for(size_t i = 2; i < max; i++){
        // auto [x, y] = vertex.at(i - 1);
        double x = vertex.at(i - 1).first;
        double y = vertex.at(i - 1).second;
        auto norm = std::sqrt(x * x + y * y);
        x /= norm;
        y /= norm;
        auto x2 = x * std::cos(M_PI_2) - y * std::sin(M_PI_2);
        auto y2 = x * std::sin(M_PI_2) + y * std::cos(M_PI_2);
        vertex.emplace_back(vertex.at(i - 1).first + x2, vertex.at(i - 1).second + y2);
    }

    for(const auto& e : index){
        std::cout << vertex.at(e - 1).first << std::endl << vertex.at(e - 1).second << std::endl;
    }

    return 0;
}



Measured memory_bytes: 3304
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n - 1; i >= 0; i--)
#define ALL(x) x.begin(),x.end()
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

const ll INF = 1e18;
const int mod = 1e9+7;
const int MAX = 1e4;

bool is_prime(int x) { // 素数判定
    if (x < 2) return false;
    for (int i = 2; i * i <= x; i++) {
        if (x % i == 0) return false;
    }
    return true;
}

int seive[MAX+1]; // 整数の素因数で最小のもの

void erat() { // エラトステネスのふるい
    rep(i, MAX+1) seive[i] = i; // 初期化
    for (int i = 2; i <= MAX; i++) {
        if (seive[i] == i) { // seive[i]=iならばiは素数
            for (int j = i + i; j <= MAX; j += i) {
                seive[j] = i;
            }
        }
    }
}

void prime_fact(int x, set<int> &fact) { // 高速素因数分解
    while (x > 1 && x % seive[x] == 0) {
        fact.insert(seive[x]); // 素因数
        x /= seive[x];
    }
}


void prime_fact(int x, vector<int> &fact) { // 素因数分解
    for (int i = 2; i * i <= x; i++) {
        while (x % i == 0) {
            fact.push_back(i); // 素因数
            x /= i;
        }
    }
    if (x != 1) {
        fact.push_back(x);
    }
}

int main() {
    // int n;
    // cin >> n;
    // map<int, int> p;
    // for (int i = 2; i <= n; i++) {
    //     int x = i;
    //     for (int j = 2; j * j <= x; j++) {
    //         while (x % j == 0) {
    //             p[j]++; // jはxの素因数
    //             x /= j;
    //         }
    //     }
    //     if (x != 1) p[x]++; // xは1か素数
    // }
    // ll ans = 1;
    // for (int i = 2; i <= n; i++) {
    //     ans *= p[i] + 1;
    //     ans %= mod;
    // }
    // cout << ans << "\n";
    int n;
    cin >> n;
    map<int, int> p;
    erat();
    for (int i = 2; i <= n; i++) {
        int x = i;
        while (x > 1 and x % seive[x] == 0) {
            p[seive[x]]++;
            x /= seive[x];
        }
    }
    ll ans = 1;
    for (int i = 2; i <= n; i++) {
        ans *= p[i] + 1;
        ans %= mod;
    }
    cout << ans << "\n";
}

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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define pb            push_back
template<class T, class S> inline pair<T, S> mp(T x, S y){ return make_pair(x, y); }
template<class T, class S> inline bool minup(T& m, S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, S x){ return m<(T)x ? (m=(T)x, true) : false; }

static const int    INF = 1000000000;
static const ll     MOD = 1000000007LL;
static const double EPS = 1E-12;

const int MAX_N = 1234567;
bool flag[MAX_N+1];
int prime[MAX_N];
int a, d, n;

int getPrime(int MAX_N = MAX_N, bool* flag = flag, int* prime = prime)
{
  int ptr = 0;
  prime[ptr++] = 2;
  flag[1] = true;
  for(int i=4; i<=MAX_N; i+=2) flag[i] = true;
  for(int i=3; i<=MAX_N; i+=2){
    if(!flag[i]){
      prime[ptr++] = i;
      for(int j=2*i; j<=MAX_N; j+=i) flag[j] = true;
    }
  }
  return ptr;
}


int main()
{
  int ptr = getPrime();

  while(cin >> a >> d >> n, a){
    int res;
    for(int i = a, cnt = 0; cnt < n; i += d){
      if(!flag[i]) cnt += 1,  res = i;
    }
    cout << res << endl;
  }

  return 0;
}

Measured memory_bytes: 2744
/*
 * atcoder/abc158/c.cpp
 */

// C++ 14
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <math.h>
#include <cstring>

#define ll long long
#define Int ll
#define loop(__x, __start, __end) for(Int __x = __start; __x < __end; __x++)
#define loopdown(__x, __start, __end) for(Int __x = __start; __x > __end; __x--)
#define rep(__n) for(Int __x = 0; __x < __n; __x++)
#define span(__a,__x,__y) __a.begin()+__x,__a.begin()+__y
#define span_all(__a) __a.begin(),__a.end()
#define len(__x) (__x.size())
#define last(__x) (__x[__x.size()-1])

using namespace std;

struct Point {
  Int x, y;
  Point(Int x, Int y): x(x), y(y) {}
  Point(): x(0), y(0) {}

  Point operator + (Point v) { return Point(x + v.x, y + v.y); }
  Point operator - (Point v) { return Point(x - v.x, y - v.y); }
  bool operator == (const Point &v) const {
    return x == v.x && y == v.y;
  }
  bool operator< (const Point &p1) const {
    return x < p1.x && y < p1.y;
  }
};
ostream & operator << (ostream & out, Point const & v) {
  out << "Point(" << v.x << ", " << v.y << ')';
  return out;
}

istream & operator >> (istream & in, Point & v) {
  Int x, y;
  in >> x; in >> y; v.x = x; v.y = y;
  return in;
}

// Geometry

#define EPS 0.0000000001

class Vector2 {
public:
  double x, y;
  
  Vector2(double x = 0, double y = 0): x(x), y(y) {}
  
  Vector2 operator + (Vector2 v) { return Vector2(x + v.x, y + v.y); }
  Vector2 operator - (Vector2 v) { return Vector2(x - v.x, y - v.y); }
  Vector2 operator * (double k) { return Vector2(x * k, y * k); }
  Vector2 operator / (double k) { return Vector2(x / k, y / k); }
  
  double length() { return sqrt(norm()); }
  double norm() { return x * x + y * y; }
  double dot (Vector2 v) { return x * v.x + y * v.y; }
  double cross (Vector2 v) { return x * v.y - y * v.x; }
  
  bool operator < (const Vector2 &v) const {
    return x != v.x ? x < v.x : y < v.y;
  }
  
  bool operator == (const Vector2 &v) const {
    return fabs(x - v.x) < EPS && fabs(y - v.y) < EPS;
  }
};

ostream & operator << (ostream & out, Vector2 const & v) { 
  out<< "Vector2(" << v.x << ", " << v.y << ')';
  return out;
}

istream & operator >> (istream & in, Vector2 & v) { 
  double x, y;
  in >> x;
  in >> y;
  v.x = x;
  v.y = y;
  return in;
}


vector<Int> slice(vector<Int> &vec, int s, int t) {
  return vector<Int>(vec.begin()+s, vec.begin()+t);
}

vector<Int> trim(vector<Int> &vec, int n) {
  auto init = slice(vec, 0, n);
  auto tail = slice(vec, n+2, vec.size());
  init.insert(init.end(), tail.begin(), tail.end());
  return init;
}


Int A, B;
// N = 100
// A = 2
// B = 2
// (N/100)*8=A
// (N/100)*10=B
// 8=A, 10=B
// N = 25
// 1/4*8=A
// 1/4*10=B
// 2=A, 2=B
// 二分探索？
// 1 10000

void input() {
  cin >> A >> B;
}

void solve() {
  loop(n,0,10001) {
    Int a = (n*8)/100;
    Int b = n/10;
    if (a == A && b == B) {
      cout << n << endl;
      return;
    }
  }
  cout << -1 << endl;
}

int main() {
  input();
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <math.h>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>
#include <map>
using namespace std;

int k;
bool clear_flag;
char B[8][8];

void init() {
    for (int i = 0; i < 8; i++) {
        for (int j = 0; j < 8; j++) {
            B[i][j] = '.';
        }
    }
    clear_flag = false;
}

void putFixedPieces() {
    cin >> k;

    int r, c;
    for (int i = 0; i < k; i++) {
        cin >> r >> c;
        B[r][c] = 'Q';
    }
}

void printBoard() {
    for (int i = 0; i < 8; i++) {
        for (int j = 0; j < 8; j++) {
            cout << B[i][j];
        }
        cout << endl;
    }
}

bool isFilled(int row) {
    for (int col = 0; col < 8; col++) {
        if (B[row][col] == 'Q') {
            return true;
        }
    }
    return false;
}

bool conflict(int row, int col) {
    for (int i = 0; i < 8; i++) {
        if (0 <= row - i) {
            if (B[row - i][col] == 'Q') {
                return true;
            }
        }
        if (row + i < 8) {
            if (B[row + i][col] == 'Q') {
                return true;
            }
        }
        if (0 <= col - i) {
            if (B[row][col - i] == 'Q') {
                return true;
            }
        }
        if (col + i < 8) {
            if (B[row][col + i] == 'Q') {
                return true;
            }
        }
        if (0 <= row - i && 0 <= col - i) {
            if (B[row - i][col - i] == 'Q') {
                return true;
            }
        }
        if (0 <= row - i && col + i < 8) {
            if (B[row - i][col + i] == 'Q') {
                return true;
            }
        }
        if (row + i < 8 && 0 <= col - i) {
            if (B[row + i][col - i] == 'Q') {
                return true;
            }
        }
        if (row + i < 8 && col + i < 8) {
            if (B[row + i][col + i] == 'Q') {
                return true;
            }
        }
    }
    return false;
}

bool isComplete() {
    int count = 0;
    for (int col = 0; col < 8; col++) {
        if (B[0][col] == 'Q') {
            count++;
        }
        if (B[1][col] == 'Q') {
            count++;
        }
        if (B[2][col] == 'Q') {
            count++;
        }
        if (B[3][col] == 'Q') {
            count++;
        }
        if (B[4][col] == 'Q') {
            count++;
        }
        if (B[5][col] == 'Q') {
            count++;
        }
        if (B[6][col] == 'Q') {
            count++;
        }
        if (B[7][col] == 'Q') {
            count++;
        }
    }

    return count == 8;
}

void solve(int row) {
    if (clear_flag) {
        return;
    }
    if (isComplete()) {
        printBoard();
        clear_flag = true;
        return;
    }
    while (isFilled(row)) {
        row++;
    }
    for (int col = 0; col < 8; col++) {
        if (!conflict(row, col)) {
            B[row][col] = 'Q';
            solve(row + 1);
            B[row][col] = '.';
        }
    }
}

int main() {
    init();
    putFixedPieces();
    solve(0);
    return 0;
}


Measured memory_bytes: 3120