akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
ll INF = 1e18;

ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
  ll g = gcd(a, b);
  return a * b / g;
}
int main() {
  //
  ll n, m;
  cin >> n >> m;
  string s, t;
  cin >> s >> t;
  assert(s.size() == n && t.size() == m);

  ll l = lcm(n, m);
  ll nn = l / n;
  ll mm = l / m;
  map<ll, char> mp;
  for (ll i = 0; i < n; i++) {
    mp[i * nn] = s[i];
    // x[i * nn] = s[i];
  }
  for (ll i = 0; i < m; i++) {
    if (mp.find(i * mm) == mp.end()) continue;
    if (mp[i * mm] != t[i]) {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << l << endl;
  return 0;
}


Measured memory_bytes: 6144
#include<iostream>
#include<string>

using namespace std;

struct Dice{
	int P[6];
	void Roll(char a){
		
	int top;
	
	switch(a) {
		
		case 'E':
		top = P[0];
		P[0] = P[3];
		P[3] = P[5];
		P[5] = P[2];
		P[2] = top;
		break;
		
		case 'W':
		top = P[0];
		P[0] = P[2];
		P[2] = P[5];
		P[5] = P[3];
		P[3] = top;
		break;
		
		case 'S':
		top = P[0];
		P[0] = P[4];
		P[4] = P[5];
		P[5] = P[1];
		P[1] = top;
		break;
		
		case 'R':
		top = P[1];
		P[1] = P[2];
		P[2] = P[4];
		P[4] = P[3];
		P[3] = top;
		break;
		
		default :
		top = P[0];
		P[0] = P[1];
		P[1] = P[5];
		P[5] = P[4];
		P[4] = top;
		break;	
	}	
}
	int Top() {
    return P[0];
  }
  	int Right(){
    return P[2];
  }
  	int Left(){
    return P[3];
  }
  	int Front(){
    return P[1];
  }
};

bool Test(Dice A,Dice B);

int main() {
	
	int n = 6;
	Dice S[2];
	
	bool flag = false;
	
		for(int i=0;i<2;i++)
		for(int j=0;j<6;j++)
		cin >> S[i].P[j];
		
		for(int i=0;i<4;i++){
			
    	S[1].Roll('R');
    	for(int j=0;j<4;j++){
    		
      	S[1].Roll('N');
      	if( Test( S[0], S[1] )) 
		  flag = true;
    }
    
  	}
  	S[1].Roll('E');
  	for(int j=0;j<4;j++){
  		
    S[1].Roll('N');
    if(Test( S[0], S[1])) 
	flag = true;
	
  }
 
  	S[1].Roll('W');
  	S[1].Roll('W');
  	for(int j=0;j<4;j++){
  		
    S[1].Roll('N');
    if(Test( S[0], S[1] )) 
	flag = true;
	
  }
   
  	if( flag )
  	cout << "Yes\n";
  	
  	else
  	cout << "No\n";
	
	return 0;
}

bool Test(Dice A,Dice B) {
  for(int i=0;i<6;i++) 
  if(A.P[i]!=B.P[i]) 
  return false;
  return true;
}



Measured memory_bytes: 3088
n = int(input())
num_list = list(map(int, input().split()))
num_list.sort(reverse=True)
result = 0
for i in range(0, len(num_list), 2):
    result += num_list[i]

for i in range(1, len(num_list), 2):
    result -= num_list[i]

print(result)

Measured memory_bytes: 3060
#include<stdio.h>
#include<algorithm>
using namespace std;
int UF[1100];
int FIND(int a){
	if(UF[a]<0)return a;
	return UF[a]=FIND(UF[a]);
}
void UNION(int a,int b){
	a=FIND(a);b=FIND(b);if(a==b)return;
	UF[a]+=UF[b];UF[b]=a;
}
pair<int,pair<int,int> > edge[11000];
int main(){
	int a,b;
	while(scanf("%d%d",&a,&b),a){
		for(int i=0;i<b;i++){
			int p,q,r;scanf("%d%d%d",&p,&q,&r);
			p--;q--;
			edge[i]=make_pair(r,make_pair(p,q));
		}
		std::sort(edge,edge+b);
		for(int i=0;i<a;i++)UF[i]=-1;
		int cnt=a;
		for(int i=0;i<b;i++){
			if(FIND(edge[i].second.first)!=FIND(edge[i].second.second)){
				cnt--;
				UNION(edge[i].second.first,edge[i].second.second);
				if(cnt==a/2){
					printf("%d\n",edge[i].first);break;
				}
			}
		}
	}
}

Measured memory_bytes: 1164
// author:-*mdragneell*

#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define ld long double
#define pb push_back
#define pi  pair<int,int>
#define pl  pair<ll,ll>

int const N=500001;
ll min(ll x,ll y) { if(x<y) return x; else return y; }
ll max(ll x,ll y) { if(x>y) return x; else return y; }

ll dp[N],n;
vector<ll>v(N);

ll solve(ll x,int k)
{

	if(x>=n) return 1e15;
	if(x==n-1) return 0;
	if(dp[x]!=-1) return dp[x];

	ll temp=1e15;

	for(int i=1;i<=k;i++)
	{
		temp=min(temp,solve(x+i,k)+abs(v[x+i]-v[x]));
	}
	return dp[x]=temp;



}

int main()
{
	ll i,k;
	cin>>n>>k;
	memset(dp,-1,sizeof(dp));

	for(i=0;i<n;i++) cin>>v[i];
	cout<<solve(0,k);

}


Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
const int MOD=1e9+7;
vector<long> fact_inv, inv, Com;
void init_nCk(int n,int k){
  fact_inv.resize(k+5);
  inv.resize(k+5);
  fact_inv[0]=fact_inv[1]=1;
  inv[1]=1;
  for(int i=2;i<k+5;i++){
    inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
    fact_inv[i]=fact_inv[i-1]*inv[i]%MOD;
  }
  Com.resize(k+5);
  Com[0]=1;
  for(int i=1;i<k+5;i++){
    Com[i]=Com[i-1]*((n-i+1)*inv[i]%MOD)%MOD;
  }
}
int a,K,i;
long x=1,ans=0;
int nCk(int k){
  if(a>=2*k){return Com[k];}
  else{return Com[a-k];}
}
int main(){
  string S;
  cin>>K>>S;
  a=K+S.size();
  init_nCk(a,a/2);
  for(i=0;i<=K;i++){
    ans+=x*nCk(i);
    ans%=MOD;
    x*=25;
    x%=MOD;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 27644
import java.util.*;
 
public class Main {
  public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
    	int x = sc.nextInt();
    	int y = sc.nextInt();
	    String[] group1 = new String[]{"1","3","5","7","8","10","12"};
    	String[] group2 = new String[]{"4","6","9","11"};
    	String[] group3 = new String[]{"2"};

	    if((Arrays.asList(group1).contains(String.valueOf(x)))&&(Arrays.asList(group1).contains(String.valueOf(y)))){
	        System.out.println("Yes");
	    }else if((Arrays.asList(group2).contains(String.valueOf(x)))&&(Arrays.asList(group2).contains(String.valueOf(y)))){
	        System.out.println("Yes");
	    }else if((Arrays.asList(group3).contains(String.valueOf(x)))&&(Arrays.asList(group3).contains(String.valueOf(y)))){
	        System.out.println("Yes");
	    }else {
          	System.out.println("No");
        }
	}
 
}

Measured memory_bytes: 22484
#include <stdio.h>

int d[128];

int bfind(int l, int r, int value, int step)
{
	int center = l + r >> 1;

	if (l > r) return (step);
	if (d[center] == value) return (step + 1);
	if (d[center] > value) return (bfind(l, center - 1, value, step + 1));
	else return (bfind(center + 1, r, value, step + 1));
}

int main(void)
{
	int n;
	int i;

	while (scanf("%d", &n), n){
		for (i = 0; i < n; i++){
			scanf("%d", d + i);
		}
		scanf("%d", &n);
		printf("%d\n", bfind(0, i - 1, n, 0));
	}

	return (0);
}

Measured memory_bytes: 600
#include <iostream>
using namespace std;
 
int main(){
    string s;
    cin >> s;
    int N;
    N=(int)(s.length());
    for(int i=0;i<(N-1)/2;i++){
        if (s[i]!=s[N-1-i]){
            cout << "No" << endl;
            return 0;
        }
    }
    for(int i=0;i<((N-1)/2)/2;i++){
        if (s[i]!=s[(N-1)/2-1-i]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
while True:
    n,r=map(int,input().split())
    if n==0:exit()
    l=[n-i for i in range(n)]
    for j in range (r):
        p,c=map(int,input().split())
        l=l[p-1:p+c-1]+l[:p-1]+l[p+c-1:]
    print(l[0])




Measured memory_bytes: 5616
import java.util.*;

public class Main{
    
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        int[] a = new int[N];
        for(int i = 0; i < N; i++){
            a[i] = sc.nextInt();
        }
        sc.close();
        
        long ans = Long.MAX_VALUE;

        for(int i = -100; i <= 100; i++){
            long sum = 0;
            for(int j = 0; j < N; j++){
                sum += (long)Math.pow(i-a[j], 2);
            }
            ans = Math.min(ans, sum);
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a);i<(b);++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
#define INF 1000000000000000
#define MOD 1000000007
using PII = pair<int64_t, int64_t>;
using VI = vector<int64_t>;
using VVI = vector<VI>;
using VS = vector<string>;
using VP = vector<PII>;
using i64 = int64_t;
template<typename T> void invec(vector<T> &A){for(T& a : A) cin >> a;} // input vector

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

int N, C; cin >> N >> C;

//imos
VVI rec(C+1, VI(100010, 0)); // rec[channel][time]
VI sum(rec[0].size(), 0);
rep(i, 0, N){
    int s, t, c; cin >> s >> t >> c;
    ++rec[c][s];
    --rec[c][t];
}

rep(c, 1, C+1){
    rep(t, 1, rec[0].size()-1){
        if (rec[c][t] == -1) 
            --sum[t+1];
        else if (rec[c][t] == 1) ++sum[t];
    }
}
rep(t, 1, sum.size()) sum[t] += sum[t-1];

cout << *max_element(ALL(sum)) << "\n";

return 0;
}
// 書いて考える．場合分け．情報整理．
// 単純に分かる量から．愚直解を実装して研究．
// 境界，出力文字列 チェック．行末にスペース入れない．
// 可読性優先．高速化次点．
// まずは全探索，分割，次にDP
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性，二分探索
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理．前処理によるクエリ高速化．
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり
// 実行エラー：vector添え字超え．0割り．



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

int main()
{
    unsigned long long int H;
    cin >> H;

    if(H==1){
        cout << 1 << endl;
        return 0;
    }
    long long int count=0;
    do{
        H = H/2;
        count++;
    }while(H > 1);

    long long int ans = 1;
    for(long long int i=0; i<count+1; i++){
        ans = ans*2;
    }

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


Measured memory_bytes: 256
#include <string>
#include <iostream>
using namespace std;
string ask(int pos) {
	cout << pos << endl;
	string res;
	cin >> res;
	return res;
}
int main() {
	int N;
	cin >> N;
	int l = 1, r = N - 1;
	string pl = ask(0);
	if (pl == "Vacant") return 0;
	string pr = ask(N - 1);
	if (pr == "Vacant") return 0;
	bool solved = false;
	while (r - l > 1) {
		int m = (l + r) >> 1;
		string pm = ask(m);
		if (pm == "Vacant") {
			solved = true;
			break;
		}
		if (((l + m + 1) % 2) ^ (pl == pm ? 0 : 1)) {
			pr = pm;
			r = m;
		}
		else {
			pl = pm;
			l = m + 1;
		}
	}
	if (!solved) ask(l);
	return 0;
}

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

int main(void){
    int t = 0;
    for (int i=0; i<3; i++) {
        char a;
        cin >> a;
        if (a == 'o') {
            t = t + 1;
        }
    }
    cout<<700+100*t<<endl;
    

    return 0;

}

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

public class Main {
	static final int mod = (int) 1e9 + 7;
	static final int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };
	static final int INF = Integer.MAX_VALUE / 3;
	static final long LINF = Long.MAX_VALUE / 3;
	static final String nextLine = "\n";

	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		int n = fs.nextInt();
		int x[] = fs.nextIntArray(n);
		int b[] = Arrays.copyOf(x, n);
		rsort(b);
		int l = n/2 - 1;
		int r = l + 1;
		for(int i=0;i<n;i++) {
			if(x[i]<=b[r])System.out.println(b[l]);
			else System.out.println(b[r]);
		}
	}
	//reverseOrderSort : O(NlogN)
	static void rsort(int[] ar) {
		Arrays.sort(ar);
		int len = ar.length;
		for (int i = 0; i < len / 2; i++) {
			int tmp = ar[i];
			ar[i] = ar[len - 1 - i];
			ar[len - 1 - i] = tmp;
		}
	}

	static void rsort(long[] ar) {
		Arrays.sort(ar);
		int len = ar.length;
		for (int i = 0; i < len / 2; i++) {
			long tmp = ar[i];
			ar[i] = ar[len - 1 - i];
			ar[len - 1 - i] = tmp;
		}
	}
	//MOD culculations
	static long plus(long x, long y) {
		long res = (x + y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long sub(long x, long y) {
		long res = (x - y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long mul(long x, long y) {
		long res = (x * y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long div(long x, long y) {
		long res = x * pow(y, mod - 2) % mod;
		return res < 0 ? res + mod : res;
	}

	static long pow(long x, long y) {
		if (y < 0)
			return 0;
		if (y == 0)
			return 1;
		if (y % 2 == 1)
			return (x * pow(x, y - 1)) % mod;
		long root = pow(x, y / 2);
		return root * root % mod;
	}
}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

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

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

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

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

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

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

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

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}

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

using namespace std;

const int64_t INF = INT64_C(1) << 60;

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

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

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int N, M, S, T;
  cin >> N >> M >> S >> T;
  S--, T--;
  vector<vector<pair<int, pair<int, int>>>> G(N);
  for (int i = 0; i < M; i++) {
    int u, v, a, b;
    cin >> u >> v >> a >> b;
    u--, v--;
    G[u].emplace_back(make_pair(v, make_pair(a, b)));
    G[v].emplace_back(make_pair(u, make_pair(a, b)));
  }
  auto dijkstra = [&](int s, bool is_a) {
    vector<int64_t> dist(N, INF);
    dist[s] = 0;
    priority_queue<pair<int64_t, int>, vector<pair<int64_t, int>>, greater<pair<int64_t, int>>> que;
    que.push(make_pair(0, s));
    while (!que.empty()) {
      auto [c, u] = que.top();
      que.pop();
      for (auto g : G[u]) {
        int v = g.first, a = g.second.first, b = g.second.second;
        if (chmin(dist[v], c + (is_a ? a : b))) {
          que.push(make_pair(dist[v], v));
        }
      }
    }
    return dist;
  };
  auto a = dijkstra(S, true), b = dijkstra(T, false);
  vector<int64_t> res(N, 1000000000000000);
  for (int i = 0; i < N; i++) {
    res[i] -= a[i] + b[i];
  }
  for (int i = N - 2; i > -1; i--) {
    chmax(res[i], res[i + 1]);
  }
  for (auto &r : res) {
    cout << r << '\n';
  }
  return 0;
}


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

using namespace std;

using ll = long long;

int main(){
    ll n, m;
    cin >> n >> m;
    ll arr[n];
    ll garbo[100001] = {0};
    for(ll i = 1; i <= n; ++i){
        cin >> arr[i];
    }
    for(ll i = 0; i < m; ++i){
        ll a, b;
        cin >> a >> b;
        if(arr[a] <= arr[b])garbo[a] = 1;
        if(arr[a] >= arr[b])garbo[b] = 1;
    }
    ll ct = 0;
    for(ll i = 1; i <= n; ++i){
        if(!garbo[i])ct++;
    }
    cout << ct;
    return 0;
}


Measured memory_bytes: 5172
#import sys
#input = sys.stdin.readline

def main():
    N = int( input())
    S = list( map( int, list( input())))
    T = [[0]*N for _ in range(10)]
    for i in range(N):
        T[S[i]][i] = 1;
    for i in range(10):
        for j in range(N-1):
            T[i][j+1] += T[i][j]
    ANS = [0]*1000
    for m in range(1, N-1):
        for i in range(10):
            for j in range(10):
                if (T[i][m-1] > 0) and (T[j][N-1] - T[j][m] > 0):
                    ANS[100*i + 10*S[m] + j] = 1


    print( sum(ANS))
if __name__ == '__main__':
    main()


Measured memory_bytes: 16392
n = gets.chomp.to_i
s = gets.chomp.split('')
if n == 1
    puts 1
    exit
elsif n == 2
    puts s[0] == s[1] ? 1 : 2
    exit
end

comp = false
ans = s.length
i = 0
while true do
    if s[i+1] == s[i]
        s.delete_at(i+1)
    else
        i += 1
    end
    break if s.length == i+2
end
puts s[i] == s[i+1] ? s.length-1 : s.length

Measured memory_bytes: 8852
n = int(input())
b = list(map(int, input().split()))

a = [0]*n

tmp = 0

a[n-1] = b[n-2]
a[0] = b[0]


for i in range(n-2):
    tmp = b[n-2-i]
    if b[n-2-i] > b[n-3-i]:
        tmp = b[n-3-i]
    a[n-2-i] = tmp

ans = sum(a)

print(ans)

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

int main(){
    
    vector<int> t1,t2;
    int input = 0;
    
    for(int i = 0;i < 6;i++){
        if(i < 4){
            cin >> input;
            t1.push_back(input);
        }else{
            cin >> input;
            t2.push_back(input);
        }
    }
    
    sort(t1.begin(), t1.end());
    sort(t2.begin(), t2.end());
    
    int result = t1[3] + t1[2] + t1[1] + t2[1];
    cout << result << endl;
    
    return 0;
}

Measured memory_bytes: 3076
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
string od[100050];
char ans[100050];
int n;
void dfs(int i,int a,int b,int c){
    if(i==n){
        printf("Yes\n");
        for(int j=0;j<n;j++)
            printf("%c\n",ans[j]);
        exit(0);
    }
    if(od[i]=="AB"){
        if(a>0) {
                ans[i]='B';
                dfs(i+1,a-1,b+1,c);
        }
        if(b>0) {
            ans[i]='A';
            dfs(i+1,a+1,b-1,c);
        }
    }
    if(od[i]=="BC"){
        if(b>0) {
            ans[i]='C';
            dfs(i+1,a,b-1,c+1);
        }
        if(c>0) {
            ans[i]='B';
            dfs(i+1,a,b+1,c-1);
        }
    }
    if(od[i]=="AC"){
        if(a>0) {
            ans[i]='C';
            dfs(i+1,a-1,b,c+1);
        }
        if(c>0) {
            ans[i]='A';
            dfs(i+1,a+1,b,c-1);
        }
    }
}
int main(){
    int a,b,c;
    scanf("%d%d%d%d",&n,&a,&b,&c);
    for(int i=0;i<n;i++){
        cin>>od[i];
    }
    dfs(0,a,b,c);
    printf("No");
}


Measured memory_bytes: 14876
#include <bits/stdc++.h>
using namespace std;
#define repr(i,k,n) for(int i = (k); i < (n); i++)
#define rep(i,n) repr(i,0,n)
#define ALL(a) begin(a),end(a)
const int INF = 114514810;
const int MOD = 1000000007;
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N,A;
	int cnt=0;
	cin >> N;
	rep(i,N){
		cin >> A;
		if (A%2==1){
			cnt++;
		}
	}
	cout << (cnt%2==0?"YES":"NO") << endl;
}

Measured memory_bytes: 256
from fractions import gcd

N = int(input())
arr = list(map(int, input().split()))

left = [0 for _ in range(N+1)]
right = [0 for _ in range(N+1)]

for i in range(N):
  left[i+1] = gcd(left[i],arr[i])
  right[-i-2] = gcd(right[-i-1], arr[-i-1])

ans = 1
for i in range(N):
  result = gcd(left[i], right[i+1])
  ans = max(ans, result)

print(ans)

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

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

for a in A:
  C[a] += 1

ans = 0
for c in C:
  ans += c*(c-1)//2
  
for a in A:
  c_a = C[a]
  print(ans - c_a*(c_a-1)//2 + (c_a-1)*(c_a-2)//2)
  
  

Measured memory_bytes: 104852
#include <bits/stdc++.h>
using namespace std;
#define repr(i, a, b) for (int i = a; i < b; i++)
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;

int main(){
    double a,b,x,menseki,ta,ata;
    cin >> a >> b >> x;
    if(2*x>=a*a*b){
        menseki=(a*a*b-x)/a;
        ta=2*menseki/(a*a);
        ata=atan(ta);
        ata=ata*180.0/3.14159265359;
        printf("%.7f",ata);
    }else{
        menseki=x/a;
        ta=b*b/(2*menseki);
        ata=atan(ta);
        ata=ata*180.0/3.14159265359;
        printf("%.7f",ata);
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
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; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    int n;
    cin >> n;
    vi a(n);
    rp(i,n) cin >> a.at(i);
    int sum=0;
    int l=0,r=0;
    ll ctr=0;
    while(l<n){
        if(r<n&&!(sum&a.at(r))){
            //print("r");
            sum+=a[r];
            r++;
        }else{
            //print("l");
            ctr+=r-l;
            sum-=a[l];
            l++;
        }
        //print(ctr);
    }
    print(ctr);
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

Measured memory_bytes: 1024
S = input()
if S =='SUN':
  print(7)
elif S == 'SAT':
  print(1)
elif S == 'FRI':
  print(2)
elif S == 'THU':
  print(3)
elif S == 'WED':
  print(4)
elif S == 'TUE':
  print(5)
else:
  print(6)

Measured memory_bytes: 2940
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
// const ll INF = 1e18;
// const ll MOD = 1e9+7;
const double pi = 3.14159265358979;
using vl = vector<ll>;
# define rep(i, n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(ll i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(ll i=((int)(n)); i>0; --i)
# define all(x) (x).begin(), (x).end()

ll N;

int Main() {
    cin >> N;
    const double PI = acos(-1);
    cout << fixed << setprecision(4) << N* PI* 2 << endl;
    return 0;
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


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

int main(){
    int n, pos;
    double t, a, h[1000];
    
    cin >> n;
    cin >> t >> a;
    for ( int i = 0; i < n; i++ ) {
        cin >> h[i];
    }
    
    pos = 0;
    h[0] = t - h[0] * 0.006;
    for ( int i = 1; i < n; i++ ) {
        h[i] = t - h[i] * 0.006;
        
        if ( abs(h[i] - a) < abs(h[pos] - a) ) {
            pos = i;
        }
    }
    
    cout << pos + 1 << endl;
    
    return (0);
}


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

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = {0, 1, 0, -1};

bool used[2510][2510];
int roomL[51][51], roomR[51][51];

inline int s_to_i(char c) {
  switch (c) {
  case '#':
    return -1;
  case '.':
    return 0;
  case 'L':
  case 'R':
    return 1;
  case '%':
    return 2;
  }
}

int main() {
  // use scanf in CodeForces!
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  while (true) {
    int R, C;
    cin >> C >> R;
    if (R == 0 && C == 0) break;
    REP(i, R) {
      string rowL, rowR;
      cin >> rowL >> rowR;
      REP(j, C) {
	roomL[i][j] = s_to_i(rowL[j]);
	roomR[i][j] = s_to_i(rowR[j]);
      }
    }	  

    int sl = 0, el = 0, sr = 0, er = 0;
    REP(r, R) REP(c, C) {
      if (roomL[r][c] == 1) sl = r * C + c;
      else if (roomL[r][c] == 2) el = r * C + c;
      if (roomR[r][c] == 1) sr = r * C + c;
      else if (roomR[r][c] == 2) er = r * C + c;
    }
    //cout << slr << ' ' << slc << ' ' << elr << ' ' << elc << ' ' << srr << ' ' << src << ' ' << err << ' ' << erc << endl;
    REP(i, R*C) REP(j, R*C) used[i][j] = false;
    
    queue<P> que;
    que.push(P(sl, sr));

    bool flag = false;
    while (!que.empty()) {
      P p = que.front(); que.pop();
      int lr = p.first / C, lc = p.first % C, rr = p.second / C, rc = p.second % C;
      //cout << lr << ' ' << lc << ' ' << rr << ' ' << rc << endl;
      if (lr * C + lc == el && rr * C + rc == er) {
	flag = true;
	break;
      } else if (used[p.first][p.second] || lr * C + lc == el || rr * C + rc == er) {
	continue;
      }

      used[p.first][p.second] = true;
      REP(i, 4) {
	int nlr = lr + dr[i], nlc = lc + dc[i], nrr = rr + dr[(i+2*(i&1))%4], nrc = rc + dc[(i+2*(i&1))%4];
	if (nlr < 0 || nlr >= R || nlc < 0 || nlc >= C || roomL[nlr][nlc] == -1) nlr = lr, nlc = lc;
	if (nrr < 0 || nrr >= R || nrc < 0 || nrc >= C || roomR[nrr][nrc] == -1) nrr = rr, nrc = rc;
	if (!used[nlr * C + nlc][nrr * C + nrc]) que.push(P(nlr * C + nlc, nrr * C + nrc));
      }
    }
    cout << (flag ? "Yes" : "No") << endl;    
  }
  return 0;
}

Measured memory_bytes: 10004
void main()
{
    int[] tmp = readln.split.to!(int[]);
    int n = tmp[0], x = tmp[1];
    int[] a = readln.split.to!(int[]);

    a.sort!"a < b";
    int cnt;
    foreach (i; 0 .. n)
    {
        if (x >= a[i])
        {
            if (i == n - 1)
            {
                if (x == a[i]) ++cnt;
            }
            else
            {
                x -= a[i];
                ++cnt;
            }
        }
        else
        {
            break;
        }
    }

    cnt.writeln;
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
	for(int i=0;i<9;i++){
		string s;
		int a,b;
		cin >> s >> a >> b;
		cout << s << " " << a+b << " " << a*200+b*300 << endl;
	}
	return 0;
}

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


int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  int wh,re;
  wh=0;
  re=0;
  for(int i=0;i<n;++i){
    if(s[i]=='R') re++;
  }
  int ans=re;
  for(int i=0;i<n;++i){
    if(s[i]=='R') re--;
    else wh++;

    if(wh<=re) ans=min(ans,re);
    else ans=min(ans,wh);
  }
  cout << ans << endl;
  //cout << wh << " " << re << endl;
  return 0;
}


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

int main(void) {

	for (int n, i = 1; ; i++) {
		cin >> n;

		if (n == 0)  break;
		cout << "Case" << " " << i << ": "<< n << endl;

	}
	return 0;
}

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

int main(){
    int n, ans;
    cin >> n;
    vector<int> a(n), b(n), c(n-1);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >>b[i];
    rep(i, n-1) cin >> c[i];
    ans = b[a[n - 1] - 1];
    for (int i = 0; i < n - 1; i++){
        ans += b[a[i] - 1];
        if (a[i + 1] == a[i] + 1 ){
            ans += c[a[i] - 1];
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main(void){
  
  	int A, B; cin >> A >> B; 
  	if(A%3 == 0||B%3 == 0||(A+B)%3 == 0) cout << "Possible" << endl;
  	else cout << "Impossible" << endl;

 	return 0;
}

Measured memory_bytes: 256
if isfile("mystdin.txt");mystdin=open("mystdin.txt","r");redirect_stdin(mystdin);end
pI(x)=parse(Int,x)
pM(x::Array{SubString{String},1})=map(pI,x)
function main()
  n=pI(readline())
  a=pM(split(readline()))
  ans=0
  for i=1:n
    if a[a[i]]==i
      ans+=1
    end
  end
  println(ans÷2)
end
main()
if isdefined(Base, :mystdin);close(mystdin);end

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

const int INF=1000000000;
const int muki[4][2]={{0,1},{1,0},{0,-1},{-1,0}};

queue<pair<int,int>> que;
char a[1002][1002];
int cost[1002][1002];
bool used[1002][1002];

int return_cost(pair<int,int> S,pair<int,int> G){
	while(!que.empty())que.pop();
	for(int i=0;i<1002;i++)for(int j=0;j<1002;j++){ cost[i][j]=INF; used[i][j]=false; }
	que.push(S);
	cost[S.first][S.second]=0;
	while(!que.empty()){
		pair<int,int> p=que.front(); que.pop();
		if(p==G)break;
		int x=p.first,y=p.second;
		if(!used[x][y]){
			for(int i=0;i<4;i++){
				int nx=x+muki[i][0],ny=y+muki[i][1];
				if(a[nx][ny]!='X'&&cost[nx][ny]>cost[x][y]+1){
					cost[nx][ny]=cost[x][y]+1;
					que.push(pair<int,int>(nx,ny));
				}
			}
			used[x][y]=true;
		}
	}
	return cost[G.first][G.second];
}

int main(){
	int h,w,n;
	pair<int,int> p[12];
	for(int i=0;i<1002;i++)for(int j=0;j<1002;j++)a[i][j]='X';

	scanf("%d%d%d",&h,&w,&n);
	for(int i=1;i<=h;i++){
scanf("\n");
	for(int j=1;j<=w;j++){
		scanf("%c",&a[i][j]);
		if(a[i][j]=='S'){
			p[0]=pair<int,int>(i,j);
		}
		else if('1'<=a[i][j]&&a[i][j]<='9'){
			p[a[i][j]-'1'+1]=pair<int,int>(i,j);
		}
	}
	}

	int ret=0;
	for(int i=0;i<n;i++){
		ret+=return_cost(p[i],p[i+1]);
	}

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

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

int main() {
	int n, d;
	cin >> n >> d;
	vector<vector<int>> x(n, vector<int>(d));
	rep(i, n) {
		rep(j, d) cin >> x[i][j];
	}
	int ans = 0;
	rep(i, n)rep(j, i) {
		int sq = 0;
		rep(k, d) {
			int s = x[i][k] - x[j][k];
			sq += s * s;
		}
		int s = sqrt(sq);
		if (s * s == sq)ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>  // ver2.1.6
#define int long long
#define endl "\n"
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define Pii pair<int,int>
#define Tiii tuple<int,int,int>
#define PQi priority_queue<int>
#define PQir priority_queue<int, vector<int>, greater<int>>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define sortr(v) sort(v,greater<>())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define dem(a,b) ((a+b-1)/(b))
#define Vout(a) rep(i,0,a.size()-1)cout<<a[i]<<' ';cout<<a.back()<<endl
#define INF 9000000000000000000  //  9.0 * 10^18
#define MOD 1000000007  //  10^9 + 7
using namespace std;

int mypow(int x, int n, int m){  //  高速累乗x^n(mod m)  O(log(n))
if(n==0)return 1;if(n%2==0)return mypow(x*x%m,n/2,m);else return x*mypow(x,n-1,m)%m;}

signed main() {
  cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(12);
  string s;
  cin >> s;
  
  int l = s.size(),zure;
  Vi a(13),memo(13);
  a[0] = 1;
  
  repreq(i,l-1,0){
    
    if(s[i]!='?') {
      zure = mypow(10,(l-1-i)%6,MOD) * (s[i]-'0') % 13;

      rep(j,0,13){
        memo[(j+zure)%13] = a[j];
      }
      a = memo;
    }
    
    if(s[i]=='?') {
      memo = {0,0,0,0,0,0,0,0,0,0,0,0,0};
        
        rep(qw,0,10){
          zure = mypow(10,(l-1-i)%6,MOD) * qw % 13;
          rep(j,0,13){
            memo[(j+zure)%13] += a[j];
          }
        }
      rep(qw,0,13) a[qw] = memo[qw]%MOD;
    }
    
  }
  //Vout(a);
  cout << a[5] << endl;
  return 0;
}

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

int main() {
  int N,K;
  string S;
  cin >> N>>S>>K;
 char x=S.at(K-1);
  
  for(int i=0;i<N;i++){
    
    if(S.at(i)!=x){
      S.at(i)='*';
     }
  }
  cout<<S<<endl;
  
  
 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define range(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, b) for (int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x) cerr << #x << " = " << (x) << endl;
#define int long long
using namespace std;

template <typename X, typename T>
auto vectors(X x, T a) {
	return vector<T>(x, a);
}

template <typename X, typename Y, typename Z, typename... Zs>
auto vectors(X x, Y y, Z z, Zs... zs) {
	auto cont = vectors(y, z, zs...);
	return vector<decltype(cont)>(x, cont);
}

template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
	rep(i, v.size()) { os << v[i] << (i == v.size() - 1 ? "" : " "); }
	return os;
}
template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
	for (T& x : v) { is >> x; }
	return is;
}

vector<int> divisor(int n) {
	vector<int> res;
	for (int i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			res.emplace_back(i);
			if (i != n / i) res.emplace_back(n / i);
		}
	}
	sort(all(res), greater<int>());
	return res;
}

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

	int a[n], b[n];
	rep(i, n) cin >> a[i];
	int sum = accumulate(a, a + n, 0LL);
	auto d  = divisor(sum);

	for (auto y : d) {
		rep(i, n) b[i] = a[i] % y;

		int msum = accumulate(b, b + n, 0LL,
							  [y](int acc, int x) { return acc + y - x; });
		int psum = 0;
		sort(b, b + n);

		if (msum == 0) {
			cout << y << endl;
			return 0;
		}

		// show(y) rep(i, n) cout << b[i] << ' '; cout << endl; cout << psum <<
		// ' ' << msum << endl;
		rep(i, n) {
			msum -= y - b[i];
			psum += b[i];
			// cout << psum << ' ' << msum << endl;
			if (abs(psum - msum) % y == 0 and
				(psum + msum) - min(psum, msum) <= k) {
				cout << y << endl;
				return 0;
			}
		}
	}
	assert(false);
	return 0;
}


Measured memory_bytes: 256
from bisect import bisect_right as br
N = int(input())
inf = 10 ** 9 + 1
lis = [inf] * (N + 1)
res = 0
for _ in range(N):
  a = -int(input())
  ind = br(lis, a)
  if a <= lis[ind]:
    lis[ind] = a

for i in range(1, N + 1):
  if lis[i] == inf:
    break
  res = i
print(res + 1)

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

#define MOD 1000000007

char str[1005];
int dp[1005][1005];

int main()
{
  int n,m;

  scanf("%d%d",&n,&m);
  dp[1][1]=1;
  for(int c=1;c<=n;c++)
  {
    scanf("%s",&str[1]);
    for(int c2=1;str[c2];c2++)
    if (str[c2]=='.'&&dp[c][c2]==0)dp[c][c2]=(dp[c-1][c2]+dp[c][c2-1])%MOD;
  }
  printf("%d\n",dp[n][m]);
}


Measured memory_bytes: 4224
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <stack>
#include <functional>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <numeric>

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vi vector<int>
#define INF (int)1e9
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
typedef long long int ll;
typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

using namespace std;

int main(){
    map<string,int> mp;
    int n; cin>>n;
    rep(i,0,n){
        string s;cin>>s;
        mp[s]++;
    }
    
    cin>>n;
    rep(i,0,n){
        string s; cin>>s;
        mp[s]--;
    }
    
    int ans=0;
    for(auto itr = mp.begin(); itr != mp.end(); ++itr){
        ans=max(ans,itr->second);
    }
    cout<<max(0,ans)<<endl;
    return 0;
}


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

using namespace std;
typedef long long ll;

int main(){
  ll N, tmp;
  cin >> N;
  vector<ll> L;
  for (ll i=0; i<N; i++){
    cin >> tmp;
    L.push_back(tmp);
  }
  sort(L.begin(), L.end());
  ll ans = 0;
  for (ll i=0; i<N; i++){
    for (ll j=0; j<N; j++){
      if (i == j) continue;
      ll lb = max(L[i] - L[j], L[j] - L[i]);
      ll ub = L[i] + L[j];
      ll lbp = upper_bound(L.begin(), L.end(), lb) - L.begin();
      ll ubp = lower_bound(L.begin(), L.end(), ub) - L.begin() - 1;
      ans += (ll)(ubp - lbp + 1 - (ll)(i >= lbp && i <= ubp) - (ll)(j >= lbp && j <= ubp));
      //cerr << ans << endl;
      //cerr << L[i] << " " << L[j] << " " << i << " " << j << " " << lbp << " " << ubp << endl;
    }
  }
  cout << ans / 6 << endl;
  return 0;
}

Measured memory_bytes: 256
n, m, l = gets.split.map(&:to_i)
a = Array.new
b = Array.new
c = Array.new( n ){ Array.new(l, 0) }
for i in 0..n-1
	a[i] = gets.split.map(&:to_i)
end
for i in 0..m-1
	b[i] = gets.split.map(&:to_i)
end
for i in 0..n-1
	for j in 0..l-1
		for k in 0..m-1
			c[i][j] +=  a[i][k] * b[k][j]
		end
	end
end
for i in 0..n-1
	puts c[i].join(" ")
end

Measured memory_bytes: 9380
//Littleboy123 Template 1.2
     
    #include <bits/stdc++.h>
    using namespace std;
     
    //pragmas
    /*
    #pragma comment(linker, "/stack:200000000")
    #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
    #pragma GCC target ("avx2")
    #pragma GCC optimization ("O3")
    #pragma GCC optimization ("unroll-loops")
    */
     
    typedef pair<int, int> ii;
    typedef vector<int> vi;
    typedef vector<ii> vii;
    typedef long long int ll;
    typedef unsigned long long int ull;
    typedef long double ld;
     
    #define FOR(a,b,c) for(ll (a)=(b);(a)<(c);++(a))
    #define FORE(a,b,c) for(ll (a)=(b);(a)<=(c);++(a))
    #define FORN(a,b,c) for(ll (a)=(b);(a)>(c);--(a))
    #define FORNE(a,b,c) for(ll (a)=(b);(a)>=(c);--(a))
    #define COUT(a) cout << (a) << '\n'
    #define MEM(a,b) memset((a), (b), sizeof((a)))
    #define MAX(a,b) (a) = max((a), (b))
    #define MIN(a,b) (a) = min((a), (b))
    #define nl '\n'
    #define fi first
    #define se second
    #define mp make_pair
    #define pb push_back
    #define pi acos(-1.0)
     
    void init(){
    	ios_base::sync_with_stdio(false);
    	cin.tie(NULL);
    	cout.tie(NULL);
    }
     
    void infile(){
    	ifstream in("input.in");
    	streambuf *cinbuf = std::cin.rdbuf();
    	cin.rdbuf(in.rdbuf());
    }
     
    void outfile(){
    	ofstream out("out.txt");
    	streambuf *coutbuf = std::cout.rdbuf();
    	cout.rdbuf(out.rdbuf());
    }
     
    //End of template
     
    int main(){
    	init();
    	//infile();
    	//outfile();
    	
    	ll n;
    	cin >> n;
    	ll ans = (n*n+n)/2;
    	ans -= n;
    	cout << ans << nl;
    	return 0;
    }

Measured memory_bytes: 256
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define range_for(i, b, e) for(int i=(b), i##_len=(e); i<=i##_len; ++i)
# define ALL(x) (x).begin(), (x).end()
# define RALL(x) (x).rbegin(), (x).rend()
# define pb push_back
# define len(x) ((int)(x).size())
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
# define debug(x) std::cerr<<#x<<": "<<(x)<<endl;
# define LINT_MAX (LONG_LONG_MAX)
# define cauto const auto
using namespace std;
using lint = long long;
template <class Type> inline constexpr bool InRange(const Type& x, const Type& i, const Type& a) { return (i <= x) && (x <= a); }
template<class Integer>bool chmax(Integer &a, const Integer &b) { if (a<b) { a=b; return 1; } return 0; }
template<class Integer>bool chmin(Integer &a, const Integer &b) { if (b<a) { a=b; return 1; } return 0; }
template<class Integer>bool IsOdd(Integer &n) { return n & 1; }
template<class Integer>bool IsEven(Integer &n) { return !(n & 1); }
int ctoi(const char c) { return ('0' <= c && c <= '9') ? (c - '0') : -1; }
string YesNo(bool b) { return b ? "Yes" : "No"; }
string YESNO(bool b) { return b ? "YES" : "NO"; }
string yesno(bool b) { return b ? "yes" : "no"; }
static const lint MOD9 = (lint)1e9+7;
int dy[4] = {0, 1, 0, -1};
int dx[4] = {1, 0, -1, 0};

// 整数の桁数を返す ( log(N) )
template <class Integer> Integer GetDigit(Integer n) {
    Integer d = 0;
    while (n) {
        n /= 10;
        d++;
    }
    return d;
}

// 素数かどうかを返す ( O(sqrt(N)) )
template <class Integer>
constexpr bool IsPrime(const Integer n) noexcept {
    if (n < 4) return n == 2 || n == 3;
    if (n % 2 == 0 || n % 3 == 0 || (n % 6 != 1 && n % 6 != 5)) return false;
    for (Integer i = 5; i * i <= n; i += 6) if (n % i == 0 || n % (i + 2) == 0) return false;
    return true;
}


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

    cout << min(n - (n/k)*k, abs(n - (n/k + 1)*k)) << "\n";

    return 0;
}


Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * c.cc: C - Step
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

typedef long long ll;

/* global variables */

/* subroutines */

/* main */

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

  ll sum = 0;
  int pa = 0;
  for (int i = 0; i < n; i++) {
    int ai;
    scanf("%d", &ai);

    if (pa > ai)
      sum += pa - ai;
    else
      pa = ai;
  }

  printf("%lld\n", sum);
  return 0;
}


Measured memory_bytes: 3192
#ifndef LOCAL
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#else
#include <iostream>
#include <iomanip> 
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <memory>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; } sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; } eni(!=) cerr << boolalpha << i; ris; } eni(==) ris << range(begin(i), end(i)); } sim, class b dor(pair < b, c > d) { ris << "(" << d.first << ", " << d.second << ")"; } sim dor(rge<c> d) { *this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]"; }
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

template<typename T> void setmax(T& x, T y) {x = max(x, y);}
template<typename T> void setmin(T& x, T y) {x = min(x, y);}
#define fix(a) fixed << setprecision(a)
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define rep(i, a, b) for (int i = int(a); i < int(b); i++)
#define all(V) V.begin(), V.end()
#define rall(V) V.rbegin(), V.rend()
#define len(V) (int)V.size()
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define endl '\n'

void solve(){
  int n;
  cin >> n;
  vector<int> a(n);
  forn(i,n) cin >> a[i];
  forn(i,n){
    if (!i) a[i]--;
    else {
      if (a[i-1] < a[i]) a[i]--;
      if (a[i-1] > a[i]){
        cout << "No";
        return;
      }
    }
  }
  cout << "Yes";
}

int main() {
  ios::sync_with_stdio(false); 
  cin.tie(0); cout.tie(0);
  int t = 1;
  // cin >> t;
  forn(i, t){
    solve();
  }
}

/* 

1
1000000000000000000


*/

Measured memory_bytes: 3712
n,s = map(int,input().split())

isloop = True
for x in range(2001):
    
    if(isloop==False):
        break
    xv = x*10000
    for y in range(2001):
        
        if(isloop==False):
            break
        yv = y*5000
        xysum = xv+yv
        if(xysum > s):
            continue
        
        z = (s-(xysum))//1000
        if((x+z+y)==n):
            print(x,y,z)
            isloop=False
            break

if(isloop==True):
    print(-1,-1,-1)

Measured memory_bytes: 3064
#pragma GCC optimize ("-O3","unroll-loops")
#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 FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define pb(a) push_back
#define print(x) cout<<(x)<<endl
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), n)
#define ub(v,n) upper_bound(v.begin(), v.end(), n)
#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
 
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
//typedef pair<int, int>P;
const int MOD = 1e9 + 7; const int MAX = 1000020;
const double pi = acos(-1); const double EPS = 1e-12;
const ll INF = 1e9;
 

double Wmax[3],Wmin[3],Hmax[3],Hmin[3];
void solve() {
	int N;cin>>N;
	REP(i,3){
		Wmax[i]=-INF;
		Wmin[i]=INF;
		Hmax[i]=-INF;
		Hmin[i]=INF;
	}
	REP(i,N){
		double x,y;cin>>x>>y;
		char d;cin>>d;
		if(d=='D'){
			Wmax[0]=max(Wmax[0],y);
			Wmin[0]=min(Wmin[0],y);
			Hmax[1]=max(Hmax[1],x);
			Hmin[1]=min(Hmin[1],x);
		}
		else if(d=='U'){
			Wmax[2]=max(Wmax[2],y);
			Wmin[2]=min(Wmin[2],y);
			Hmax[1]=max(Hmax[1],x);
			Hmin[1]=min(Hmin[1],x);
		}
		else if(d=='L'){
			Wmax[1]=max(Wmax[1],y);
			Wmin[1]=min(Wmin[1],y);
			Hmax[0]=max(Hmax[0],x);
			Hmin[0]=min(Hmin[0],x);
		}
		else if(d=='R'){
			Wmax[1]=max(Wmax[1],y);
			Wmin[1]=min(Wmin[1],y);
			Hmax[2]=max(Hmax[2],x);
			Hmin[2]=min(Hmin[2],x);
		}
	}
	double ans=1e18;
	if(N==1)ans=0;
	REP(T,100000010){
		double t=T;
		double Wma=max({Wmax[0]-t,Wmax[1],Wmax[2]+t});
		double Wmi=min({Wmin[0]-t,Wmin[1],Wmin[2]+t});
		double Hma=max({Hmax[0]-t,Hmax[1],Hmax[2]+t});
		double Hmi=min({Hmin[0]-t,Hmin[1],Hmin[2]+t});
		// DEBUG(t);
		// DEBUG(Wma);DEBUG(Wmi);DEBUG(Hma);DEBUG(Hmi);
		double tmp=abs(Wma-Wmi)*abs(Hma-Hmi);
		ans=min(ans,tmp);
		t+=0.5;
		Wma=max({Wmax[0]-t,Wmax[1],Wmax[2]+t});
		Wmi=min({Wmin[0]-t,Wmin[1],Wmin[2]+t});
		Hma=max({Hmax[0]-t,Hmax[1],Hmax[2]+t});
		Hmi=min({Hmin[0]-t,Hmin[1],Hmin[2]+t});

		tmp=abs(Wma-Wmi)*abs(Hma-Hmi);
		ans=min(ans,tmp);
	}
	cout<<setprecision(20)<<ans<<endl;
}
 
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
 
	solve();
 
}

Measured memory_bytes: 384
#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;

#define ll long long

int N;
ll x, y;

int main(){
    cin >> N;

    x = 2, y = 1;

    for(int i = 0;i < N; i++){
        if(i % 2 == 0) x += y;
        else y += x;
    }

    if(N % 2 == 0) cout << x << endl;
    else cout << y << endl;
}


Measured memory_bytes: 256