akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
  
public class Main {
    Scanner sc = new Scanner(System.in);
  
    public static void main(String[] args) {
        new Main(); 
    }
  
    public Main() {
        new aoj1155().doIt();
    }
    class aoj1155{
    	Stack<Integer> st = new Stack<Integer>();
    	int stack(int P,int Q,int R,char ctr[]){
    		int cnt = 0;
    		for(int i = 0;i < ctr.length;i++){
    			if(ctr[i] == ')'){
    				int result = st.pop();
    				while(true){
    					int num = st.pop();
    					if(num == -1){
    						if(st.size() > 0){
    							int mainus = st.pop();
    							if(mainus == -2){
    								if(result == 0)result = 2;
    	    						else if(result == 1)result = 1;
    	    						else result = 0;
    								st.push(result);
    							}else{
    								st.push(mainus);
    								st.push(result);
    							}
    						}else{
    							st.push(result);
    						}
    						break;
    					}
    					else if(num == -2){
    						if(result == 0)result = 2;
    						else if(result == 1)result = 1;
    						else result = 0;
    					}else if(num == -3){
    						int num2 = st.pop();
    						result = ((result|num2) == 3 ? 2:(result|num2));
    					}else if(num == -4){
    						int num2 = st.pop();
    						result = result == num2 ? result:(result+num2) == 3 ? 1:0;
    					}
    				}
//    				System.out.println(st.toString());
//    				System.out.println(result);
    			}else{
    				//??°?????????
    				if(ctr[i] == '('){
    					if(cnt % 2 == 1)st.push(-2);
    					cnt = 0;
    					st.push(-1);
    				}
    				else if(ctr[i] == 'P'){
    					if(cnt % 2 == 1){
    						if(P == 0)st.push(2);
    						else if(P == 1)st.push(1);
    						else st.push(0);
    					}else st.push(P);
    					cnt = 0;
    				}
    				else if(ctr[i] == 'Q'){
    					if(cnt % 2 == 1){
    						if(Q == 0)st.push(2);
    						else if(Q == 1)st.push(1);
    						else st.push(0);
    					}else st.push(Q);
    					cnt = 0;
    				}
    				else if(ctr[i] == 'R'){
    					if(cnt % 2 == 1){
    						if(R == 0)st.push(2);
    						else if(R == 1)st.push(1);
    						else st.push(0);
    					}else st.push(R);
    					cnt = 0;
    				}
    				else if(ctr[i] == '-'){
    					cnt++;
    				}
    				else if(ctr[i] == '+')st.push(-3);
    				else if(ctr[i] == '*')st.push(-4);
    				else if(ctr[i] == '0'){
    					if(cnt % 2 == 1)st.push(2);
    					else st.push(0);
    					cnt = 0;
    				}
    				else if(ctr[i] == '1'){
    					st.push(1);
    					cnt = 0;
    				}
    				else if(ctr[i] == '2'){
    					if(cnt % 2 == 1)st.push(0);
    					else st.push(2);
    					cnt = 0;
    				}
    			}
    		}
    		return st.pop();
    	}
    	void doIt(){
    		while(true){
    			String str = sc.next();
    			if(str.equals("."))break;
    			int ans = 0;
    			for(int i = 0;i < 3;i++){
    				for(int j = 0;j < 3;j++){
    					for(int k = 0;k < 3;k++){
//    						System.out.println("+++++++");
    						if(stack(i,j,k,str.toCharArray()) == 2)ans++;
    					}
    				}
    			}
    			System.out.println(ans);
    		}
    	}
     }
}

Measured memory_bytes: 32492
#include <stdio.h>

int main(void){
	int h, w, i, j;
	while(1){
		scanf("%d %d", &h, &w);
		if (h == 0 && w == 0) break;
		for (i = 0; i < h; i++){
			for (j = 0; j < w; j++){
				if ((i+j)%2 == 0) printf("#");
				else printf(".");
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}

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

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;

int N;
int X[110];

signed main() {
    cin >> N;
    rep(i, N) {
        cin >> X[i];
    }
    int ans = INF;
    for (int i = 1; i <= 100; ++i) {
        int c = 0;
        rep(j, N) {
            c += (X[j] - i) * (X[j] - i);
        }
        ans = min(ans, c);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

int n, m, b[20], bitstr[20], p[20];

int count(int flg){
	int ret=0, c=0, count;
	REP(i,n){
		bitstr[i] = b[i];
	}
	count = p[c];
	REP(i,n){
		if (bitstr[i]!=flg){
			bool notfound=1;
			for (int k=i+1; k<n; k++){
				if (bitstr[k]==flg){
					ret += k-i;
					notfound = false;
					bitstr[i] = flg;
					bitstr[k] = (flg ^ 1);
					break;
				}
			}
			if (notfound){
				ret = -1;
				break;
			}
		}
		count--;
		if (count==0){
			flg = (flg ^ 1);
			c++;
			count = p[c];
		}
	}
	return ret;
}

int main(){
	int count0=0, count1=0;
	
	cin >> n >> m;
	REP(i,n){
		cin >> b[i];
	}
	REP(i,m){
		cin >> p[i];
	}
	
	// cout << (flg ^ 1) << endl;
	count0 = count(0);
	count1 = count(1);
	
	// printf("count0: %d, count1: %d\n", count0, count1);
	
	if (count0<0){
		cout << count1 << endl;
	}else if (count1<0){
		cout << count0 << endl;
	}else{
		cout << min(count0, count1) << endl;
	}
	
}


Measured memory_bytes: 3120
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace ConsoleApplication6
{
    class Program
    {
        static void Main(string[] args)
        {
            /*var ab = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var a = ab[0];
            var b = ab[1];
            Console.WriteLine("{0} {1}",a*b,(a+b)*2);
            Console.ReadLine();
            var a = int.Parse(Console.ReadLine());
            var b = a / 60;
            var c = b / 60;
            Console.WriteLine("{0}:{1}:{2}", c, b % 60, a % 60);*/
            var ab = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var a = ab[0];
            var b = ab[1];
            {
            if (a > b) 
            Console.WriteLine("a > b");
            if (a < b) 
            Console.WriteLine("a < b");
            if (a == b)
            Console.WriteLine("a == b");
            }


            

            
        }
    }
}

Measured memory_bytes: 9320
#include <iostream>
#include <ios>
#include <vector>
#include <algorithm>
using namespace std;
long n, A[20] = {};

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	long m, i, j, k;
	cin >> n;
	for (i = 0; i < n; ++i)
		cin >> A[i];

	vector<long> vN;
	vN.reserve(1024 * 1024);
	for (i = 0; i < n; ++i){
		vN.push_back(A[i]);
		int s = vN.size();
		for (j = 0; j < s - 1; ++j)
			vN.push_back(vN[j] + A[i]);
	}
	sort(vN.begin(), vN.end());
	cin >> m;
	for (i = 0; i < m; ++i){
		cin >> k;
		cout << (binary_search(vN.begin(), vN.end(), k) ? "yes\n" : "no\n");
	}

	return 0;
}

Measured memory_bytes: 9248
#include <iostream>
#include <cstring>
#include <cstdio>

using namespace std;
const int maxn = 2e5 + 1111;
#define ll long long
int N, a[maxn];
ll ans = 0, cnt[maxn];

int main(){
    scanf("%d", &N);
    for (int i = 1; i <= N; i++){
        scanf("%d", &a[i]);
        cnt[a[i]]++;
    }
    cnt[a[1]]--;
    for (int i = 1; i <= N; i++){
        ans += cnt[i]*(cnt[i]-1)/2;
    }
    printf("%lld\n", ans);
    for (int i = 2; i <= N; i++){
        cnt[a[i]]--;
        ans = ans + cnt[a[i-1]]-cnt[a[i]];
        cnt[a[i-1]]++;
        printf("%lld\n", ans);
    }
}


Measured memory_bytes: 3968
import java.math.BigInteger;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        long c = sc.nextLong();
        long d = sc.nextLong();

        BigInteger ac = BigInteger.valueOf(a).multiply(BigInteger.valueOf(c));
        BigInteger ad = BigInteger.valueOf(a).multiply(BigInteger.valueOf(d));

        BigInteger result1 = ac.max(ad);

        BigInteger bc = BigInteger.valueOf(b).multiply(BigInteger.valueOf(c));
        BigInteger bd = BigInteger.valueOf(b).multiply(BigInteger.valueOf(d));

        BigInteger result2 = bc.max(bd);

        System.out.println(result1.max(result2));

    }
}

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

int main(void)
{
    string s;
    getline(cin, s);  // 1行読み込む
    for(int i = 0; i < s.size(); i++) {
        char c = s[i];
        if ('A' <= c && c <= 'Z') {
            //c = tolower(c);
            c = c + 32;
        }
        else if('a' <= c && c <= 'z') {
            c = c - 32;
        }
        cout << c;
    }
    cout << endl;
}




Measured memory_bytes: 3164
#include<bits/stdc++.h>
using namespace std;
class IN{
public:
    template<typename T>
    IN& operator >>(T &x){read(x);return *this;}
    IN& operator >>(double &x){scanf("%lf",&x);return *this;}
    IN& operator >>(char *s){scanf("%s",s);return *this;}
    IN& operator >>(char &c){c=getchar();return *this;}
private:
    template<typename T>
    void read(T &x){
        T f=1;int c=getchar();x=0;
        while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
        while(c>='0'&&c<='9')x=(x<<3)+(x<<1)+(c^48),c=getchar();
        x*=f;
    }
}in;
class NL{}nl;
class BK{}bk;
class OUT{
public:
    template<typename T>
    OUT& operator <<(T x){write(x);return *this;}
    OUT& operator <<(const char *s){printf("%s",s);return *this;}
    OUT& operator <<(char c){putchar(c);return *this;}
    OUT& operator <<(BK x){putchar(' ');return *this;}
    OUT& operator <<(NL x){putchar('\n');return *this;}
private:
    template<typename T>
    void write(T x){
        if(x<0)putchar('-'),x=-x;
        if(x>=10)write(x/10);
        putchar(x%10+48);
    }
}out;

#define pb(x) push_back(x)
#define fi first
#define se second
#define rep(i,a,n) for(int i=a;i<=n;++i)
#define per(i,n,a) for(int i=n;i>=a;--i)
#define mem(a,x) memset(a,x,sizeof(a))
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef vector<int> VI;
typedef vector<ll> VL;
/*****************************************************************************************************/
ll Pow(ll a,ll b,ll mod){ll res=1;a%=mod;while(b){if(b&1)(res*=a)%=mod;(a*=a)%=mod;b>>=1;}return res%mod;}
ll inv(ll a,ll p){if(a==1)return 1;return (p-p/a)*inv(p%a,p)%p;}//p为素数,a<p
ll C(ll n,ll m,ll p){ll res=1;for(ll i=1,j=n-m+1;i<=m;++i,++j){res=res*inv(i,p)%p*j%p;}return res;}
/*****************************************************************************************************/
/*ll ask(int x){ll res=0;while(x)res+=c[x],x-=x&-x;return res;}
void add(ll v,int x){while(x<=n)c[x]+=v,x+=x&-x;}*/
const int p=1e9+7;
const int N=2e5+10;

ll a[N];
int main(){
    int n;in>>n;
    ll ans=0;
    rep(i,1,n)in>>a[i];
    rep(i,2,n){
        if(a[i]<a[i-1]){
            ans+=a[i-1]-a[i];
            a[i]=a[i-1];
            
        }
    }
    out<<ans;
    return 0;
}

Measured memory_bytes: 5080
import java.util.*;

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

        int N = sc.nextInt();
        String S = sc.next();
        sc.close();

        int [] member = new int [N];
        int [] w = new int [N];
        int [] e = new int [N];

        for (int i = 0; i < N; i++) {
            int w_sum = 0;
            int e_sum = 0;
            if (S.charAt(i) == 'E') {
                e_sum++;
            } else {
                w_sum++;
            }
            if (i < 1) {
                e[i] = e_sum;
                w[i] = w_sum;
            }else{
                e[i] = e_sum + e[i-1];
                w[i] = w_sum + w[i-1];
            }
        }

        for (int i = 0; i < N; i++) {
            if (i < 1) {
                member[i] = e[N-1] - e[i];
            } else if ( i == N - 1) {
                member[i] = w[i];
            } else {
                member[i] = w[i-1] + (e[N-1] - e[i]);
            }
        }

        int ans = member[0];
        for (int i = 1; i < N; i++) {
            int result = member[i];
            ans = Math.min(ans, result);
        }

        System.out.println(ans);
    }
}

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

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

using Graph = vector<vector<int>>;

ll calc(ll a, ll b, ll p){//aのb乗をpで割った余り
  if(b == 0) return 1;

  else if(b%2 == 0){
    ll d = calc(a,b/2,p);
    return (d*d)%p;
  }
  else if(b%2 == 1){
    return (a * calc(a,b-1,p))%p;
  }
}

typedef pair<int,int> P;

bool is_prime(int n){//nが素数であるかどうか判定 iで割り切れると素数でない
    if(n == 1) return false;//1は例外
    for(int i = 2;i*i <= n;i++){
        if(n%i == 0) return false;
    }
    
    return true;
}
int factorial(int a){
  int res = 1;
  while(a){
    res *= a;
    a--;
  }
  return res;
}

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(b-a == c-b) cout << "YES" << endl;
  else cout << "NO" << endl;
  
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;
using TP = tuple<int, int, int>;

// Binary Indexed Tree (Fenwick Tree)
// https://youtu.be/lyHk98daDJo?t=7960
template<typename T>
struct BIT {
    int n;
    vector<T> d;
    BIT(int n=0):n(n),d(n+1) {}
    void add(int i, T x=1) {
        for (i++; i <= n; i += i&-i) {
            d[i] += x;
        }
    }
    T sum(int i) {
        T x = 0;
        for (i++; i; i -= i&-i) {
            x += d[i];
        }
        return x;
    }
    T sum(int l, int r) {
        return sum(r-1) - sum(l-1);
    }
};

const ll INF = 1e18;
void Main(){
    ll n, d, a; cin >> n >> d >> a;
    vector<pair<ll, ll>> m(n);
    rep(i, n) cin >> m[i].fi >> m[i].se;
    sort(all(m));

    BIT<ll> bit(n+1);
    
    ll ans = 0;
    rep(i, n){
        ll l = m[i].fi;
        ll hp = m[i].se;
        hp -= bit.sum(i);
        if(hp <= 0) continue;
        ll cnt = (hp + a - 1) / a;
        ll damage = a * cnt;
        ll r = l + 2 * d;
        pair<ll, ll> R = {r, INF};
        ll ni = upper_bound(all(m), R) - m.begin();
        bit.add(i, damage);
        bit.add(ni, -damage);
        ans += cnt;
        // cout << i << ": " << l << ", " << r << ": " << ni << " " << cnt << endl;
    }
    
    cout << ans << endl;    


    return;
}

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

Measured memory_bytes: 7936
#include <bits/stdc++.h>
#include <cassert>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
template<class T> bool chmax(T &a, const T &b) { if(a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if(a > b) { a = b; return true; } return false; }
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using ii = pair<int, int>;
using vvi = vector<vi>;
using vii = vector<ii>;
using gt = greater<int>;
using minq = priority_queue<int, vector<int>, gt>;
using P = pair<ll,ll>;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int R,C,K;
ll dp[3005][3005][4];
int main() {
  cin >> R >> C>> K;
  vector<vll> grid(R,vll(C));
  rep(i,K) {
    int r,c,v; cin >> r >> c >> v;
    r--, c--;
    grid[r][c] = v;
  }
  rep(i,R) rep(j,C) {
    rep(k,4) {
      // taking 
      if (k != 3) {
        chmax(dp[i+1][j][0], dp[i][j][k] + grid[i][j]);
        chmax(dp[i][j+1][k+1], dp[i][j][k] + grid[i][j]);
      }
      // not taking
      chmax(dp[i+1][j][k], dp[i][j][k]);
      chmax(dp[i][j+1][k], dp[i][j][k]);
    }
  }
  rep(i,4) if(i!=3) dp[R-1][C-1][i] += grid[R-1][C-1];
  ll ans = 0;
  rep(i,4) {
    chmax(ans, dp[R-1][C-1][i]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 355432
h, w, k = map(int, input().split())
tbl = [input() for _ in range(h)]

# ビット全探索で全パターンをチェック
# n個のものからいくつか選ぶ組み合わせの数は 2**n 
# 例えば、3個の場合は 2**3 = 8通り
# 0: 0b000
# 1: 0b001
# 2: 0b010
# 3: 0b011
# 4: 0b100
# 5: 0b101
# 6: 0b110
# 7: 0b111
# バイナリの 0 は選ばれている、1 は選ばれていない
# https://drken1215.hatenablog.com/entry/2019/12/14/171657
ans = 0
for i in range(2**h):
    for j in range(2**w):
        ct = 0
        for ii in range(h):
            for jj in range(w):
                # 塗りつぶされない黒をカウントする
                # カウントした結果が残った数と同じであれば、回答に+1
                if (i>>ii)&1 == 0 and (j>>jj)&1 == 0:
                    if tbl[ii][jj] == '#':
                        ct += 1
        if ct == k:
            ans += 1
print(ans)
                    


Measured memory_bytes: 9088
#include <bits/stdc++.h>
#include <string>
using namespace std;
typedef long long int ll;
typedef double ld;
typedef long double lld;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define pb push_back
#define mp make_pair
#define pi pair<int,int>
#define pl pair<ll,ll>
#define ONLINE_JUDGE
template<class T> T umax(T a,T b) {return (a>b?a:b);}
template<class T> T umin(T a,T b) {return (a<b?a:b);}
template<class T,class P> T umax(T a,P b) {return (a>b?a:b);}
template<class T,class P> T umin(T a,P b) {return (a<b?a:b);}

const ll mod = 1e9+7;

int X[] = {0,1,0,-1,-1,-1,1,1};
int Y[] = {1,0,-1,0,-1,1,-1,1};

ll power(ll a,ll b) {
    ll res = 1;
    while(b) {
        if(b&1) res = (res*a)%mod;
        a = (a*a)%mod;
        b >>= 1;
    }
    return res;
}

const int maxn = 1e6+1;

int main() {
#ifndef ONLINE_JUDGE
    freopen("planetdistancesmall.in","r",stdin);
    freopen("ans.txt","w",stdout);
#endif
    ios::sync_with_stdio(false);
    // logic
    int n,cp;
    cin >> n;
    cp = n;
    int cnt = 0;
    while(n > 0) {
        cnt += n%10;
        n /= 10;
    }
    string res = (cp%cnt == 0) ? "Yes" : "No";
    cout << res << endl;
#ifndef ONLINE_JUDGE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>

#define SIZE 200000

int PAR1[SIZE],RANK1[SIZE];
int PAR2[SIZE],RANK2[SIZE];
int LIST[SIZE],NEXT[SIZE],G[SIZE],GC[SIZE],COUNT[SIZE];
void init_uf(int n){for(int i=0;i<n;i++){PAR1[i]=PAR2[i]=i;RANK1[i]=RANK2[i]=0;}}
int root1(int i){return PAR1[i]==i?i:(PAR1[i]=root1(PAR1[i]));}
int root2(int i){return PAR2[i]==i?i:(PAR2[i]=root2(PAR2[i]));}
int same1(int x,int y){return root1(x)==root1(y);}
int same2(int x,int y){return root2(x)==root2(y);}
void unite1(int x,int y){
  x=root1(x);y=root1(y);
  if(x==y)return;
  if(RANK1[x]<RANK1[y])PAR1[x]=y;
  else{PAR1[y]=x;if(RANK1[x]==RANK1[y])RANK1[x]++;}
}
void unite2(int x,int y){
  x=root2(x);y=root2(y);
  if(x==y)return;
  if(RANK2[x]<RANK2[y])PAR2[x]=y;
  else{PAR2[y]=x;if(RANK2[x]==RANK2[y])RANK2[x]++;}
}
void makelist(int n){
  int i,j;
  for(i=0;i<n;i++)LIST[i]=-1;
  for(i=0;i<n;i++){j=root1(i);NEXT[i]=LIST[j];LIST[j]=i;}
}
int main(){
  int n,k,l,i,j,a,b;
  scanf("%d%d%d",&n,&k,&l);
  init_uf(n);
  for(i=0;i<k;i++){scanf("%d%d",&a,&b);unite1(a-1,b-1);}
  for(i=0;i<l;i++){scanf("%d%d",&a,&b);unite2(a-1,b-1);}
  makelist(n);
  for(i=0;i<n;i++)G[i]=-1;
  for(i=0;i<n;i++)if(LIST[i]!=-1){
    for(j=LIST[i];j!=-1;j=NEXT[j]){
      a=root2(j);
      if(G[a]==i)GC[a]++;
      else{G[a]=i;GC[a]=1;}
    }
    for(j=LIST[i];j!=-1;j=NEXT[j])COUNT[j]=GC[root2(j)];
  }
  for(i=0;i<n;i++)printf("%d ",COUNT[i]);
}


Measured memory_bytes: 7680
#include <bits/stdc++.h>
#include <iostream>
#include <functional>
#include <vector>
#include <stdio.h>
#include <queue>
#include <string.h>
#include <math.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define rep1(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=a;i>=n;i--)
#define per1(i,a,n) for (int i=a;i>n;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define endl "\n"
#define pi 3.14159265358979323846264338327950288419716939937510
#define IOS cin.sync_with_stdio(false);cin.tie(0);cout.tie(0);
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll mod=1000000007;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
ll qpow(ll a,ll b){ll s=1;while(b>0){if(b%2==1){s=s*a;}a=a*a;b=b>>1;}return s;}
ll qpowmod(ll a, ll b, ll c){ll res, t;res=1;t=a%c;while(b){if(b & 1){res=res*t%c;}t=t*t%c;b>>=1;}return res;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline long long read(){long long k=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){k=k*10+ch-'0';ch=getchar();}return k*f;}
inline void write(long long x){if(x<0)x=-x,putchar('-');if(x>9)write(x/10);putchar(x%10+'0');}
// head
ll n,sum;
int main()
{
    //IOS;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        if(i%3!=0&&i%5!=0)
        {
            sum+=i;
        }
    }
    cout<<sum;
    return 0;
}
/*

*/


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

using namespace std;


int main(){
	string S;
	cin >> S;
	vector<string>SS;
	for( size_t i = 0; i < S.size(); i++ ){
		for( size_t j = 1; i + j <= S.size() && j <= 5; j++ ){
			SS.push_back(S.substr(i, j));
		}
	}
	sort(SS.begin(), SS.end());
	SS.erase(unique(SS.begin(), SS.end()), SS.end());
	long long int K;
	cin >> K;
	cout << SS[K - 1] << endl;
}


Measured memory_bytes: 1660
using System;

namespace ForAtcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var arg = Console.ReadLine().Split(" ");
            var x = long.Parse(arg[0]);
            var y = long.Parse(arg[1]);
            for (var i = 0; i <= 100; i ++)
            {
                for (var j = 0; j <= 100; j++)
                {
                    if (i + j == x && 2 * i + 4 * j == y)
                    {
                        Console.WriteLine("Yes");
                        goto END;
                    }
                    if (i == 100 && j == 100) Console.WriteLine("No");
                }
            }
            END:;
        }
    }
}

Measured memory_bytes: 27520
#include <iostream>

using namespace std;

int main(void)
{
    int A, B;
    cin >> A >> B;

    int ans = 0;
    for(int i = A; i <= B; ++i)
    {
        int a = i / 100;
        int b = i % 1000;
        int c = ((a % 10) * 100) + ((a / 10) % 10 * 10) + (a / 100);
        if(b == c)
        {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
// Problem : A - Transfer
// Contest : AtCoder Beginner Contest 136
// URL : https://atcoder.jp/contests/abc136/tasks/abc136_a
// Memory Limit : 1024,000000 MB 
// Time Limit : 2000,000000 milisec 
// Powered by CP Editor (https://github.com/coder3101/cp-editor2)

#include <algorithm>
#include <cmath>
#include <iostream>
#include <iterator>
#include <map>
#include <set>
#include <vector>

using namespace std;

int main() {
#ifdef _DEBUG
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif

  ios_base::sync_with_stdio(false);
  cin.tie(0);

  cout.precision(16);
  cout << fixed;
  
  int a;
  int b;
  int c;
  cin >> a >> b >> c;
  
  while (c && a > b) {
    --c;
    ++b;
  }
  
  cout << c;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pll = pair<ll, ll>;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, m, n) for(ll i = m; i > n; i--)
#define Rep(i, m, n) for(ll i = m; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define lmax(x, y) max<ll>(x, y)
#define lmin(x, y) min<ll>(x, y)
#define tmax(x, y, z) lmax((x), lmax((y), (z)))
#define tmin(x, y, z) lmin((x), lmin((y), (z)))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define ZERO(a) memset(a, 0, sizeof(a))
const ll INF = 1LL << 60;
const ll MM = 1000000000; const ll MOD = MM + 7; const ll MMM=9223372036854775807;//2^63 -1
#define ADD(a,b) a = (a + ll(b)) % MOD
#define MUL(a,b) a = (a * ll(b)) % MOD
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
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;}
template<typename A, size_t N, typename T> void FILL(A (&array)[N], const T &val){ fill( (T*)array, (T*)(array+N), val );}
// struct edge{ ll from, to, cost; };
// struct edge{ ll to, cost; };
// using Graph = vector<vector<ll>>;  // 重み無し
// using Graph = vector<edge>;  // 辺
// using Graph = vector<vector<edge>>;  // 重み付き
ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
ll ddx[8] = {1, 1, 0, -1, -1, -1, 0, 1}, ddy[8] = {0, 1, 1, 1, 0, -1, -1, -1};


int main(){
    ll x, a, b; cin >> x >> a >> b;
    if(b - a > x) cout << "dangerous" << endl;
    else if(b - a <= 0) cout << "delicious" << endl;
    else cout << "safe" << endl;
}


Measured memory_bytes: 3644
n,x=map(int,input().split())
c=0
def p(n):
  return 2*(2**n)-1
def f(n):
  return 4*(2**n)-3

c=0
for i in range(n,0,-1):
  if x:
    x-=1
  if x>=f(i-1):
    x-=f(i-1)
    c+=p(i-1)
    if x:
      x-=1
      c+=1
      if x>=f(i-1):
        x-=f(i-1)
        c+=p(i-1)
        if x:
          x-=1
print(c)

Measured memory_bytes: 62000
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long LL;
const int N=100005;
struct node { int y,next; } a[N<<1];
LL an;
int S[N],fa[N],h[N],head[N],s[N],k[N],i,j,n,m,x,y,z,g;
char c;

inline char getc()
{
	#define VV 10000000
	static char s[VV],*l=s,*r=s;
	if (l==r)
		l=s,r=s+fread(s,1,VV,stdin);
	return l==r?0:*l++;
}

int read(){ int z=0; do c=getc(); while (c<'0'||c>'9'); while (c>='0'&&c<='9') z*=10,z+=c-'0',c=getc(); return z; }

void jb(int x,int y)
{
	a[++g]=(node){y,head[x]},head[x]=g,
	a[++g]=(node){x,head[y]},head[y]=g;
}

void dfs(int w,int sp)
{
	h[w]=h[fa[w]]+1,
	s[w]=h[w]&1?1:-1;
	for (register int j=head[w];j;j=a[j].next)
		if ((j^1)!=sp)
		{
			int c=a[j].y;
			if (h[c])
				x=w,y=c;
			else
				fa[c]=w,dfs(c,j),s[w]+=s[c];
		}
}

int main()
{
	n=read(),m=read(),g=1;
	for (i=1;i<=m;++i) jb(read(),read());
	dfs(1,0);
	if (m==n-1)
	{
		if (s[1])
			an=-1;
		else
			for (i=2;i<=n;++i)
				an+=abs(s[i]);
	}
	else
		if (h[x]-h[y]&1)
			if (s[1])
				an=-1;
			else
			{
				S[g=1]=0;
				for (;x;x=fa[x])
					++k[x];
				for (;y;y=fa[y])
					--k[y];
				for (i=1;i<=n;++i)
					if (k[i])
						S[++g]=k[i]*s[i];
					else
						an+=abs(s[i]);
				sort(S+1,S+g+1);
				z=S[g+1>>1];
				for (i=1;i<=g;++i)
					an+=abs(z-S[i]);
			}
		else
		{
			
			if (abs(s[1])&1)
				an=-1;
			else
			{
				an=abs(z=s[1]/2);
				for (;x;x=fa[x])
					s[x]-=z;
				for (;y;y=fa[y])
					s[y]-=z;
				for (i=2;i<=n;++i)
					an+=abs(s[i]);
			}
		}
	printf("%lld\n",an);
	return 0;
}

Measured memory_bytes: 11008
n,q = map(int,input().split())
graph = [[] for _ in range(n)]
point = [0]*n
for i in range(n-1):
    a,b = map(int,input().split())
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)
for _ in range(q):
    a,b = map(int,input().split())
    a = a -1
    point[a]+=b
stack = [];
stack.append(0)
visited = [False]*n
while stack:
    x = stack.pop()
    visited[x] = True
    for y in graph[x]:
        if visited[y] == False:
            point[y] += point[x]
            stack.append(y)
print(*point)

Measured memory_bytes: 55856
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n;
  cin >> n;
  vl a(n);
  rep(i, n) cin >> a[i];
  sort(all(a));
  ll ans = 0;
  rep(i, n - 2) rep2(j, i + 1, n - 1) {
    ll in = lower_bound(all(a), a[i] + a[j]) - a.begin();
    ans += in - j - 1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define in insert
#define all(x) (x).begin(), (x).end()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
int main(){
    int n;
    cin>>n;
    vector<int> v(n);
    int mxpos=0,mx2=0;
    forn(i,n){
        cin>>v[i];
        if(v[i]>v[mxpos]) mxpos=i;
    }
    forn(i,n){
        if(i==mxpos) continue;
        if(v[i]>mx2) mx2=v[i];
    }
    forn(i,n){
        if(i==mxpos) cout<<mx2<<endl;
        else cout<<v[mxpos]<<endl;
    }
}

Measured memory_bytes: 2432
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, std.bitmanip;

void main() {
    auto S = readln.chomp;
    auto N = S.length.to!int;

    int[] cnt = new int[](26);
    foreach (s; S) cnt[s-'a'] += 1;

    if (cnt.map!(c => c % 2).sum > 1) {
        writeln(-1);
        return;
    }

    int[] cnt2 = new int[](26);
    string s1, s2;

    foreach(s; S) {
        int c = s - 'a';
        cnt2[c] += 1;
        if (cnt2[c] <= (cnt[c] + 1) / 2) s1 ~= s;
        else s2 ~= s;
    }

    auto number = new int[][](26);
    int tmp = 0;
    foreach (s; s1) number[s-'a'] ~= tmp++;

    int[] cnt3 = new int[](26);
    int[] new_s = new int[](N);
    foreach (i; 0..N) {
        int c = S[N-i-1] - 'a';
        if (cnt3[c] + 1 == number[c].length && cnt[c] % 2) new_s[i] = 2*N - 2, cnt3[c]++;
        else if (cnt3[c] < number[c].length) new_s[i] = number[c][cnt3[c]++];
        else new_s[i] = 2*N-1;
    }
    
    auto st = new SegmentTree(2*N+1);
    long ans;
    foreach (s; new_s) {
        ans += st.sum(s+1, 2*N+1);
        st.add(s, 1);
    }
    ans.writeln;
}

class SegmentTree {
    long[] table;
    int size;

    this(int n) {
        assert(bsr(n) < 29);
        size = 1 << (bsr(n) + 2);
        table = new long[](size);
    }

    void add(int pos, long num) {
        return add(pos, num, 0, 0, size/2-1);
    }

    void add(int pos, long num, int i, int left, int right) {
        table[i] += num;
        if (left == right)
            return;
        auto mid = (left + right) / 2;
        if (pos <= mid)
            add(pos, num, i*2+1, left, mid);
        else
            add(pos, num, i*2+2, mid+1, right);
    }

    long sum(int pl, int pr) {
        return sum(pl, pr, 0, 0, size/2-1);
    }

    long sum(int pl, int pr, int i, int left, int right) {
        if (pl > right || pr < left)
            return 0;
        else if (pl <= left && right <= pr)
            return table[i];
        else
            return
                sum(pl, pr, i*2+1, left, (left+right)/2) +
                sum(pl, pr, i*2+2, (left+right)/2+1, right);
    }
}

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


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

    int A,B,K;
    cin >> A >> B >> K;

    if(B-A+1<=2*K){
        for(int i=A;i<=B;i++) cout << i << endl;
    }
    else{
        for(int i=A;i<=A+K-1;i++) {
            cout << i << endl;
        }
        for(int i=B-K+1;i<=B;i++) {
            cout << i << endl;
        }
    }


}


Measured memory_bytes: 256
process.stdin.resume();
process.stdin.setEncoding("utf-8");

process.stdin.on("data", function(chunk){
  var array = chunk.replace("\n", "").split(" ");
  var a = array[0];
  var b = array[1];
  var c = Math.pow(b-1, a-1);
  var result = b * c;
  process.stdout.write(JSON.stringify(result));
})


Measured memory_bytes: 7028
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <queue>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct TEMP_OMAZINAI_ { TEMP_OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } TEMP__omazinai_instance__;
#define INF ((1LL<<61) + (1<<29))
#define YesNo(x) {std::cout << ((x)?"Yes":"No") << std::endl;}
#define YESNO(x) {std::cout << ((x)?"YES":"NO") << std::endl;}
#define OddEven(x) {std::cout << ((x)%2?"Odd":"Even") << std::endl;}
#define ODDEVEN(x) {std::cout << ((x)%2?"ODD":"EVEN") << std::endl;}
typedef long long int ll;
ll my_gcd(ll a, ll b) { return b ? my_gcd(b, a%b) : a; };
void TEMP_INPUT_IMPL_() {};
template <class T, class... Args> void TEMP_INPUT_IMPL_(T& dest, Args&... args) { cin >> dest; TEMP_INPUT_IMPL_(args...); }
void TEMP_OUTPUT_IMPL_() {};
template <class T, class... Args> void TEMP_OUTPUT_IMPL_(T dest, Args... args) { cout << dest << (sizeof...(Args) ? " " : ""); TEMP_OUTPUT_IMPL_(args...); }
#define in(type, ...) type __VA_ARGS__; TEMP_INPUT_IMPL_(__VA_ARGS__)
#define in_v(type, name, cnt) vector<type> name(cnt); loop(i, cnt) cin >> name[i];
#define sort_v(v) std::sort(v.begin(), v.end())
#define unique_v(v) v.erase(std::unique(v.begin(), v.end()), v.end()) //必ずソート後に実行
#define out(...) (TEMP_OUTPUT_IMPL_(__VA_ARGS__), std::cout<<std::endl)
#define set_fix(x) ((std::cerr<<std::fixed<<std::setprecision(x)),(std::cout<<std::fixed<<std::setprecision(x)))
//小さい方に寄る
#define space_op(x, y, a, b, c) ([](auto x_, auto y_, auto a_, auto b_, auto c_){if(x_<y_)return a_;if(x_>y_)return c_;return b_;}(x,y,a,b,c))
#define space_out(x, y, a, b, c) out(space_op(x, y, a, b, c))
 
 // ^^^ Template ^^^ //

int main() {
	in(ll, x);
	ll ans = x / 11;
	ans *= 2;
	x %= 11;
	if(x == 0)
		cout << ans << endl;
	else if(x <= 6)
		cout << ans + 1 << endl;
	else
		cout << ans + 2 << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

vector<int> cnt;
vector<pii> ans;

int n, m;
vector<vector<int>> tree;

void bfs() {
  queue<int> q;
  q.push(0);
  cnt[0] = 1;
  ans[0] = pii(-1,0);
  while(!q.empty()) {
    int i = q.front();
    q.pop();
    for(int j: tree[i]) {
      if (cnt[j]) continue;
      cnt[j] = 1;
      ans[j] = pii(i, ans[i].second);
      q.push(j);
    }
  }
}

void solve() {
  cin >> n >> m;
  tree.resize(n);
  cnt.resize(n);
  ans.resize(n);
  rep(i,m) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    tree[a].push_back(b);
    tree[b].push_back(a);
  }

  bfs();
  bool b = true;
  rep(i,n) if (!cnt[i]) b = false;
  if (!b) cout << "No" << endl;
  else {
    cout << "Yes" << endl;
    rep(i,n-1) cout << ans[i+1].first + 1 << endl;
  }

}

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

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

using namespace std;

using LL = long long;
const LL INF = (LL)1e9 + 7;
const LL NS = (LL)1e15;
LL era[(LL)4e7 + 4];
vector < LL > prime;
LL ans = (LL)1e18;

pair<LL, LL> extended_euclidean(LL a, LL b) {
    if (b == 0)
        return {1, 0};
    LL g, x, y;
    pair < LL, LL > gap = extended_euclidean(b, a%b);
    x = gap.first, y = gap.second;
    return {y, x-(a/b)*y};
}

void dfs(LL pos, LL A, LL B){
    if(pos >= (LL)prime.size()){
        auto rv = extended_euclidean(B, A);
        LL gap = -rv.second;
        if(gap <= 0) gap += (-gap / B) * B + 2 * B;
        gap %= B;
        if(!gap) gap = B;
        gap = max(gap, (B - 1) / A + ((B - 1) % A > 0));
        ans = min(ans, gap * A);
        return;
    }
    dfs(pos + 1, A * prime[pos], B);
    dfs(pos + 1, A, B * prime[pos]);
}

int main(){
    era[1] = 1;
    for(LL i = 2; i * i <= NS; ++i){
        if(era[i]) continue;
        for(LL j = i + i; j * j <= NS; j += i){
            era[j] = 1;
        }
    }
    LL N;
    scanf("%lld", &N);
    N *= 2;
    for(LL i = 2; i * i <= N; ++i){
        if(era[i] || N % i) continue;
        prime.push_back(1);
        while(N % i == 0){
            N /= i; prime.back() *= i;
        }
    }
    if(N > 1) prime.push_back(N);
    dfs(0, 1, 1);
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 250884
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
using namespace std;


int main (int argc, char const *argv[])
{
    string A;
    cin>>A;

    if (A[0]!=A[1]&&A[1]!=A[2]&&A[2]!=A[0]) {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 1e18;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, a, b) for (int i = b - 1; i >= a; i--)
#define int ll
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

signed main() {
    int h, w, k;
    cin >> h >> w >> k;
    char g[h][w];
    int ans[h][w] = {};
    rep(i, 0, h) rep(j, 0, w) ans[i][j] = 0;
    int cnt = 0;
    rep(i, 0, h) {
        rep(j, 0, w) {
            cin >> g[i][j];
            if (g[i][j] == '#') {
                ans[i][j] = ++cnt;
            }
        }
    }
    rep(i, 0, h) {
        rep(j, 1, w) {
            if (ans[i][j] == 0) ans[i][j] = ans[i][j - 1];
        }
        per(j, 0, w - 1) {
            if (ans[i][j] == 0) ans[i][j] = ans[i][j + 1];
        }
    }
    rep(i, 1, h) {
        if (ans[i][0] == 0) {
            rep(j, 0, w) ans[i][j] = ans[i - 1][j];
        }
    }
    per(i, 0, h - 1) {
        if (ans[i][0] == 0) {
            rep(j, 0, w) ans[i][j] = ans[i + 1][j];
        }
    }
    rep(i, 0, h) {
        rep(j, 0, w) cout << ans[i][j] << " ";
        cout << "\n";
    }
}

Measured memory_bytes: 4320
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)
#define REV(X, Y, Z) for (ll(X) = (Y); (X) > (Z); (X)--)

using namespace std;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMod = 1e9 + 7;

ll gcd(ll a, ll b) {
  if (a < b) {
    return gcd(b, a);
  }
  ll c = a % b;
  while (c != 0) {
    a = b;
    b = c;
    c = a % b;
  }
  return b;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

  ll N;
  cin >> N;
  umll A;
  REP(i, 0, N) {
    ll a;
    cin >> a;
    if (A.find(a) != A.end()) {
      A[a]++;
    } else {
      A.emplace(a, 1);
    }
  }
  cout << count_if(A.begin(), A.end(), [](pll p) {
    return p.second > 0 && p.second % 2 != 0;
  }) << endl;

  return 0;
}


Measured memory_bytes: 4388
N = int(input())
A = list(map(int,input().split()))
gu=False
min_i = [0,10**5]
count = 0
for i in range(N):
    if(A[i] < 0):
        count = count + 1

if(count%2 == 0):
    gu=True

if(gu or 0 in A):
    print(sum(list(map(abs,A))))
else:

    for i in range(N):
        if(abs(A[i])<min_i[1]):
            min_i[0] = i
            min_i[1] = abs(A[i])
    a =sum(list(map(abs,A)))
    print(a-min_i[1]*2)


Measured memory_bytes: 14436
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

fn solve() {
    input! {
        s: Chars
    };

    let mut res = 0;
    let mut c = 0;
    let mut prev = 'x';
    for ch in s {
        if ch == 'R' {
            if prev == 'R' {
                c += 1;
            } else {
                c = 1;
            }
        } else {
            c = 0;
        };
        if c > res {
            res = c;
        }
        prev = ch;
    }
    println!("{}", res);
}

fn main() {
    std::thread::Builder::new()
        .name("big stack size".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(|| {
            solve();
        })
        .unwrap()
        .join()
        .unwrap();
}


Measured memory_bytes: 2272
N = int(input())
result = [1, 0]
for i in range(2, N+1, 2):
    count = 0
    tmp = i
    while True:
        if tmp % 2:
            break
        tmp = tmp / 2
        count += 1
    if count > result[1]:
        result[0] = i
        result[1] = count
print(result[0])


Measured memory_bytes: 3060
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;
 
template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)
 
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;
  

int main() {
    string S;
    cin >> S;
    string D[7] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};

    rep(i,7){
        if (D[i] == S) cout << 7 - i << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for (ll i = (ll)(n) - 1; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1LL << 62)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second > b.second;
    }
}

template <typename T> 
ostream& operator<<(ostream& os, const vector<T>& v) 
{ 
    for (int i = 0; i < (int)v.size(); ++i) { 
        os << v[i]; 
        if (i != (int)v.size() - 1) 
            os << " "; 
    } 
    return os; 
} 

bool pairCompareS(const P& firstElof, const P& secondElof)
{
    return firstElof.second < secondElof.second;
}

int main()
{
    ll N, M;
    cin >> N >> M;
    vector<P> p(M);
    rep(i, M) {
        ll a,b;
        cin >> a >> b;
        a--; b--;
        p[i] = P(a,b);
    }
    sort(all(p), pairCompareS);
    ll pre = -1;
    ll cnt = 0;
    rep(i, M) {
        if (p[i].first > pre) {
            pre = p[i].second-1;
            cnt++;
        }
    }
    print(cnt);
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <map>
using namespace std;

#define INF 1e9
#define LLINF 1e18
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;

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


int main() {
    char a;
    cin >> a;
    if (a - 'a' >= 0) cout << 'a' << endl;
    else cout << 'A' << endl;
}

Measured memory_bytes: 3600
#include<stdio.h>
 
int max(int a,int b){return (a<b?b:a);};
typedef struct {
  int p,s,deg,dep,h,left,right;
} Node;
 
Node t[100000];
int n;
 
void setdepth(int x){
  if(t[x].p==-1){
    t[x].dep=0;
    return;
  }
  if(t[x].dep==-1){
    setdepth(t[x].p);
    t[x].dep=t[t[x].p].dep+1;
  }
}
 
void setheight(int x){
 
  int l=t[x].left;
  int r=t[x].right;
  if(t[x].deg==0){
    t[x].h=0;
    return;
  }
  if(t[x].h==-1){
    if(l!=-1){
      setheight(l);
      t[x].h=max(t[x].h,t[l].h+1);
    }
    if(r!=-1){
      setheight(r);
      t[x].h=max(t[x].h,t[r].h+1);
    }
  }
}
 
void init(){
  int i;
  for(i=0;i<100000;i++){
    t[i].p=t[i].s=t[i].deg=t[i].dep=t[i].h=t[i].left=t[i].right=-1;
  }
}
 
int main(){
  init();
  int i,id,a,b;
 
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d %d %d",&id,&a,&b);
    if(a!=-1){
      t[id].left=a;
      t[a].p=id;
    }
    if(b!=-1){
      t[id].right=b;
      t[b].p=id;
    }
    if(a!=-1&&b!=-1){
      t[a].s=b;
      t[b].s=a;
    }
    t[id].deg=(a!=-1)+(b!=-1);
    
  }
 
  for(i=0;i<n;i++){
    printf("node %d: parent = %d, sibling = %d, degree = %d, ",i,t[i].p,t[i].s,t[i].deg);
    setdepth(i);
    setheight(i);
    printf("depth = %d, height = %d, ",t[i].dep,t[i].h);
     
    if(t[i].p==-1)printf("root\n");
    else if(t[i].deg!=0)printf("internal node\n");
    else printf("leaf\n");
     
  }
  return 0;
}

Measured memory_bytes: 3776
// Ballazt
//0a..brute force
//0b..greedy
//1..memorizatton of some sort	remember something cleverly
//2..sort
//3..binary search	keep check a particular solution
//4..dp				repeating strucutre,limited choices
//5..dfs/bfs		matrix with obstacles
//6..correlate to graph in some way		each state is a point
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl "\n"


const int maxn=2e5+10;

ll d[maxn]={-1};
int main()

{
	ios::sync_with_stdio(0);
	cin.tie(0);

	
	int n,s;
	cin>>n;

	s=n-(n/10)*10;

	if(s==3) cout<<"bon";

	else if(s==0||s==1||s==6||s==8) cout<<"pon";

	else cout<<"hon";

	
}

Measured memory_bytes: 3712
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#define int long long
using namespace std;

int n;
int p[100000];
bool f[100001];

signed main() {
	int i;
	
	cin >> n;
	for (i = 0; i < n; i++) { cin >> p[i]; f[i] = (p[i] == i + 1); }
	
	//ox→xx, oo→xx, 全部xにするには？
	//貪欲にやればよい
	int ans = 0;
	for (i = 0; i < n; i++) {
		if (f[i] == true) {
			f[i] = false;
			f[i + 1] = false;
			ans++;
		}
	}
	
	cout << ans << endl;
	return 0;
}

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

using namespace std;

int main()
{
    string s,t;
    cin>>s>>t;
    int s1 = s.length();
    int s2 = t.length();
    int arr[s1+1][s2+1];
    for(int i=0;i<=s1;i++)
        arr[i][0] = 0;
    for(int i=0;i<=s2;i++)
        arr[0][i] = 0;
    for(int i=1;i<=s1;i++)
    {
        for(int j=1;j<=s2;j++)
        {
            if(s[i-1] == t[j-1])
            {
                arr[i][j] = max(arr[i-1][j-1]+1 , max(arr[i-1][j] , arr[i][j-1]));
            }
            else
                arr[i][j] = max(arr[i-1][j-1] , max(arr[i-1][j] , arr[i][j-1]));
        }
    }
    string ans = "";
    if(arr[s1][s2] == 0)
        cout<<"";
    else{
        int x = s1;
        int y = s2;
        while(true)
        {
           if(s[x-1] == t[y-1] && arr[x][y] == (arr[x-1][y-1]+1))
           {
               ans = ans+s[x-1];
               x = x-1;
               y = y-1;
           }
           else
           {
               if(arr[x][y] == arr[x-1][y])
               {
                   x = x-1;
                   y = y;
               }
               else if(arr[x][y] == arr[x][y-1])
               {
                   x = x;
                   y = y-1;
               }
               else
               {
                   x = x-1;
                   y = y-1;
               }
           }
           if(arr[x][y] == 0)
           {
            break;
           }
        }
        string ans2 = "";
        for(int i=ans.length()-1;i>=0;i--)
        {
            ans2 = ans2+ans[i];
        }
        cout<<ans2;
    }
}









Measured memory_bytes: 35456