akhauriyash/Code-Regression huggingface dataset:
# from collections import defaultdict,deque
# import sys,heapq,bisect,math,itertools,string,queue,copy,time
# sys.setrecursionlimit(10**8)
#
#
import sys
import itertools
INF = float("INF")

N = int(input())
AA = list(map(int, sys.stdin.readline().split()))
BB = list(map(int, sys.stdin.readline().split()))

cards = set()
for i,(a,b) in enumerate(zip(AA,BB)):
    if i%2 == 0:
        cards.add((a, b, i))
    else:
        cards.add((b, a, i))

def solve(ii):
    tmp = 0
    for i in range(N):
        for j in range(i+1,N):
            if ii[i] > ii[j]:
                tmp += 1
    return tmp

ans = INF
for Acards in itertools.combinations(cards, (N+1)//2):
    Bcards = cards - set(Acards)

    Ais = sorted([(card[0], card[2]) for card in Acards])
    Bis = sorted([(card[1], card[2]) for card in Bcards])

    bn = -1
    ii = []
    flag = False
    for i in range(N):
        if i%2 == 0:
            n,i = Ais[i//2]
        else:
            n,i = Bis[i//2]
        if bn > n:
            flag = True
        bn = n
        ii.append(i)

    if flag: continue

    ans = min(ans,solve(ii))


if ans == INF:
    print(-1)
else:
    print(ans)


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

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

typedef long long LL;
const LL mod=1000000007;
#define MAX 10000
const double PI  = acos(-1.0);

//-------------------------------------------


int main(){

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

    int n,a,b,c,d;
    cin>>n;
    d=n%10;n=n/10;
    c=n%10;n=n/10;
    b=n%10;n=n/10;
    a=n%10;

    if(a+b+c+d==7)cout<<a<<"+"<<b<<"+"<<c<<"+"<<d<<"=7";
    else if(a+b+c-d==7)cout<<a<<"+"<<b<<"+"<<c<<"-"<<d<<"=7";
    else if(a+b-c+d==7)cout<<a<<"+"<<b<<"-"<<c<<"+"<<d<<"=7";
    else if(a+b-c-d==7)cout<<a<<"+"<<b<<"-"<<c<<"-"<<d<<"=7";
    else if(a-b+c+d==7)cout<<a<<"-"<<b<<"+"<<c<<"+"<<d<<"=7";
    else if(a-b+c-d==7)cout<<a<<"-"<<b<<"+"<<c<<"-"<<d<<"=7";
    else if(a-b-c+d==7)cout<<a<<"-"<<b<<"-"<<c<<"+"<<d<<"=7";
    else if(a-b-c-d==7)cout<<a<<"-"<<b<<"-"<<c<<"-"<<d<<"=7";
    return 0;

}


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

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int m = sc.nextInt();

		boolean red[] = new boolean[n + 1];
		red[1] = true;
		int ball[] = new int[n + 1];
		Arrays.fill(ball, 1);
		for(int i = 0 ; i < m; i++){
			int x = sc.nextInt();
			int y = sc.nextInt();
			ball[x]--;
			ball[y]++;

			if(red[x]){
				red[y] = true;

				if(ball[x] == 0){
					red[x] = false;
				}
			}

//			for(int j = 1; j <= n; j++){
//				System.out.print(red[j]+ " ");
//			}
//			System.out.println();
		}

//		for(int i = 1; i <= n; i++){
//			System.out.print(ball[i]+" ");
//		}
//		System.out.println();

		int count = 0;
		for(int i = 1; i < red.length; i++){
			if(red[i] && ball[i] != 0){
				count++;
			}
		}

		System.out.println(count);
	}

}


Measured memory_bytes: 49292
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;


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

	int x, y, z;
	cin >> x >> y >> z;
	x -= z;
	int ans = 0;
	do {
		x -= y + z;
		ans++;
	} while (x >= y+z);

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
n = gets.to_i
a = gets.split.map(&:to_i)
h = {}
(0..a[0]).each {|i| h[i] = a[0] - i}
a[1..-1].each do |c|
    new_h = Hash.new(Float::INFINITY)
    h.each do |r, m|
        if r > c
            k = m + 2 * r
            new_h[0] = k if k < new_h[0]
        else
            (r..c).each do |t|
                k = m + 2 * t
                new_h[c-t] = k if k < new_h[c-t]
            end
        end
    end
    h = new_h
end
p h.map {|r, m| r + m}.min


Measured memory_bytes: 8904
#include<iostream>
#include<string>
using namespace std;
 
int main(){
  int n, k;
  cin >> n >> k;
  
  int *h;
  h = new int[n];
  for(int i=0; i<n; i++){
    cin >> h[i];
  }

  int ct = 0;
  for(int i=0; i<n; i++){
    if(h[i]>=k){
      ct++;
    }
  }
  
  cout << ct << endl;
  return 0;
}

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


int main(){


    int i;

    int k = 0;

    string s;

 
    cin >> s;


    for( i = 0 ; i < 3 ; i = i + 1 ){

         if( s.at(i) == '1' ) k += 1;

         }


    cout << k << endl;


    return 0;


    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define IOS cin.tie(0); ios::sync_with_stdio(false)
const int INF = 1e9;
using namespace std;

main() {
    int N; cin >> N;
    int A[N];
    rep(i,N) cin >> A[i];
    sort(A,A+N);
    int ans=0;
    double pos; double hanbun=(double)A[N-1]/2;
    for(int i=N-2; i>=0; i--){
        if(i==N-2) {
            ans=A[i]; pos=fabs(hanbun-A[i]);  
        }
        else if(pos>fabs(hanbun-A[i])){
            ans=A[i]; pos=fabs(hanbun-A[i]);
        }
    }
    cout << A[N-1] <<" "<< ans << endl;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>

#define INFTY 2147483647

int count;

void merge( int *a, int left, int mid, int right) {

  int *l, *r;
  int n1, n2;

  int i, j, k;

  n1 = mid - left;
  n2 = right - mid;
  
  l = (int *)malloc(sizeof(int) *(n1+1));
  r = (int *)malloc(sizeof(int) *(n2+1));

  for( i=0; i<n1; i++) {
    l[i] = a[left+i];
  }
  for( i=0; i<n2; i++) {
    r[i] = a[mid+i];
  }

  l[n1] = INFTY;
  r[n2] = INFTY;

  i=0;
  j=0;

  for( k=left; k<right; k++) {

    if( l[i] <= r[j]) {
      a[k] = l[i];
      i++;
    }
    else {
      a[k] = r[j];
      j++;
    }

    count++;

  }

  free(l);
  free(r);

}


void mergeSort( int *a, int left, int right) {

  int mid;

  if( left+1 < right) {
    mid = ( left + right)/2;
    mergeSort( a, left, mid);
    mergeSort( a, mid, right);
    merge( a, left, mid, right);
  }

}


int *makeIntArray( int n) { 

  int *a;
  int i;

  a = (int *)malloc(sizeof(int) *n);

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

  return a; //配列ポインタ

}


int main() {

  int n;
  int *a;

  int i;


  scanf("%d", &n);
  a = makeIntArray( n );

  mergeSort( a, 0, n);

  for( i=0; i<n-1; i++) {
    printf("%d ", a[i]);
  }
  printf("%d\n%d\n", a[i], count);

  return 0;

}

Measured memory_bytes: 4484
#include<iostream>
#include<string>
#include<cstdio>
#include <cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define int long long

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
    int n; cin >> n;
    char c[4040]; int a[4040];
    int dp[2020][2020]; //左から(B,0),..,(B,i-1), (W,0),..(W,j-1)を目標順にするための最小swap数
    rep(i, 2 * n) {
        cin >> c[i] >> a[i];
        --a[i];
    }

    vector<vector<int>> black(n, vector<int>(n + 1, 0));
    //(B, i)の前に(B, iより大),(W, j以上)が何個あるか
    vector<vector<int>> white(n, vector<int>(n + 1, 0));
    //(W, i)の前に(W, iより大),(B, j以上)が何個あるか

    vector<int> bnum(n, 0);
    vector<int> wnum(n, 0);
    rep(i, 2 * n) {
        int num = a[i];
        char col = c[i];
        vector<int> bsum(n+1, 0), wsum(n+1, 0); //前にあるi以上の個数
        per(j, n) {
            bsum[j] = bsum[j+1] + bnum[j];
            wsum[j] = wsum[j+1] + wnum[j];
        } //後ろからみる
        per(j, n+1) {
            if(col == 'B') black[num][j] = bsum[num+1] + wsum[j];
            if(col == 'W') white[num][j] = wsum[num+1] + bsum[j];
        }
        if(col == 'B') {
            bnum[num] ++;
        } else {
            wnum[num] ++;
        }
    }

    rep(i, 2020) {
        rep(j, 2020) {
            dp[i][j] = INF;
        }
    }
    dp[0][0] = 0;
    rep(i, n + 1) {
        rep(j, n + 1) {
            if(i < n) dp[i+1][j] = min(dp[i+1][j], dp[i][j] + black[i][j]);
            if(j < n) dp[i][j+1] = min(dp[i][j+1], dp[i][j] + white[j][i]);
        }
    }
    cout << dp[n][n] << endl;
	return 0;
}

Measured memory_bytes: 94848
a = []
for _ in range(5):
    a.append(int(input()))
c = 0
d = 0
for i in range(5):
    b = a[i] % 10
    if b != 0 and abs(10 - b) > c:
        c = abs(10 - b)
        d = i
e = a.pop(d)
f = 0
for j in a:
    g = j % 10
    if g == 0:
        f += j
    else:
        f += (j // 10 + 1) * 10
f += e
print(f)

Measured memory_bytes: 9204
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;*/
#include<algorithm>
#include <bits/stdc++.h>
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<ctype.h>
using namespace std;
#define pb push_back
#define S second
#define F first
#define f(i,n) for(ll i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<int>
#define pii pair<int,int>
#define CASES  ll t;cin>>t;while(t--)
typedef long long ll;
typedef unsigned long long ull;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
//*X.find_by_order()
//X.order_of_key()
int main()
{
fast;
ll n;
cin>>n;
set<string>se;
f(i,n)
{
    string s;
    cin>>s;
    se.insert(s);
}
cout<<se.size();
    return 0;
}

Measured memory_bytes: 19244
import java.io.PrintWriter; 
import java.util.Scanner; 

public class Main
{
	static Scanner in; 
	static PrintWriter out; 

	static void solve()
	{
		Scanner stdIn = new Scanner(System.in);
		int x_fee = stdIn.nextInt();
		int y_fee = stdIn.nextInt();
		int x = x_fee + (y_fee / 2);
		System.out.println(x);
	}

	public static void main(String[] args) 
	{ 
		in = new Scanner(System.in); 
		out = new PrintWriter(System.out); 
		solve(); 
		out.flush(); 
		out.close(); 
		in.close(); 
	} 
}

Measured memory_bytes: 21716
typedef long long ll;
typedef long double ld;
#include <bits/stdc++.h>
using namespace std;

int main() {
    ll n,q;
    std::cin >> n>>q;
    string s;
    std::cin >> s;
    vector<char> t(q),d(q);
    for (int i = 0; i < q; i++) {
        std::cin >> t[i]>>d[i];
    }
    
    ll l = -1;
    ll r = n;
    while(r-l>1){
        ll mid = (r+l)/2;
        ll now = mid;
        bool ok = false;
        for (int i = 0; i < q; i++) {
            if(s[now]==t[i]){
                if(d[i]=='R'){
                    now++;
                }else{
                    now--;
                }
                if(now==-1){
                    ok = true;
                    break;
                }
            }
        }
        if(ok){
            l = mid;
        }else{
            r = mid;
        }
    }
    
    ll lcnt = l+1;
    // std::cout << lcnt << std::endl;
    l = -1;
    r = n;
    while(r-l>1){
        ll mid = (r+l)/2;
        ll now = mid;
        bool ok = false;
        for (int i = 0; i < q; i++) {
            if(s[n-1-now]==t[i]){
                if(d[i]=='R'){
                    now--;
                }else{
                    now++;
                }
                if(now==-1){
                    ok = true;
                    break;
                }
            }
        }
        if(ok){
            l = mid;
        }else{
            r = mid;
        }
    }
    // std::cout << l+1 << std::endl;
    std::cout << n-min(n,lcnt+l+1) << std::endl;
}


Measured memory_bytes: 900
#include<bits/stdc++.h>
using namespace std;
 
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false

typedef long long ll;
typedef pair<int, int> ii;

int main() {
	
	rep(i, 3){
		string s;
		cin >> s;
		cout << s[0];
	}
	cout << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long fac[10000010], finv[10000010], inv[10000010]; 
long long P = 998244353;
long long Pow(long long int a, long long n) {
	long long tmp = a; 
	long long pow = n;
	long long Q = 1;  
  	while(pow > 0){
		if(pow & 1){
			Q *= tmp; Q %= P; 
		}
		tmp = tmp * tmp % P; 
     		pow >>= 1; 
  	}
	return Q;
} 
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < 10000005; i++) {
        fac[i] = fac[i - 1] * i % P;
        inv[i] = P - inv[P % i] * (P / i) % P;
        finv[i] = finv[i - 1] * inv[i] % P;
    }
}
long long COM(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % P) % P;
}
int main(){
	int N; cin >> N; 
	COMinit(); 
	long long ans = Pow(3, N); 
	for(int i = 0; i < N/2; i++){
		long long tmp = 2 * COM(N, i) * Pow(2, i) % P; 
		ans += P - tmp; 
		if(ans >= P) ans -= P; 
	}
	cout << ans << endl;  
}

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

int main() {
	int L;
	cin>>L; L--;
	int m=18*2+1;
	stringstream ss;
	int accum = 0;
	if ( L&(1<<19) ) {//bit 20
		ss<<19<<" "<<20<<" "<<1<<endl;
		ss<<19<<" "<<20<<" "<<(1<<18)+1<<endl;
		m += 2;
		accum = (1<<19);
	}
	for (int bit=19; bit>=1; bit--)
		if ( L&(1<<(bit-1)) ) {
			ss<<bit<<" "<<20<<" "<<1+accum<<endl;
			m++;
			accum += (1<<(bit-1));
		}
	cout<<20<<" "<<m<<endl;
	cout<<ss.str();
	//print fix part
	cout<<1<<" "<<20<<" "<<0<<endl;
	for (int i=2; i<=19; i++) {
		cout<<i-1<<" "<<i<<" "<<0<<endl;
		cout<<i-1<<" "<<i<<" "<< (1<<(i-2)) <<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>

using namespace std;

int n, m;
string bt;
vector<string> vec;
vector<string> res;
map<string, string> mpp;

void conv()
{
  string str;

  for(int i = 0; i < n; ++i){
    str = "";
    for(int j = 0; j < vec[i].size(); ++j){
      if(vec[i][j] <= 'c') str += '2';
      else if(vec[i][j] <= 'f') str += '3';
      else if(vec[i][j] <= 'i') str += '4';
      else if(vec[i][j] <= 'l') str += '5';
      else if(vec[i][j] <= 'o') str += '6';
      else if(vec[i][j] <= 's') str += '7';
      else if(vec[i][j] <= 'v') str += '8';
      else str += '9';
    }
    mpp[vec[i]] = str;
  }
}

void solve(string str, int p)
{
  if(p == m){
    str += ".";
    res.push_back(str);
    return;
  }

  int l;
  for(int i = 0; i < n; ++i){
    l =vec[i].size();
    if(l+p <= m && mpp[vec[i]] == bt.substr(p, l)){
      if(p > 0) solve((str+" "+vec[i]), p+l);
      else solve(vec[i], p+l);
    }
  }
}

int main()
{
  while(cin>>n && n){
    vec = vector<string>(n);
    for(int i = 0; i < n; ++i) cin >> vec[i];
    cin >> bt;

    m = bt.size();
    conv();
    solve("", 0);
    for(int i = 0; i < res.size(); ++i)
      cout << res[i] << endl;
    cout << "--" << endl;

    mpp.clear();
    vec.clear();
    res.clear();
  }

  return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {

//    	File file = new File("test.txt");
//    	Scanner sc = new Scanner(file);
    	Scanner sc = new Scanner(System.in);
    	int n = sc.nextInt();
    	int[] ary = new int[n];
    	int sum = 0;
    	for(int i = 0; i < n; i++){
    		 ary[i] = sc.nextInt();
    		 sum += ary[i];
    	}
    	sc.close();
    	int ans = 0;
    	double q = Math.round((double)sum / n);
    	for(int i = 0; i < n; i++){
    		ans += Math.pow((ary[i] - q), 2);
    	}
    	System.out.println(ans);
    }
}

Measured memory_bytes: 21716
#include <iostream>
#include <cmath>
#include <string>
#include <set>
#include <vector>
#include <map>
#include <list>
using namespace std;
typedef pair<int, int> point;
typedef long long ll;
int main(void) {
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    if(k&1)
        cout << -a+b << endl;
    else
        cout << a-b << endl;
    
}


Measured memory_bytes: 256
function Main(input) {
	input = input.split("\n");
	var N = input[0];
	var arr = input[1].split(" ");
	var sabun = arr.slice(0, arr.length);
	var count = 0;
	arr = arr.sort(function(a,b){return a-b;});
	for(var i=0;i<arr.length;i++){
		if(arr[i]!=sabun[i]) count++;
	}
	if(count==0||count==2){
		console.log("YES")
	}else{
		console.log("NO")
	}
}Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());

Measured memory_bytes: 7372
#include<iostream>
#include<bits/stdc++.h>
#include<string>
#include<limits>
#include<queue>
#include<stack>
#include<set>
#include<unordered_set>
#include<unordered_map>
#include<map>
#include <algorithm>
#include<utility>
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define vi  vector<int>
#define ll long long
#define pb push_back
#define ff first
#define ss second 
#define rep(n) for(int i=0; i<n ; i++)
#define input(n) for(int i=0; i<n ; i++){cin>>arr[i];}
#define output(n) for(int i=0; i<n ; i++){cout<<arr[i]<<" ";}
#define tc int t; cin>>t; while(t--)
using namespace std;
int32_t main()
{
	int n;
	cin>>n;
	
	int w;
	cin>>w;

	long long int weight[n];
	long long int value[n];

	rep(n)
	{
		cin>>weight[i];
		cin>>value[i];
	}

	long long int dp[2][w+1];

	memset(dp,0,sizeof(dp));

	int i;
	for( i=1; i<=n ; i++)
	{
		for(int j=1; j<=w ; j++)
		{
			if(i%2==1)
			{
			if(j >= weight[i-1])
			{
				dp[1][j] = max(dp[0][j],dp[0][j - weight[i-1]]+value[i-1]);
			}
			else
				dp[1][j]= dp[0][j];
			}
			else
			{
				if(j >= weight[i-1])
			{
				dp[0][j] = max(dp[1][j],dp[1][j - weight[i-1]]+value[i-1]);
			}
			else
				dp[0][j]= dp[1][j];

			}

		}
	}

	// for(int i=0; i<2 ; i++)
	// {
	// 	for(int j=0; j<=w; j++)
	// 		cout<<dp[i][j]<<" ";
	// 	cout<<endl;
	// }

	
	if(i%2==0)
	cout<<dp[1][w]<<endl;
	else
	cout<<dp[0][w]<<endl;




	

	return 0;
}


Measured memory_bytes: 1792
n,a,b=map(int,input().split())
v=list(map(int,input().split()))
v.sort()
max_mean=sum(v[-a:])/a
print(max_mean)
from collections import Counter
cva=Counter(v[-a:])
cv=Counter(v)
import math
def ncr(n, r):
  return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

# 選んだa個が全て同じ値なら
if v[-a]==max_mean:
  ans=0
  for k in range(a,min(b,cv[v[-a]])+1):
    ans+=ncr(cv[v[-a]],k)
  print(ans)
else:
  # aの中で一番小さな数字は何個あるか。
  k0=cva[v[-a]]
  k1=cv[v[-a]]
  ans=ncr(k1,k0)
  print(ans)

Measured memory_bytes: 3316
<?php
# 入力部
// fscanf(STDIN, "%s %s", $s, $t);
// fscanf(STDIN, "%d %d", $n, $m);
// fscanf(STDIN, "%s", $u);
// fscanf(STDIN, "%d %d", $k, $x);
// $s1 = fgets(STDIN); //"\n"の2文字
// $s2 = fgets(STDIN);
fscanf(STDIN, "%d", $a);
fscanf(STDIN, "%d", $b);
// fscanf(STDIN, "%s", $s);
// fscanf(STDIN, "%c", $c);
// fscanf(STDIN, "%s", $s2);
// fscanf(STDIN, "%d %d %d", $a, $b, $c);


# 処理部
// $arr = str_split($s);
// $arr2 = str_split($s2);
// $arr1 = explode(" ", $s1);
// $arr2 = explode(" ", $s2);
// for ($i = 0; $n > $x * $i; $i++) {
// }
// if (strpos($s, 'RRR') !== false) {
//   $r = 3;
// } elseif (strpos($s, 'RR') !== false) {
//   $r = 2;
// } elseif (strpos($s, 'R') !== false) {
//   $r = 1;
// } else {
//   $r = 0;
// }
// $s = "No";
// if ($x >= 30) {
//   $s = "Yes";
// }
// for ($i = 0; $i * 1000 < $n; $i++) {
// }
// $c = "a";
// if (ctype_upper($a)) {
//   $c = "A";
// }
// $s = "Yes";
// echo count($arr1);
// for ($i = 0; $i < strlen($s1); $i++) {
//   if ($arr1[$i] != $arr2[$i]) {
//     $s = "No";
//   }
// }
// $unit;
// switch ($n % 10) {
//   case 0:
//   case 1:
//   case 6:
//   case 8:
//     $unit = "pon";
//     break;
//   case 3:
//     $unit = "bon";
//     break;
//   default:
//     $unit = "hon";
//     break;
// }
// if ($s == "ABC") {
//   $r = "ARC";
// } else {
//   $r = "ABC";
// }
// $r = "NG";
// for ($i = $a; $i <= $b; $i++) {
//   if ($i % $k == 0) {
//     $r = "OK";
//   }
// }
// $r = "safe";
// if ($s <= $w) {
//   $r = "unsafe";
// }
// $r = "No";
// if (strpos($n, "7") !== false) {
//   $r = "Yes";
// }
// $r = "No";
// if ($arr[2] == $arr[3] && $arr[4] == $arr[5]) {
//   $r = "Yes";
// }
// $r = "Yes";
// if ($s == "AAA" || $s == "BBB") {
//   $r = "No";
// }
// if ($n % 2 == 0) {
//   $r = $n / 2;
// } else {
//   $r = ($n + 1) / 2;
// }
// if ($n < 10) {
//   $r += (10 - $n) * 100;
// }
// $arr = array($a, $b, $c);
// $arr = array_unique($arr);
// if (count($arr) == 2) {
//   $r = "Yes";
// } else {
//   $r = "No";
// }
// if ($s == $u) {
//   $a--;
// } else {
//   $b--;
// }
// for ($i = 0; $h > 0; $i++) {
//   $h -= $a;
// }
// $r = "No";
// if ($n == $m) {
//   $r = "Yes";
// }
// $r = "No";
// if ($k * 500 >= $x) {
//   $r = "Yes";
// }
$arr = array(1, 2, 3);
unset($arr[$a - 1]);
unset($arr[$b - 1]);
$arr = array_values($arr);
# 出力部
// echo ($n * ($n - 1) / 2) + ($m * ($m - 1) / 2) . "\n";
// echo $z . " " . $x . " " . $y . "\n";
// echo ($i * 1000) - $n . "\n";
// echo json_encode($arr) . "\n";
echo $arr[0] . "\n";

// echo $r . "\n";
// echo ++$c . "\n";
// echo $a . " " . $b . "\n";
// echo $t . $s . "\n";


Measured memory_bytes: 16108
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
#include<set>
using namespace std;
typedef long long ll;
typedef long long int llint;
typedef pair<ll, ll> pa;
#define MM 1e9
#define MOD MM+7
#define MAX 101000
#define MAP 110
#define initial_value -1
#define Pair pair<int,int>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define INF (1 << 29) //536870912
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
ll N;
ll a[100010];
int main(){
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> a[i];
    }
    ll ans = a[0];
    for(int i = 1; i < N; i++){
        if(a[i] < ans){
            ll tmp = a[i];
            a[i] = ans;
            ans = tmp;
        }
        ll r = a[i] % ans;
        while(r != 0){
            a[i] = ans;
            ans = r;
            r = a[i] % ans;
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (ll i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define P pair<int,int> 
signed main(){
    int n;cin>>n;
    int ans=0;
    int sum=0;
    for (int i=1;i<=n;i++){
        if((i%2)==0)continue;
        for(int j=1;j<=i;j++){
            if((j%2)==0)continue;
            if((i%j)==0)sum++;
        }
        if(sum==8)ans++;
        sum=0;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
# coding:utf-8                                                                                     

A, B = map(int, raw_input().split())
S = raw_input()

flag = False
if S[A] == '-':
    Ss = S.split('-')
    if len(Ss) == 2:
        if len(Ss[0]) == A and len(Ss[1]) == B:
            if Ss[0].isdigit() and Ss[1].isdigit():
                flag = True

if flag:
    print 'Yes'
else:
    print 'No'

Measured memory_bytes: 2568
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {

            var input = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
            var a = input[0];
            var b = input[1];
            var k = input[2];

            for (int i = 0; i < k; i++)
            {
                if(a % 2 == 1)
                {
                    a--;
                }

                var newb = a / 2;
                a = b + a / 2;
                b = newb;
            }

            if (k % 2 == 0)
            {
                Console.WriteLine(a + " " + b);
            }
            else
            {
                Console.WriteLine(b + " " + a);
            }
    }
}



Measured memory_bytes: 13396
import sys


def df(N: int) -> int:
    y = 0
    while N > 0:
        y += N % 10
        N //= 10
    return y


def func(N: int) -> int:
    min_val, min_t = N / df(N), N
    d = 0
    while N > 0:
        N //= 10
        d = d * 10 + 9
        NN = N * (d + 1) + d
        val = NN / df(NN)
        if min_val > val:
            min_val = val
            min_t = NN
    return min_t


N = int(sys.stdin.readline())
z = 0
for _ in range(N):
    z = func(z + 1)
    print(z)


Measured memory_bytes: 3188
//ABC161 A

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

int X,Y,Z,temp;
long long ans = 0;

int main() {
  cin >> X >> Y >> Z;
  
  temp = X;
  X = Y;
  Y = temp;
  
  temp = X;
  X = Z;
  Z = temp;
  
  
  printf("%d %d %d\n",X,Y,Z);
}


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

using namespace std;

typedef long long ll;
const int N = (int) 2e5 + 7;
int n, a[N], t[4 * N];
ll dp[N];

void build(int v, int tl, int tr) {
  if (tl == tr) {
    t[v] = a[tl];
  } else {
    int tm = (tl + tr) / 2;
    build(2 * v, tl, tm);
    build(2 * v + 1, tm + 1, tr);
    t[v] = min(t[2 * v], t[2 * v + 1]);
  }
}

int get(int v, int tl, int tr, int l, int r) {
  if (tr < l || r < tl) {
    return (int) 1e9;
  }
  if (l <= tl && tr <= r) {
    return t[v];
  }
  int tm = (tl + tr) / 2;
  return min(get(2 * v, tl, tm, l, r), get(2 * v + 1, tm + 1, tr, l, r));
}

int get(int l, int r) {
  return get(1, 1, n, l, r);
}

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

  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  build(1, 1, n);
  ll sol = 0;
  for (int i = n; i >= 1; i--) {
    int l = i + 1, r = n, ans = i;
    while (l <= r) {
      int m = (l + r) / 2;
      if (get(i, m) == a[i]) {
        ans = m;
        l = m + 1;
      } else {
        r = m - 1;
      }
    }
    dp[i] = (ll) a[i] * (ans - i + 1) + dp[ans + 1];
    sol += dp[i];
  }
  cout << sol << "\n";


}


Measured memory_bytes: 5756
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
ll INF = (1LL << 32) - 1;
int MOD = 1e9+7;
ll N,Z,W;
vector<ll> V;
ll dp[2010][2010];
main(){    
    cin >> N >> Z >> W;
    V.resize(N);
    rep(i,0,N)cin >> V[i];
    //V = vector<ll>(N,1);
    rep(i,0,N+1)rep(j,0,N+1)dp[i][j] = -1;

    rep(i,0,N){
        if(i == 1)continue;
        if(i == 0)dp[N][i] = abs(V[N-1] - W);
        else dp[N][i] = abs(V[N-1] - V[i-1]);
    }
    rep(i,1,N){
        dp[i][N] = abs(V[i-1] - V[N-1]);
    }

    rep(i,1,N){
        ll mini = dp[i][N];
        rep(j,i+1,N)mini = min(mini, dp[N][j]);
        dp[i][0] = mini;
    }
    /*
    rep(i,0,N+1)rep(j,0,N+1){
        printf("%3d",dp[i][j]);
        if(j==N)cout << endl;
        //cout << dp[i][j] << " \n"[j==N];
    }
    */
    ll maxi = 0;
    rep(i,1,N+1)maxi = max(maxi, dp[i][0]);
    cout << maxi << endl;
}

Measured memory_bytes: 31744
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(void){
  string s, t;
  cin >> s >> t;

  int count = 0;
  rep(i,3){
    if (s[i] == t[i]) count++;
  }

  cout << count << endl;
}


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

typedef long long ll;
#define forn(i,n) for (int i = 0; i < int(n); i++)

vector<pair<int,int>> adj;

int n;
const int N = 1e5;
bool vis[N];
int dfs(int u, int s, int val) {
    cerr << u << ' ' << s << ' ' << val << endl;
    if (vis[u]) return -1;
    if (u == n+s) return val;
    vis[u] = true;
    for (auto xy : adj) {
        int x,y; tie(x,y) = xy;
        if (x == u || y == u) {
            int v = x+y-u;
            int aa = dfs(v, s, val^(v - n*(v > n)));
            if (aa != -1) return aa;
        }
    }
    return -1;
}

bool check() {
    n = (adj.size()+1)/2;
    for (int u = 1; u <= n; u++) {
        fill_n(vis, 2*n+2, 0);
        int val = dfs(u,u,u);
        if (val != u) {
            cerr << "error " << u << " val = " << val << endl;
            return false;
        }
    }
    return true;
}

bool solve(int n) {
    if (n < 3) return false;
    int r = n%4;

    vector<int> row;
    if (r == 0) {
        int a = n&(-n);
        int b = n-a;
        if (a == n) return false;

        row.push_back(a);
        row.push_back(b);
        for (int i = 1; i < n; i++) if (i != a && i != b) row.push_back(i);
        int sz = row.size();
        forn(i,sz) row.push_back(n + row[i]);
        forn(i, int(row.size())-1) adj.emplace_back(row[i], row[i+1]);
        adj.emplace_back(n, row[0]);
        adj.emplace_back(row[1], n+n);
    }
    else if (r == 1) {
        for (int i = 2; i <= n; i++) row.push_back(i);
        int sz = row.size();
        forn(i,sz) row.push_back(n + row[i]);
        forn(i, int(row.size())-1) adj.emplace_back(row[i], row[i+1]);
        adj.emplace_back(1, row[0]);
        adj.emplace_back(row[1], n+1);
    }
    else if (r == 2) {
        for (auto x : {3,2,n-2}) row.push_back(x);
        for (int i = 4; i < n; i++) if (i != n-2) row.push_back(i);
        int sz = row.size();
        forn(i,sz) row.push_back(n + row[i]);
        forn(i, int(row.size())-1) adj.emplace_back(row[i], row[i+1]);
        adj.emplace_back(1, row[0]);
        adj.emplace_back(row[1], n+1);
        adj.emplace_back(n, row[1]);
        adj.emplace_back(row[2], n+n);
    }
    else {
        forn(i,n) row.push_back(i+1);
        int sz = row.size();
        forn(i,sz) row.push_back(n + row[i]);
        forn(i, int(row.size())-1) adj.emplace_back(row[i], row[i+1]);
    }
    return true;
}

int main() {
    int n; cin >> n;
    bool ans = solve(n);
    if (ans) {
        cout << "Yes\n";
        for (auto uv : adj) {
            int u,v; tie(u,v) = uv;
            cout << u << ' ' << v << '\n';
        }
    }
    else cout << "No\n";
    return 0;
}


Measured memory_bytes: 4448
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<V>;
using VVV = vector<VV>;
using VL = vector<ll>;
using VVL = vector<VL>;
using VVVL = vector<VVL>;
template<class T> using VE = vector<T>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const long double pi = 3.141592653589793;
int main() {
	int n;
	cin >> n;
	V a(n);
	rep(i, n) {
		cin >> a[i];
	}
	map<ll, ll> mp;
	ll ans = 0;
	rep(i, n) {
		ans += mp[-a[i] + i];
		mp[a[i] + i]++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 26536
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n * m) / gcd(n, m);//gl=xy
}
 
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;
}
 
using namespace std;
//ここから

using P=pair<int,int>;
void solve(){
  int n;
  cin>>n;
  vector<int>s(1<<n);
  map<int,int>mp;
  rep(i,(1<<n))cin>>s[i],mp[-s[i]]++;
  vector<int>v;
  v.pb(mp.begin()->first);
  mp[mp.begin()->first]--;
  if(mp.begin()->second==0)mp.erase(mp.begin());
  bool ng=false;
  rep(i,n){
    int sz=v.size();
    rep(j,sz){
      auto itr=mp.upper_bound(v[j]);
      if(itr==mp.end())ng=true;
      else{
        v.pb(itr->first);
        mp[itr->first]--;
        if(mp[itr->first]==0)mp.erase(itr);
      }
    }
    sort(all(v));
  }
  if(ng)cout<<"No";
  else cout<<"Yes";
}

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


Measured memory_bytes: 14712
<?php
fscanf(STDIN, "%d", $X);
// 預金額
$money = 100;
// 答え
$ans = 0;
while($X > $money) {
    $money += intdiv($money, 100);
    $ans++;
    //printf("%d,%d\n", $ans, $money);
}
printf("%d", $ans);


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

int main() {
    string a,b;
    std::cin >> a>>b;
    cout<<(floor(floor(sqrt(stod(a+b)))*floor(sqrt(stod(a+b))))==floor(stod(a+b)) ? "Yes":"No")<<endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  
  int n;
  cin >> n;
  
  vector<int> v(n);
  for(int i; i < n; i++)
    cin >> v.at(i);
  
  sort(v.begin(), v.end());
  int j = v.at((n / 2) - 1);
  int k = v.at(n / 2);
  
  cout << k - j << endl;
}
   

Measured memory_bytes: 640
N, Q = [int(i) for i in input().split()]
S = input()
t = [0] * (N + 1)
for i in range(N):
    end = i + 2
    t[i + 1] = t[i] + (1 if S[i:end] == "AC" else 0)
for i in range(Q):
    l, r = [int(i) for i in input().split()]
    print(t[r - 1] - t[l - 1])


Measured memory_bytes: 7748
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  vector<vector<int> >in(a);
  rep(i,a){
    rep(j,b){
      int tmp;
      cin>>tmp;
      in[i].pb(tmp);
    }
  }
  vector<int>out(b);
  rep(i,b)cin>>out[i];
  rep(i,a){
    int ans=0;
    rep(j,b){
      ans+=in[i][j]*out[j];
    }
    cout<<ans<<endl;
  }



}


Measured memory_bytes: 3156
//	ZapZu's code hohoho
//	#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define dfs_black 1
#define dfs_white -1
#define pr pair
#define vt vector
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef double db;
typedef long long li;
typedef long double ld;

typedef pr<int, int> ii;
typedef pr<ld,ld> dd;

typedef vt<int> vi;
typedef vt<li> vli;
typedef vt<ld> vld;
typedef vt<ii> vii;

typedef map<int, int> mii;
typedef map<int, bool> mib;
typedef map<int, char> mic;

typedef set<int> s_i;
typedef set<char> s_c;

const int MOD = 1e9+7;
const li INF = 1e18;
const ld PI = 4*atan((ld)1);
int a[200005];
int b[200005];
signed main()
{
//	freopen(".inp", "r", stdin);
//	freopen(".out", "w", stdout);
	int k, q;
	cin>>k>>q;
	for(int i=0; i<k; i++)
	{
		cin>>a[i];
	}
	while(q--)
	{
		int n, x, m, c_sum=0, c_cnt=0;
		cin>>n>>x>>m; x%=m; n--;
		for(int i=0; i<k; i++)
		{
			b[i]=a[i]%m;
			if(!b[i]) b[i]=m;
			c_sum+=b[i];
		}
		int c_num=n/k, l_num=n%k, ans=0;
		x+=c_sum*c_num;
		for(int i=0; i<l_num; i++)
		{
			x+=b[i];
		}
		ans=x/m;
		cout<<n-ans<<endl;
	}
}




Measured memory_bytes: 3700
N, M, X, Y = map(int, input().split())
x_list = list(map(int, input().split()))
y_list = list(map(int, input().split()))

# Judge "War" or "No War"
max_x = max(max(x_list), X)
min_y = min(min(y_list), Y)

if max_x < min_y:
    print("No War")
else:
    print("War")

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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vint;
typedef vector<double> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<int>> vvint;
typedef vector<pair<int, int>> vpii;
typedef vector<pair<ll, ll>> vpll;
typedef priority_queue<int, vector<int>, greater<int>> spqint; //小さい順に取り出し
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;     //小さい順に取り出し
typedef priority_queue<int, vector<int>, less<int>> bpqint;    //大きい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;        //大きい順に取り出し

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (int)a; i < (int)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); i++)
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define PF push_front
#define TS to_string
#define BS binary_search
#define LB lower_bound
#define UB upper_bound
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)

int INF = 1e9;
int NIL = -1;
ll MOD = 1000000007;
ll LINF = 1e18;
double EPS = 1e-9;
double PI = M_PI;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}
//-----------------------------------------

//-----------------------------------------
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::chrono::system_clock::time_point start,end;
    start = std::chrono::system_clock::now();

    int n ;
    string s ;
    cin >> n >> s ;
    s = '.' + s + '#' ;
    vint cntblack(n+2,1) ;
    vint cntwhite(n+2,0) ;
    FOR(i,1,n+2){
        if(s[i]=='.'){
            cntwhite[i] = cntwhite[i-1] + 1 ;
            cntblack[i] = cntblack[i-1] ;
        }
        else{
            cntwhite[i] = cntwhite[i-1] ;
            cntblack[i] = cntblack[i-1] + 1 ;
        }
    }
    int ans = INF ;
    REP(i,n+1){
        int tmp = cntblack[i] + ( cntwhite[n+1] - cntwhite[i] ) ;
        ans = min(ans,tmp) ;
    }
    cout << ans - 1 <<endl;




    end = std::chrono::system_clock::now();
    auto elapsed = std::chrono::duration_cast< std::chrono::milliseconds >(end - start).count();
    //std::cout << elapsed <<"ms"<< std::endl;

    

    return 0;
}



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

int main(){
    int dis[10];
    char c;
    int v1,v2;
    while(cin>>dis[0]){
        int m=100000;
        for(int i=1;i<10;i++)
            cin>>c>>dis[i];
        int to=0;
        for(int i=0;i<10;i++){
            to+=dis[i];
            m=min(m,dis[i]);
        }
        cin>>c>>v1>>c>>v2;
        double ma=max(v1,v2);
        double x=m/ma;
        x=x/2;
        double tot=0;
        for(double i=0;i<1.0*to/(v2+v1)+1;i+=x){
            tot+=(v1+v2)*x;
            if(tot>=to){
                i=tot/(v1+v2);
                double cam=v1*i;
                for(int i=0;i<10;i++){
                    if(cam<=dis[i]){
                        cout<<i+1<<endl;
                        goto next;
                    }
                    dis[i+1]+=dis[i];
                }
            }
        }
    next:;
    }
    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define Int long long
#define pb push_back
using namespace std;
using namespace __gnu_pbds;

#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> 

Int N,M,K;

const int MOD=(int)(1e9+7);
const int MAXN=500005;
vector<Int> adj[MAXN];
vector<Int> degree;
bool VIS[MAXN];     

int main()
{
       cin>>N;
       vector<Int> A(N);
       
       for(auto &x:A) cin>>x;
       Int ans=0;
       sort(A.begin(),A.end());
       for(int i=0;i<N;++i){
           for(int j=i+1;j<N;++j){
               for(int k=j+1;k<N;++k){
                   bool ok=true;
                   if(A[i]+A[j]<=A[k]) ok=false;
                   if(A[i]+A[k]<=A[j]) ok=false;
                   if(A[k]+A[k]<=A[j]) ok=false;
                   if(A[i]==A[j]||A[j]==A[k]||A[i]==A[k]) ok=false;
                   ans+=ok;
               }
           }
       }
       cout<<ans<<"\n";
}

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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)
#define In(vec) rep(i, n) cin>>vec[i];
#define ANS(s) cout << s << endl
#define inc(a, b) cin >> a >> b;

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vd = vector<double>;
using vvi = vector<vector<int>>;
using vii = vector<pair<int, int>>;

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; }

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
int round_int(int a, int b) { return (a + (b - 1)) / b; }


// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
//int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
//int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

constexpr auto MAX = 100010;

// ────────────────────────────────────────────────────

int main() {
	string s; cin >> s;
	
	bool ok = true;
	while (ok) {
		s.pop_back();
		if (s.size() % 2 == 0) {
			string a = s.substr(0, s.size() / 2);
			string b = s.substr(s.size() / 2);
			if (!a.compare(b)) {
				cout << s.size() << endl;
				ok = false;
				return 0;
			}
		}
	}
}

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

int main() {
    int N;
    int Alice{0};
    int Bob{0};
    std::cin >> N;
    std::vector<int> cards(N);

    for (auto &card : cards)
        std::cin >> card;
    
    std::sort(cards.begin(), cards.end(), std::greater<int>());

    for (int i{0}; i < cards.size(); i++) {
        if (i % 2 == 0)
            Alice += cards.at(i);
        else
            Bob += cards.at(i);
    }

    std::cout << Alice - Bob;

}


Measured memory_bytes: 256
import java.util.Scanner;

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

    public static void solve(Scanner sc) {
        int h = sc.nextInt();
        int w = sc.nextInt();
        sc.nextLine();

        for (int i = 0; i < w + 2; i++) {
            System.out.print("#");
        }
        System.out.println();
        
        for (int i = 0; i < h; i++) {
            String s = sc.nextLine();
            System.out.println("#" + s + "#");
        }

        for (int i = 0; i < w + 2; i++) {
            System.out.print("#");
        }
        System.out.println();
    }
}

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

int N;
const int MAX = 10000;
int L[MAX];
int len;

void input(){
  for(int i = 0 ; i < N ; i++){
    cin >> L[i];
  }
}

bool check(){
  for(int i = 0 ; i < len ; i++){
    if(i+1 != L[i])return false;
  }
  return true;
}

void display(){
  for(int i = 0 ; i < len ; i++){
    cout << "i = " << i << " L[i] = " << L[i] << endl;
  }
  cout << endl;
}

int solve(){
  input();
  len = N;
  for(int i = 0 ; i < MAX ; i++){
    //display();
    if(check())return i;
    vector<int> next;
    for(int i = 0 ; i < len ; i++){
      L[i]--;
      if(L[i] != 0)next.push_back(i);
    }
    for(int i = 0 ; i < next.size() ; i++){
      L[i] = L[next[i]];
    }
    L[next.size()] = len;
    len = next.size()+1;
  }
  return -1;
}

int main(){
  while(cin >> N,N)cout << solve() << endl;
  return 0;
}

Measured memory_bytes: 1244