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

#define int long long
#define rep(i, n) for (int i = 0; i < (int) (n); i++)
#define reps(i, n) for (int i = 1; i <= (int) (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end())
#define bit(n) (1LL << (n))
#define cdiv(a, b) (((a) - 1) / (b) + 1)
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr double PI = 3.1415926535897932384626433832795028;
constexpr int DY[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
constexpr int DX[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
int sign(int x) { return (x > 0) - (x < 0); }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const deque<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const set<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const map<T, U> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int N;
int A[110000];
signed main() {
    cin >> N;
    rep(i, N) { cin >> A[i]; }
    int cnt = 0;
    rep(i, N) { if (A[i] & 1) { cnt++; }}
    if (cnt & 1) { cout << "NO" << endl; }
    else { cout << "YES" << endl; }
}

Measured memory_bytes: 4380
# -*- coding: utf-8 -*-

import math

def isPrime(n):
    if n==2:
        return True
    d=math.ceil(math.sqrt(n))
    for i in range(2,d+1):
        if n%i==0:
            return False
    return True

x=int(input())
while True:
    if isPrime(x):
        print(x)
        break
    x+=1


Measured memory_bytes: 2940
n = int(input())
s = input()
a = []
for i in range(n):
    if s[i] == 'R' :
         a.append(0)
    if s[i] == 'G' :
         a.append(1)
    if s[i] == 'B' :
         a.append(2)
cnt = [0,0,0]
for i in range(n):
    cnt[a[i]] +=1
ans = 1

for i in range(3):
    ans *= cnt[i]
# print(a)
for i in range(n):
    for j in range(i+1,n):
        k = j+(j-i)
        if k<n:
            if a[i] != a[j] and  a[i] != a[k]and a[k] != a[j]:
                # print(i,j,k,a[i],a[j],a[k])
                ans -=1



# print(cnt)
print(ans)


Measured memory_bytes: 9192
#include <iostream>
#include <fstream>
#include <string>

using namespace std;



int main(){

  int n;
  cin >> n;

  string c = to_string(n);

  for(int i=0; i< c.size();i++){
    if(c[i] == '1'){
      cout << '9';
    }else{
      cout << '1';
    }
  }

  cout << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
int n;
int main() {
	int k = 100000;
	cin >> n;
	rep(i,n) {
		int r = (int)(k * 1.05) % 1000;
		if(r == 0) {
			k = (int)((k * 1.05) / 1000) * 1000;
		} else {
			k = (int)((k * 1.05) / 1000 + 1) * 1000;		
		}
	}
	cout << k << endl;
	return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>
int main(void) {
	int n[4], ans[4] = { 1,9,7,4 }, check[4] = { -99,-99,-99,-99 };
	int i, j, k, temp, tempi, swi = 0, cnt = 0;

	for (i = 0; i < 4; i++) {
		scanf("%d", &n[i]);
	}

	for (i = 0; i < 4; i++) {
		if (n[i] == ans[i]) {
			check[i] = 1;
		}
		else {
			for (j = 0; j < 4; j++) {
				if (n[j] == ans[i] && check[j] == -99) {
					temp = n[i];
					n[i] = n[j];
					n[j] = temp;
					check[i] = 1;
				}
			}
		}
	}

	for (i = 0; i < 4; i++) {
		if (check[i] == 1) {
			cnt++;
		}
	}
	if (cnt == 4) {
		printf("YES\n");
	}
	else {
		printf("NO\n");
	}

	return 0;
}

Measured memory_bytes: 128
n=int(input())
hi=list(map(int, input().split()))

dhir={i:hi[n-1-i] for i in range(n)}

check=1
for i in range(n-1):
    if dhir[i] >= dhir[i+1]:
        continue
    elif dhir[i] == dhir[i+1]-1:
        dhir[i+1]-=1
        continue
    else:
        check=0

if check == 0:
    print("No")
else:
    print("Yes")


Measured memory_bytes: 21020
from fractions import gcd
N = int(input())
aa = list(map(int, input().split()))
front = [0]*N
back = [0]*N
front[0] = aa[0]
back[-1] = aa[-1]
for i in range(1, N):
    front[i] = gcd(front[i-1], aa[i])
    back[-1-i] = gcd(back[-i], aa[-1-i])
ans = back[1]
for i in range(2, N):
    ans = max(gcd(front[i-2], back[i]), ans)
ans = max(front[-2], ans,)
print(ans)

Measured memory_bytes: 16612
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
int character_count(string text, char character){ int ans = 0; for(int i = 0; i < text.size(); i++){ ans += (text[i] == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position move_pattern[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
#define mod long(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl(long(n))

int main(){
    string S;
    int w;
    cin >> S >> w;
    string ans;
    int counter = 0;
    while(counter < S.size()){
        ans.push_back(S[counter]);
        counter += w;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<vector>
#include<queue>
#include<map>
using namespace std;
#define pi acos(-1.0)
#define maxd 1000000007

int read()
{
	int x=0,f=1;char ch=getchar();
	while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
	while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
	return x*f;
}

#define LL long long
const int N = 1005;
const int md = (int)1e9 + 7;
int n, m;
int a[N], b[N];
int mp[N][N], leftpoint = 1;
int used[N][N];
pair<int, int> point[N * N];
int choose, fix;
struct node
{
	int x, y;
	bool operator <(const node &rhs)const
	{
		return min(a[x], b[y]) > min(a[rhs.x], b[rhs.y]);
	}
	int val()
	{
		return min(a[x], b[y]);
	}
	int check()
	{
		return (used[x][y] == 0);
	}
} expand[N * N];
int mark[N * N];
long long ans = 1;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	cin >> n >> m;
	for (int i = 1; i <= n; ++i)
	{
		cin >> a[i];
		if (mark[a[i]])
			return cout << 0, 0; 
		 point[a[i]].first = i;
		mark[a[i]] = 1;
	} 
	memset(mark, 0, sizeof(mark));
	for (int i = 1; i <= m; ++i)
	{
		cin >> b[i], point[b[i]].second = i;
		if (mark[b[i]])
			return cout << 0, 0;
		mark[b[i]] = 1;
	}
	for (int i = 1; i <= n; ++i)
		for (int j = 1; j <= m; ++j)
			expand[(i - 1) * m + j] = (node){i, j};
	sort(expand + 1, expand + n * m + 1);
	for (int i = n * m; i > 0; --i)
	{
//		cout << ans << endl;
		if (point[i].first > 0 && point[i].second > 0)
		{
			used[point[i].first][point[i].second] = 1;
//			++fix;
			--choose;
			continue;
		}
		if (point[i].first > 0)
		{
//			++fix;
			int tot = 0;
			int x = point[i].first;
			for (int j = 1; j <= m; ++j)
			if (used[x][j] == 0 && i <= b[j])
				++tot;
			ans = ans * tot % md;
			--choose;
			continue;
		}
		if (point[i].second > 0)
		{
//			++fix;
			int tot = 0;
			int y = point[i].second;
			for (int j = 1; j <= n; ++j)
			if (used[j][y] == 0 && i <= a[j])
				++tot;
			ans = ans * tot % md;
			--choose;
			continue;
		}
		while (leftpoint <= n * m && i <= expand[leftpoint].val())
		{
			leftpoint++;
//			--choose;
			choose++;
		}
		ans = ans * (choose - fix) % md;
//		cout << choose<< endl;
		--choose;
	}
//	cout << leftpoint << endl;
	cout << ans;
	return 0;
}


Measured memory_bytes: 20736
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rem(i, m, n) for (int i = m; i < (n); i++)
#define eps (1e-7)
#define inf (1e9)
#define pi (acos(-1))
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

vl memo(100, 0);

ll lucas(int n)
{
    if (memo[n] != 0)
        return memo[n];
    return memo[n] = lucas(n - 1) + lucas(n - 2);
}

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

    int n;
    cin >> n;
    memo[0] = 2;
    memo[1] = 1;
    cout << lucas(n) << "\n";

    return 0;
}

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back

//#define int long long

#define upper(n,m) (n+m-1)/m
#define rounding(n) (int)((double)n+0.5)

#define REP(i,n) for(int i=0;i<(n);i++)
#define REAP(i,a,n) for(int i=(a);i<(n);i++)
#define ALL(a) a.begin(),a.end()

#define coutALL(i,a) {int i=0;for(int e:a) cout<<(i++?" ":"")<<e; cout<<endl;}
#define coutYN(a) cout<<(a?"Yes":"No")<<endl;
#define coutyn(a) cout<<(a?"yes":"no")<<endl;

#define deb cout<<"debug"<<endl
#define debn(n) cout<<"debug: "<<n<<endl

const int INF=INT_MAX;
const int MOD=(int)1e9+7;
const double EPS=1e-12;
//const int dx[]={0,1,0,-1},dy[]={-1,0,1,0};
const int dx[]={-1,-1,-1,0,1,1,1,0},dy[]={-1,0,1,1,1,0,-1,-1};

using namespace std;

typedef pair<int,int> P;
typedef long long LL;

LL ans;

void merge(vector <int> &A,int left,int mid,int right){

  int n1=mid-left;
  int n2=right-mid;
  int L[n1], R[n2];

  for(int i=0;i<n1;i++) L[i] = A[left + i];
  for(int i = 0;i<n2;i++) R[i] = A[mid + i];

  L[n1] = INF;
  R[n2] = INF;

  for(int i=0,j=0,k=left;k<right;k++){

    if(L[i]<=R[j]){

      A[k] = L[i];
      i++;

    }

    else {

      A[k] = R[j];
      j++;
      ans+=(LL)n1-(LL)i;

    }

  }

}

void mergeSort(vector <int> &A,int left,int right){

  if(left+1 < right){

    int mid = (left + right)/2;

    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);

  }

}

signed main(){

  int n;
  cin>>n;

  vector <int> a(n);
  REP(i,n) cin>>a[i];

  mergeSort(a,0,n);

  cout<<ans<<endl;

  return 0;

}



Measured memory_bytes: 4404
#include<bits/stdc++.h>
#include<numeric>
#define int long long
#define ld long double
#define all(x) x.begin(),x.end()
const int maxn=1000000;
#define what_is(x) cerr << #x << " is " << x << endl;
const int MOD = 1e9 + 7;
using namespace std;
string abc="abcdefghijklmnopqrstuvwxyz";
int powmod(int a, int b, int MOD = MOD){
    if(!a and !b)    return 1ll;
    if(!a)    return a;
    int res = 1ll;
    b %= (MOD - 1ll), a %= MOD;
    while(b){
        if(b%2 == 1)    res = (res * a) % MOD;
        a = (a * a) % MOD;
        b /= 2;
    }
    return res;
}
int popcount(uint32_t n)
{
    n = n - ((n >> 1) & 0x55555555);
    n = (n & 0x33333333) + ((n >> 2) & 0x33333333);
    return ((n + (n >> 4) & 0xF0F0F0F) * 0x1010101) >> 24;
}
bool check(int n) {return (((double)sqrt(n)-floor((double)sqrt(n)))==0);}
vector<bool> sieve(maxn + 1, true);
void fillprime() {
    sieve[0] = sieve[1] = false;
    for (int i = 2; i <= maxn; ++i) {
        if (sieve[i] && (int) i * i <= maxn) {
            for (int j = i * i; j <= maxn; j += i) {
                sieve[j] = false;
            }
        }
    }
}
const int nn=1e5+5;
int result[100005];
void solve() {
   int n;
   cin>>n;
   ld x=((n/2)+1)/n;
   if(n==1) cout<<"1.0000000000"<<"\n";
   else if(n%2==0) {
       cout<<0.5000000000<<"\n";
   }
   else {
       cout<<fixed<<setprecision(10)<<(long double)((n/2)+1)/n<<"\n";
   }
    
}
int32_t main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    //fillprime();
    //int t;cin>>t;while(t--)
    solve();
}

Measured memory_bytes: 3964
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repa(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define ALL(a) (a).begin(), (a).end()
#define _GLIBCXX_DEBUG

int main(){
  
  int a, b, h;
  cin >> a >> b >> h;
  cout << ((a+b) * h) / 2 << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<iostream>
using namespace std;
 
int main() {
    vector<int>a(3);
    for(int i = 0;i < 3;i++){
        cin >> a[i];
    }
   sort(a.begin(),a.end());
  
    if((a[0] + a[1]) == a[2]){
        cout << "Yes";
    }else{
        cout << "No";
    }
}
   


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

int main() {
  string N;
  char c;
  cin >> N;
  c = N.at(N.size()-1) ;
  if ( c == '3'){
    cout << "bon" << endl;
  }
  else if ( c == '0' || c == '1' || c == '6' || c == '8'){
    cout << "pon" << endl;
  }
  else {
    cout << "hon" << endl;
  }
}

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

typedef pair<int, int> P;
const int N = 1e3+10;
const int INF = 1e18;

struct edge{ int to,cost; };
vector< edge > G[N];
bool judge[N][N];

void dikstra(int s,int n){
  priority_queue<P,vector<P>,greater<P>> que;
  int d[N]; //sからの最短距離
  fill(d,d+N,INF);
  d[s] = 0;
  que.push({0,s}); //{頂点,最短距離}
  int path[N];
  fill(path,path+N,0);

  while( !que.empty() ){
    P p = que.top(); que.pop();
    int v = p.second;
    if(d[v] < p.first) continue;
    for(int i = 0; i < G[v].size(); i++){
      edge e = G[v][i];
      if(d[e.to] > d[v] + e.cost){
        d[e.to] = d[v] + e.cost;
        path[e.to] = v;
        que.push( {d[e.to],e.to} );
      }
    }
  }

  for(int i = 1; i <= n; i++){
    if(s == i) continue;
    int j = i;
    while(1){
      if(path[j] == 0) break;
      judge[path[j]][j] = 0;
      if(path[j] == s) break;
      j = path[j];
    }
  }
}

signed main(){

  int n,m; cin >> n >> m;
  for(int i = 0; i < m; i++){
    int a,b,c; cin >> a >> b >> c;
    G[a].push_back({b,c});
    G[b].push_back({a,c});
    judge[a][b]++;
  }
  for(int i = 1; i <= n; i++){
    dikstra(i,n);
  }

  int ans = 0;
  for(int i = 1; i < N; i++){
    for(int j = 1; j < N; j++){
      if(judge[i][j]) ans++;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 384
H,W=map(int,input().split())
matrix=[list(map(str,input().split())) for i in range(H)]
count_delete_H=0 #消した数を記憶しておく
count_delete_W=0 #同上

for i in range(H):
  matrix[i-count_delete_H]=list(*matrix[i-count_delete_H])#要素の文字列を1文字ごとに分解
  #print(matrix[i-count_delete_H].count('#'))
  if(matrix[i-count_delete_H].count('#')==0):
    del matrix[i-count_delete_H]
    count_delete_H+=1
    
matrix_t = [list(x) for x in zip(*matrix)]#転置をとる。
for i in range(W):
  #print(matrix_t[i-count_delete_W].count('#'))
  if(matrix_t[i-count_delete_W].count('#')==0):
    del matrix_t[i-count_delete_W]
    count_delete_W+=1
    
matrix_tt = [list(x) for x in zip(*matrix_t)]#転置をとって元に戻す。
#print(matrix_tt)
for i in range(H-count_delete_H):
  for j in range(W-count_delete_W):
    print(matrix_tt[i][j],end='')
  print('')#改行

Measured memory_bytes: 4724
N, x = gets.split.map(&:to_i)
A = Array.new(N+1,0)
gets.split.map(&:to_i).each_with_index do |v,i|
  A[i + 1] = v
end
ans = (1 .. N).inject(0) do |s, i|
  a = A[i - 1]
  b = A[i]
  
  d = a + b > x ? a + b - x : 0
  A[i] -= d

  s + d
end
puts ans


Measured memory_bytes: 9348
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>a>>b>>s;
    if(s[a]!='-')Cout("No");
    else{
        rep(i,Size(s)){
            if(i==a)continue;
            if(s[i]=='-'){
                Cout("No");
                return 0;
            }
        }
        Cout("Yes");
    }
    return 0;
}


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

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()
#define clr(a,v) memset(a, v, sizeof(a))

#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)
#define reflex ios_base::sync_with_stdio(false)

#define nl '\n'
#define ioi exit(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

typedef pair<int,int> pii;
typedef pair<int,int> pll;
const int N= (int)2e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
const ll linf = (ll)1e18 + 7;

const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int kx[] = {-1,1,2,2,1,-1,-2,-2};
const int ky[] = {2,2,1,-1,-2,-2,-1,1};


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


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
x=0
for i in range(n):
    x+=b[a[i]-1]

for j in range(n-1):
    if a[j+1]==a[j]+1:
        x+=c[a[j]-1]

print(x)

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#include <vector>
#include <limits>
#include <algorithm>
#include <functional>
#include <cstdio>
using namespace std;

#define FOR( i, m, n )	for( int (i) = (m); (i) < (n); i++ )
#define REP( i, n )		FOR( i, 0, n )
#define ALL( x )	(x).begin(), (x).end()

int main() {
	int a, b;
	while( 1 ) {
		cin >> a >> b;
		if( a == 0 && b == 0 ) break;
		if( a > b ) swap( a, b );
		cout << a << " " << b << endl;
	}
}


Measured memory_bytes: 3096
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        char[] ary = new char[s.length()];
        ary = s.toCharArray();
        for (int i = 0; i < s.length() - 1; i++) {
            if (ary[i] == ary[i + 1]) {
                System.out.println((i + 1) + " " + (i + 2));
                return;
            }
            if (i != s.length() - 2 && ary[i] == ary[i + 2]) {
                System.out.println((i + 1) + " " + (i + 3));
                return;
            }
        }
        System.out.println("-1 -1");
    }
}

Measured memory_bytes: 26324
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <sstream>
#include <set>
#include <tuple>
#include <algorithm>
#include <memory>
#include <numeric>
#include <queue>
#include <functional>
#include <cmath>
#include <cstring>
#include <map>
#include <unordered_map>
#include <sstream>
#include <iomanip>

using namespace std;
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; }

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

const ll INF = 1LL << 60;
const ll MOD = 1000000007;

ll NN;

ll f(const vector<ll>& pf_keys, const vector<ll>& pf_vals, const ll tidx, const ll tval)
{
	//cout << tidx << " : " << tval << endl;

	if (pf_keys.size() == tidx)
	{
		//cout << tval << endl;
		if (tval < 1) return 0;
		ll m = (NN / tval) - 1;
		if (m < 1) return 0;
		if (NN / m != NN % m) return 0;
		return m;
	}

	ll s = 0;
	for (ll i = 0; i <= pf_vals[tidx]; ++i)
	{
		s = s + f(pf_keys, pf_vals, tidx + 1, tval*pow(pf_keys[tidx], i));
	}

	return s;
}

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

	ll N;
	cin >> N;
	NN = N;

	ll ans = 0;

	map<ll, ll> pf;

	for (ll i = 2; i * i <= N; i++)
	{
		while (N % i == 0)
		{
			pf[i]++;
			N /= i;
		}
	}

	if (N != 1) pf[N] = 1;

	if (pf.size() == 0)
	{
		ans = 0;
	}
	else
	{
		vector<ll> pf_keys;
		vector<ll> pf_vals;
		for (const auto& e : pf)
		{
			pf_keys.push_back(e.first);
			pf_vals.push_back(e.second);
		}

		 ans = f(pf_keys, pf_vals, 0, 1);
	}

	cout << ans << endl;

	//system("pause");
}

Measured memory_bytes: 512
#include <cstdio>
#include <map>
#include <algorithm>
#include <functional>
#include <vector>
using namespace std;

typedef unsigned long long ull;

const int thr = 3;

map<ull,int> memo;

vector<ull> tbl;

void maketbl(ull s, int t, int u){
	if(t == 0){
		tbl.push_back(s);
	}
	for(u = min(t, u); u >= 1; --u){
		maketbl(s + (1ull << ((u - 1) * 8)), t - u, u);
	}
}

int dfs2(ull, int, int);

int dfs1(ull s){
	if(s < 10){ return 0; }
	if(memo.count(s)){
		return memo[s];
	}
	int k;
	for(k = 8; !(s >> ((k - 1) * 8)); --k);

	int res = 0;
	if(k <= thr){
		ull r = s;
		for(size_t i = 0; i < tbl.size(); ){
			ull p = r;
			bool ok = true;
			for(int j = thr; j >= 1; --j){
				if((p >> ((j - 1) * 8) & 0xff) >= (tbl[i] >> ((j - 1) * 8) & 0xff)){
					p -= tbl[i] & (0xffull << ((j - 1) * 8));
				}
				else{
					ok = false;
				}
			}
			if(ok){
				r = p;
				++res;
			}
			else{
				++i;
			}
		}
	}
	else{
		int a = dfs2(s - (1ull << ((k - 1) * 8)), 10 - k, k);
		int b = dfs1(s & ((1ull << ((k - 1) * 8)) - 1));
		res = max(a, b);
	}
	
	memo[s] = res;
	return res;
}

int dfs2(ull s, int t, int u){
	if(s >> ((t - 1) * 8) & 0xff){
		return dfs1(s - (1ull << ((t - 1) * 8))) + 1;
	}
	if(t == 1){
		return 0;
	}
	if(t == 2){
		if((s & 0xff) >= 2){
			return dfs1(s - 2) + 1;
		}
		return 0;
	}
	if(t == 3){
		if(s & 0xff && s & 0xff00){
			return dfs1(s - 0x101) + 1;
		}
		if((s & 0xff) >= 3){
			return dfs1(s - 3) + 1;
		}
		return 0;
	}
	
	int res = 0;
	for(u = min(t, u); u >= 1; --u){
		if(s >> ((u - 1) * 8) & 0xff){
			int a = dfs2(s - (1ull << ((u - 1) * 8)), t - u, u);
			res = max(res, a);
		}
	}
	return res;
}

int main(){
	maketbl(0, 10, thr);
	sort(tbl.begin(), tbl.end(), greater<ull>());

	int n, x;
	while(scanf("%d", &n), n){
		int cnt[10] = {};
		for(int i = 0; i < n; ++i){
			scanf("%d", &x);
			++cnt[x];
		}
		
		int ans = 0;
		for(int i = 1; i <= 4; ++i){
			x = min(cnt[i], cnt[10 - i]);
			ans += x;
			cnt[i] -= x;
			cnt[10 - i] -= x;
		}
		
		ans += cnt[5] / 2;
		cnt[5] &= 1;
		
		ull s = 0;
		for(int i = 1; i <= 8; ++i){
			s |= (ull)cnt[i] << ((i - 1) * 8);
		}
		
		memo.clear();
		ans += dfs1(s);
		printf("%d\n", ans);
	}
}

Measured memory_bytes: 1296
n, q = map(int, input().split())
S = input()
T = [0] * (n - 1)
for i in range(n - 1):
    if S[i : i + 2] == "AC":
        T[i] = 1
for i in range(1, n - 1):
    T[i] += T[i - 1]
T = [0] + T
for _ in range(q):
    l, r = map(int, input().split())
    print(T[r - 1] - T[l - 1])


Measured memory_bytes: 7924
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <map>
#include <functional>
#include <cmath>
#include <cstdint>
#include <mutex>
#include <thread>
#include <bitset>

using namespace std;
typedef long long int ll;

int main(void)
{
	int n, x, t;
	cin >> n >> x >> t;

	int i = t;

	while (1)
	{
		if (n <= (i/t) * x)
			break;
		i += t;
	}

	cout << i;

	return 0;
}

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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define AND(x,y,z) set_intersection((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define CONCAT(x,y) (x).insert((x).end(),(y).begin(),(y).end())
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define FOR(i,a,b) for (int i=(int)(a);i<(int)(b);++i)
#define OR(x,y,z) set_union((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<int> VECINT;
typedef vector<ll> VECLL;

int main() {
  string num;
  REP(i,2) {
    string c;cin>>c;
    num += c;
  }
  int ans = stoi(num);
  int sq = sqrt(ans);
  pow(sq,2)==ans ? OUT("Yes") : OUT("No");

  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <climits>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

const int INF = 1e9;
const long long LINF = 1e18;

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

    int sumR = 0;
    vector<int> W(N);
    for (int i = 0; i < N; i++) {
        cin >> W[i];
        sumR += W[i];
    }

    int ans = INF;
    int sumL = 0;
    for (int i = 0; i < N; i++) {
        sumR -= W[i];
        sumL += W[i];
        ans = min(ans, abs(sumL - sumR));
    }

    cout << ans << endl;

    return 0;
}


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


void bfs(int Sh, int Sw, vector<string> &S, vector<vector<bool>> &visited, queue<pair<int,int>> &now_pos) {
  vector<vector<int>> directions = {{0,1},{0,-1},{1,0},{-1,0}};
  queue<pair<int,int>> q;
  q.push(make_pair(Sh, Sw));
  int h, w, y, x;
  while (!q.empty()) {
    tie(h, w) = q.front(); q.pop();
    now_pos.push(make_pair(h, w));
    for (auto next: directions) {
      y = h + next[0];
      x = w + next[1];
      if (S[y][x] == '#') continue;
      if (visited[y][x]) continue;
      q.push(make_pair(y, x));
      visited[y][x] = true;
    }
  }
}


void move_b(int Sh, int Sw, vector<string> &S, vector<vector<bool>> &visited, queue<pair<int,int>> &next_pos) {
  int h, w;
  for (int i: {-2, -1, 0, 1, 2}) {
    h = Sh + i;
    for (int j: {-2, -1, 0, 1, 2}) {
      w = Sw + j;
      if (S[h][w] == '#') continue;
      if (visited[h][w]) continue;
      next_pos.push(make_pair(h, w));
      visited[h][w] = true;
    }
  }
}


int main() {
  int H, W, Ch, Cw, Dh, Dw;
  cin >> H >> W >> Ch >> Cw >> Dh >> Dw;
  Ch++; Cw++; Dh++; Dw++;
  vector<string> S(H + 4);
  for (int i: {0, 1, H + 2, H + 3}) {
    S[i] = string(W + 4, '#');
  }
  string s;
  for (int i = 2; i < H + 2; i++) {
    cin >> s;
    S[i] = "##" + s + "##";
  }

  int ans = 0;
  vector<vector<bool>> visited(H + 4, vector<bool>(W + 4, false));
  queue<pair<int,int>> now_pos;
  queue<pair<int,int>> next_pos;
  next_pos.push(make_pair(Ch, Cw));
  visited[Ch][Cw] = true;
  int h, w;
  while (true) {
    while (!next_pos.empty()) {
      tie(h, w) = next_pos.front(); next_pos.pop();
      bfs(h, w, S, visited, now_pos);
    }

    if (visited[Dh][Dw]) break;

    while (!now_pos.empty()){
      tie(h, w) = now_pos.front(); now_pos.pop();
      move_b(h, w, S, visited, next_pos);
    }
    if (next_pos.empty()) {
      ans = -1;
      break;
    }
    ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5804
import sys
input = sys.stdin.readline
from itertools import accumulate

N,M,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
a = [0]+list(accumulate(A))
b = [0]+list(accumulate(B))
ans,j = 0,M
for i in range(N+1):
    if a[i] > K:
        break
    while b[j] > K - a[i]:
        j -= 1
    ans = max(ans,i+j)
print(ans)

Measured memory_bytes: 49056
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
long long n, m, a[1000000], b[1000000], c[1000000];
int main() {
	cin >> n >> m;
	for (int i = 0; i < m; i++) { cin >> a[i] >> b[i]; if (a[i] > b[i])swap(a[i], b[i]); c[a[i]]++; c[b[i]]--; }
	for (int i = 1; i <= 900000; i++)c[i] += c[i - 1];
	for (int i = 0; i < 900000; i++) {
		if (c[i] % 2 == 1) { cout << "NO" << endl; return 0; }
	}
	cout << "YES" << endl;
	return 0;
}

Measured memory_bytes: 14592
# input
P1 = list(map(int, input().split()))
P2 = list(map(int, input().split()))
P3 = list(map(int, input().split()))

P1_P2 = set(P1) & set(P2)
P2_P3 = set(P2) & set(P3)
P3_P1 = set(P3) & set(P1)

if P1_P2 == P2_P3:
    print('NO')
else:
    print('YES')

Measured memory_bytes: 3064
from bisect import bisect_left
from itertools import product
from sys import maxsize

a, b, q = map(int, input().split())
s = [-maxsize] + [int(input()) for _ in range(a)] + [maxsize]
t = [-maxsize] + [int(input()) for _ in range(b)] + [maxsize]

for _ in range(q):
    x = int(input())
    i = bisect_left(s, x)
    j = bisect_left(t, x)
    res = maxsize
    for ss, tt in product((s[i-1], s[i]), (t[j-1], t[j])):
        res = min(res, abs(ss-x)+abs(tt-ss), abs(tt-x)+abs(ss-tt))
    print(res)


Measured memory_bytes: 17792
S=input()
n=len(S)-1
for i in range(1<<n):
    op=["-"]*n
    for j in range(n):
        if i&(1<<j):
            op[j]="+"
    f="".join([S[i//2] if i%2==0 else op[i//2] for i in range(2*(n+1)-1)])
    if eval(f)==7:
        print("%s=7"%f)
        quit()

Measured memory_bytes: 3060
#include <stdio.h>

int main(void)
{
  int N;
  scanf("%d",&N);
  int N_=0;
  int H[N];
  while(N_<N)
  {
    scanf("%d",&H[N_]);
    N_++;
  }
  N_=0;
  int answer=0,highscore=0;
  while(N_<N)
  {
    if (N_==0)
    {
      answer++;
      highscore=H[0];
    }
    else
    {
      if (highscore<=H[N_])
      {
        answer++;
        highscore=H[N_];
      }
    }
    N_++;
  }
  printf("%d",answer);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}
long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}
int main() {
long long a,b;
cin >> a >>b;
cout <<lcm(a,b);
}


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

int main(){
  long long N, X, D;
  cin >> N >> X >> D;
  if(X == 0 and D == 0){
    cout << 1 << endl;
    return 0;
  }
  if(!D){
    cout << N+1 << endl;
    return 0;
  }
  if(D < 0){
    X = X+(N-1)*D;
    D *= -1;
  }
  cerr << N << " " << X << " " << D << endl;

  long long ans = 0;
  map<long long,long long> M;
  
  auto f = [=](long long x){
             pair<long long,long long> ret(x*(x-1)/2,(2*N-x-1)*x/2);
             ++ret.second;
             // cerr << ret.first << " " << ret.second << endl;
             return ret;
           };
  
  for(int i = 0; i <= N; ++i){
    long long t = ((i*X)%D+D)%D;
    // cerr << i << " " << t << endl;
    if(M.count(t)){
      auto p = f(i), q = f(M[t]);
      assert(p.first < p.second);
      assert(q.first < q.second);
      q.second += -(i-M[t])*X/D;
      q.first += -(i-M[t])*X/D;

      if(q.first <= p.second and p.first <= q.first){
        // cerr << i << " " << 0 << endl;
        ans += q.first - p.first;
      }
      if(q.second <= p.second and p.first <= q.second){
        // cerr << i << " " << 1  << endl;
        ans += p.second - q.second;
      }
      if(q.second < p.first or q.first > p.second){
        // cerr << i << " " << 2 << endl;
        ans += p.second - p.first;
      }

      // cerr << "? " << i << " " << q.first << " " << q.second << endl;
      // cerr << "! " << i << " " << p.first << " "  << p.second << endl;

      M[t] = i;
      // cerr << i << ", ans = " << ans << endl;
      continue;
    }
    M[t] = i;
    auto p = f(i);
    ans += p.second - p.first;
    // cerr << "$ " << i << ", ans = " << ans << endl;
  }
  cout << ans << endl;
}


Measured memory_bytes: 12800
module app;

import core.bitop;

import std.algorithm;
import std.array;
import std.bigint;
import std.conv;
import std.stdio;
import std.string;

struct Magic
{
    int a;
    int b;
}

struct Input
{
	int h;
	int n;
    Magic[] m;
}

void parseInput(T)(out Input input, T file)
{
	with (file) with (input)
	{
		auto hn = readln().strip().split();
		h = hn[0].to!int;
		n = hn[1].to!int;

        foreach (i; 0..n)
        {
            auto ab = readln().strip().split().map!(to!int).array;
            Magic temp;
            temp.a = ab[0];
            temp.b = ab[1];
            m ~= temp;
        }
	}
}

struct Output
{
}


auto main2(Input* input)
{
    auto dp = new int[10000*10000+1];

    input.m.sort!((m1, m2) => m1.b < m2.b);

    LOOP_DP:
    for (int limMp = 1; limMp < dp.length; limMp++)
    {
        foreach (m; input.m)
        {
            auto mp = m.b;

            if (mp > limMp)
                continue LOOP_DP;

            if (dp[limMp] < dp[limMp - mp] + m.a)
                dp[limMp] = dp[limMp - mp] + m.a;

            if (dp[limMp] >= input.h)
                return limMp;
        }
    }

	assert(0);
}

unittest { writeln("begin unittest"); }

unittest // example1
{
	string example =
`9 3
8 3
4 2
2 1`;
	Input input = void;
	parseExample(input, example);
	auto result = main2(&input);
	writeln(result);
	assert(result == 4);
}

unittest // example2
{
	string example =
`100 6
1 1
2 3
3 9
4 27
5 81
6 243`;
	Input input = void;
	parseExample(input, example);
	auto result = main2(&input);
	writeln(result);
	assert(result == 100);
}

unittest // example3
{
	string example =
`9999 10
540 7550
691 9680
700 9790
510 7150
415 5818
551 7712
587 8227
619 8671
588 8228
176 2461`;
	Input input = void;
	parseExample(input, example);
	auto result = main2(&input);
	writeln(result);
	assert(result == 139815);
}

unittest { writeln("end unittest"); }

void parseExample(out Input input, string example)
{
	struct Adapter
	{
		string[] _lines;
		this(string input) { _lines = input.splitLines(); }
		string readln() { auto line = _lines[0]; _lines = _lines[1..$]; return line; }
	}
	parseInput(input, Adapter(example));
}

void main()
{
	Input input = void;
	parseInput(input, stdin);
	auto result = main2(&input);
	writeln(result);
}


Measured memory_bytes: 393596
def beforeTax(n):
  li = int(n // 1.08)
  if int(li * 1.08) == n:
    print(li)
  elif int((li + 1) * 1.08) == n:
    print(li + 1)
  else:
  	print(':(')
 
if __name__ == "__main__":
  import sys
  in_str = ''
  for line in sys.stdin:
    in_str += line
  n = [int(_) for _ in in_str.split()][0]
  beforeTax(n)

Measured memory_bytes: 3060
A, B, C, D, E, F = map(int, input().split(" "))

node = 0
aa = 0
bb = 0
cc = 0
dd = 0
na = int(F/(100*A))
nb = int(F/(100*B))
nc = int(F/C)
nd = int(F/D)
for a in range(na+1):
    for b in range(nb+1):
        for c in range(nc+1):
            for d in range(nd+1):
                if 100 * A * a + 100 * B * b + C * c + D * d > F or (A * a + B * b) * E < C * c + D * d:
                    break
                else:
                    if a == b == c == d == 0:
                        continue
                    else:
                        cand = (100 * (C * c + D * d)) / (100 * (A * a + B * b) + (C * c + D * d))
                        if cand > node:
                            node = cand
                            aa = a
                            bb = b
                            cc = c
                            dd = d
if node == 0:
    print("{} {}".format(100*A, 0))
else:
    print("{} {}".format(100*(A * aa + B * bb)+(C * cc + D * dd), C * cc + D * dd))

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

int main(){
	long int n,k,a,ans=0;
  vector<int> h;
  cin >> n >> k;
  for(int i=0; i<n; i++){
  	cin >> a;
    h.push_back(a);
  }
  sort(h.begin(),h.end());
  for(int i=0; i<n-k; i++){
  	ans += h.at(i);
  }
  cout << ans;
}


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

int main(void)
{
    long long int a, b, x;

    cin >> a >> b >> x;

    long long int bn = b/x;
    long long int an = a/x;
    if (a%x == 0) cout << bn - an + 1 << endl;
    else cout << bn - an << endl;

    return 0;



}


Measured memory_bytes: 3628
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def modfact(n):
    fact=[1]*(n+1)
    invfact=[1]*(n+1)
    for i in range(1,n+1):
        fact[i]=i*fact[i-1]%MOD
    invfact[n]=pow(fact[n],MOD-2,MOD)
    for i in range(n-1,-1,-1):
        invfact[i]=invfact[i+1]*(i+1)%MOD
    return fact,invfact

def resolve():
    from math import factorial as fact
    n,m,k=map(int,input().split())
    fact,invfact=modfact(n*m)
    ans=1
    ans*=fact[m*n-2]*invfact[k-2]*invfact[m*n-k]
    ans*=((n-1)*n*(n+1)*m*m+(m-1)*m*(m+1)*n*n)//6
    print(ans%MOD)
resolve()

Measured memory_bytes: 41712
import java.util.*; 

class Main{
public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int k=sc.nextInt();
		
		String s=sc.next();
     

  		String[] s1=s.split("");
		
    
 	if(s1[k-1].equals("A")){
    		s1[k-1]="a";
    	}else if(s1[k-1].equals("B")){
     		s1[k-1]="b";
   	 }else{
    	s1[k-1]="c";
    }
  		String ans="";
		for(String a:s1){
    		ans+=a;
        }
  		System.out.println(ans);
    }
}

Measured memory_bytes: 22100
#include <iostream>
 #include <vector>
 #include <map>
 #include <string>
 #include <algorithm>
 using namespace std;

 template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

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



 int main()
 {
     const long long p = 1000000007;
    int n, m;
    cin >> n >> m;

    vector<bool> a(n+1, true);
    for(int i = 0;i < m; i++)
    {
        int y;
        cin >> y; 
        a.at(y) = false;

    }

    vector<long long> dp(n+1, 0);

    dp.at(0) = 1;
    for(int i = 1; i < n+1; i++)
    {
        if(a.at(i))
        {
            dp.at(i) += dp.at(i-1);
            if(i > 1) dp.at(i) += dp.at(i-2);
            dp.at(i) %= p;
        }
    }

    cout << dp.at(n) << endl;

    return 0;
 }

Measured memory_bytes: 1024
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <vector>

#define REP(i,n) for(int i=0; i<n; i++)
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;
 
#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9

using namespace std;
typedef long long ll;

int main(){
	bool furui[102];
	vector<int> primes;
	
	REP(i,102) furui[i] = true;
	furui[0] = false;
	furui[1] = false;
	for (int i=2; i<=102; i++){
		if (furui[i]){
			primes.push_back(i);
			for (int j=2; i*j<=102; j++){
				furui[i*j] = false;
			}
		}
	}
	
	const int len = primes.size();
	vector<int> countprimes(len);
	REP(i,len){
		countprimes[i] = 0;
	}
	
	int n, ans=0;
	
	cin >> n;
	
	for (int i=2; i<=n; i++){
		REP(j,len){
			if (i%primes[j]==0){
				for (int k=1; k<8; k++){
					if (i%(int)(pow(primes[j],k))==0){
						countprimes[j] += 1; 
					}
				}
			}
		}
	}
	
	REP(i,len){
		ans += (countprimes[i]>=74);
		REP(j,len){
			if (i==j){
				continue;
			}
			// 3*25
			ans += (countprimes[i]>=2) && (countprimes[j]>=24);
			// 5*15
			ans += (countprimes[i]>=4) && (countprimes[j]>=14);
			for (int k=j+1; k<len; k++){
				if (i==k || j==k){
					continue;
				}
				// 3*5*5
				ans += (countprimes[i]>=2) && (countprimes[j]>=4) && (countprimes[k]>=4);
			}
		}
	}
		
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
X = int(input())
N1 = 0
N2 = 0

A = [0] * 1000
for i in range(1000):
    A[i] = (i-500)**5

for i in range(1000):
    for j in range(1000):
        if A[i] - A[j] == X:
            N1 = i-500
            N2 = j-500
            break

print(N1,N2)


Measured memory_bytes: 9188
extern crate core;

use std::io::{self, Read};

#[macro_export]
macro_rules! input {
  ($s:expr=>$($t:tt)*) => {
    let mut lines=$s.split("\n");
    $(
        line_parse!(lines,$t);
    )*
  };
}

macro_rules! line_parse {
  ($lines:expr,($($name:ident:$t:tt)*)) => {
    let mut line=$lines.next().unwrap().split_whitespace();
    $(value_def!(line,$name,$t);)*
  };

  //複数行
  ($lines:expr,{$n:expr;$name:ident:$t:tt}) => {
    values_def!($lines,$n,$name,$t);
  };
}

macro_rules! value_def {
    ($line:expr, $name:ident, $t:tt) => {
        let $name = value!($line, $t);
    };
}

macro_rules! values_def {
    ($lines:expr, $n:expr, $name:ident, $t:tt) => {
        let $name = {
            let mut vec = Vec::new();
            for i in 0..$n {
                let mut next = $lines.next().unwrap().split_whitespace();
                vec.push(value!(next, $t));
            }
            vec
        };
    };
}

macro_rules! value {
  //配列
  ($line:expr,[$t:tt]) => {
    $line.map(|x|{
      let mut iter=::std::iter::once(x);
      value!(iter,$t)
    }).collect::<Vec<_>>()
  };
  //タプル
  ($line:expr,($($t:tt),*)) => {
    ($(value!($line,$t),)*)
  };
  //文字列
  ($line:expr,#) => {
    $line.next().unwrap()
  };
  //単一値
  ($line:expr,$t:ty) => {
    $line.next().unwrap().parse::<$t>().unwrap()
  };
  //インデックス(-1)
  ($line:expr,@) => {
    $line.next().unwrap().parse::<usize>().unwrap()-1
  };
}

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let output = solve(input.trim().to_string());
    println!("{}", output);
}

fn solve(input: String) -> String {
    input!(input=>(n:usize));
    (1..n + 1)
        .filter(|&x| x % 2 != 0 && divisor(x).len() == 8)
        .count()
        .to_string()
}

pub fn divisor(n: usize) -> Vec<usize> {
    let mut res = Vec::new();
    for i in (1..).take_while(|x| x * x <= n) {
        if n % i == 0 {
            res.push(i);
            if i != n / i {
                res.push(n / i);
            }
        }
    }
    res
}

macro_rules! tests {
    ($($name:ident: $input:expr=>$output:expr,)*) => {
        mod tests {
            $(
                #[test]
                fn $name() {
                    assert_eq!($output.trim().to_string(),super::solve($input.trim().to_string()));
                }
            )*
        }
    }
}

tests! {
    test1: "105" => "1",
    test2: "7" => "0",
}


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

using namespace std;

int main() {
	long long t1, t2, a1, a2, b1, b2;
	scanf("%lld%lld%lld%lld%lld%lld", &t1, &t2, &a1, &a2, &b1, &b2);
	
	long long len1 = t1 * a1 + t2 * a2;
	long long len2 = t1 * b1 + t2 * b2;
	if (len1 == len2) return 0 * printf("infinity\n");
	
	if (len1 > len2) {
		swap(a1, b1);
		swap(a2, b2);
		swap(len1, len2);
	}
	
	//len1 < len2
	
	if (a1 < b1) return 0 * printf("0\n");
	
	//n * len1 + t1 * a1 >= n * len2 + t1 * b1
	//t1 * (a1 - b1) >= n * (len2 - len1)
	//n <= t1 * (a1 - b1) / (len2 - len1)
	
	long long n = t1 * (a1 - b1) / (len2 - len1);
	
	long long res = 0;
	
	if (n * len1 + t1 * a1 == n * len2 + t1 * b1) res = n * 2;
	else res = n * 2 + 1;
	
	printf("%lld\n", res);
}


Measured memory_bytes: 256
import std.stdio;

void show(int[][] square) {
  for(int i = 0; i < square.length; i++)
    for(int j = 0; j < square[i].length; j++)
      writef("%4d%s", square[i][j], j == square.length - 1 ? "\n" : "");
}

int[][] magic_square(int[][] square, int n) {
  int x = (n - 1) / 2;
  int y = (n - 1) / 2 - 1;
  int len = 0;
  while(len <= n * n) {
    x = (x + n) % n;
    y = (y + n) % n;
    if (square[x][y] == 0) {
      square[x][y] = len;
      x = x + 1;
      y = y + 1;
      len++;
    }
    else {
      x = x + 1;
      y = y - 1;
    }
  }
  return square;
}

void main() {
  for(int n; readf("%d\n", &n), n != 0;) {
    magic_square(new int[][](n, n), n).show;
  }
}

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

int modSubtract(int a, int b){
  if(a>b) return a-b;
  else return b-a;
}  

int path(int h[], int n, int k){
  int dp[n], i, j, minval;
  dp[0]=0, dp[1]=modSubtract(h[1],h[0]);
  for(i=2; i<k+1 && i<n; i++){
    minval=dp[0]+modSubtract(h[i],h[0]);
    for(j=0; j<i; j++){
      minval=min(minval, dp[j]+modSubtract(h[i],h[j]));
    }
    dp[i]=minval;
  }
  for(i=k+1; i<n; i++){
    minval=dp[i-k]+modSubtract(h[i],h[i-k]);
    for(j=i-k; j<i; j++){
      minval=min(minval, dp[j]+modSubtract(h[i],h[j]));
    }
    dp[i]=minval;
  }
  return dp[n-1];
}

int main(){
  int n,k;
  cin>>n>>k;
  int h[n];
  for(int i=0; i<n; i++){
    cin>>h[i];
  }
  int val = path(h,n,k);
  cout<<val<<endl;
}


Measured memory_bytes: 4364
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>
#include <set>
#include <map>
#include <iomanip>
#include <cassert>
#include <functional>
#include <cstring>

using namespace std;

#define mp make_pair
#define FOR(i, a, b) for(int (i)=a;(i)<(b);++(i))
#define rep(i, n)  FOR(i,0,n)
#define FFOR(i, a, b) for(int (i)=a;(i)>(b);--(i))
#define rrep(i,n) FFOR(i,0,n)
#define vsort(v) sort((v).begin(), (v).end());					//小さい順
#define rvsort(v) sort(v.begin(), v.end(),greater<>());		//大きい順
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define all(c) (c).begin(),(c).end()
#define ll long long
#define lb long double
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define Print(p) cout<<(p)<<endl
#define F first
#define S second
#define pb push_back
#define mod 1000000007LL
#define INF 123456789012345
#define int ll
typedef pair<int, int> P;
typedef pair<int, P> PP;

const int maxn =1e5 + 10;

//initialization here
//

//
//initialization finish


// your function is here
//

//
// your function finished

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	// your code is here
	//

	int a,b,c; cin >>a>>b>>c;
    int k; cin >> k;

    int m = max(a,b);
    m = max(m,c);
    int ka = m;

    rep(i,k) ka *= 2;

    Print(a+b+c-m+ka);
    

	//
	// your code finished


	return 0;
}

Measured memory_bytes: 256