akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <vector>

const int MAX_N = 100000;
const int MOD = 1e9 + 7;

struct DFS {
  int countWhite;
  int countBlack;
};

std::vector<int> neighbours[1 + MAX_N];

void mulSelf(int &a, int b) {
  a = (long long)a * b % MOD;
}

int add(int a, int b) {
  a += b;
  if (a >= MOD)
    a -= MOD;
  return a;
}

DFS dfs(int v, int p = -1) {
  DFS dfsV = {1, 1};
  for (int c : neighbours[v]) {
    if (c != p) {
      DFS dfsC = dfs(c, v);
      mulSelf(dfsV.countWhite, add(dfsC.countWhite, dfsC.countBlack));
      mulSelf(dfsV.countBlack, dfsC.countWhite);
    }
  }
  return dfsV;
}

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    neighbours[u].push_back(v);
    neighbours[v].push_back(u);
  }
  DFS dfsRoot = dfs(1);
  int answer = add(dfsRoot.countWhite, dfsRoot.countBlack);
  printf("%d\n", answer);
  return 0;
}


Measured memory_bytes: 12672
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;

using namespace std;

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

  string t;
  
  rep(i, n) {
    int q;
    cin >> q;
    if (q == 1) {
      swap(s,t);
      continue;
    }
    int q2;
    char c;
    cin >> q2 >> c;
    if (q2 == 1) {
      t += c;
    } else {
      s += c;
    }
  }
  reverse(t.begin(), t.end());
  t += s;
  cout << t << endl;
}


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

int N, X[111], Y[111], d[111], sum = 0, a[111], b[111], ans;

int main(){
	
	cin >> N;
	for (int i = 0; i < N; i ++) cin >> X[i];
	for (int i = 0; i < N; i ++) cin >> Y[i];
	for (int i = 0; i < N; i ++) sum = sum + Y[i];
	a[0] = X[0]; for (int i = 1; i < N; i ++) a[i] = a[i - 1] + X[i];
	b[0] = sum; for (int i = 1; i < N; i ++) b[i] = b[i - 1] - Y[i - 1];
	for (int i = 0; i < N; i ++) d[i] = a[i] + b[i];
	for (int i = 0; i < N; i ++) ans = max(ans, d[i]);
	cout << ans;
	
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author tarek
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        ATenki solver = new ATenki();
        solver.solve(1, in, out);
        out.close();
    }

    static class ATenki {
        public void solve(int testNumber, InputReader in, OutputWriter out) {
            String s1 = in.readLine();
            String s2 = in.readLine();
            int count = 0;
            for (int i = 0; i < s1.length(); i++) {
                if (s1.charAt(i) == s2.charAt(i)) {
                    count++;
                }
            }
            out.printLine(count);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        private String readLine0() {
            StringBuilder buf = new StringBuilder();
            int c = read();
            while (c != '\n' && c != -1) {
                if (c != '\r') {
                    buf.appendCodePoint(c);
                }
                c = read();
            }
            return buf.toString();
        }

        public String readLine() {
            String s = readLine0();
            while (s.trim().length() == 0) {
                s = readLine0();
            }
            return s;
        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void close() {
            writer.close();
        }

        public void printLine(int i) {
            writer.println(i);
        }

    }
}



Measured memory_bytes: 21204
#include<stdio.h>

int n;
int a[1000010];
int ans[100],len;
int cnt;

int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++)scanf("%d",a+i);
	ans[len++]=1;
	while(ans[len-1]*3+1<n)ans[len]=ans[len-1]*3+1,len++;
	for(int k=len-1;k>=0;k--){
		for(int i=0;i<n;i++){
			int t=a[i];
			int j=i;
			while(j-ans[k]>=0&&a[j-ans[k]]>t){
				a[j]=a[j-ans[k]];
				j-=ans[k];
				cnt++;
			}
			a[j]=t;
		}
	}
	printf("%d\n",len);
	for(int i=len-1;i>=0;i--)printf("%d%c",ans[i],i?32:10);
	printf("%d\n",cnt);
	for(int i=0;i<n;i++)printf("%d\n",a[i]);
}


Measured memory_bytes: 5640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C;
  cin >> A >> B >> C;
  if (A == B) {
    if (B != C) {
      cout << "Yes" << endl;
    }
	else {
      cout << "No" << endl;
    }
  }
  else {
    if (C == A || C == B) {
	  cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 200010;
int n,rec[N][26],las[N][26],sta[26],cur[26];
char s[N];
void solve(int p) {
  if (p > n) return;
  for (int i = 0 ; i < 26 ; ++ i) {
    if (!las[p][i]) {
      cout << (char)(i + 'a');
      solve(rec[p][i]);
      return;
    }
  }
}
int main() {
  scanf("%s",s+1);
  n = strlen(s+1);
  for (int i = 0 ; i < 26 ; ++ i)
    sta[i] = n + 1;
  for (int i = n ; i >= 0 ; -- i) {
    for (int j = 0 ; j < 26 ; ++ j)
      las[i][j] = cur[j], rec[i][j] = sta[j];
    if (!i) break;
    cur[s[i] - 'a'] = i;
    sta[s[i] - 'a'] = i;
    int key = 1;
    for (int i = 0 ; i < 26 ; ++ i)
      key &= (cur[i] > 0);
    if (key) memset(cur,0,sizeof cur);
  }
  solve(0);
  cout << endl;
  return 0;
}


Measured memory_bytes: 41472
#!/usr/bin/env python3
import sys


def solve(X: int, A: int):
    if X < A:
        ret = 0
    else:
        ret = 10
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    solve(X, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
                     
#define int             long long
#define ld              long double
#define mp              make_pair
#define ff              first
#define ss              second
#define pb              push_back
#define fo(i,n)         for(i=0;i<n;i++)
#define fo1(i,n)        for(i=1;i<=n;i++)
#define FO(i,k,n)       for(i=k;k<=n?i<=n:i>=n;k<=n?i++:i--)
#define all(c)          c.begin(),c.end()
#define rall(c)         c.rbegin(),c.rend()
#define si              set<int>
#define vi              vector<int>
#define mii             map<int,int>
#define pii             pair<int,int>
#define vpii            vector<pii>
#define vvi             vector<vi>
#define usi             unordered_set<int>
#define umii            unordered_map<int,int>
#define pqmx            priority_queue<int>
#define pqmn            priority_queue<int,vi,greater<int> >
#define sp(x)           cout<<setprecision(x)<<fixed;
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)     __builtin_ctzll(x)
#define in(a,n)         vi a(n);fo(i,n)cin>>a[i];
#define in1(a,n)        vi a(n+1);fo1(i,n)cin>>a[i];
#define w(t)            int t;cin>>t;while(t--)
#define gcd             __gcd
#define lcm(x,y)        x*(y/gcd(x,y))
#define endl            '\n'
#define PI              3.14159265358979323846
const int inf =         1e18;
const int mod =         1e9+7;
void __p(int x) {cout<<x;}
void __p(int32_t x){cout<<x;}
void __p(float x){cout<<x;}
void __p(double x){cout<<x;}
void __p(ld x) {cout<<x;}
void __p(char x){cout <<'\''<<x<<'\'';}
void __p(const char *x){cout <<'\"' <<x<<'\"';}
void __p(const string &x) {cout<<'\"'<<x<<'\"';}
void __p(bool x) {cout<<(x?"true":"false");}
void _p() {cout << "]\n";}
template<typename T,typename V>     void __p(const pair<T,V> &x) {cout<<'{';__p(x.first);cout<<',';__p(x.second);cout<<'}';}
template<typename T>                void __p(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __p(i); cout << "}";}
template <typename T,typename... V> void _p(T t, V... v) {__p(t);if(sizeof...(v))cout<<", ";_p(v...);}
int po(int x,int p,int m = inf) {int ans=1;x%=m;while(p>0){if(p&1)ans=(ans*x)%m;p=p>>1;x=(x*x)%m;}return ans;}
int inv(int x,int m=mod){return po(x,m-2,m)%m;}
#ifndef ONLINE_JUDGE
#define dbg(x...) cout<<"["<<#x<<"]=[";_p(x)
#else 
#define dbg(x...)
#endif
//=================================================================================




const int N=1e6+6;
int n,m,k,x,y,z,a,b,c,d,i,j,l,r,f;








void sol()
{   string a,b;
    cin>>a>>b;
    x=0;
    fo(i,a.size())
    {
        if(a[i]!=b[i])x++;
    }
    
    
    cout<< x <<endl;
}





int32_t main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //sp(10);
    // w(t)
    sol();
    return 0;
}

Measured memory_bytes: 3808
#include<stdio.h>
#include<ctype.h>
int main(){
  char ch;
  while(1){
  scanf("%c",&ch);
  if(islower(ch)){
    printf("%c", toupper(ch));
  } else{
      printf("%c",tolower(ch));  
    }
 

  if(ch=='\n') break;
  }
  return 0;
}

Measured memory_bytes: 524
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repo(i, n) for(int i=1; i<=n; i++)
#define INF 1001001001
#define INFll 100100100100100
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

using namespace std;
using ull = unsigned long long;
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

ll f(ll num)
{
    if (num < 2) return 1;
    else if (num == 2) return 2;
    else if (num % 2 == 0) return 2; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (ll i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return i;
        }
    }

    // 素数である
    return num;
}

vector<ll> factorList(ll x) {
  vector<ll> res;
  while (x != 1) {
    res.push_back(f(x));
    x /= f(x);
  }
  return res;
}

int main(){
  ll a, b;
  cin >> a >> b;
  vector<ll> af=factorList(a);
  vector<ll> bf=factorList(b);
  map<ll, int> ma;
  ll ans=1;
  for(ll p: af){
    ma[p]++;
  }
  for(ll p: bf){
    if(ma[p]>0){
      ma[p]=0;
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <cstdint>
#include <unordered_set>
#include <ctime>
#include <numeric>
#include <cstdint>

using llint = long long int;

void solve(void){

  int h, w, m;
  std::cin >> h >> w >> m;
  
  std::vector<int> h_cnt(h+1);
  std::vector<int> w_cnt(w+1);

  std::set<std::array<int, 2> > things;
  for(int i=0; i<m; i++){
    std::array<int, 2> tmp;
    std::cin >> tmp[0] >> tmp[1];
    things.insert(tmp);
    
    h_cnt[tmp[0]]++;
    w_cnt[tmp[1]]++;
  }

  int max_h_cnt = 0, max_w_cnt = 0;
  for(int i=0; i<h_cnt.size(); i++){
    max_h_cnt = std::max(max_h_cnt, h_cnt[i]);
  }
  for(int i=0; i<w_cnt.size(); i++){
    max_w_cnt = std::max(max_w_cnt, w_cnt[i]);
  }

  std::vector<int> possible_h;
  for(int i=0; i<h_cnt.size(); i++){
    if(max_h_cnt == h_cnt[i]) possible_h.push_back(i);
  }
  std::vector<int> possible_w;
  for(int i=0; i<w_cnt.size(); i++){
    if(max_w_cnt == w_cnt[i]) possible_w.push_back(i);
  }

  for(const auto& elem_h: possible_h){
    for(const auto& elem_w: possible_w){
      if(things.find({elem_h, elem_w}) == things.end()){
	std::cout << max_h_cnt + max_w_cnt << std::endl;
	return;
      }
    }
  }

  std::cout << max_h_cnt + max_w_cnt -1 << std::endl;
  
  return;
}
int main(void){
  solve();
  return 0;
}





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

#define ll long long
#define INF_LL 1LL << 60
#define INF 99999999
#define MOD (ll)1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, a, n) for(int i = a; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

void put_double(double obj){printf("%.12f\n",obj);};

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }


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

    ll ans = 1;

    rep(i,N)
    {
        chmax(ans, min(ans*2, ans+K) );
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
const long long MOD=1e9+7;

using namespace std;

string s;
long long dp1[100009], dp2[100009];


void solve(){
    dp1[0] = 1;
    dp2[0] = 2;
    for(int i=1;i<s.length();i++){
        if(s[i]=='1'){
            dp1[i] = (dp1[i-1] * 3 + dp2[i-1])%MOD;
            dp2[i] = (dp2[i-1] * 2)%MOD;
        }
        else if(s[i] == '0'){
            dp1[i] = (dp1[i-1] * 3)%MOD;
            dp2[i] = dp2[i-1];
        }
    }
    cout << (dp1[s.length()-1] + dp2[s.length()-1])%MOD << endl;
}

int main(){
    cin >> s;
    solve();
}

Measured memory_bytes: 2048
//Author: AnandRaj doubleux
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll; 

#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define test() int t;cin>>t;while(t--)
#define forn(i,f,n) for(int i=f;i<f+n;i++)
#define rforn(i,l,n) for(int i=l;i>l-n;i--)
#define all(v) v.begin(),v.end()
#define prin(V) for(auto v:V) cout<<v<<" ";cout<<endl
#define take(V,f,n) for(int i=f;i<f+n;i++) cin>>V[i]
#define what(x) cerr<<#x<<" = "<<x<<endl
#define KStest() int t,t1;cin>>t;t1=t;while(t--)
#define KScout cout<<"Case #"<<t1-t<<": "

const int MOD = 1e9+7,MAX = 1e5+5;
/////////////////FastExp///////////////////
ll powN(ll a,ll p)
{
	if(p==0) return 1;
	ll z=powN(a,p/2);
	z=(z*z)%MOD;
	if(p%2) z=(z*a)%MOD;
	return z;
}
/////////////////FastExp///////////////////
//////////////////Sieve////////////////////
vector<bool> is_prime(MAX+1, true);
void Sieve()
{
	is_prime[0] = is_prime[1] = false;
	int i,j;
	for (i = 2; i*i <= MAX; i++) 
	{
    	if (is_prime[i]) 
    	{
        	for (j = i * i; j <= MAX; j += i)
            	is_prime[j] = false;
    	}
	}
}
//////////////////Sieve////////////////////

int main()
{	
	ll h,w;
	cin>>h>>w;
	if(h==1||w==1) {cout<<1<<endl;return 0;} 
	cout<<((h*w+1)/2)<<endl;
}		

Measured memory_bytes: 256
//QWsin
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define rep(i,x,y) for(int i=x;i<=y;++i)
#define out(i,u) for(int i=first[u];i!=-1;i=nxt[i])
#define repvc(i,vc) for(int i=0,Sz=vc.size();i<Sz;++i)
using namespace std;
inline int read()
{
	char ch=getchar();int ret=0,f=1;
	while(ch<'0' || ch>'9') {if(ch=='-')f=-1;ch=getchar();}
	for(;ch>='0' && ch<='9';ch=getchar()) ret=ret*10+ch-'0';
	return ret*f;
}

inline void print(string name,int *arr,int len){
	rep(i,1,len) printf("%s[%d]=%d\n",name.c_str(),i,arr[i]);puts("");
}
inline void print(string name,int a){
	printf("%s=%d\n",name.c_str(),a);puts("");
}

typedef long long ll;
const int INF=1<<30;

const int maxn=200000+10;

int a[maxn],dp[maxn],t[maxn];
int main()
{
	int n;cin>>n;
	rep(i,1,n) a[i]=read();
	int l=0;
	for(int i=n;i>=1;--i)
	{
		if(a[i]>=t[l]) t[++l]=a[i];
		else{
			int pos=upper_bound(t+1,t+l+1,a[i])-t;
			if(t[pos]==a[i]) ++pos;
			t[pos]=a[i];
			l=max(l,pos);
		}
	}
	cout<<l<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
using ll = int64_t;
int main(){
    string s;
    cin >> s;
    bool po = true;
    po &= s[0] == 'A';
    bool yo = false;
    for(ll i = 2; i < s.size() - 1; i++) yo |= (s[i] == 'C');
    po &= yo;
    ll count = 0;
    for(ll i = 0; i < s.size(); i++) if('A' <= s[i] && s[i] <= 'Z') count++;
    po &= (count == 2);
    cout << (po ? "AC" : "WA") << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main {
	
	public static void main(String[] args) {
	
		MyScanner sc = new MyScanner();
		Long a=sc.nextLong();
		Long b=sc.nextLong();
		Long x=sc.nextLong();
		Long A=a==0?0:(a-1)/x+1;
		Long B=b/x+1;
        System.out.println(B-A);
		
	}
	
	
	
	
//----------------------------------------------------------
	static int l_min(int[] a) {
		Arrays.sort(a);
		return a[0];
	}
	static int l_max(int[] a) {
		int l=a.length;
		Arrays.sort(a);
		return a[l-1];
	}
	public static PrintWriter out;

	public static class MyScanner {
		BufferedReader br;
		StringTokenizer st;

		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

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

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

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

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}

	}
	

}





Measured memory_bytes: 21332
#include<bits/stdc++.h>
#include<boost/algorithm/string/replace.hpp>
#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::algorithm;
using namespace boost::multiprecision;
 
#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;
 
const int INF = 1e9;
const int MOD = 1e9+7;

template<typename T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//C++17以上
template<typename T>
T GCD(T a,T b){ return b ? GCD(b,a%b) : a ;}
template<typename T>
T LCM(T a,T b){ return a*b / GCD(a,b) ;}

template<typename T>//文字列の置換/Boost:replace_all()
T replace_str(T str, string target, string str_to) {
    string::size_type pos = 0;
    while (pos = str.find(target, pos), pos != string::npos) {
        str.replace(pos, target.length(), str_to);
        pos += str_to.length();
    }
    return str;
}

int main(){
        int a,b;cin >> a >> b;
        cout << max({a+b,a-b,a*b}) << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.lang.Math;

public class Main {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int[] stones = new int[N];
        for(int i = 0; i < N; i++) stones[i] = scanner.nextInt();

        int[] dp = new int[N];
        dp[1] = Math.abs(stones[1] - stones[0]);
        for(int i = 2; i < N; i++) {
            dp[i] = Math.min(Math.abs(stones[i] - stones[i - 2]) + dp[i - 2],
                    Math.abs(stones[i] - stones[i - 1]) + dp[i - 1]);
        }
        System.out.println(dp[N - 1]);
    }
}

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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplece_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define Edge pair< i_i, int>
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; scanf("%lld", &x);
#define int2(x, y) int x, y; scanf("%lld %lld", &x, &y);
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
 
//int dxy[5] = {0, 1, 0, -1, 0};
// assign
 
signed main()
{
    Int(n);
    vi data(n*3), dpl(n+1), dpr(n+1);
    rep(i, data.size()) {
        cin >> data[i];
    }

    priority_queue<int> pq;
    int sum = 0;
    rep(i, n) {
        pq.push(-data[i]);
        sum += data[i];
    }
    dpl[0] = sum;
    Rep(i, n+1) {
        pq.push(-data[i+n-1]);
        sum += data[i+n-1];
        sum += pq.top(); pq.pop();
        dpl[i] = sum;
    }
    //rep(i, n+1) cout << dpl[i] << " "; cout << endl;

    priority_queue<int> pp;
    int sm = 0;
    reverse(all(data));
    rep(i, n) {
        pp.push(data[i]);
        sm += data[i];
    }
    dpr[0] = sm;
    Rep(i, n+1) {
        pp.push(data[i+n-1]);
        sm += data[i+n-1];
        sm -= pp.top(); pp.pop();
        dpr[i] = sm;
    }
    //rep(i, n+1) cout << dpr[i] << " "; cout << endl;

    int ans = -INF;
    rep(i, n+1) {
        ans = max(ans, dpl[i] - dpr[n-i]);
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 6516
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)

	writer := bufio.NewWriter(os.Stdout)

	n := getNextInt(scanner)
	d := getNextInt(scanner)
	xx := make([][]int, n)
	for i := 0; i < n; i++ {
		xx[i] = make([]int, d)
		for ii := 0; ii < d; ii++ {
			xx[i][ii] = getNextInt(scanner)
		}
	}

	ans := 0
	for i := 0; i < n-1; i++ {
		for j := i + 1; j < n; j++ {
			x := 0
			for ii := 0; ii < d; ii++ {
				x += (xx[j][ii] - xx[i][ii]) * (xx[j][ii] - xx[i][ii])
			}
			if root(x) {
				ans++
			}

		}
	}

	fmt.Fprintln(writer, ans)
	writer.Flush()
}

func root(x int) bool {
	for i := 1; i*i <= x; i++ {
		if i*i == x {
			return true
		}
	}
	return false
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    char C;
    cin >> C;
    char x = C + 1;
    cout << x << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
mt19937 rnd(1337);
#define rall(x) (x).rbegin(), (x).rend()
#define all(x) (x).begin(), (x).end()
#define pNN pair <Node *, Node *>
#define SZ(x) (int)(x).size()
#define pii pair <int, int>
#define pb push_back
#define rev reverse
#define ins insert
#define ers erase
#define S second
#define F first
const int N = 2e3 + 10, INF = 1e9 + 10;

vector <int> g[N];
bool used[N];
int d[N], ans[N];

void bfs(int start) {
	fill(used, used + N, false);
	queue <int> q;
	q.push(start);
	used[start] = true;
	d[start] = 0;
	while (SZ(q) > 0) {
		int v = q.front();
		q.pop();
		for (auto to : g[v]) {
			if (!used[to]) {
				used[to] = true;
				q.push(to);
				d[to] = d[v] + 1;
				++ans[d[to]];
			}
		}
	}
}

void solve() {
	int n;
	cin >> n;
	int x, y;
	cin >> x >> y;
	for (int i = 1; i < n; ++i) {
		g[i].pb(i + 1);
		g[i + 1].pb(i);
	}
	g[x].pb(y);
	g[y].pb(x);
	for (int i = 1; i <= n; ++i) {
		bfs(i);
	}
	for (int i = 1; i < n; ++i) {
		cout << ans[i] / 2 << '\n';
	}
}
 
signed main () {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.precision(12);
    #ifdef Solenoid555
        freopen("input.txt", "r", stdin);
    #endif
    solve();
    return 0;
}

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

int main(){
    long long n,m,ans;
    cin >> n >> m;
    if(m==1||n==1){
        ans = m * n -2;
        if(ans<0)ans = 0;
        if(m*n==1)ans=1;
    }else if(m==2||n==2){
        ans = 0;
    }else{
        ans = (m-2) * (n-2);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
constexpr int N = 2E5;
int n;
LL k;
int a[N], f[N];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n >> k;
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    for (int i = 0; i < n; ++i)
        cin >> f[i];
    sort(a, a + n);
    sort(f, f + n, greater<int>());
    LL l = 0, r = 1E12;
    while (l < r) {
        LL x = (l + r) / 2;
        LL need = 0;
        for (int i = 0; i < n; ++i)
            need += max(0LL, a[i] - x / f[i]);
        if (need <= k)
            r = x;
        else
            l = x + 1;
    }
    cout << l << endl;
    return 0;
}


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

class UnionFindTree {
   public:
    vector<int> parent;

    UnionFindTree(int n) {
        parent.resize(n);
        for (int i = 0; i < n; i++) {
            parent[i] = i;
        }
    }

    int root(int x) {
        if (parent[x] == x) return x;
        return parent[x] = root(parent[x]);
    }

    void unite(int x, int y) {
        int rx = root(x); int ry = root(y);
        if (rx == ry) return;
        parent[rx] = ry;
    }

    bool same(int x, int y) {
        return root(x) == root(y);
    }
};

int main() {
    int N, M; cin >> N >> M;
    
    vector<int> p(N);
    vector<int> idx(N + 1);
    REP(i, 0, N) {
        cin >> p[i];
        idx[p[i]] = i + 1;
    }

    UnionFindTree *uft = new UnionFindTree(N + 1);
    REP(i, 0, M) {
        int x, y; cin >> x >> y;
        uft->unite(x, y);
    }

    int ans = 0;
    REP(i, 0, N) {
        if (p[i] == i + 1) {
            ans++;
        }
        else if (uft->same(i + 1, idx[i + 1])) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

namespace _0272
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                int n = RInt();
                if (n == 0) break;

                int[] a = RArInt();
                int[] b = RArInt();

                Array.Sort(a); Array.Reverse(a);
                Array.Sort(b); Array.Reverse(b);

                Console.WriteLine(CalcMinK(a, b));
            }

        }

        static string CalcMinK(int[] a, int[] b)
        {
            BinaryIndexTree winCnt = new BinaryIndexTree(b.Length);
            int idxA = 0;
            for (int k = 0; k < b.Length; k++)
            {
                int requiredWinCnt = (k + 1) / 2 + 1;
                while (a[idxA] > b[k] && idxA < a.Length - 1) idxA++;
                winCnt.Add(idxA + 1, 1);
                if (k + 1 - winCnt.Sum(k + 1) >= requiredWinCnt) return (k + 1).ToString();
            }
            return "NA";
        }


        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RArSt(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RArInt(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RArLong(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RArDouble(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }

    class BinaryIndexTree　//添え字1始まり
    {
        private int N { get; set; }
        private int[] Bit { get; set; }

        public BinaryIndexTree(int n)
        {
            N = n; Bit = new int[n + 1];
        }

        public void Add(int idx, int value)
        {
            for (int i = idx; i <= N; i += i & -i) Bit[i] += value;
        }

        public int Sum(int idx) //bit[1]～bit[idx]までの和
        {
            int ret = 0;
            for (int i = idx; i > 0; i -= i & -i) ret += Bit[i];
            return ret;
        }
    }
}



Measured memory_bytes: 42924
import java.util.Scanner;

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

		for(int i = 0; i < S.length(); i++) {
			if(i % 2 == 0) {
				System.out.print(SArray[i]);
			}
		}
	}

}

Measured memory_bytes: 36024
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

template <class T>
bool INRANGE(T x, T a, T b) { return a <= x && x <= b; }
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;
}

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

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

    int r, D, x_2000;
    cin >> r >> D >> x_2000;

    int x = r*x_2000-D;
    REP(i,10){
        cout << x << endl;
        x = r*x-D;
    }

    return 0;
}


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

using namespace std;


void solve(long long N, vector<long double> x, vector<string> u)
{
    long double ans = 0;
    for (int i = 0; i < N; ++i) {
        if (u[i] == "JPY")
            ans += x[i];
        else
            ans += x[i] * (long double) 380000.0;
    }
    cout << fixed << setprecision(12) << ans << endl;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    long long N;
    cin >> N;
    vector<long double> x(N);
    vector<string> u(N);
    for(int i = 0 ; i < N ; i++){
        cin >> x[i];
        cin >> u[i];
    }
    solve(N, move(x), move(u));
    return 0;
}


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

#define rep(i, n) for ( int i = 0; i < (n); ++i )
using namespace std;
using ll =  long long;
using P = pair<ll, ll>;

int main( void )
{
	ll n;
	cin >> n;

	set<string> s;
	rep( i, n ) {
		string tmp;
		cin >> tmp;
		s.insert(tmp);
	}

	cout << s.size() << endl;

	return 0;
}


Measured memory_bytes: 19076
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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 (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;

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

	int N;
	cin >> N;
	map<int, int> vmap;
	vector<int> A(N);
	rep(i, 0, N)
	{
		cin >> A[i];
		vmap[A[i]]++;
	}

	int res = 0;
	for (auto p : vmap)
	{
		res += p.second*(p.second - 1) / 2;
	}

	rep(i, 0, N)
	{
		cout << res - vmap[A[i]] * (vmap[A[i]] - 1) / 2 + (vmap[A[i]] - 1)*(vmap[A[i]] - 2) / 2 << endl;
	}

	return 0;
}

Measured memory_bytes: 11136
/* monkukui 競技プログラミング用のテンプレート  (ここから) */
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
using ll = long long int;
using lnt = long long int;
using graph = vector<vector<long long int>>;
using wgraph = vector<vector<pair<long long int, long long int>>>;
long long int INF = 1001001001001001LL;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;
long long int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
long long int dj[] = {0, 1, 0, -1, 1, 1, -1, -1};

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;}
inline void yes(){ cout << "yes" << endl; }
inline void Yes(){ cout << "Yes" << endl; }
inline void YES(){ cout << "YES" << endl; }
inline void no(){ cout << "no" << endl; }
inline void No(){ cout << "No" << endl; }
inline void NO(){ cout << "NO" << endl; }
inline void possible(){ cout << "possible" << endl; }
inline void Possible(){ cout << "Possible" << endl; }
inline void POSSIBLE(){ cout << "POSSIBLE" << endl; }
inline void impossible(){ cout << "impossible" << endl; }
inline void Impossible(){ cout << "Impossible" << endl; }
inline void IMPOSSIBLE(){ cout << "IMPOSSIBLE" << endl; }

#define rep(i,n) for(long long int i = 0; i < (n); i++)
#define rrep(i,n) for(long long int i = 1; i <= (n); i++)
#define drep(i,n) for(long long int i = (n)-1; i >= 0; i--)
#define srep(i,s,t) for(long long int i = s; i < t; i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back

/* monkukui 競技プログラミング用のテンプレート (ここまで)*/

int main(){
  
  int n, k; cin >> n >> k;
  string s; cin >> s;
  s = "z" + s + "z";

  int ans = 0;

  char cur = 'a';
  int cnt = 0;
  
  int val = 0;

  rep(i, s.size()) {
    if(cur == s[i]) cnt++;
    else {
      if(s[i] != 'z') val++;
      ans += cnt;
      cur = s[i];
      cnt = 0;
    }
  }
  
  rep(i, k) {
    if(val == 1) break;
    else if(val == 2) {
      ans += 1;
      break;
    }else{
      ans += 2;
      val -= 2;
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
	vector<int> A1(3);
  	vector<int> A2(3);
  	vector<int> A3(3);
  int N;
  string Ans = "No";
  
  for(int i = 0;i<3;i++){
  cin >> A1.at(i);
  }
    for(int i = 0;i<3;i++){
  cin >> A2.at(i);
  }
    for(int i = 0;i<3;i++){
  cin >> A3.at(i);
  }
  
  cin >> N;
  vector<int>b(N);
  
      for(int i = 0;i<N;i++){
  cin >> b.at(i);
  }
  
  for(int i = 0; i < N; i++){
  	for(int j = 0; j < 3; j++){
    	if(b.at(i) == A1.at(j)){
        A1.at(j) = 0;
        }
          	if(b.at(i) == A2.at(j)){
        A2.at(j) = 0;
        }
          	if(b.at(i) == A3.at(j)){
        A3.at(j) = 0;
        }
    }
  }
  
  if(A1.at(0) == 0 && A2.at(0) == 0 && A3.at(0) ==0){
  Ans = "Yes";
  }
  if(A1.at(1) == 0 && A2.at(1) == 0 && A3.at(1) ==0){
  Ans = "Yes";
  }
  if(A1.at(2) == 0 && A2.at(2) == 0 && A3.at(2) ==0){
  Ans = "Yes";
  }
  if(A1.at(0) == 0 && A1.at(1) == 0 && A1.at(2) ==0){
  Ans = "Yes";
  }
  if(A2.at(0) == 0 && A2.at(1) == 0 && A2.at(2) ==0){
  Ans = "Yes";
  }
  if(A3.at(0) == 0 && A3.at(1) == 0 && A3.at(2) ==0){
  Ans = "Yes";
  }
  
  if(A1.at(0) == 0 && A2.at(1) == 0 && A3.at(2) ==0){
  Ans = "Yes";
  }
  
  if(A3.at(0) == 0 && A2.at(1) == 0 && A1.at(2) ==0){
  Ans = "Yes";
  }
  
  cout << Ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int n, K;
ll L;
int a[SIZE];

bool check(int x){
  int r = 0;
  int counter = 0;
  ll res = 0;
  
  for(int l=0;l<n;l++){
    while(counter < K && r < n){
      counter += a[r] <= x;
      r++;
    }

    if(r == n && counter < K) break;
    
    res += n - r + 1;
    
    counter -= a[l] <= x;
  }
  
  return res >= L;
}

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

  for(int i=0;i<n;i++)
    scanf("%d", a+i);

  int l = 1, r = n;

  while(l < r){
    int mid = (r+l)/2;

    if(check(mid)){
      r = mid;
    }else{
      l = mid + 1;
    }
  }
  
  printf("%d\n", l);
  
  return 0;
}



Measured memory_bytes: 4000
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for (int i = a; i < b; i++)
using namespace std;

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <tuple>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <stack>
#include <bitset>

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

	int a = s[0] - '0';
	int b = s[1] - '0';
	int c = s[2] - '0';
	int d = s[3] - '0';
	
	if (a + b + c + d == 7) cout << s[0] << "+" << s[1] << "+" << s[2] << "+" << s[3] << "=7" << endl;
	else if (a - b + c + d == 7) cout << s[0] << "-" << s[1] << "+" << s[2] << "+" << s[3] << "=7" << endl;
	else if (a + b - c + d == 7) cout << s[0] << "+" << s[1] << "-" << s[2] << "+" << s[3] << "=7" << endl;
	else if (a + b + c - d == 7) cout << s[0] << "+" << s[1] << "+" << s[2] << "-" << s[3] << "=7" << endl;
	else if (a - b - c + d == 7) cout << s[0] << "-" << s[1] << "-" << s[2] << "+" << s[3] << "=7" << endl;
	else if (a - b - c - d == 7) cout << s[0] << "-" << s[1] << "-" << s[2] << "-" << s[3] << "=7" << endl;
	else if (a + b - c - d == 7) cout << s[0] << "+" << s[1] << "-" << s[2] << "-" << s[3] << "=7" << endl;
	else if (a - b + c - d == 7) cout << s[0] << "-" << s[1] << "+" << s[2] << "-" << s[3] << "=7" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void) 
{
    int N, M, s[100], c[100], i,t, number;
    int num[40] = {0};
    number = 0;
 
    scanf("%d%d", &N, &M);
 
    for (i = 1; i <= M; i++){
        scanf("%d%d", &s[i], &c[i]);
    }
 
    for (i = 1; i <= M; i++){
        if (N != 1 && s[i] == 1 && c[i] == 0)
        number = -1;
    }
 
    for (i = 1; i <= M; i++){
        for (t = 1; t <= M; t++){
            if (s[i] == s[t] && c[i] != c[t])
                number = -1;
        }
    }
 
    if (number == -1)
        printf("%d", number);    
    
    else{
        for (i = 1; i <= M; i++){
            switch (s[i]){
                case 1: num[1] = c[i]; break;
                case 2: num[2] = c[i]; break;
                case 3: num[3] = c[i]; break;
            }
        }
    if (N == 2 && num[1] == 0)
        num[1] = 1;
    if (N == 3 && num[1] == 0)
        num[1] = 1;
        
    if (N == 1)
        printf("%d", num[1]);
    else if (N == 2)
        printf("%d", 10*num[1] + num[2]);
    else 
        printf("%d", 100*num[1] + 10*num[2] + num[3]);
    }
    return 0;
}

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 1e6 + 5;





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

    int a,b,c;
    cin>>a>>b>>c;
    if (a==b && a==c && b==c) out("Yes");
    out("No");
    
    
    return 0;
}


Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
int main(){
    ios::sync_with_stdio(false);
    int a,b;
    cin >> a >> b;
    cout << a*b << endl;
}

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

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<double, double> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<string> &o) {
    string a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;


int main() {
    ll a, b;
    cin >> a >> b;
    if (a == 0 || b == 0 || (a < 0 && 0 < b)) {
        cout << "Zero" << endl;
    } else if (a > 0) {
        cout << "Positive" << endl;
    } else {
        ll diff = b - a + 1;
        if (diff % 2 == 0) {
            cout << "Positive" << endl;
        } else {
            cout << "Negative" << endl;
        }
    }
}


Measured memory_bytes: 256
import math
from typing import List, Any


def read_int() -> int:
    return int(input().strip())


def read_ints() -> List[int]:
    return list(map(int, input().strip().split(' ')))


def solve() -> Any:
    """
    x = a+b
    y = b+c
    z = a+c
    """
    N, K = read_ints()
    answer = 0
    for a in range(1, N+1):
        complement = K-(a%K)
        if 2*complement%K == 0:
            if N-complement >= 0:
                answer += ((N-complement)//K+1)**2
    return answer


if __name__ == '__main__':
    print(solve())


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

int main() {
	int n,q;
	cin>>n>>q;
    string s;
    cin>>s;
    vector<int> frq(n + 1, 0);
    for (int i = 0; i < n - 1; i++) {
	    frq[i + 2] = frq[i + 1];
	    if (s[i] == 'A' && s[i + 1] == 'C') frq[i + 2]++;
	  }
	  for (int i = 0; i < q; i++) {
	    int l, r;
	    cin >> l >> r;
	    cout << frq[r] - frq[l] << '\n';
	  }
    
	return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <math.h>

using namespace std;

int main()
{
	int K;
	unsigned long X;

	cin >> K >> X;
	if ( (500 * K) >= X)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
	return 0;
}


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

ll _pow_(ll a, ll n, ll m) {
	ll ret = 1;
	for (; n > 0; n >>= 1, a = a * a % m) {
		if (n % 2 == 1) {
			ret = ret * a % m;
		}
	}
	return ret;
}

int main() {
  int n;
  cin >> n;
  vector<ll> d(n, 0);
  rep(i, n){
    int tmp;
    cin >> tmp;
    d[tmp]++;
    if(i == 0 && tmp != 0){
      cout << 0 << endl;
      return 0;
    }
  }
  
  if(d[0] != 1){
    cout << 0 << endl;
    return 0;
  }

  ll ans = 1;
  for(int i = 1; i < n; ++i){
    ans *= _pow_(d[i-1], d[i], MOD);
    ans %= MOD;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<stdlib.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
//#include <boost/multiprecision/cpp_int.hpp>

//namespace mp = boost::multiprecision;
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int>a(n), b(n),c(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
    long long int countf = 0;
	int f = 0;
	deque<unsigned long long int>plus;
	for (int i = 0; i < n; i++) {
		cin >> b[i];
		int t = a[i]-b[i];
		if (t < 0) {
			countf -= t;
			f++;
		}
		else if(t>0) {
			plus.push_back(t);
		}
	}
	//cout << countf << endl;
	sort(plus.begin(), plus.end());
	reverse(plus.begin(), plus.end());
	int flag = 0;
	if (countf == 0) {
		cout << 0 << endl;
		flag++;
	}
	else {
		while (plus.size() != 0) {

			countf -= plus.front();
			f++;
			plus.pop_front();
			if (countf <= 0) {
				cout << f << endl;
				flag++;
				break;
			}
		}
	}
	if (flag == 0) {
		cout << -1 << endl;
	}
}

Measured memory_bytes: 1920
n, w = map(int, input().split())
item = [list(map(int, input().split())) for _ in range(n)]


"""
  dp[i + 1][j] i番目までの品物から，総和がj以下になるように選んだときの最大値
  - dp[0][j] = 0
  - dp[i+1][j] = max{ dp[i][j - k w[i]] + k v[i] | 0 <= k}
"""

dp = [[0] * (w + 1) for _ in range(n + 1)]

for i in range(n):
    for j in range(w + 1):
        # k = 0
        # while k * item[i][1] <= j:
        #     dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - k * item[i][1]] + k * item[i][0])
        #     k += 1
        if j < item[i][1]:
            dp[i + 1][j] = dp[i][j]
        else:
            dp[i + 1][j] = max(dp[i][j], dp[i + 1][j - item[i][1]] + item[i][0])
print(dp[n][w])


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

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

  string out;
  for(auto i : s){
      if(i=='B'){
          if(!out.empty())
            out.pop_back();
      }
      else 
          out.push_back(i);
  }
  
  cout << out << endl;
  return 0;
}


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

using ll = long long;
#define REP(i, n) for(int (i)=0; (i)< (n); ++i)
#define REPR(i, n) for(int (i)=(n); (i)>=0; --i)
#define FOR(i, n, m) for(int (i)=(n); (i)<(m); ++i)

int main(){
  ll ans = 0;
  ll x;
  cin >> x;
  ans += x / 500 * 1000;
  x %= 500;
  ans += x/5 * 5;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256