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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

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

template<typename T>
class segtree{
	int nn;vector<T> dat;T ZERO;
public:
	segtree(int n_,T zero):ZERO(zero){
	  nn = 1;
	  while(nn < n_)nn*=2;
	  dat.resize(2*nn);
	  for(int i = 0;i < 2*nn;i++)dat[i] = ZERO;
	}
	void update(int k, int a){
	  k += nn - 1;dat[k] = a;
	  while(k > 0){
		k = (k-1)/2;
		dat[k] = function(dat[k*2+1],dat[k*2+2]);
	  }
	}
	
	T function(T a,T b){
		return a + b;
	}
	
	T get(int k){return dat[k+nn-1];}
	T que(int a,int b){
		T L = ZERO,R = ZERO;
		int A = a + nn - 1;
		int B = b + nn - 1;
		while(A < B){
			if((A & 1) == 0)L = function(L,dat[A++]);
            if((B & 1) == 0)R = function(R,dat[--B]);
            A = A >> 1;
            B = B >> 1;
		}
		return function(L,R);
	}
};

ll n;
ll v[111111];
ll now[111111];

bool check(ll mid){
	ll ret = 0;
	REP(i,n){
		if(v[i] >= mid)now[i] = 1;
		else now[i] = -1;
	}
	
	ll mi = 0;
	REP(i,n){
		now[i+1] += now[i];
		mi = min(mi,now[i]);
	}

	REP(i,n)now[i] -= mi;
	
	segtree<ll> sg(n+2,0);
	sg.update(-mi,1);
	
	REP(i,n){
		ret += sg.que(0,now[i]+1);
		sg.update(now[i],sg.get(now[i])+1);
	}

	return ret >= n * n / 4;
}

int main(){
	
	cin >> n;
	REP(i,n)cin >> v[i];
	
	ll tb = LLINF;
	ll ub = -LLINF;
	
	if(n == 1){
		cout << v[0] << endl;
		return 0;
	}
	
	while(abs(tb-ub) > 1){
		ll mid = (tb + ub) / 2;
		if(check(mid))ub = mid;
		else tb = mid;
		DBG(cout << mid << endl;)
	}
	
	cout << ub << endl;
	
	return 0;
}


Measured memory_bytes: 3840
#include <stdio.h>
int main(void){
    int atk_a,atk_b,hp_a,hp_b;
    int i=0;
    scanf("%d",&hp_a);
    scanf("%d",&atk_a);
    scanf("%d",&hp_b);
    scanf("%d",&atk_b);

    while(hp_a>0 && hp_b>0){
        if(i%2==0){
            hp_b -= atk_a;
        }
        if(i%2==1){
            hp_a -= atk_b;
        }
        i++;
    }
    if(hp_a<=0){
        printf("No\n");
        return 0;
    }
    printf("Yes\n");
    return 0;
}
    


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

int main()
{
    string s, t;
    cin >> s >> t;
    int ans = 0;

    for(int i=0; i<s.length(); i++){
        if(s[i] != t[i]) ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3824
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using vl = vector<ll>;
using vvl = vector<vl>;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
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;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

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

long long lcm(long long a, long long b) {
    long long temp = gcd(a, b);
    return temp ? (a / temp * b) : 0;
}

int main() {
    ll Q, H, S, D;
    cin >> Q >> H >> S >> D;
    ll N;
    cin >> N;
    H = min(H, 2 * Q);
    // Qの存在を忘れる
    S = min(S, 2 * H);
    // Sの存在を忘れる
    ll ans = 0LL;
    if(D < 2 * S) {
        ans += N / 2 * D;
        if(N % 2 == 1) {
            ans += S;
        }
    } else {
        ans = N * S;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#define N 1100000
using namespace std;
int sosu[N];
int check(int);
int main(){
  int a,d,n,i,j,out,judge;
  for(i=0;i<N;i++) sosu[i]=1;
  sosu[0]=0;
  sosu[1]=0;
  for(i=0;i<N/2;i++){
    if(sosu[i]==1){
      for(j=i*2;j<N;j+=i){
    sosu[j]=0;
      }
    }
  }
  while(1){
    cin >> a >> d >> n;
    if(a==0&&d==0&&n==0) break;
    j=0;
    while(n){
      if(j==1) out=a;
      out=a+j*d;
      j++;
      judge=check(out);
      if(judge==1){
    n--;
      }
    }
    cout << out << endl;
  }
  return 0;
}
int check(int n){
  if(sosu[n]==1) return 1;
  else return 0;
}

Measured memory_bytes: 5456
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include<iomanip>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout<<setprecision(10);
  int n;
  cin>>n;
  vector<int>d(n);
  rep(i,n)cin>>d[i];
  set<int> se=set<int>(all(d));
  cout<<se.size()<<endl;
  return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define db(x) cout << (x) << '\n';
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pii;
typedef pair<double,ll> pdi;
typedef pair<string,ll> psi;
typedef pair<ll,string> pls;
typedef pair<string,string> pss;
typedef pair<ll,pii> pip;
typedef pair<pii,pii> ppp;

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

    ll a,b,c;
    cin >> a >> b >> c;
    c=min(b-1,c);
    db((a*c/b)-(a*(c/b)))


    return 0;
}


Measured memory_bytes: 3640
# include <bits/stdc++.h>
# define rep(i, n) for (ll i = 0; i < (n); i++)
# define reps(i, n) for (ll i = 1; i <= (n); i++)
# define foreps(i, m, n) for (ll i = (m); i < (n); i++)
# define len(x) ((int)(x).size())
# define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
const long long mod = 1e9 + 7;
const long long inf = 1e18;

int main() {
    ll n; cin >> n;
    vector<string> s(n);
    rep(i, n) cin >> s[i];

    string ans;
    for (char c = 'a'; c <= 'z'; c++) {
        ll res = 1e18;
        rep(i, n) {
            ll cnt = 0;
            rep(j, len(s[i])) {
                if (s[i][j] == c) ++cnt;
            }
            res = min(res, cnt);
        }
        rep(i, res) ans += c;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3620
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		List<String> soot = new ArrayList<>();
		List<Integer> cardnum = new ArrayList<>();
		//int[][] cardpattern = new int[4][13];
		List<List<Integer>> cardpattern = new ArrayList<>();
		for(int i = 0; i < num; i++){
			soot.add(sc.next());
			cardnum.add(sc.nextInt());
		}
		for(int i = 0 ; i < 4 ; i++){
			List<Integer> cn = new ArrayList<>();
			for(int j = 1; j <= 13; j++){
				cn.add(j);
			}
			cardpattern.add(cn);
			cn = null;
			//System.out.println(cardpattern.get(i).size());
		}
		for(int i = 0; i < num; i++){

			switch(soot.get(i)){
			case "S":
				for(int j = 0; j < cardpattern.get(0).size(); j++){
					if(cardpattern.get(0).get(j) == cardnum.get(i)){
						cardpattern.get(0).remove(j);
					}
				}
				//cardpattern.get(0).remove(cardnum.get(i)-1);
				break;
			case "H":
				for(int j = 0; j < cardpattern.get(1).size(); j++){
					if(cardpattern.get(1).get(j) == cardnum.get(i)){
						cardpattern.get(1).remove(j);
					}
				}
				//cardpattern.get(1).remove(cardnum.get(i)-1);
				break;
			case "C":
				for(int j = 0; j < cardpattern.get(2).size(); j++){
					if(cardpattern.get(2).get(j) == cardnum.get(i)){
						cardpattern.get(2).remove(j);
					}
				}
				//cardpattern.get(2).remove(cardnum.get(i)-1);
				break;
			case "D":
				for(int j = 0; j < cardpattern.get(3).size(); j++){
					if(cardpattern.get(3).get(j) == cardnum.get(i)){
						cardpattern.get(3).remove(j);
					}
				}
				//cardpattern.get(3).remove(cardnum.get(i)-1);
				break;
			}
		}
		for(int i = 0;i < cardpattern.size(); i++){
			for(int j = 0; j < cardpattern.get(i).size(); j++){
				switch(i){
				case 0:
					System.out.println("S" + " " + cardpattern.get(i).get(j));
					break;
				case 1:
					System.out.println("H" + " " + cardpattern.get(i).get(j));
					break;
				case 2:
					System.out.println("C" + " " + cardpattern.get(i).get(j));
					break;
				case 3:
					System.out.println("D" + " " + cardpattern.get(i).get(j));
					break;
				}
			}
		}

	}

}


Measured memory_bytes: 26240
//17571@nith.ac.in (mail address) @Ankit Verma
#include<bits/stdc++.h>
using namespace std;
int main()
{  
 
    cin.tie(NULL);
    cout.tie(NULL);
    int a, b, c; cin >> a >> b >> c;
    int x = a - b;
    if(c - x < 0) {
    	cout << 0 << endl;
    } else 
    cout << c - x << endl;

     return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
  int n,m,cor=0,pen=0,pe[100002]={0};
  cin>>n>>m;
  bool f[100001]={false};
  string str;
  int j;
  for(int i=1;i<m+1;i++){
    cin>>j>>str;
    if(f[j]==false && str=="AC"){
      f[j]=true;
      cor++;
      pen+=pe[j];
    }
    else if(f[j]==false && str=="WA"){
      pe[j]++;
    }
  }
  cout<<cor<<" "<<pen<<endl;
  return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;

string s;

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> s;
	if (s[0] == s[2]) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll  long long int
#define all(x) x.begin(), x.end()
bool isPowerOfTwo(int n)
{
    return (ceil(log2(n)) == floor(log2(n)));
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    map<int,int>val;
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        int x;
        cin>>x;
        val[x]++;
    }
    int ans=0;
    for(auto it=val.begin();it!=val.end();it++)
    {
        if(it->second%2!=0)ans++;
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 8232
K = int(input())

if K % 2 == 0 or K % 5 == 0:
	print(-1)
else:
	n = 1
	m = 0
	d = 7
	while True:
		m = (m + d) % K
		if m == 0:
			break
		if d == 0:
			n = -1
			break
		n += 1
		d = (d * 10) % K
	print(n)


Measured memory_bytes: 9168
K = int(input())
A, B = map(int, input().split())
count = 0

for i in range(B - A + 1):
  if ((A+i)%K == 0):
    count += 1
  else:
    count += 0
    
if(count == 0):
  print("NG")
else:
  print("OK")

Measured memory_bytes: 9184
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdin = new Scanner(System.in);
		int n, k;
		n = stdin.nextInt();
		k = stdin.nextInt();
		int[] A = new int[n];
		for (int i = 0; i < n; i++) {
			A[i] = stdin.nextInt();
		}
		Arrays.sort(A);
		int max = 0;
		for (int i = n - k; i < n; i++) {
			max += A[i];
		}
		System.out.println(max);
	}

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INTINF = 1<<29;
const ll LLINF = 1LL<<61;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int DX[8]={ 0, 1, 0,-1, 1, 1,-1,-1};
const int DY[8]={ 1, 0,-1, 0, 1,-1, 1,-1};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b;
  string op;
  cin >> a;
  cin >> op;
  cin >> b;
  if (op=="+"){
      cout << a + b << endl;
  }else{
      cout << a - b << endl;
  }
}

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

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

int H, W;
int N;
int A[10100];
deque<int> ans[110];

signed main() {
    cin >> H >> W;
    cin >> N;
    rep(i, N) {
        cin >> A[i];
    }
    int r = 0;
    rep(i, N) {
        while (A[i]) {
            if (ans[r].size() == W)r++;
            if (r % 2 == 0) {
                ans[r].push_back(i + 1);
            } else {
                ans[r].push_front(i + 1);
            }
            A[i]--;
        }
    }
    rep(i, H) {
        rep(j, W) {
            cout << (j ? " " : "") << ans[i][j];
        }
        cout << endl;
    }
}

Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main(void){
    
    int x,y;
    for(int i = 0;i<3000;i++){
        cin>>x>>y;
    
        if(x == 0&& y == 0){
            break;
        }
    
        if(x>y){
            cout << y << " " << x <<endl;
        }else{
            cout << x << " " << y <<endl;
        }
    }
    
    
}



Measured memory_bytes: 3072
N=int(input())
a=0
b=[0]
for i in range(N):
  tmp=int(input())
  if tmp%10!=0:
    b.append(tmp)
  a+=tmp
b.sort()
if a%10!=0:
  print(a)
else:
  if len(b)!=1:
    print(a-b[1])
  else:
    print(0)

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

using namespace std;

template<class T, class U>
void ckmin(T &a, U b)
{
	if (a > b) a = b;
}
template<class T, class U>
void ckmax(T &a, U b)
{
	if (a < b) a = b;
}

#define MP make_pair
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define FOR(i, a, b) for (auto i = (a); i < (b); i++)
#define FORD(i, a, b) for (auto i = (a) - 1; i >= (b); i--)
#define SZ(x) ((int) ((x).size()))
#define ALL(x) (x).begin(), (x).end()
#define INF 1000000007
#define LLINF 2696969696969696969ll
#define MAXN 200013

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;

int N;
int fen[MAXN];
int H[MAXN];
ll A[MAXN];
ll seg[3 * MAXN];
ll ans;

void update(int w, int L, int R, int a, ll v)
{
	if (L == R)
	{
		// cerr << L << ' ' << v << endl;
		ckmax(seg[w], v);
		return;
	}
	int mid = (L + R) >> 1;
	if (a <= mid) update(w << 1, L, mid, a, v);
	else update(w << 1 | 1, mid + 1, R, a, v);
	seg[w] = max(seg[w << 1], seg[w << 1 | 1]);
}
ll query(int w, int L, int R, int a, int b)
{
	if (a <= L && R <= b) return seg[w];
	int mid = (L + R) >> 1;
	if (b <= mid) return query(w << 1, L, mid, a, b);
	if (mid < a) return query(w << 1 | 1, mid + 1, R, a, b);
	return max(query(w << 1, L, mid, a, b), query(w << 1 | 1, mid + 1, R, a, b));
}

int32_t main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> N;
	FOR(i, 0, N) cin >> H[i];
	FOR(i, 0, N) cin >> A[i];
	FOR(i, 0, N)
	{
		int h = H[i]; ll a = A[i];
		update(1, 0, N, h, query(1, 0, N, 0, h - 1) + a);
		// cerr << "HI" << endl;
	}
	ans = query(1, 0, N, 0, N);
	cout << ans << '\n';
	return 0;
}


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

class Dice {
	int num[6];
public:
	void set(int n, int s) {
		num[s] = n;
	}

	void move(char c) {
		if (c == 'E') {
			swap(num[0], num[3]);
			swap(num[3], num[5]);
			swap(num[5], num[2]);
		}
		else if (c == 'N') {
			swap(num[0], num[1]);
			swap(num[1], num[5]);
			swap(num[5], num[4]);
		}
		else if (c == 'S') {
			swap(num[0], num[4]);
			swap(num[4], num[5]);
			swap(num[5], num[1]);
		}
		else if (c == 'W') {
			swap(num[0], num[2]);
			swap(num[2], num[5]);
			swap(num[5], num[3]);
		}
	}

	int up() {
		return num[0];
	}

	void move_up(int n) {
		for (int i = 0; num[0] != n && i < 4; i++)
			move('E');
		for (int i = 0; num[0] != n && i < 4; i++)
			move('N');
	}

	int up_front_to_right(int n, int m) {
		move_up(n);
		if (num[1] == m) {
			return num[2];
		}
		else if (num[2] == m) {
			return num[4];
		}
		else if (num[3] == m) {
			return num[1];
		}
		else {
			return num[3];
		}
	}

	int get_num(int n) {
		return num[n];
	}
};

int main() {
	Dice d1, d2;
	int n;
	for (int i = 0; i < 6; i++) {
		scanf("%d", &n);
		d1.set(n, i);
	}
	for (int i = 0; i < 6; i++) {
		scanf("%d", &n);
		d2.set(n, i);
	}
	for (int l = 0; l < 2; l++) {
		for (int i = 0; i < 4; i++) {
			for (int j = 0; j < 4; j++) {
				for (int k = 0; k < 6; k++) {
					if (d1.get_num(k) != d2.get_num(k)) {
						break;
					}
					if (k == 5) {
						puts("Yes");
						exit(0);
					}
				}
				d2.move('E');
			}
			d2.move('N');
		}
		d2.move('N');
		d2.move('E');
		d2.move('S');
	}
	puts("No");
}

Measured memory_bytes: 1012
#include <bits/stdc++.h>
using namespace std;
#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL);

int main() {
  FAST;
  int64_t H, W, result;
  cin >> H >> W;
  if (W == 1 || H == 1) {
    result = 1;
  } 
  else if (W % 2 == 0) {
    result = W / 2 * H; 
  }
  else if (H % 2 == 0) {
    result = W * (H / 2);
  }
  else {
    result = (W / 2 + 1) * (H / 2 + 1) + ((W / 2) * (H / 2));
  }
  cout << result << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,int>
const int MOD=998244353;
const int MAX=1e5+10;
const double PI=acos(-1);


int main() {
    ios_base::sync_with_stdio(false);

    ll a,b,v,w,t;
    cin >> a >> v >> b >> w >> t;
    ll d=abs(a-b);
    if (d<=(v-w)*t) cout << "YES" << endl;
    else cout << "NO" << endl;
     
    return 0;   
}

Measured memory_bytes: 3608
#include<iostream>
#include<algorithm>
#include<cstdio>

using namespace std;
typedef long long ll;
const int N = 200010;

int s[N];

int main()
{
	int n;
	scanf("%d", &n);
	
	for(int i = 1; i <= n; i++)
	{
		int x;
		scanf("%d", &x);
		s[i] = s[i - 1] ^ x;
	}
	
	for(int i = 1; i <= n; i++)
	{
		if(i == 1)
		{
			printf("%d ", s[n] ^ s[i]);
		}
		else if(i == n)
		{
			printf("%d", s[n - 1] ^ s[0]);
		}
		else
		{
			int t = s[n] ^ s[i];
			int p = s[i - 1] ^ s[0];
			printf("%d ", t ^ p);
		}
	}
	
	
	/*
	printf("%d\n", 11 ^ 9 ^ 24);
	printf("%d\n", 20 ^ 9 ^ 24);
	printf("%d\n", 20 ^ 11 ^ 24);
	printf("%d\n", 20 ^ 11 ^ 9);
	*/
	return 0;
}



Measured memory_bytes: 4492
//code by parshuram_84
#include <bits/stdc++.h>
#define floop(i,a,n) for (int i=a;i<n;i++)
#define mod 1000000007
#define pii pair<int,int>
#define pll pair<long long,long long>
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);cout.precision(dbl::max_digits10);
#define pb push_back
#define mod 1000000007 //998244353
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define vp vector<pair<long long,long long>>
#define vpp vector<pair<pair<long long,long long>,long long>>
#define mp make_pair
typedef std::numeric_limits< double > dbl;
using namespace std;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll ncr(ll n,ll r) { ll p=1,k=1; if(n-r<r) r=n-r; if(r!=0) {while(r!=0) {p*=n; k*=r; ll temp=gcd(p,k); p/=temp; k/=temp; n--; r--;} } else p=1; return p;}
ll pm(ll x,ll n) {ll result=1; while(n>0){if(n%2==1) result=((result%mod)*(x%mod))%mod; x=((x%mod)*(x%mod))%mod; n/=2;} return result;}
ll p(ll x,ll n) {ll result=1; while(n>0){if(n%2==1) result=result*x; x=x*x; n/=2;} return result;}
ll factorial[300000+1];
void fact(ll n) { factorial[0]=1; factorial[1]=1; floop(i,2,n+1) factorial[i] = (i * factorial[i-1]%mod) % mod; }

int32_t main() {
	IOS;
	ll a,b,c;
	cin>>a>>b;
	c=a*b;
	cout<<c;
	return 0;
}

Measured memory_bytes: 3652
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
typedef long long ll;

int main(){
  string s;
  cin>>s;
  bool W=0,E=0,S=0,N=0;
  if(s.find("N")==string::npos) N = true;
  if(s.find("W")==string::npos) W = true;
  if(s.find("E")==string::npos) E = true;
  if(s.find("S")==string::npos) S = true;
  cout << ((N^S)||(E^W) ? "No" : "Yes") << endl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define COLOR 8
using namespace std;
int AtCoder1(int a, vector<bool> &colors) {
  for (int i = 0; i < COLOR; i++) {
    if (a >= i*400 && a < (i+1)*400) {
      colors[i] = true;
      return 0;
    }
  }
  return 1;
}
void AtCoder2(int a, vector<bool> &colors) {
  for (int i = 0; i < COLOR; i++) {
    if (a >= i*400 && a < (i+1)*400) {
      colors[i] = true;
    }
  }
}
int main() {
  vector<bool> colors1(COLOR), colors2(COLOR);
  int N,a,b=0;
  for (cin>>N; N; N--) {
    cin>>a;
    b+=AtCoder1(a,colors1);
    AtCoder2(a,colors2);
  }
  a=count(colors2.begin(),colors2.end(),true);
  cout<<max(a,1)<<' '<<b+count(colors1.begin(),colors1.end(),true);
}

Measured memory_bytes: 3580
#include <stdio.h>
int main(void) {
    int a,b;
    scanf("%d %d",&a,&b);
    if (a < b) {
        printf("a < b\n");
    }
    else if (a > b) {
        printf("a > b\n");
    }
    else if (a == b) {
        printf("a == b\n");
    }
    
    return 0;
}

Measured memory_bytes: 580
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll inf=1e9+7;
const ll mod=998244353;
int main(){
    ll now=1;
    ll h,w,k;cin>>h>>w>>k;
    vector<string>s(h);
    vector<vector<ll> >a(h,vector<ll>(w));
    rep(i,h)cin>>s[i];
    vector<bool>c(h);
    rep(i,h){
        bool t=0;
        rep(j,w)if(s[i][j]=='#')t=1;
        c[i]=t;
    }
    rep(i,h){
        if(!c[i])continue;
        int cnt=0;
        rep(j,w){
            if(s[i][j]=='#')cnt++;
            if(cnt>=2&&s[i][j]=='#')now++;
            a[i][j]=now;
        }
        now++;
    }
    REP(i,1,h){
        if(c[i])continue;
        rep(j,w)a[i][j]=a[i-1][j];
    }
    for(int i=h-2;i>=0;i--){
        if(c[i])continue;
        rep(j,w)a[i][j]=a[i+1][j];
    }
    rep(i,h){
        rep(j,w)cout<<a[i][j]<<' ';
        cout<<endl;
    }
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define INF 10000000
using ll = long long ;

using namespace std;

int main(){
    int n; cin >> n;
    vector<int> vec;
    vec.push_back(0);
    rep(i,n) {
        int a;
        cin >> a;
        vec.push_back(a);
    }
    int tmp=1;
    int count = 0;
    while ((tmp != 0) && (tmp != 2)){
        int tmp2;
        tmp2 = vec[tmp];
        vec[tmp] = 0;
        tmp = tmp2;
        count += 1;
    }
    if (tmp == 0) cout << -1 << endl;
    if (tmp == 2) cout << count << endl;
    
}

Measured memory_bytes: 1020
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
const int INF = 1 << 30;
const ll INFll = 1ll << 60;

int main() {
  int n;
  cin >> n;
  string s, t;
  cin >> s >> t;
  for (int i = 0; i < n; i++) {
    cout << s[i] << t[i];
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1000000000
#define LINF 1000000000000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

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

int main() {
    
    int A, B, Q;
    cin >> A >> B >> Q;
    vector<long long> s(A + 2), t(B + 2), x(Q);
    s[0] = (-1) * LINF; t[0] = (-1) * LINF;
    s[A + 1] = LINF; t[B + 1] = LINF;
    rep(i,A) cin >> s[i + 1];
    rep(i,B) cin >> t[i + 1];
    rep(i,Q) cin >> x[i];

    rep(i,Q) {
        auto s_itr = lower_bound(s.begin(), s.end(), x[i]);
        auto t_itr = lower_bound(t.begin(), t.end(), x[i]);
        long long s0 = *s_itr;
        long long s1 = *(--s_itr);
        long long t0 = *t_itr;
        long long t1 = *(--t_itr);
        long long minimum = LINF;
        minimum = min(minimum, min(abs(x[i] - s0), abs(x[i] - t0)) + abs(s0 - t0));
        minimum = min(minimum, min(abs(x[i] - s1), abs(x[i] - t0)) + abs(s1 - t0));
        minimum = min(minimum, min(abs(x[i] - s0), abs(x[i] - t1)) + abs(s0 - t1));
        minimum = min(minimum, min(abs(x[i] - s1), abs(x[i] - t1)) + abs(s1 - t1));
        cout << minimum << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3712
D = int(input())
c = list(map(int,input().split()))
s = list(list(map(int,input().split())) for i in range(D))
t = []
score = 0
last = [0]*26
#v = [0]*D

def calc(d):
    """
    貪欲法でd日目のスコアが最も高くなるコンテストを出力
    """
    score = 0
    t = 0
    contest = 0
    for i in range(26):
        temp = 0
        temp += s[d][i]
        for j in range(26):
            temp -= c[j]*(d+1-last[j])
        if score > temp:
            continue
        else:
            score = temp
            contest = i
    return contest

for d in range(D):
    i = calc(d)
    t.append(i)
    last[i] = d+1
for i in range(D):
    print(t[i]+1)

Measured memory_bytes: 9304
#include <iostream>
#include <cmath>

using namespace std;

int main() {
	int K, M = 1;
	
	cin >> K;
	
	if( K%2 == 0 or K%5 == 0 ){
		
		cout << -1;
		return 0;
	}
	
	if ( K%7 == 0 ){
		K = 9 * K / 7;
	}
	else {
		K = 9 * K;
	}
	
	for(int i = 0; i < K; i++){
		
		M = M * 10;
		M = M % K;
		
		if( M == 1 ){
			cout << i + 1;
			return 0;
		}
	}	
	
	return 0;
}

Measured memory_bytes: 3576
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <set>
using ll = long long;
using graph = std::vector<std::vector<ll>>;
using wGraph = std::vector<std::vector<std::pair<ll,ll>>>;
#define rep(i,n) for (int i=0; i < int(n); i++)

using namespace std;

int main() {
    string s;
    cin >> s;
    bool judge = true;
    for (int i = 0; i < (s.size() - 1)/2; ++i) {
        if(s[i] != s[(s.size() - 1) / 2 - i - 1]){
            judge = false;
        }
    }
    for (int i = (s.size() + 1)/2; i < s.size(); ++i) {
        if(s[i] != s[s.size() - i - 1]){
            judge = false;
        }
    }
    if(judge){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef double dd;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef pair<ll , ll> lli;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;
typedef vector<lli> vlli;
 
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define in insert
#define f0(b) for(int i=0;i<(b);i++)
#define f00(b) for(int j=0;j<(b);j++)
#define f1(b) for(int i=1;i<=(b);i++)
#define f11(b) for(int j=1;j<=(b);j++)
#define f2(a,b) for(int i=(a);i<=(b);i++)
#define f22(a,b) for(int j=(a);j<=(b);j++)
#define sf(a) scanf("%lld",&a)
#define sff(a,b) scanf("%lld %lld", &a , &b)
#define pf(a) printf("%lld\n",a)
#define pff(a,b) printf("%lld %lld\n", a , b)
#define PI 3.14159265359
#define bug printf("**!\n")
#define mem(a , b) memset(a, b ,sizeof(a))
#define front_zero(n) __builtin_clzll(n)
#define back_zero(n) __builtin_ctzll(n)
#define total_one(n) __builtin_popcountll(n)

const ll mod = (ll)998244353;
const ll maxn = (ll)5e5+5;
const int nnn = 1048590;
const int inf = numeric_limits<int>::max()-1;
//const ll INF = numeric_limits<ll>::max()-1;
const ll INF = 1e18;

ll dx[]={0,1,0,-1};
ll dy[]={1,0,-1,0};
ll dxx[]={0,1,0,-1,1,1,-1,-1};
ll dyy[]={1,0,-1,0,1,-1,1,-1};

ll b[4*maxn][30];
char a[maxn] ;
ll x, y,n;
char c;
ll ok[30];
void tree(ll l , ll r, ll node){
	if(l == r){
		b[node][a[l]-'a']++;
		return; 
	}
	ll mid = (l+r)/2;
	ll n1 = 2*node;
	ll n2 = n1+1;
	tree(l , mid , n1);
	tree(mid+1 , r, n2);
	f0(27) b[node][i] = b[n1][i] + b[n2][i];
	return;
}
void update(ll l , ll r, ll node){
	if(r < x || l > x) return;
	if(l == r && l == x){
		b[node][a[l]-'a']--;
		b[node][c-'a']++;
		a[l] = c; 
		return;
	}
	ll mid = (l+r)/2;
	ll n1 = 2*node;
	ll n2 = n1+1;
	update(l , mid , n1);
	update(mid+1 , r, n2);
	f0(27) b[node][i] = b[n1][i] + b[n2][i];
	return;
}
void give(ll l , ll r,  ll node){
	if(x > r || l > y) return;
	if(x <= l && y >= r){
		f0(27) ok[i] += b[node][i];
		return;
	}
	ll mid = (l+r)/2;
	give(l, mid , 2*node);
	give(mid+1 , r , (2*node)+1);
	return;
}
void solve(){
    mem(b,0);
    cin >> n;
    f1(n) cin >> a[i];
    ll q;
    tree(1,n,1);
    cin >> q;
    while(q--){
    	ll ty;
    	cin >> ty;
    	if(ty == 1){
    		cin >> x >> c;
    		update(1,n,1);
		}else{
			mem(ok , 0);
			cin >> x >> y;
			give(1,n,1);
			ll ans= 0 ;
			f0(27){
				if(ok[i] > 0) ans++; 
			}
			cout << ans << '\n';
		}
	}
	return;
}


int main() {
   
    ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
    ll T;
    T=1;
    //cin >> T;
    //scanf("%lld",&T);
    ll CT = 0;
    //work();
    while(T--){
    	//cout << "Case " << ++CT <<": " ;
    	//printf("Case %lld: ",++CT);
		solve();
	}
    
    return 0;
}


Measured memory_bytes: 469632
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0)
#define pb push_back
//#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define int long long
const int MOD=1e7+7;
const int N=2e5+10;
int gcd(int n,int m)
{
    if(n==0)
        return m;
    else
        return gcd(m%n,n);
}
int power(int a,int b)
{
    int ans=1;
    while(b)
    {
        if(b&1)
            ans=(ans*a)%MOD;
        b/=2;
        a=(a*a)%MOD;
    }
    return ans;
}
int prime[N];
int check[N];
void seive()
{
    prime[1]=0;
    for(int i=2;i<=100000;i++)
    {
        prime[i]=1;
    }

    for(int i=2;i*i<=100000;i++)
    {
        if(prime[i]==1)
        {
            for(int j=i*i;j<=100000;j+=i)
            {
                prime[j]=0;
            }
        }
    }
    check[1]=0;
    for(int i=2;i<=100000;i++)
    { 
        check[i]=check[i-1];
        if(prime[i])
        {
            if(prime[(i+1)/2])
            {
                check[i]+=1;
            }

        }
    }
}
int32_t main()
{
    int t;
    cin>>t;
    int a,b;
    seive();
    while(t--)
    {
      cin>>a>>b;
      cout<<check[b]-check[a-1]<<endl;
    }
    

}

Measured memory_bytes: 2176
fn main() {
    let s = {
        let mut line = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim_right().to_owned()
    };
    let zero = s.chars().filter(|c| *c == '0').count();
    let one = s.chars().filter(|c| *c == '1').count();
    println!("{}", std::cmp::min(zero, one) * 2);
}

Measured memory_bytes: 4352
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, core.stdc.string;

bool solve() {
    auto s = readln.split.map!(to!int);
    auto N = s[0];
    auto Q = s[1];
    if (N == 0) return false;

    auto G = new int[][](N);
    auto D = new int[](N);
    auto P = new int[](N);
    P[0] = -1;

    foreach (i; 1..N) {
        auto n = readln.chomp.to!int;
        P[i] = n-1;
        G[i] ~= n-1;
        G[n-1] ~= i;
    }

    void dfs(int n, int p, int d) {
        D[n] = d;
        foreach (m; G[n]) if (m != p) dfs(m, n, d+1);
    }

    dfs(0, -1, 0);

    Tuple!(int, int)[] queries;
    auto marked = new int[](N);

    foreach (i; 1..Q+1) {
        auto t = readln.split;
        auto n = t[1].to!int - 1;
        if (t[0] == "M" && !marked[n]) {
            queries ~= tuple(0, n);
            marked[n] = i;
        } else if (t[0] == "Q") {
            queries ~= tuple(1, n);
        }
    }

    auto uf = new UnionFind(N, D);
    foreach (i; 0..N) if (!marked[i]) uf.unite(i, P[i]);
    long ans = 0;

    foreach_reverse (q; queries) {
        if (q[0] == 0) {
            uf.unite(q[1], P[q[1]]);
        } else {
            ans += uf.find(q[1]) + 1;
        }
    }

    ans.writeln;

    return true;
}

void main() {
    while (solve()) {}
}


class UnionFind {
    int N;
    int[] table;
    int[] depth;

    this(int n, int[] d) {
        N = n;
        table = new int[](N);
        fill(table, -1);
        depth = d.dup;
    }

    int find(int x) {
        return table[x] < 0 ? x : (table[x] = find(table[x]));
    }

    void unite(int x, int y) {
        if (x == -1 || y == -1) return;
        x = find(x);
        y = find(y);
        if (x == y) return;
        if (depth[x] > depth[y]) swap(x, y);
        table[x] += table[y];
        table[y] = x;
    }
}



Measured memory_bytes: 47692
#include<bits/stdc++.h>
#define int long long
int a[114][514];
using namespace std;
signed main(){
    int n;
    cin>>n;
    for(int i=0;i<2;i++){
        for(int j=0;j<n;j++){
            cin>>a[i][j];
        }
    }
    if(n==1){
        cout<<a[0][0]+a[1][0]<<endl;
        return 0;
    }
    int ans=0;
    int sum=0;
    for(int i=0;i<n;i++){
        sum=0;
        for(int j=0;j<i+1;j++){
            sum+=a[0][j];
        }
        for(int k=i;k<n;k++){
            sum+=a[1][k];
        }
        if(sum>ans){
            ans=sum;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
n,k=gets.split.map &:to_i;a=$<.map{|e|e.split.map &:to_i};q=0
p (0..31).map{|i|
	l=k&~(1<<i-1)|q;q+=1<<i-1;i>0&&k[i-1]<1?0:a.select{|x,y|x|l==l}.map(&:last).reduce(0,:+)
}.max

Measured memory_bytes: 34556
import java.util.*;

class Main {
  public static void main (String[] args) {
    Scanner scanner = new Scanner(System.in);
    while (scanner.hasNext()) {
      int ms = Integer.MIN_VALUE;
      int mv = Integer.MIN_VALUE;
      for (int ii = 0; ii < 5; ii++) {
        int am = scanner.nextInt();
        int pm = scanner.nextInt();
        if (am == 0 && pm == 0) {
          break;
        }
        if (am + pm > mv) {
          ms = ii;
          mv = am + pm;
        }
      }
      if (mv == Integer.MIN_VALUE) {
        return;
      }
      System.out.printf("%c %d\n", ms + 'A', mv);
    }
  }
}

Measured memory_bytes: 21476
#include <string>
#include <iostream>
#include <vector>

using namespace std;

class Dice
{
private:
	int top_;		// ?????¢
	int north_;		// ?????¢
	int south_;		// ?????¢
	int east_; 		// ??±??¢
	int west_; 		// ?\???¢
	int bottom_;	// ?????¢

private:
	Dice() {}

public:
	Dice(const Dice& dice) { operator =(dice); }

	Dice(const int& topNumber
	   , const int& northNumber
	   , const int& southNumber
	   , const int& eastNumber
	   , const int& westNumber
	   , const int& bottomNumber )

	   : top_	(topNumber)
	   , north_	(northNumber)
	   , south_	(southNumber)
	   , east_	(eastNumber)
	   , west_	(westNumber)
	   , bottom_(bottomNumber)
	{}

	~Dice() {}

	Dice& operator =(const Dice& dice) {
		top_	= dice.top_;	
		north_	= dice.north_;	
		south_	= dice.south_;	
		east_	= dice.east_; 	
		west_	= dice.west_; 	
		bottom_	= dice.bottom_;

		return *this;
	}

	// ?????????
	int getTopNumber()		{ return top_; }
	int getNorthNumber()	{ return north_; }
	int getSouthNumber()	{ return south_; }
	int getEastNumber()		{ return east_; }
	int getWestNumber()		{ return west_; }
	int getBottomNumber()	{ return bottom_; }

private:
	// ?????¢?£??????¢??°
	void rotate(int& a, int& b, int& c, int& d) const {
		int tmp = a;
		a = b;
		b = c;
		c = d;
		d = tmp;
	}

public:
	void rotateNorth()			{ rotate(top_, south_, bottom_, north_); }
	void rotateSouth()			{ rotate(top_, north_, bottom_, south_); }
	void rotateEast()			{ rotate(top_, west_, bottom_, east_); }
	void rotateWest()			{ rotate(top_, east_, bottom_, west_); }
	void rotateClockwise()		{ rotate(north_, west_, south_, east_); }
	void rotateAnticlockwise()	{ rotate(north_, east_, south_, west_); }
};

// ???????????????????????????????????±??¢????????´??¢??????????????????
int getEastNumber(const Dice& dice, const int& top, const int& south)
{
	Dice tmp(dice);

	bool findTop = false;
	for ( int i = 0; i < 4; ++i ) {
		if ( tmp.getTopNumber() == top ) {
			findTop = true;
			break;
		}
		tmp.rotateNorth();
	}

	if ( !findTop ) {
		for ( int i = 0; i < 4; ++i ) {
			tmp.rotateEast();
			if ( tmp.getTopNumber() == top ) {
				findTop = true;
				break;
			}
		}
	}

	for ( int i = 0; i < 4; ++i ) {
		if ( tmp.getSouthNumber() == south ) {
			break;
		}
		tmp.rotateClockwise();
	}

	return tmp.getEastNumber();
}

int main(int, char**)
{
	const int diceSize = 6;
	int diceNumbers[diceSize];
	for ( int i = 0; i < diceSize; ++i) {
		cin >> diceNumbers[i];
	}

	Dice dice(diceNumbers[0]	// ?????¢
			, diceNumbers[4]	// ?????¢
			, diceNumbers[1]	// ?????¢
			, diceNumbers[2]	// ??±??¢
			, diceNumbers[3]	// ?\???¢
			, diceNumbers[5]);	// ?????¢

	int commandCount;
	cin >> commandCount;
	vector<int> output;
	for ( int i = 0; i < commandCount; ++i ) {

		int topNumber;		// ?????¢
		int southNumber;	// ?????¢????????¢???
		cin >> topNumber;
		cin >> southNumber;

		output.push_back(getEastNumber(dice, topNumber, southNumber));
	}

	for ( vector<int>::const_iterator it = output.begin();
									  it != output.end();
									++it )
	{
		cout << *it << endl;
	}

	return 0;
}

Measured memory_bytes: 1216
from collections import deque
H,W,K,*L = open(0).read().split()
L = [list(a) for a in L]
H,W,K = map(int, (H,W,K))
q = deque([])
step = [(-1,0),(1,0),(0,-1),(0,1)]
for i,a in enumerate(L):
  if 'S' in a:
    q = deque([(0,i,a.index('S'))])
    break
ans = 10**10
while q:
  c,a,b = q.popleft()
  x = min(a,H-a-1,b,W-b-1)
  cnt = 1+(x+K-1)//K
  ans = min(cnt,ans)
  if c+1>K:
    continue
  for dx,dy in step:
    n = a+dx
    m = b+dy
    if not(-1<n<H and -1<m<W):
      continue
    if L[n][m]=='.':
      L[n][m]='#'
      q.append((c+1,n,m))
print(ans)

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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x,ll y,ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}
void anss(bool x,string y,string z){if(x)cout<<y<<endl;else cout<<z<<endl;}   
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}

int main(){
  ll i,j,o;
  ll res=0,res1=0,res2=INF,buf=0,buf1=0,buf2=0,buf3=0,buf4=0,sum=0;
  ll l,r;
  //bool judge = true;
  ll n;cin>>n;
  string s;cin>>s;
  vector<string> a(4);
  vector<bool> judge(4,false);
  a[0].push_back('S');
  a[0].push_back('S');
  a[1].push_back('S');
  a[1].push_back('W');
  a[2].push_back('W');
  a[2].push_back('S');
  a[3].push_back('W');
  a[3].push_back('W');
  for(j=0;j<4;j++){
  for(i=1;i<n-1;i++){
    if((s[i]=='o'&&a[j][i]=='S')||(s[i]=='x'&&a[j][i]=='W')){
      a[j].push_back(a[j][i-1]);
    }
    else a[j].push_back(a[j][i-1]=='S'?'W':'S');
  }
  if((s[n-1]=='o'&&a[j][n-2]==a[j][0]&&a[j][n-1]=='S')||
     (s[n-1]=='x'&&a[j][n-2]!=a[j][0]&&a[j][n-1]=='S')||
     (s[n-1]=='o'&&a[j][n-2]!=a[j][0]&&a[j][n-1]=='W')||
     (s[n-1]=='x'&&a[j][n-2]==a[j][0]&&a[j][n-1]=='W')
    )
  if((s[0]=='o'&&a[j][n-1]==a[j][1]&&a[j][0]=='S')||
     (s[0]=='x'&&a[j][n-1]!=a[j][1]&&a[j][0]=='S')||
     (s[0]=='o'&&a[j][n-1]!=a[j][1]&&a[j][0]=='W')||
     (s[0]=='x'&&a[j][n-1]==a[j][1]&&a[j][0]=='W')
    )
  judge[j]=true;
  }
  bool bufj=true;

  for(i=0;i<4;i++){
    if(judge[i]){
      bufj=false;
      cout<<a[i]<<endl;
      break;
    }
  }
  if(bufj)cout<<-1<<endl;

  //for(i=0;i<4;i++)cout<<a[i]<<endl;
    
  

  return 0;
}

Measured memory_bytes: 1024
//
// Created by kuroneko on 2019-09-07.
//

#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <string>

using namespace std;

typedef long long ll;

#define INF 1000000000000009LL
#define MOD 1000000007LL

typedef int Weight;
struct Edge {
    int src, dst;
    Weight weight;
    Edge(int src, int dst, Weight weight):src(src), dst(dst), weight(weight) {}
};

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

typedef vector<Weight> Array;
typedef vector<Array> Matrix;

int main() {
    int N; cin >> N;
    vector<int> a(N), b(N), c(N-1);
    for (int i = 0; i < N; i++) {
        cin >> a[i];
        a[i]--;
    }
    for (int i = 0; i < N; i++) cin >> b[i];
    for (int i = 0; i < N-1; i++) cin >> c[i];

    int res = 0;
    for (int i = 0; i < N; i++) {
        res += b[a[i]];
        if (i < N-1 && a[i+1] == a[i] + 1) res += c[a[i]];
    }

    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#define INF 0x3f3f3f3f

using namespace std;
const int maxn=55;
int N,a[maxn];

int main()
{
    while(~scanf("%d",&N))
    {
        int t_min=INF,t_max=-INF;
        int pos_min=1;
        int pos_max=1;
        for(int i=1;i<=N;i++)
            scanf("%d",&a[i]);
        for(int i=1;i<=N;i++)
        {
            if(a[i]<t_min)
                t_min=a[i],pos_min=i;
            if(a[i]>t_max)
                t_max=a[i],pos_max=i;
        }
        printf("%d\n",N*2-2);
        if(abs(t_min)<=abs(t_max))
        {
            for(int i=1;i<=N;i++)
            {
                if(i==pos_max) continue;
                printf("%d %d\n",pos_max,i);
            }
            for(int i=2;i<=N;i++)
                printf("%d %d\n",i-1,i);
        }
        else
        {
            for(int i=1;i<=N;i++)
            {
                if(i==pos_min) continue;
                printf("%d %d\n",pos_min,i);

            }
            for(int i=N-1;i>=1;i--)
                printf("%d %d\n",i+1,i);
        }
    }
    return 0;
}


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

P p[200000];
int main(){
	int n,k;scanf("%d%d",&n,&k);
	rep(i,n)scanf("%d%d",&p[i].first,&p[i].second);
	sort(p,p+n,[](P a,P b){return a.second>b.second;});
	set<int>a;
	priority_queue<int,vector<int>,greater<int>>que;
	//1個以上あるネタ、2個以上あるネタ
	ll Max=0;
	ll sum=0;
	rep(i,k){
		sum+=p[i].second;
		if(a.count(p[i].first)){
			que.push(p[i].second);
		}
		a.insert(p[i].first);
	}
	Max=max(Max,(ll)sum+(ll)a.size()*(ll)a.size());
	for(int i=k;i<n;i++){
		if(a.count(p[i].first)||que.empty())continue;
		int u=que.top();que.pop();
		sum-=u;
		sum+=p[i].second;
		a.insert(p[i].first);
		Max=max(Max,sum+(ll)a.size()*(ll)a.size());
	}
	cout<<Max<<endl;
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  rep(i, n) cin >> p[i];
  int ans = 0;
  int minv = p[0];
  rep(i, n) {
    if (p[i] <= minv) ans++;
    minv = min(minv, p[i]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e9;
const ll mod = 1e9+7;
typedef pair<int,int> P;
#define rep(i,N) for(int i=0;i<N;i++)
#define mm(n,m) memset(n,m,sizeof(n))

int main(){
    int a,b;
    cin>>a>>b;
    int now = a;
    int ans = 1;
    while(now<b){
        now += (a-1);
        ans++;
    }
    if(b==1)ans=0;
    
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
# define maxh 2000
# define maxn 100001
// # define mod 1e9+7

int main() {
  int N,M,a[maxn]={0};
  ll dp[maxn]={0};
  cin>>N>>M;
  ll MOD = 1e9+7;
  for (int n(0);n<M;n++){
    int ai;
    cin>>ai;
    a[ai]=1;
  }
  dp[0]=1;
  for (int i(0);i<N;i++){
    if(a[i+1]!=1) (dp[i+1]+=dp[i]) %= MOD;
    if (i!=N-1) if(a[i+2]!=1) (dp[i+2]+=dp[i]) %= MOD;
  }
  cout << dp[N]%MOD<<endl;
}

Measured memory_bytes: 1408
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<set>
#include<queue>
#include<string>
#include<sstream>
#include<iostream>
#include<sstream>
#include<stack>
#include<map>
#include<vector>
#include<math.h>
using namespace std;
long long a[210000];
int main()
{
	memset(a, 0, sizeof(a));
	long long n,i;
	long long num=0;
	scanf("%lld", &n);
	for (i = 1; i <= n; i++)
	{
		scanf("%lld", &a[i]);
	}
	a[0] = -1;
	int flag = 1;
	for (i = 1; i <= n; i++)
	{
		if (a[i] == a[i - 1] + 1)num++;
		else if (a[i] <= a[i - 1])num += a[i];
		else if (a[i] > a[i - 1] + 1)
		{
			flag = 0;
			break;
		}
	}
	num--;
	if (flag == 0)printf("-1");
	else printf("%lld", num);
}

Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
struct node{
	int x,y;
	node(int a,int b):x(a),y(b){}
};
int vis[maxn],f[maxn],l[maxn];
int main(){
	int n,k;
	scanf("%d%d",&n,&k);
	scanf("%d",&f[1]);
	for(int i=2;i<=n;++i){
		int x;
		scanf("%d",&x);
		f[i]=x;
		vis[x]++;
	}
	int ans=0;
	if(f[1]!=1)ans++;
	queue<int> q;
	for(int i=1;i<=n;++i){
		if(!vis[i])q.push(i),l[i]=0;
	}
	while(!q.empty()){
		int v=q.front(),h=l[v];q.pop();
		if(h==k-1&&f[v]!=1){
			ans++;
			h=-1;
		}
		if(f[v]!=0&&f[v]!=1){
			l[f[v]]=max(l[f[v]],h+1);
			vis[f[v]]--;
			if(vis[f[v]]==0)q.push(f[v]);
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792