akhauriyash/Code-Regression huggingface dataset:
import java.util.Arrays;
import java.io.BufferedWriter;
import java.util.InputMismatchException;
import java.io.InputStream;
import java.util.NoSuchElementException;
import java.io.OutputStreamWriter;
import java.math.BigInteger;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Writer;
import java.io.IOException;

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

class TaskA {
    public void solve(int testNumber, MyScanner in, MyPrintWriter out) {
        int n = in.nextInt();
        int r = 0;
        for (int i = 0; i < n; i++) {
            r += in.nextInt();
        }
        out.println(r%2==0 ? "YES" : "NO");
    }
}

class MyScanner {
    private final InputStream in;

    public MyScanner(InputStream in) {
        this.in = in;
    }

    private static final int BUFSIZE = 65536;
    int bufLen;
    int bufPtr;
    byte[] buf = new byte[BUFSIZE];

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

    public int nextInt() {
        int c = read();
        if (c == -1) throw new NoSuchElementException();
        while (c != '-' && (c < '0' || '9' < c)) {
            c = read();
            if (c == -1) throw new NoSuchElementException();
        }
        if (c == '-') return -nextInt();
        int res = 0;
        do {
            res *= 10;
            res += c - '0';
            c = read();
        } while ('0' <= c && c <= '9');
        return res;
    }

}

class MyPrintWriter {
    PrintWriter out;

    public MyPrintWriter(OutputStream outputStream) {
        out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
    }

    public void println(Object... os) {
        if (os.length == 0) {
            out.println();
            return;
        }
        for (int i = 0; i < os.length - 1; i++) {
            out.print(os[i]);
            out.print(' ');
        }
        out.println(os[os.length - 1]);
    }

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

}



Measured memory_bytes: 9168
///******* In the name of Allah *******///

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

//long int ar[10013];
//long int gcd(long int a, long int b)
//{
//    if(b==0)
//        return a;
//    return gcd(b,a%b);
//}
//long int sieve(long long int a)
//{
//    long long int i,j,k = 0;
//    memset(ar,0,sizeof(ar));
//    ar[1] = 1;
//    for(i=2; i<=713; i++)
//    {
//        if(ar[i]==0)
//        {
//            for(j=i+i; j<=713; j+=i)
//            {
//                ar[j] = 1;
//            }
//        }
//    }
//    return ar[a];
//}

void Ok()
{
    long int a,b,c,d,e,h,t,i,j,k,l,m,n;
    long int ans_1,ans_2,ans_3,ans_4,cnt = 0,Max,Min,flag,temp,sum = 0;
    double aa,bb,cc,dd,ee,ff,gg;
    char aaa[113],bbb[113],ccc,ddd;
    string spc,in,store[13];

    cin>>k;
    cin>>aaa;
    l = strlen(aaa);
    if(l>k)
    {
        for(i=0;i<k;i++)
            cout<<aaa[i];
        cout<<"..."<<endl;
    }
    else
        cout<<aaa<<endl;


    return;
}

int main()
{
    Ok();

    return 0;
}


Measured memory_bytes: 3624
n, m = map(int, input().split())
MOD = 10**9+7
ans = 1
if abs(n-m) == 0:
    for i in range(1, n+1):
        ans *= i
        ans %= MOD
    else:
        ans = 2 * pow(ans, 2, MOD) % MOD
elif abs(n-m) == 1:
    cnt_n = 1
    cnt_m = 1
    for i in range(1, n+1):
        cnt_n = cnt_n * i % MOD
    for i in range(1, m+1):
        cnt_m = cnt_m * i % MOD
    else:
        ans = cnt_n * cnt_m % MOD
else:
    ans = 0

print(ans)


Measured memory_bytes: 9096
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using in6 = int64_t;
using ind = double;
using pii = pair<int,int>;
using psi = pair<string,int>;
using vpi = vector<pii>;
using vps = vector<psi>;
#define rep(i, n) for (in6 i = 0; i < (in6)(n); i++)
#define repa(i,a,n) for(in6 i = a; i < (in6)(n); i++)
#define repdown(i,n) for(in6 i = n; i > 0; i--)
#define kyun ios::sync_with_stdio(false)
#define hinata cout << "\n"
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define inf 2147483647
#define dset(n) cout << fixed << setprecision(n)

void yes() {
  cout << "Yes";
}

void no() {
  cout << "No";
}

int main() {
  kyun;
  int s,w;
  cin >> s >> w;
  if(s <= w) cout << "unsafe";
  else cout << "safe";
  hinata;
}

Measured memory_bytes: 3688
# frozen_string_literal: true
d = []
def chmin(a, b)
  a > b ? b : a
end
a, b, k = gets.split.map(&:to_i)

c = a

cnt = 0
i = 1
ans = 0
while c
    if a < i || b < i
        break
    end
  if a % i == 0 && b % i == 0
    d << i
  end
  i += 1
end

puts d[d.length - k]


Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <random>

using namespace std;

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

	int n, m;
	cin >> n >> m;
	vector<pair<int, char>> a(m);
	for (auto &t : a) {
		cin >> t.first >> t.second;
		t.first--;
	}
	for (int i = 0; i < 1e4; i++) {
		string s = to_string(i);
		if ((int)s.size() != n) continue;
		int ok = 1;
		for (auto t : a) {
			ok &= (s[t.first] == t.second);
		}
		if (ok) {
			cout << s << endl;
			return 0;
		}
	}
	cout << -1 << endl;
}


Measured memory_bytes: 256
n ,m ,k = map(int,input().split())

sum = 0

for a in range(n +1 ):  # 行の操作回数
  for b in range(m + 1): # 列の操作回数
    sum = ( n - a) * b + (m - b ) * a
    if sum == k:
 #     print(sum,"_",a,"_",b)
      print("Yes")
      exit()
 
print("No") #Yesが出ない時に出力

   
      

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

int main() {
  int n,T;
  cin>>n>>T;
  ll sum=0;
  int t[n];
  for(int i=0;i<n;i++){
    cin>>t[i];
  }
  for(int i=0;i<n;i++){
    if(i==n-1){
      sum+=T;
      break;
    }
    sum+=min(T,t[i+1]-t[i]);
  }
  cout<<sum<<endl;
  return 0;
}


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

typedef long long int lli;

int main(void)
{
	lli n, a, b, c, d;
	scanf("%lld%lld%lld%lld%lld", &n, &a, &b, &c, &d);

	for(lli i = 0;i < n;i++)
	{
		lli x = i, y = n-i-1;
		lli L = x*c-y*d, R = x*d-y*c;
		if(a+L <= b && b <= a+R)
		{
			printf("YES\n");
			return 0;
		}
	}
	printf("NO\n");
}

Measured memory_bytes: 256
#include<algorithm>
#include<functional>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<sstream>
#include<iostream>
#include<iomanip>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<bitset>
#include<climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define FOR(itr,data) for(__typeof((data).begin()) itr=(data).begin();itr!=(data).end();++itr)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

typedef unsigned long long UInt64;
typedef long long Int64;

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

using namespace std;

typedef pair<int ,int > P;


int x,y,z;

    //マス目,金額(50*100<6000)
    double dp[57][6000];
int solve() {
    int r[5];
    P event[57];
    rep(i,57) rep(j,6000) dp[i][j]=0.0;
    rep(i,x) cin>>r[i];
    rep(i,z) {
        int n,e,a;
        cin>>n>>e>>a;
        event[n]=P(e,a);
    }

    dp[0][0] = 1.0;

    rep(i,y) rep(j,6000) rep(k,x) {
        //dp[i][j] が event を利用して 確率1/xで遷移する?

        int tx = min(i+r[k],y);
        P p = event[tx];
        if(p.first==1) {
            dp[min(y,tx+p.sc)][j] += dp[i][j] * (1.0/x);
        }
        else if(p.first==2) {
            dp[tx][j+p.sc] += dp[i][j] * (1.0/x);
        }
        else {
            dp[tx][max(0,j-p.sc)] += dp[i][j] * (1.0/x);

        }

    }

    double ans=0.0;
    rep(i,6000) {
        ans += dp[y][i]*i;
    }
    return (int) ans;



}

int main()
{
    while(cin>>x>>y>>z) {
        if(x+y+z==0) return 0;
        cout<<solve()<<endl;
    }
    return 0;
}

Measured memory_bytes: 3832
//package Atcoder;
import java.util.*;
import java.io.*;
public class Main
{
	static final int mod=(int)1e9+7;
	static final int inf=(int)1e9;
	static final long INF=(long)1e18;
	public static void main(String[] args)
	{
		FastScanner fs=new FastScanner();
		int n=fs.nextInt();
		long suf[]=new long[n+1];
		suf[0]=0;
		long arr[]=new long[n];
		for(int i=0;i<n;i++)
		{
			arr[i]=fs.nextLong();
		}
		suf[n]=0;
		for(int i=n-1;i>=0;i--)
		{
			suf[i]=suf[i+1]+arr[i];
		}
		//System.out.println(Arrays.toString(suf));
		long sum=0;
		for(int i=0;i<n;i++)
		{
			long diff=suf[i]-arr[i];
			long second_p=((arr[i]%mod)*(diff%mod))%mod;
			sum=((sum%mod)+(second_p%mod))%mod;
		}
		System.out.println(sum);
	}
}
class FastScanner 
{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");
		public String next() 
		{
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
			
		}
		
		long pow(long x,long n)
		{
			long res=1;
			while(n>0)
			{
			   	if(n%2!=0)
			   	{
			   		res=(res*x);n--;
			   	}
			   	else
			   	{
			   		x=(x*x);n/=2;
			   	}
			}
			return res;
		}
		int gcd(int a,int b)
		{
			if(b==0)
			{
				return a;
			}
			return gcd(b,a%b);
		}
		long longgcd(long a,long b)
		{
			if(b==0)
			{
				return a;
			}
			return longgcd(b,a%b);
		}
		int[] sort(int arr[])
		{
			ArrayList<Integer> list = new ArrayList<Integer>();
			for(int i:arr)list.add(i);
			Collections.sort(list);
			for(int i=0;i<arr.length;i++)
			{
				arr[i]=list.get(i);
			}
			return arr;
		}
		char[] charsort(char arr[])
	        {
	    	ArrayList<Character> list = new ArrayList<>();
	    	for(char c:arr)list.add(c);
	    	Collections.sort(list);
	    	for(int i=0;i<list.size();i++)
	    	{
	    		arr[i]=list.get(i);
	    	}
	    	return arr;
	        }
		long[] longsort(long arr[])
		{
			ArrayList<Long> list = new ArrayList<Long>();
			for(long i:arr)list.add(i);
			Collections.sort(list);
			for(int i=0;i<arr.length;i++)
			{
				arr[i]=list.get(i);
			}
			return arr;
		}
		public int nextInt() 
		{
			return Integer.parseInt(next());
		}
		public int[] readArray(int n)
		{
			int[] arr=new int[n];
			for (int i=0; i<n; i++) arr[i]=nextInt();
			return arr;
		}	
		public long nextLong()
		{
			return Long.parseLong(next());
		}
		public long[] longreadArray(int n) 
		{
			long[] a=new long[n];
			for (int i=0; i<n; i++) a[i]=nextLong();
			return a;
		}
}

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

int main(){
	int n,k;
	string s;
	cin >> n >> k;
	cin >> s;
	
	int res = 0;
	
	int tmp_res = 0;
	int tmp_k = 0;

	
	int r = 0;
	int l = 0;
	char before_r = 'd';
	//for(int l=0;l<s.size();++l){
	while(r < s.size() && l < s.size()){
		while(tmp_k < k && r+1 < s.size()){
			r++;
			if(r-1 >= 0 && s[r-1] == '0' &&  s[r] == '1' ){
				tmp_k++;
				while(r+1 < s.size() && s[r+1] == '1') r++;
			}
		}
		
//		cout << tmp_k <<endl;
//		cout << l <<" " << r << " " << r-l+1 <<endl;
		res = max(res,r-l+1);

		l++;
		while(!(s[l-1] == '0' && s[l] == '1') && l < s.size()){
			l++;
		}
//		cout << "--" << s[l-1] <<" " << s[l] <<" " << l <<endl;
		tmp_k--;
	}
	
	cout << res <<endl;
		
	return 0;
}



Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

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

        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in));) {
            List<String> cardsOfA = new ArrayList<>(Arrays.asList(br.readLine().split("")));
            List<String> cardsOfB = new ArrayList<>(Arrays.asList(br.readLine().split("")));
            List<String> cardsOfC = new ArrayList<>(Arrays.asList(br.readLine().split("")));

            String turn = "a";
            String winner = "";
            while (true) {
                if (turn.equals("a")) {
                    if (cardsOfA.size() == 0) {
                        winner = "A";
                        break;
                    }
                    turn = cardsOfA.get(0);
                    cardsOfA.remove(0);
                } else if (turn.equals("b")) {
                    if (cardsOfB.size() == 0) {
                        winner = "B";
                        break;
                    }
                    turn = cardsOfB.get(0);
                    cardsOfB.remove(0);
                } else if (turn.equals("c")) {
                    if (cardsOfC.size() == 0) {
                        winner = "C";
                        break;
                    }
                    turn = cardsOfC.get(0);
                    cardsOfC.remove(0);
                }
            }
            
            System.out.println(winner);
        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);  
        }
    }
}

Measured memory_bytes: 21332
#include <bits/stdc++.h>
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
using Int = long long;
const char newl = '\n';

//INSERT ABOVE HERE
const Int M = 15;
Int dp[2][1<<M][M+1];
Int pp[1<<M];
Int dst[M];

Int ans[M*2];
Int ord[M];

Int ox[M];

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

  Int n;
  cin>>n;

  vector<Int> xs(n),ys(n),ps(n);
  for(Int i=0;i<n;i++) cin>>xs[i]>>ys[i]>>ps[i];

  const Int INF = 1e18;
  Int sz=1<<n;
  for(Int i=0;i<=n;i++)
    for(Int b=0;b<sz;b++)
      dp[0][b][i]=dp[1][b][i]=INF;

  pp[0]=0;
  for(Int i=1;i<sz;i++) pp[i]=pp[i>>1]+(i&1);


  for(Int k=0;k<2;k++){
    for(Int i=0;i<n;i++) ord[i]=i;
    sort(ord,ord+n,[&](Int i,Int j){
      return xs[i]!=xs[j]?xs[i]<xs[j]:i<j;
    });

    for(Int i=0;i<n;i++) ox[i]=xs[ord[i]];

    for(Int b=0;b<sz;b++){
      for(Int a=b;;a=(a-1)&b){
        for(Int i=0;i<n;i++) dst[i]=abs(xs[i]);
        Int lst;

        lst=-INF;
        for(Int i=0;i<n;i++){
          if((a>>ord[i])&1) lst=ox[i];
          chmin(dst[ord[i]],abs(ox[i]-lst));
        }

        lst=+INF;
        for(Int i=n-1;i>=0;i--){
          if((a>>ord[i])&1) lst=ox[i];
          chmin(dst[ord[i]],abs(ox[i]-lst));
        }

        Int res=0;
        for(Int i=0;i<n;i++)
          if((b>>i)&1) res+=dst[i]*ps[i];

        chmin(dp[k][b][pp[a]],res);
        if(a==0) break;
      }
    }
    for(Int i=0;i<n;i++) swap(xs[i],ys[i]);
  }

  for(Int i=0;i<=n;i++) ans[i]=INF;
  for(Int b=0;b<sz;b++)
    for(Int i=0;i<=n;i++)
      for(Int j=0;j<=n;j++)
        chmin(ans[i+j],dp[0][b][i]+dp[1][(sz-1)^b][j]);

  for(Int i=0;i<=n;i++) cout<<ans[i]<<endl;
  return 0;
}


Measured memory_bytes: 12080
let scan2 f = stdin.ReadLine().Split() |> Array.map f |> (fun a -> (a.[0], a.[1]))
let scanVecH f = stdin.ReadLine().Split() |> Array.map f

let n, k = scan2 int
let data = scanVecH int

let f x1 x2 = abs (x2 - x1) + (min (abs x1) (abs x2))

[0..n-k]
|> List.map (fun i -> f data.[i] data.[i+k-1])
|> List.min
|> printfn "%d"

Measured memory_bytes: 29144
#include <iostream>
#include<iomanip>
#include <string>
#include<vector>
#include<algorithm>
#include<utility>
#include<queue>
#include<math.h>
#include<stack>
#include<set>
#include<map>
#define INF  int(1e6+1)
#define rep(i,n,m) for(int i=n;i<m;i++)

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int>a(n);
	rep(i, 0, n)cin >> a[i];

	int x,cnt = 0;
	long int ans = 1000;
	rep(i, 0, n-1) {
		x = a[i];
		int cnt = 0;
		while (a[i + 1] - a[i] >= 0 ) {
			i++;
			cnt++;
			if (i == n - 1)break;
		}
		if (cnt) {
			ans = ans % x + (ans / x) * a[i];
		}
	}
	cout << ans << endl;
}




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

int main(){
  long N, K, idx;
  cin >> N >> K;
  for(int i=1; i<=N; i++){
    int a; cin >> a;
  }
  cout << (long)ceil((double)(N-1)/(K-1)) << endl;
  return 0;
}

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

#define si(v) v.size()
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep2(i, n, m) for (ll i = n; i <= (n); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (m); --i)

using ll = long long;
using ld = long double;
using namespace std;

signed main()
{
  cout << fixed << setprecision(20);
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  int a, b, c; cin >> a >> b >> c;
  if (a + c == b || b + c == a || a + b == c) cout << "Yes\n";
  else cout << "No\n";
  
  return (0);
}

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

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;


void main() {
    int n;
    scan(n);
    auto a = readArrLine!(long)(n);
    a.sort();

    auto b = new long[](n);
    foreach (i ; 0 .. n) {
        b[i] = (-1)^^(i % 2);
        if (i != 0 && i != n - 1) b[i] *= 2;
    }
    b.sort();
    long ans;
    foreach (i ; 0 .. n) {
        ans += a[i] * b[i];
    }

    auto c = new long[](n);
    foreach (i ; 0 .. n) {
        c[i] = (-1)^^((i + 1) % 2);
        if (i != 0 && i != n - 1) c[i] *= 2;
    }
    c.sort();

    long ans2;
    foreach (i ; 0 .. n) {
        ans2 += a[i] * c[i];
    }

    writeln(max(ans, ans2));
}








int[][] readGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new int[][](n, 0);

    foreach (i ; 0 .. m) {
        int u, v;
        scan(u, v);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= v;
        if (isUndirected) {
            adj[v] ~= u;
        }
    }

    return adj;
}

alias Edge = Tuple!(int, "to", int, "cost");

Edge[][] readWeightedGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new Edge[][](n, 0);

    foreach (i ; 0 .. m) {
        int u, v, c;
        scan(u, v, c);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= Edge(v, c);
        if (isUndirected) {
            adj[v] ~= Edge(u, c);
        }
    }

    return adj;
}

void yes(bool b) {writeln(b ? "Yes" : "No");}
void YES(bool b) {writeln(b ? "YES" : "NO");}
T[] readArr(T)() {return readln.split.to!(T[]);}
T[] readArrLine(T)(int n) {return iota(n).map!(i => readln.chomp.to!T).array;}

void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


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

using namespace std;

using ll = long long ;

const ll INF = 1e18 + 5;

int main (){
	
	int n,w;
	cin>>n>>w;
	
	ll tot=0;
	
	int weight[n+1],val[n+1];
	
	for (int i=1;i<=n;i++) {
		cin>>weight[i]>>val[i];
		tot+=val[i];
		//cout<<weight[i]<<" " << val[i]<<endl;
	}
	
	ll dp[n+1][tot+1];
	
	//memset(dp,INF,sizeof dp);
	

	for (int i=0;i<=n;i++) {

		for (int j=0;j<=tot;j++) {
			dp[i][j]=INF;
			if (j==0) dp[i][j]=0;
			
			if (i) {
			if (j - val[i] <0) dp[i][j]=dp[i-1][j];
			if (j - val[i] >=0) dp[i][j]=min(dp[i-1][j],dp[i-1][j-val[i]] + weight[i]);
		}
		}
	}
	
	ll ans=0;
	
	for (int i=0;i<=n;i++) {
		for (int j=0;j<=tot;j++) {
			
		//	if (dp[i][j] >= INF) cout<<"I" << " ";
			
		//	else cout<<dp[i][j]<<" ";
			
			if (dp[i][j] <= w) ans=max(ans,(ll) j);
		}
		//cout<<'\n';
	}
	
	
	cout<<ans<<endl;
}
			


Measured memory_bytes: 82332
#include<stdio.h>
int main(){
  int n;
  int a;
  int mn=1000000000;
  int i,ans=-1000000000;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a);
    if(i==0 && mn>a) mn=a;
    if(i>0 && ans<a-mn) ans=a-mn;
    if(i>0 && mn>a) mn=a;
  }
  printf("%d\n",ans);
  return 0;
}



Measured memory_bytes: 2108
#include <bits/stdc++.h>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
struct Edge
{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w) {}
};
using Graph = vector<vector<Edge>>;
// using Graph = vector<vector<int>>;

const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
// int dx[8] = {-1, -1, -1, 0, 0, 1, 1, 1}, dy[8] = {-1, 0, 1, 1, -1, 1, 0, -1};

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  vector<int> A(3);
  for (auto &it : A)
    cin >> it;
  vector<int> l(N);
  for (auto &it : l)
    cin >> it;
  int res = 1 << 29;
  vector<int> bit(3);
  for (bit[0] = 1; bit[0] < (1 << N); bit[0]++)
  { // 0は含めない
    for (bit[1] = 1; bit[1] < (1 << N); bit[1]++)
    {
      if (bit[1] & bit[0])
        continue;
      for (bit[2] = 1; bit[2] < (1 << N); bit[2]++)
      {
        if (bit[2] & bit[0])
          continue;
        if (bit[2] & bit[1])
          continue;
        // sums: A ～ Cに選んだ竹の長さの合計 nums: A ～ Cに選んだ竹の数
        vector<int> sums(3, 0), nums(3, 0);
        for (int i = 0; i < N; i++)
        {
          for (int j = 0; j < 3; j++)
          {
            if (bit[j] & (1 << i))
            {
              sums[j] += l[i];
              nums[j]++;
            }
          }
        }
        int score = 0;
        for (int i = 0; i < 3; i++)
        {
          score += abs(sums[i] - A[i]); // +1, -1のコスト
          score += (nums[i] - 1) * 10;  // 合体のコスト
        }
        res = min(res, score);
      }
    }
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

int main()
{
	LL N;
	std::string S, T;
	in >> N >> S >> T;
	rep(i, N) out << S[i] << T[i];
	out << std::endl;
}


Measured memory_bytes: 256
typedef long long ll;
#include "bits/stdc++.h"
using namespace std;
int main() {
	int n;
	cin >> n;

	if (n == 3 || n == 5 || n == 7) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	

}

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

using namespace std;

#define ll long long
#define pb push_back
#define vi vector<int>
#define bn(n) (n).begin(), (n).end()
#define FOR(n) for(int i = 0; i < (int)n; i++)

void solve() {
    ll a, b, c;
    cin >> a >> b >> c;
    cout << (a > b * c ? "No" : "Yes");
}

int main () {
    int t = 1, i = 1;
    //cin >> t;
    while(t--) {
        //cout << "Case #" << i << ": ";
        solve();
        //i++;
    }
    return 0;
}


Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/
const int dx[] = { -1, 0, 0, 1 }, dy[] = { 0, -1, 1, 0 };
//[const int dx[] = { -1, -1, -1, 0, 0, 1, 1, 1 }, dy[] = { 0, -1, 1, -1, 1, 0, -1, 1 };
bool valid(int x, int y, int h, int w) { return (x >= 0 && y >= 0 && x < h&&y < w); }
int place(int x, int y, int w) { return w*x + y; }

int w, h;
vs fld;
int dp[22][22][22][22];

int grundy(int top, int left, int bottom, int right)
{
	if (dp[top][left][bottom][right] >=0) return dp[top][left][bottom][right];
	set<int> st;
	FOR(i, top, bottom)FOR(j, left, right) 
	{
		if (fld[i][j] == 'X') continue;
		st.insert(grundy(top, left, i, j) ^ grundy(i + 1, left, bottom, j) ^ grundy(top, j + 1, i, right) ^ grundy(i + 1, j + 1, bottom, right));
	}
	int res = 0;
	while (st.count(res)) res++;
	return dp[top][left][bottom][right] = res;
}

int main()
{
	cin.sync_with_stdio(false);
	MS(dp, -1);
	cin >> h >> w;
	fld.resize(h);
	REP(i, h) cin >> fld[i];
	if (grundy(0, 0, h, w)) puts("First");
	else puts("Second");
	return 0;
}

Measured memory_bytes: 4128
n=input()
#print(n)
ans=9*len(n)*2

n=int(n)
for i in range(1,n):
  j=n-i
  sumi=sum([int(i) for i in str(i)])
  sumj=sum([int(j) for j in str(j)])
  tmpans=sumi+sumj
  if tmpans < ans:
    ans=tmpans

print(ans)



Measured memory_bytes: 3060
#include<stdio.h>
#include<ctype.h>
int main(){
    int i, n;
    char moji;

    for(;;){
        scanf("%c", &moji);
        if( moji == '\n' ){
          break;
        }
        else if( islower( moji )){
            moji = toupper( moji );
        }else if( isupper( moji )){
            moji = tolower( moji );
        }
        printf("%c", moji);
    }
            printf("\n");
    return 0;
}

Measured memory_bytes: 524
/*
    @uthor: Varun Mishra
    "varun21999" ->  Codechef, Codeforce, Hackerrank, Hackerearth;
*/
//#include<boost/multiprecision/cpp_int.hpp>
//using boost::multiprecision::cpp_int;

//#include <boost/math/common_factor.hpp> 

#include<bits/stdc++.h>
#include<numeric>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
#define int     long long int
#define ull     unsigned int
#define ld      long double
#define pb      push_back
#define pa      pair<int,int>
#define ppa     pair<pair<int,int>,int>
#define pap     pair<int,pair<int,int>>
#define v1d     vector<int>
#define v2d     vector<vector<int> >
#define vpa     vector<pair<int,int>>
#define M       1000000007
#define MN      LLONG_MIN
#define MX      LLONG_MAX
#define ff      first
#define ss      second
#define endl    "\n"
#define v1s     vector<string>
#define all(v)  v.begin(),v.end()
#define S(v)    sort(v.begin(),v.end())
#define RS(v)          sort(v.rbegin(),v.rend())
#define R(v)           reverse(v.begin(),v.end())
#define mxpq(T)        priority_queue <T>
#define mnpq(T)        priority_queue<T,vector<T>,greater<T>>
#define T              int tc;cin>>tc;while(tc--)
#define p2d(v)         for(auto a:v){for(auto b:a)cout<<b<<" ";cout<<endl;}
#define p1d(v)         for(auto a:v)cout<<a<<" ";cout<<endl;
#define ppd(v)         for(auto a:v)cout<<a.ff<<" "<<a.ss<<endl;
#define forI(i,n)  for(auto i=0;i<n;i++);
#define forD(i,n)  for(auto i=n-1;i>=0;i--);
#define qqq 400005
//#define isEven(n)  (!n & 1);
const int MOD = 1e9 + 7;

bool isEven(int n){
    return (!(n & 1));
}
int popcount(int num){
    num = num - ((num >> 1) & 0x55555555);
    num = (num & 0x33333333) + ((num >> 2) & 0x33333333);
    return ((num + (num >> 4) & 0xF0F0F0F) * 0x1010101) >> 24;
}
int powerOfTwo(int n){
    return 1 << n;
}




void codeforce2(){
    int a,b; cin>>a>>b;
    if(a<=(2*b)){
        cout << "0" << endl; return;
    }
    cout << (a-(2*b)) << endl;

    return;
}




int32_t main(){

    cout<<fixed<<setprecision(10);
    cin.sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    
    /*#ifndef _DEBUG
     freopen("input.txt",  "r",  stdin);
     freopen("output.txt", "w", stdout);
    #endif*/
    //auto start = high_resolution_clock::now();

    // T{

    //     codeforce2();
    // }
    codeforce2();

    

   /* auto stop = high_resolution_clock::now();
    auto duration = duration_cast<seconds>(stop - start);
    cout << "Time: "<<duration.count()<<endl;*/
    return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define  INF 1ll<<60
signed main(){
  string a,b;
  int k=0;
  cin>>a>>b;
  for(int i=0; i<3; i++){
    if(a[i]==b[i]){
      k++;
    }
  }
  cout<<k<<endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int A,B;
    cin >> A >> B;
    for (int i=0; i<2000; i++){
        if( int(i*0.08) == A && int(i*0.1) == B ){
            cout << i << endl;
            return 0;
        }
    }
     cout << "-1" << endl;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

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

        int N = scanner.nextInt();
        int X = scanner.nextInt();

        ArrayList<Integer> ms = new ArrayList();

        for (int i = 0; i < N; i++) {
            ms.add(scanner.nextInt());
        }

        Collections.sort(ms);

        int atLeastX = ms.stream().reduce(0, (i1, i2) -> i1 + i2);

        int count = 0;

        if (X - atLeastX >= 0) {
            count += ms.size();
            X -= atLeastX;
        }

        while (X - ms.get(0) >= 0) {
            count++;
            X -= ms.get(0);
        }

        System.out.print(count);
    }
}

Measured memory_bytes: 26964
N, M = map(int, input().split())
A = input()
B = []
atemp = A.split()
c = 0
for i, num in enumerate(atemp):
    B.append(atemp[i])
    c += int(num)

if N-c < 0:
    print('-1')
else:
    print(N-c)


Measured memory_bytes: 9908
n, k, q = map(int, input().split())
A = [int(input()) for _ in range(q)]
menb = [0] * n
for a in A:
  menb[a - 1] += 1
  
for m in menb:
  if m >= q - k + 1:
    print("Yes")
  else:
    print("No")

Measured memory_bytes: 8592
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+5;
const int mod=1e9+7;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define per(i,a,n) for(int i=n-1;i>=a;i--)
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
ll qpow(ll a,ll b){ll ans=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)ans=ans*a%mod;a=a*a%mod;}return ans;}
ll gcd(ll a,ll b){return b>0?gcd(b,a%b):a;}

int a[maxn];

int main(){
    int n,k,T;
    cin>>n>>k;
    if((n+1)/2>=k){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
p = [int(i) for i in input().split()]

exp = [(a+1)/2 for a in p]

tot = sum(exp[:K])
max_tot = tot
for i in range(N-K):
    tot += exp[i+K]- exp[i]
    if tot > max_tot:
        max_tot = tot
        
print(max_tot)

Measured memory_bytes: 25188
#include <iostream>
#include <map>
using namespace std;
long long n,p,cnt;
map<long long, int>v;
int main(){
    cin >> n >> p;
    for(int i = 2; i *1ll* i <= p; i ++)
        while(p % i == 0)
            v[i] ++, p /= i, cnt ++;
    if(p > 1)
        v[p] ++;
    long long res = 1;
    for(map<long long, int> :: iterator it = v.begin(); it != v.end(); it ++)
        for(int i = 0; i < (*it).second / n; i ++)
            res *= it->first;
    cout << res;


}


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


#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ", "; dbg(rst...); }
template <class T> void amax(T& a,T b){ a=max(a,b);}

int cv(char q){return q=='r'? 0: q=='s'? 1: 2;}

int main() {
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n, k, r, s, p;
	string t; 
	cin >> n >>k >>r >>s >>p >>t;
	int pt[] = {r, s, p};
	ll ans = 0;
	VI rrk(n);
	rep(i, k){
		rep(j, n){
			int ps = i+j*k;
			if(ps >=n) break;
			int cr = cv(t[ps]);
			if(ps < k){
				ans += pt[(cr+2)%3];
				rrk[ps]=1;
				continue;
			}
			if(t[ps] == t[ps-k] && rrk[ps-k]==1) continue;
			ans += pt[(cr+2)%3];
			rrk[ps] =1;
		}
	}
	
	cout << ans <<"\n";
	return 0;
}



Measured memory_bytes: 848
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int inputs = sc.nextInt();
    int[] nums = new int[inputs];
    for (int i = 0; i < nums.length; i++) {
      nums[i] = sc.nextInt();
    }

    int ope = 0;
    while (true) {
      for (int i = 0; i < nums.length; i++) {
        // 割り切れないなら現在の操作回数を出力して終了
        if (nums[i] % 2 == 0) {
          nums[i] = nums[i] / 2;
        } else {
          System.out.println(ope);
          return;
        }
      }
      // 全探索を終えたら操作回数を増やす
      ope++;
    }
  }
}


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


public class Main{
  public static void main(String[] args) {
    MyScanner sc = new MyScanner();
    out = new PrintWriter(new BufferedOutputStream(System.out));

    int N = sc.nextInt();
    int K = sc.nextInt();

    int[] cost = new int[N];

    for (int i = 0; i < N; i ++) {
      cost[i] = sc.nextInt();
    }

    int[] dp = new int[N];

    dp[0] = 0;

    for (int i = 1; i < Math.min(N, K); i ++) {
      int minVal = Integer.MAX_VALUE;
      for (int j = 0; j < i; j ++) {
        minVal = Math.min(Math.abs(cost[i] - cost[j]) + dp[j], minVal);
      }
      dp[i] = minVal;
    }

    for (int i = K; i < N; i ++) {
      int minVal = Integer.MAX_VALUE;
      for (int j = Math.max(i - K, 0); j < i; j ++) {
        minVal = Math.min(Math.abs(cost[i] - cost[j]) + dp[j], minVal);
      }
      dp[i] = minVal;

    }

    out.println(dp[N - 1]);

    // Start writing your solution here. -------------------------------------

    /*
    int n      = sc.nextInt();        // read input as integer
    long k     = sc.nextLong();       // read input as long
    double d   = sc.nextDouble();     // read input as double
    String str = sc.next();           // read input as String
    String s   = sc.nextLine();       // read whole line as String

    int result = 3*n;
    out.println(result);                    // print via PrintWriter
    */

    // Stop writing your solution here. -------------------------------------
    out.close();
  }


  //-----------PrintWriter for faster output---------------------------------
  public static PrintWriter out;

  //-----------MyScanner class for faster input----------
  public static class MyScanner {
    BufferedReader br;
    StringTokenizer st;

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

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

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

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

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

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

  }
  //--------------------------------------------------------
}

Measured memory_bytes: 33764
N = int(input())
A = list(map(int, input().split()))
sm = sum(A)
x = sm-2*sum(A[1::2])
X = []
X.append(str(x))
for i in range(N-1):
   x = 2*A[i]-x
   X.append(str(x))
print (" ".join(X))

Measured memory_bytes: 17228
#include<stdio.h>
#include<string.h>

int main()
{
	long long n;
	char pass[26] = {0};
	
	scanf("%lld", &n);
	int i = 0;
	
	--n;
	while(n >= 0){
		pass[i] = (n % 26) + 'a';
		n /= 26;
		++i;
		--n;
	}
	
	int len = strlen(pass);
	
	for(int i = len - 1 ; i >= 0; i--){
		printf("%c", pass[i]);
	}
	puts("");
}

Measured memory_bytes: 1632
#include <algorithm>
#include <string.h>
#include <iostream>
#include <stdio.h>
using namespace std;

const int N = 2e5 + 10;
double sum[N];
double f[N];
long long n, m;

int main() {
	cin >> n >> m;
	for (int i = 1; i <= n; i++) {
		cin >> f[i];
		sum[i] = sum[i - 1] + (f[i] + 1) / 2;
	}
	double ans = 0;
	for (int i = 1; i <= n - m + 1; i++) {
		ans = max(ans, sum[i + m - 1] - sum[i - 1]);
	}

	printf("%.8f\n", ans);

	return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int main() {
	string s; cin >> s;
	int ans = 1e9;
	for (int i = 0; i+2 < s.size(); i++)
	{
		string t = s.substr(i, 3);
		ans = min(ans, abs(753 - stoi(t)));
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i==n-1];};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    ll N,K;
    cin >> N >> K;
    ll t[100010], d[100010];
    rep(i,0,N) cin >> t[i] >> d[i];
    vector<lpair> lp;
    rep(i,0,N) lp.push_back(make_pair(d[i], t[i]));
    sort(lp.begin(), lp.end(), greater<lpair>());
    map<ll,ll> mp, mp2;
    priority_queue<lpair, vector<lpair>, greater<lpair> > pq;
    vector<lpair> ans;
    rep(i,0,K){
        mp[lp[i].second]++;
    }
    bool is_first[100010];
    memset(is_first, false, sizeof(is_first));
    ll sum = 0;
    rep(i,0,K){
        ll idx = lp[i].second;
        sum += lp[i].first;
        if(not is_first[idx]){
            is_first[idx] = true;
            ans.push_back(lp[i]);
        }else{
            pq.push(lp[i]);
        }
    }
    ll syurui = 0;
    rep(i,1,N+1){
        if(is_first[i] == true) syurui++;
    }
    ll val[100010] = {};
    val[syurui] = sum;

    rep(i,K,N){
        lpair l1 = lp[i];
        if(mp[l1.second] != 0) continue;
        if(not pq.empty()){
            lpair l2 = pq.top();
            pq.pop();
            syurui++;
            ans.push_back(l1);
            sum += l1.first - l2.first;
            val[syurui] = sum;
            mp[l1.second]++;
        }
    }
    while(not pq.empty()){
        ans.push_back(pq.top());
        pq.pop();
    }

    ll res = 0;
    rep(i,1,syurui+1){
        res = max(res, val[i] + i*i);
    }
    print(res);



}

Measured memory_bytes: 12144
s = list(input())
ans1 = 0
ans2 = 0

for i in range(len(s)):
    if i%2 == 0:
        if s[i] == "0":
            ans1 += 1
        else:
            ans2 += 1
    else:
        if s[i] == "0":
            ans2 += 1
        else:
            ans1 += 1
else:
    if ans1 < ans2:
        ans = ans1
    else:
        ans = ans2

print(ans)

Measured memory_bytes: 3956
import math

while True:
    n = int(input())
    if n == 0:
        break
    points = list(map(int, input().split()))

    m = sum(points) / n
    variance = sum(map(lambda x: (x - m) ** 2, points)) / n
    standard_deviation = math.sqrt(variance)
    print(standard_deviation)



Measured memory_bytes: 5696
import java.util.*;
 
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        
        int a = sc.nextInt();
        int b = sc.nextInt();

        int count = 0;

        while ((a-1) * count + 1 < b) {
            count++;
        }

        System.out.println(count);
	}
}


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

int main(){
	while(1){
		int r, c;
		int a[10][10000];
		
		scanf(" %d %d", &r, &c);
		if(r==0) break;	
		
		for(int i=0; i<r; ++i)
		for(int j=0; j<c; ++j)
		scanf(" %d", &a[i][j]);
		
		long ans=0;
		//?????????????????£?????????????????¨??¢?´¢
		for(int i=(1<<r)-1; i>=0; --i){
			
			//????????¶???????????????
			int b[10][10000];
			for(int j=0; j<r; ++j)
			for(int k=0; k<c; ++k)
			b[j][k]=a[j][k];
			
			//j???????????¨???
			for(int j=0; j<r; ++j){
				if(i>>j & 1){ //?????£????????????
					for(int k=0; k<c; ++k)
						b[j][k]=(b[j][k]==1) ? 0 : 1;
					
				}
			}
			
			long tmp=0;
			//????????§1??¨0???????????????tmp?????????
			for(int j=0; j<c; ++j){
				int x=0, y=0;	
				for(int k=0; k<r; ++k){
					if(b[k][j]==0) x++;
					else y++;	
				}
				
				tmp+=max(x,y);
			}
			
			ans=max(tmp,ans);	
		}
		
		printf("%ld\n", ans);
	}
}

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


int main(){
        int h, w;
        cin >> h >> w;
        map<int, int> s;
        multiset<int> vals;
        rep(i, w) s[i] = i;
        rep(i, w) vals.insert(0);
        rep(i, h){
                int l, r;
                cin >> l >> r;
                --l;
                map<int, int>::iterator it = s.lower_bound(l);
                int mr = -1;
                while (it != s.end() && it->first <= r) {
                        mr = max(mr, it->second);
                        int x = it->first - it->second;
                        vals.erase(vals.find(x));
                        s.erase(it++);
                }
                if (mr != -1 && r < w) {
                        vals.insert(r - mr);
                        s[r] = mr;
                }
                int ans = -1;
                if (vals.size() > 0) {
                        ans = *vals.begin() + (i+1);
                }
                cout << ans << endl;
        }
        return 0;
}


Measured memory_bytes: 22348
//itp1_6-d
#include <iostream>
#include <vector>
using namespace std;

int main(){
 int n,m;
 cin>>n>>m;
 vector<vector<int> > a(n,vector<int>(m));
 vector<int> b(m);
 vector<int> c(n);

 for(int i=0;i<n;i++){
  for(int j=0;j<m;j++){
   int x;
   cin>>x;
   a[i][j]=x;
  }
 }
 for(int i=0;i<m;i++){
  int x;
  cin>>x;
  b[i]=x;
 }
 for(int i=0;i<n;i++){
  int temp=0;
  for(int j=0;j<m;j++){
   temp+=(a[i][j]*b[j]);
  }
  c[i]=temp;
 }

 for(int i=0;i<n;i++)
  cout<<c[i]<<endl;
 
 return 0;
}

Measured memory_bytes: 1256
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
using Graph = vector<vector<int>>;

int main()
{
    int N, M;
    cin >> N >> M;
    Graph G(100001);
    for (int i = 0; i < M; ++i)
    {
        int a, b;
        cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    vector<int> dist(100001, -1);
    vector<int> ans(100001, 0);
    queue<int> que;
    dist[0] = 0;
    que.push(1);
    while (!que.empty())
    {
        int v = que.front();
        que.pop();
        for (int nv : G[v])
        {
            if (dist[nv] != -1) continue;
            dist[nv] = dist[v] + 1;
            ans[nv] = v;
            que.push(nv);
        }
    }
    cout << "Yes" << endl;
    for (int v = 2; v <= N; ++v)
    {
        cout << ans[v] << endl;
    }
}

Measured memory_bytes: 10596
// https://atcoder.jp/contests/

#include <bits/stdc++.h>
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for (int(i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for (int(i) = (m); (i) < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;

ll x, c;
int main()
{
  cin >> x;

  c = (x / 11) * 2 + ((x % 11) + 5) / 6;

  cout << c << '\n';

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define BEGIN ios_base::sync_with_stdio(0);cin.tie(0)
#define END return EXIT_SUCCESS
#define FOR(I,A,B) for((I)=(A);(I)<(B);(I)++)
#define REP(I,N) FOR(I,0,N)
#define ALL(C) (C).begin(),(C).end()
#define INPUT(P) std::cin>>(P)
#define INPUT2(P1,P2) std::cin>>(P1)>>(P2)
#define INPUT3(P1,P2,P3) std::cin>>(P1)>>(P2)>>(P3)
#define INPUTS(I,N,V) REP(I,N) std::cin>>V[I]
#define OUTPUT(P) std::cout<<P<<std::endl
#define OUTPUT2(P1,P2) std::cout<<P1<<" "<<P2<<std::endl
#define OUTPUT3(P1,P2,P3) std::cout<<P1<<" "<<P2<<" "<<P3<<std::endl
#define OUTPUTS(I,N,V) REP(I,N) std::cout<<V[i]<<std::endl
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
using namespace std;
int i,j,k;
string S,T;
map<char,char> S2T;
map<char,char> T2S;
int s_size;
int t_size;
inline void solve(){
  INPUT2(S,T);
  s_size=S.size();
  t_size=T.size();
  if(s_size!=t_size){
    OUTPUT("No");
    return;
  }
  REP(i,s_size){
    if((S2T[S[i]] && S2T[S[i]]!=T[i]) ||
       (T2S[T[i]] && T2S[T[i]]!=S[i]) ){
         OUTPUT("No");
         return;
       }
    S2T[S[i]]=T[i];
    T2S[T[i]]=S[i];
  }
  OUTPUT("Yes");
}

int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


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

int main(){
	int n; cin>>n;
	map<string, int> a;
	rep(i,n){
		string s; cin>>s;
		a[s]++;
	}
	int m; cin>>m;
	map<string, int> b;
	rep(i,m){
		string s; cin>>s;
		b[s]++;
	}
	int ans=0;
	for(auto x:a){
		if(b.find(x.first)==b.end()) ans=max(ans,x.second);
		if(auto it=b.find(x.first); it!=end(b)){
			ans=max(ans,x.second-(it->second));
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 3608
#pragma region Macros
#include <bits/stdc++.h>

#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 SZ(x) ((int)(x).size())
#define IN(x, a, b) x >= a and x < b

using namespace std;
using ll = long long;

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;
}
template <typename T> constexpr T INF = numeric_limits<T>::max() / 2;
#pragma endregion

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

  int N;
  cin >> N;
  vector<int> xs(N), ys(N);
  REP(i, N) { cin >> xs[i] >> ys[i]; }
  vector<vector<double>> dist(N, vector<double>(N));

  REP(i, N) {
    REP(j, N) { dist[i][j] = hypot(xs[j] - xs[i], ys[j] - ys[i]); }
  }

  vector<int> v(N);
  iota(ALL(v), 0);
  double ans = 0;
  int k = 0;
  do {
    double tmp = 0;
    REP(i, N - 1) { tmp += dist[v[i]][v[i + 1]]; }
    ans += tmp;
    k++;
  } while (next_permutation(ALL(v)));

  printf("%.10lf", ans / k);

  return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <cstdio>
using namespace std;
int main(){
	int n,d,x;
	scanf("%d%d%d",&n,&d,&x);
	vector<vector<int> >p(d);
	for(int i=0;i<d;i++){
		p[i].resize(n);
		for(int j=0;j<n;j++)scanf("%d",&p[i][j]);
	}
	for(int i=0;i<d-1;i++){
		int ret=x+1;
		vector<int>bag(x+1);
		bag[0]=1;
		for(int j=0;j<n;j++)for(int k=p[i][j];k<=x;k++){
			if(bag[k-p[i][j]]>=1&&bag[k]<bag[k-p[i][j]]+p[i+1][j]){
				bag[k]=bag[k-p[i][j]]+p[i+1][j];
				if(ret<bag[k]+x-k)ret=bag[k]+x-k;
			}
		}
		x=ret-1;
	}
	printf("%d\n",x);
}

Measured memory_bytes: 1132