akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

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

		String str = sc.next();

		if (Character.isUpperCase(str.charAt(0))) {
			System.out.println("A");
		} else {
			System.out.println("a");
		}
	}
}

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

int main(){
    vector<string> s(3);
    cin >> s[0] >> s[1] >> s[2];

    vector<int> p = {0,0,0};// position
    int i = 0;
    while(1){
        p[i] += 1;
        if(p[i] > s[i].length()){
            cout << (char)('A' + i) << endl;
            return 0;
        }

        if     (s[i][p[i]-1] == 'a') i = 0;
        else if(s[i][p[i]-1] == 'b') i = 1;
        else if(s[i][p[i]-1] == 'c') i = 2;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;


template <typename T>using ordered_set = tree<T, null_type, less<T>,rb_tree_tag, tree_order_statistics_node_update>;

#define PI              acos(-1.0)
#define en '\n'
#define Infi 0x3f3f3f3f
#define LInfi 0x3f3f3f3f3f3f3f3f

#define setzero(a)    memset(a,0,sizeof(a))
#define setneg(a)     memset(a,-1,sizeof(a))
#define setinf(a)     memset(a,126,sizeof(a))


#define READ_IN freopen("Input.txt","r",stdin);
#define READ_OUT freopen("Output.txt","w",stdout);


const int dx[] = {+1,-1,+0,+0};                         // 4 X directions
const int dy[] = {+0,+0,+1,-1};                         // 4 Y directions
const int dx8[] = {+0,+0,+1,-1,-1,+1,-1,+1};            // King X Moves
const int dy8[] = {-1,+1,+0,+0,+1,+1,-1,-1};            // King Y Moves
const int kx[] = {-2, -2, -1, -1,  1,  1,  2,  2};      // Knight X Moves
const int ky[] = {-1,  1, -2,  2, -2,  2, -1,  1};      // Knight Y Moves



int  Set    (int N,int pos) {return N=N | (1<<pos);}    /// turn a bit on
int  reset  (int N,int pos) {return N= N & ~(1<<pos);}  /// turn a bit off
bool check  (int N,int pos) {return (bool)(N & (1<<pos));} /// check, if a bit is on or not

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define trace(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define trace(x...)
#endif

typedef long long int  ll;
typedef unsigned long long int llu;

int dp[100005];

int n,k;

vector<int> vec(n);

int make(int now){

    if(now>=n-1)return 0;

    if(dp[now]!=-1)return dp[now];

    int ans = Infi;

    for(int i=now+1;i<=now+k & i<n;i++){

        ans = min(ans , make(i) + abs(vec[now] - vec[i]));
    }

    return dp[now] = ans;
}

int main(void){

    cin >> n >> k;

    vec.assign(n,0);

    for(int i=0;i<n;i++){
        cin >> vec[i];
    }

    memset(dp,-1,sizeof(dp));

    int ans = make(0);

    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 11928
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class F
{
	public static void Main() => (new Solver()).Solve();
}

public class Solver
{
	public void Solve()
	{
		int N = GetInt();
		int u = GetInt() - 1;
		int v = GetInt() - 1;
		var adj = Enumerable.Range(0, N).Select(_ => new List<int>()).ToArray();
		for(int i = 0; i < N - 1; i++)
		{
			int A = GetInt() - 1;
			int B = GetInt() - 1;
			adj[A].Add(B);
			adj[B].Add(A);
		}

		var tak = bfs(N, u, adj);
		var aok = bfs(N, v, adj);

		int ans = 0;
		for(int i = 0; i < N; i++)
		{
			if(tak[i] >= aok[i])
				continue;

			chmax(ref ans, aok[i] - 1);
		}
		WriteLine(ans);
	}

	private int[] bfs(int N, int s, List<int>[] adj)
	{
		int INF = int.MaxValue / N;
		var res = Enumerable.Repeat(INF, N).ToArray();
		var queue = new Queue<int>();
		res[s] = 0;
		queue.Enqueue(s);
		while(queue.Count > 0)
		{
			int v = queue.Dequeue();
			foreach(int u in adj[v])
			{
				if(res[u] != INF)
					continue;

				res[u] = res[v] + 1;
				queue.Enqueue(u);
			}
		}
		return res;
	}
}

public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => Enumerable.Range(0, (int)N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(long N) => Enumerable.Range(0, (int)N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDouble()).ToArray();
	public static decimal[] GetDecimals(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDecimal()).ToArray();
	public static string[] GetStrings(long N) => Enumerable.Range(0, (int)N).Select(_ => GetString()).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) < 0)
			x = y;
	}

	public static void chmin<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) > 0)
			x = y;
	}

	public static void swap<T>(ref T x, ref T y)
	{
		T tmp = x;
		x = y;
		y = tmp;
	}
}

Measured memory_bytes: 34060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(12);
    ll N;
    cin >> N;
    vector<ll> A(N);
    REP(i,N)cin >> A[i];
    sort(ALL(A),greater<>());
    ll ans = A[0];
    REPS(i,N/2-1)ans += A[i]*2;
    if(N%2 == 1)ans += A[N/2];
    cout << ans << "\n";
}

Measured memory_bytes: 4788
def manhattan(a,b):
    return abs(a[0]-b[0]) + abs(a[1]-b[1])

h,w,d = map(int,input().split())
A = [(0,0)]*(h*w)
for i in range(h):
    a = list(map(int,input().split()))
    for j in range(w):
        A[a[j]-1] = (i,j)

dist = [0]*(h*w)
for i in range(d,h*w):
    dist[i] = dist[i-d] + manhattan(A[i],A[i-d])

q = int(input())
ans_list = [0]*q
for i in range(q):
    l,r = map(int,input().split())
    ans = dist[r-1] - dist[l-1]
    ans_list[i] = ans

for ans in ans_list:
    print(ans)

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, n) for (int i = 1; i <= (int)(n); i++)
using ll = long long;

/*
  小さい順: sort(v.begin(), v.end());
  逆順: reverse(v.begin(), v.end());
  vector<pair<ll, ll> > p; ＃ソートした場合、１つ目でソート
  tie(b, a) = p.at(i); #pairを分割
  tasks.emplace_back(b, a)  ＃配列tasksの最後に(b,a)を追加
    string -> int : stoi(S);
  int -> string : to_string(N);
  Sのn文字以降をm文字取り出す : S.substr(n,m)

  int: -2,147,483,648 ～ 2,147,483,647 (2×10^9)
  ll: -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 (9×10^18)

*/
//126~
//126-e

int main() {

    ll N, count=0, ans=0;
    ll BIG=1000000007;
    string S;
    ll m10=1,m9=1,m8=1;
    cin >> N;
    rep(i,N){
        m10 *= 10;
        m10 %= BIG;
    }
    rep(i,N){
        m9 *= 9;
        m9 %= BIG;
    }
    rep(i,N){
        m8 *= 8;
        m8 %= BIG;
    }

    ans = m10 - 2*m9;
    ans %= BIG;
    ans += m8;
    ans %= BIG;
    ans += BIG;
    ans %= BIG;



    cout << ans << endl;
}



Measured memory_bytes: 3596
x, y = map(int, input().split())

from operator import mul
from functools import reduce
def combination_count(n, r):
  r = min(n-r, r)
  num = reduce(modmul, range(n, n-r, -1), 1)
  denom = reduce(modmul, range(r, 1, -1), 1)
  return num*mod_inv(denom,10**9+7)

def modmul(a, b):
  return mul(a,b)%(10**9+7)

def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    #[x,y]
    return [w[0],w[1]]

# aの逆元(mod m)を求める。(aとmは互いに素であることが前提)
def mod_inv(a,m):
    x = extgcd(a,m)[0]
    return (m+x%m)%m

if (x+y)%3 != 0:
  print('0')
else:
  m = (2*x - y)//3
  n = x - 2*m
  if m < 0 or n < 0:
    print('0')
  else:
    c = combination_count(m+n, m)
    print(c%(10**9+7))



Measured memory_bytes: 3688
N=int(input())
M=N//2
l=[int(input()) for i in range(N)]
l.sort()
if N%2==0:
   print(-2*sum(l[0:M-1])-l[M-1]+l[M]+2*sum(l[M+1:]))
else:
   pt1=-2*sum(l[:M-1])-l[M-1]-l[M] +2*sum(l[M+1:])
   pt2=-2*sum(l[:M]) +l[M] + l[M+1] +2*sum(l[M+2:])
   print(max(pt1,pt2))

Measured memory_bytes: 13376
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N, M;
    cin >> N >> M;
    int x[100000], y[100000];
    for(int i=0;i<M;i++)
        cin >> x[i] >> y[i];
    
    // はじめ
    int r[100000] = {}, b[100000] = {};
    r[0] = 1;
    for(int i=0;i<N;i++)
        b[i] = 1;
    // M回の操作
    for(int i=0;i<M;i++){
        b[x[i]-1]--;
        b[y[i]-1]++;
        // 移動元に赤玉がある場合
        if(r[x[i]-1] == 1)
            r[y[i]-1] = 1;
        // 移動元の箱が空になった場合
        if(b[x[i]-1] == 0)
            r[x[i]-1] = 0;
    }

    int ans = 0;
    for(int i=0;i<N;i++){
        // cout << "b:" << b[i] << ", r:" << r[i] << endl;
        if(r[i] == 1)
            ans++;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>

using namespace std;

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

long long int INF = 1e18;
long long int mod = 1000000007;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
ll bit[500005];
//↓,→,↑,←

#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(15)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,n) for(i=0;i<n;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl

ll rui(ll abc,ll bed){
    //abcのbed乗を計算する
    if(bed==0){return 1;}
    else{
        ll ced = rui(abc,bed/2);
        ced *= ced;
        ced %= mod;
        if(bed%2==1){ced*=abc; ced%=mod;}
        return ced;
    }
}
ll gcd(ll number1,ll number2){
	if(number1 > number2){
		swap(number1,number2);
	}
	if(number1 == 0 || number1 == number2){
		return number2;
	}else{
		return gcd(number2 % number1,number1);
	}
}

ll i,j,k,ii,jj,r,l;
ll n,m,num,sum,ans;
ll a,b,c,d,e,g,h,w;
ll x[500005],y[500005],z[500005];
bool dp[10000];
char s[500005];

ll bitsum(ll i){
	ll s = 0;
	while(i>0){
		//p("hoi");
		s += bit[i];
		i -= i & -i;
	}
	return s;
}
void bitadd(ll b,ll x){
	while(b <= n){
		//p("hoi");
		bit[b] += x;
		b += b & -b;
	}
}

int main(){
	cin >> a >> b;
	p(a + 1 - b);
 
 
	return 0;
}

Measured memory_bytes: 27520
#include<bits/stdc++.h>
#pragma GCC optimize("O3")
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define mod 1000000007

using namespace std;

typedef long long ll;


int add(int a, int b)
{
    ll x = a+b;
    if(x >= mod)
        x -= mod;
    if(x < 0)
        x += mod;
    return x;
}
ll mul(ll a, ll b)
{
    return (a*b) % mod;
}

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

int n;
pair<int, int> p[1002];
vector<ll> d;
vector<string> s(1002, "");
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    for(int i = 1; i <= n; ++i)
        cin >> p[i].fi >> p[i].se;
    if((p[1].fi & 1) == (p[1].se & 1))
    {
        d.push_back(1);
        for(int i = 1; i <= n; i++)
        {
            s[i].push_back('U');
            p[i].se--;
        }
    }
    ll step = 1;
    while(step < (1LL << 33))
    {
        d.push_back(step);
        for(int i = 1; i <= n; i++)
        {
            if((p[i].fi & 1) == (p[i].se & 1))
            {
                cout << -1 << '\n';
                return 0;
            }
            if (p[i].fi & 1)
            {
                if (((p[i].fi - 1) & 2) != (p[i].se & 2))
                {
                    p[i].fi--;
                    s[i].pb('R');
                }
                else
                {
                    p[i].fi++;
                    s[i].pb('L');
                }
            }
            else
            {
                if (((p[i].se - 1) & 2) != (p[i].fi & 2))
                {
                    p[i].se--;
                    s[i].pb('U');
                }
                else
                {
                    p[i].se++;
                    s[i].pb('D');
                }
            }
            p[i].fi /= 2;
            p[i].se /= 2;
        }
        step <<= 1;
    }
    d.push_back(step);
    for (int i = 1; i <= n; i++)
    {
        if(p[i].fi == 1)
            s[i].pb('R');
        else
            if(p[i].fi == -1)
                s[i].pb('L');
            else
                if(p[i].se == 1)
                    s[i].pb('U');
                else
                    s[i].pb('D');
    }
    int m = d.size();
    cout << m << '\n';
    for (int i = 0; i < m; i++)
        cout << d[i] << " ";
    cout << '\n';
    for (int i = 1; i <= n; i++)
        cout << s[i] << '\n';
    return 0;
}



Measured memory_bytes: 512
#include <iostream>
using namespace std;
string a;
int n;
int main() {
	cin>>a;
	n = a.size();
	a = '.' + a + '.';
	for(int i=1; i<n; i++) {
		if(a[i]==a[i+1]) {cout<<i<<' '<<i+1; return 0;}
		if(a[i]==a[i+2]) {cout<<i<<' '<<i+2; return 0;}
	}
	cout<<"-1 -1";
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>

using namespace std;

const int SMALL[][2] = {
	{  0,  0 },
	{  0,  1 },
	{  1,  0 },
	{  0, -1 },
	{ -1,  0 }
};

const int MIDIUM[][2] = {
	{  1,  1 },
	{  1, -1 },
	{ -1, -1 },
	{ -1,  1 }
};

const int LARGE[][2] = {
	{  0,  2 },
	{  2,  0 },
	{  0, -2 },
	{ -2,  0 }
};

class Paper
{
private:
	int paper[10][10];
public:
	Paper()
	{
		for ( int i = 0; i < 10; i++ )
		{
			for ( int j = 0; j < 10; j++ )
			{
				paper[i][j] = 0;
			}
		}

		return;
	}

	void put( int x, int y )
	{
		if ( inside( x, y ) )
		{
			paper[x][y]++;
		}
		return;
	}

	bool inside( int x, int y )
	{
		return 0 <= x && x < 10 && 0 <= y && y < 10;
	}

	int countWhite()
	{
		int res = 0;

		for ( int i = 0; i < 10; i++ )
		{
			for ( int j = 0; j < 10; j++ )
			{
				if ( paper[i][j] == 0 )
				{
					res++;
				}
			}
		}

		return res;
	}

	int getMax()
	{
		int max = 0;

		for ( int i = 0; i < 10; i++ )
		{
			for ( int j = 0; j < 10; j++ )
			{
				if ( max < paper[i][j] )
				{
					max = paper[i][j];
				}
			}
		}

		return max;
	}
};

int main()
{
	Paper paper;
	string buffer;

	while ( cin >> buffer )
	{
		int x, y, size;

		for ( unsigned int i = 0; i < buffer.length(); i++ )
		{
			if ( buffer[i] == ',' )
			{
				buffer[i] = ' ';
			}
		}

		istringstream( buffer ) >> x >> y >> size;

		for ( int i = 0; i < sizeof( SMALL ) / sizeof( SMALL[0] ); i++ )
		{
			paper.put( x + SMALL[i][0], y + SMALL[i][1] );
		}

		if ( 2 <= size )
		{
			for ( int i = 0; i < sizeof( MIDIUM ) / sizeof( MIDIUM[0] ); i++ )
			{
				paper.put( x + MIDIUM[i][0], y + MIDIUM[i][1] );
			}
		}

		if ( 3 <= size )
		{
			for ( int i = 0; i < sizeof( LARGE ) / sizeof( LARGE[0] ); i++ )
			{
				paper.put( x + LARGE[i][0], y + LARGE[i][1] );
			}
		}
	}

	cout << paper.countWhite() << endl;
	cout << paper.getMax() << endl;

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <map>
#include <string>
#define Z(z)m[a+b]=1;m[b+a]=1;reverse(z.begin(),z.end());
using namespace std;main(){
	string s,a,b;
	for(cin>>s;cin>>s;){
		map<string,int> m;
		for(int i=0;++i<s.length();){a=s.substr(0,i),b=s.substr(i);Z(a)Z(b)Z(a)Z(b)}
		cout<<m.size()<<endl;
	}
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
 
#define F(i,a,b) for(long long  i =a; i<b; i++)
#define rF(i,a,b) for(long long i=a-1; i>=b;i--)
#define endl "\n"
#define min1(x,y,z) min(x, min(y,z))
#define max1(x,y,z) max(x, max(y,z))
#define input_vector(v,n,type) vector<type> v;for(int i=0;i<n;i++){type x;cin>>x;v.push_back(x);}
#define IOS ios_base::sync_with_stdio(false);  cin.tie(NULL);  cout.tie(NULL);
#define int long long
#define inf (1LL<<61)
typedef pair<int,int> ii;
typedef vector<pair<int,int>> vii;
typedef vector<int> vi;
 
 
 
int32_t main()
{
        IOS;

        int n, m;
        cin>>n>>m;

        cout<<n*(n-1)/2+m*(m-1)/2<<endl;





        
 
 
 
            
 
 
 
      
 
 
        
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
        return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
int cnt[101]={0};
int main(){
	int i,j,n,k,d,num;
	cin>>n>>k;
	for(i=0;i<k;i++){
		cin>>d;
		for(j=0;j<d;j++){
			cin>>num;
			cnt[num]++;
		}
	}
	int ans=0;
	for(i=1;i<=n;i++)
		if(cnt[i]==0)
			ans++;
	printf("%d\n",ans);
}


Measured memory_bytes: 3712
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
// const int dy[] = {1, 1, 0, -1, -1, -1, 0, 1},
//           dx[] = {0, -1, -1, -1, 0, 1, 1, 1};

struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    cerr << fixed << setprecision(10);
  }
} iosetup;
/*-------------------------------------------------*/
int main() {
  int h, w, n; cin >> h >> w >> n;
  vector<int> a(n + 1); FOR(i, 1, n + 1) cin >> a[i];
  vector<vector<int> > ans(h, vector<int>(w));
  int idx = 1;
  REP(i, h) {
    if (i % 2 == 0) {
      REP(j, w) {
        if (a[idx] == 0) ++idx;
        ans[i][j] = idx;
        --a[idx];
      }
    } else {
      for (int j = w - 1; j >= 0; --j) {
        if (a[idx] == 0) ++idx;
        ans[i][j] = idx;
        --a[idx];
      }
    }
  }
  REP(i, h) {
    REP(j, w) cout << ans[i][j] << (j + 1 == w ? '\n' : ' ');
  }
  return 0;
}


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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()

void solve() {
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;
  for (int i = sy; i < ty; i++) cout << 'U';
  for (int i = sx; i < tx; i++) cout << 'R';
  for (int i = sy; i < ty; i++) cout << 'D';
  for (int i = sx; i < tx; i++) cout << 'L';
  cout << 'L';
  for (int i = sy; i <= ty; i++) cout << 'U';
  for (int i = sx; i <= tx; i++) cout << 'R';
  cout << 'D';
  cout << 'R';
  for (int i = sy; i <= ty; i++) cout << 'D';
  for (int i = sx; i <= tx; i++) cout << 'L';
  cout << 'U';
  cout << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) solve();
}


Measured memory_bytes: 3588
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <map>

using ll = long long;

using namespace std;

int main() {
    int n;
    cin >> n;
    int cnt[n];
    fill(cnt, cnt+n, 0);
    for (int i=0, a; i<n; i++) {
        cin >> a;
        cnt[a-1]++;
    }
    int rui[n+1];
    fill(rui, rui+n+1, 0);
    for (auto &ci:cnt)
        rui[ci]++;
    int prev = n;
    for (auto &ri:rui) {
        ri = prev - ri;
        prev = ri;
    }
    int lim[n+1], remain=n;
    lim[0] = n;
    for (int i=n; i>0; i--) {
        remain -= rui[i];
        lim[i] = remain / i;
        //cerr << i << ' ' << lim[i] << ' ' << rui[i] << ' ' << remain << '\n';
    }
    for (int i=1; i<=n; i++)
        cout << partition_point(lim, lim+n+1, [&] (int x) { return x >= i; }) - lim - 1 << '\n';
    return 0;
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using i128 = boost::multiprecision::int128_t;
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using VVV = vector<VV>;
using VVVll = vector<VVll>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
#define rep2(i, m, n) for(int i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(int i=int(m)-1; i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline int sz(T &x) { return x.size(); }
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << " "; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int fLog2(const int x) { return 31-__builtin_clz(x); } // floor(log2(x))
inline int fLog2(const ll x) { return 63-__builtin_clzll(x); }
inline int cLog2(const int x) { return (x == 1) ? 0 : 32-__builtin_clz(x-1); } // ceil(log2(x))
inline int cLog2(const ll x) { return (x == 1) ? 0 : 64-__builtin_clzll(x-1); }
inline int popcount(const int x) { return __builtin_popcount(x); }
inline int popcount(const ll x) { return __builtin_popcountll(x); }
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const ld PI    = acos(-1.0);
const int MOD  = int(1e9)+7;
// const int MOD  = 998244353;


int main() {
  int n; cin >> n;
  int N = 1<<n;
  V a(N); cin >> a;

  vector<set<P>> VS(N);
  VS[0].emplace(-a[0], 0);
  V ans(N);

  rep(S, N) {
    if (S == 0) continue;
    rep(i, n) if (S>>i&1) {
      for (auto &e : VS[S^(1<<i)]) VS[S].insert(e);
    }
    VS[S].emplace(-a[S], S);
    auto it = VS[S].begin();
    ++it;
    ++it;
    VS[S].erase(it, VS[S].end());
    for (auto &e : VS[S]) ans[S] -= e.first;
  }

  rep2(S, 1, N) chmax(ans[S], ans[S-1]); 
  rep2(S, 1, N) cout << ans[S] << '\n';
  return 0;
}


Measured memory_bytes: 42364
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <complex>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
#include <limits>
#include <time.h>
#include <cstdint>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(ll i=n-1;i>=0;i--)
#define rRep(i,a,b) for(ll i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template <class T, class U> inline bool chmax(T& lhs, const U& rhs) { if (lhs < rhs) { lhs = rhs; return 1; } return 0; }
template <class T, class U> inline bool chmin(T& lhs, const U& rhs) { if (lhs > rhs) { lhs = rhs; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

ll  C,D,E,F,G,H,L,M,N,P,Q,R,U,W;
string S;
ll A[100007];

ll cme;

ll modpow(ll b, ll e, ll m){  // bのe乗のmod m を返す
  if (e == 0) return 1;
  cme = modpow(b, e / 2, m);
  cme = (cme * cme) % m;
  if (e % 2 == 1) cme = (cme * b) % m;
  return cme;
}


int main(){
  cin  >> N >> P >> S;
  ll ans=0;
  if(P==2){
    rep(i,N){
      if(ctoi(S[i])%2==0){
        ans+=i+1;
      }
    }
    cout << ans << endl;
    return 0;
  }
  if(P==5){
    rep(i,N){
      if(ctoi(S[i])%5==0){
        ans+=i+1;
      }
    }
    cout << ans << endl;
    return 0;
  }
  reverse(ALL(S));
  ll Z=0;
  A[0]=1;
  rep(i,N){
    ll K=modpow(10,i,P);
    ll X=ctoi(S[i]);
    Z=(Z+K*X)%P;
    A[Z]++;
  }
  rep(i,P){
    ans+=A[i]*(A[i]-1)/2;
  }
  cout << ans << endl;
}


Measured memory_bytes: 644
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	num, _ := strconv.Atoi(scanString())
	return num
}

func scanString() string {
	sc.Scan()
	return sc.Text()
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	n, m := scanInt(), scanInt()
	arr := make([][]int, m)
	for i := range arr {
		k := scanInt()
		arr[i] = make([]int, k)
		for j := range arr[i] {
			arr[i][j] = scanInt()
			arr[i][j]--
		}
	}
	p := make([]int, m)
	for i := range arr {
		p[i] = scanInt()
	}

	allOnCnt := 0
	for b := 0; b < (1 << uint64(n)); b++ {
		isAllOn := true
		for i := range arr {
			onCnt := 0
			for _, e := range arr[i] {
				if (b>>uint64(e))&1 == 1 {
					onCnt++
				}
			}
			if onCnt%2 != p[i] {
				isAllOn = false
				break
			}
		}
		if isAllOn {
			allOnCnt++
		}
	}

	fmt.Println(allOnCnt)
}


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

int main(){
  int y,m,d ;
  char c1,c2 ;
  cin >> y >> c1 >> m >> c2 >> d ;
  if(m <= 04)
    cout <<"Heisei"<< endl;
  else
    cout <<"TBD"<< endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>
using namespace std;
bool is_int_lround(double x){
  return std::lround(x)==x;
}
int main(){
  int N,D;
  cin >>N>>D;
  vector<vector<int>> cod(N,vector<int>(D));
  for(int i=0;i<N ;i++){
    for(int j=0; j<D;j++){
      cin >> cod.at(i).at(j);
    }
  }
  int count =0;
  int sum=0;
  for(int i=0; i<N-1;i++){
    for(int l=i+1 ;l <N ;l++){
      sum =0;
      for(int j=0; j<D ;j++){
       sum += (cod.at(i).at(j)- cod.at(l).at(j))* (cod.at(i).at(j)- cod.at(l).at(j));
       
      }
      if(is_int_lround(sqrt(sum))){
        count ++;
      }
    }
  }
  cout << count <<endl;
}


Measured memory_bytes: 256
//Coronados de gloria vivamos, o juremos con gloria morir
#include <bits/stdc++.h>

using namespace std;

#ifdef ACMTUYO
#define mine(x) x
#else
#define mine(x)
#endif


#define forn(i,n) for(int i=0;i<(int)(n);i++)
#define forsn(i,s,n) for(int i=(s);i<(int)(n);i++)
#define dforn(i,n) for(int i=(int)((n)-1);i>=0;i--)
#define dforsn(i,s,n) for(int i=(int)((n)-1);i>=(int)(s);i--)
#define all(c) begin(c), end(c)
#define esta(x,c) ((c).find(x) != end(c))


#define wbe(f, c, as...) f(all(c), ##as)
#define wbeb(f, c, d, as...) f(all(c), begin(d), ##as)
#define L(r, as...) [&](as){return r;}

#define LEA mine(freopen("in.txt", "r", stdin))

#define dbgi(a) << #a << " = " << (a) <<
#define dbg1(a, z...) 	dbgi(a) ""
#define dbg2(a, z...)  	dbgi(a) ", " dbg1(z)
#define dbg3(a, z...)  	dbgi(a) ", " dbg2(z)
#define dbg4(a, z...)  	dbgi(a) ", " dbg3(z)
#define dbg5(a, z...)   dbgi(a) ", " dbg4(z)

#define dbgx(v1, v2, v3, v4, v5, v6, z...) v6
#define dbg(z...)  mine( cerr dbgx(z, dbg5(z), dbg4(z), dbg3(z), dbg2(z), dbg1(z)) << endl );

#define raya mine(cerr << "----------" << endl)

// TYPEDEFS
typedef long long tint;
typedef vector<int> vint;
typedef vector<vector<int>> grint;
typedef pair<int,int> pint;
typedef long double tdbl;

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back

const double PI=acos(-1.0);

int n, m, mask = 0;

bool bad(int n){
	while(n){
		if(mask & (1<<n%10)) return true;
		n/=10;
	}
	return false;
}

int main(int argc, char **argv) {
	//        LEA;
	ios_base::sync_with_stdio(0);



	cin >> n >> m;

	forn(i, m){
		int d;
		cin >> d;
		mask |= (1<<d);
	}

	while(bad(n))n++;

	cout << n << endl;

	return 0;
}


Measured memory_bytes: 256
# coding: utf-8

intA, intB, intC = map(int, input().split())

if intA < intB:
    if intA < intC and intC < intB:
        print('Yes')
    else:
        print("No")
else:
    if intB < intC and intC < intA:
        print("Yes")
    else:
        print("No")


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

int n, stack, previous = -1;
vector<int> mochi;

int main() {
	int a;
	
	cin >> n;
	
	for(int i = 0; i < n; ++i){
		cin >> a;
		mochi.push_back(a);
	}
	
	sort(mochi.begin(), mochi.end());
	
	for(int i = n-1; i >= 0; --i){
		if(previous != mochi[i]){
			++stack;
			previous = mochi[i];
		}
	}
	
	cout << stack;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void)
{
    int N;
    cin >> N;
    N=N%10;
    if(N==3){ cout << "bon" ;
    }
    else if(N==0 || N==1 || N==6 || N==8){
              cout << "pon";
    }
    else      cout << "hon";
    return 0;
    }

Measured memory_bytes: 3636
#include <iostream>
#include <string>
using namespace std;
int main(){
    int k;
    string s;
    cin >> k >> s;
    int n;
    n = s.length();
    if(k>=n){
        cout << s;
    }else{
        s.resize(k);
        cout << s << "...";
    }

    return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  int cnt[10];
  int flag=0;
  int t[10] = {1,2,4,8,16,32,64,128,256,512};
  while(cin>>n){
    flag = 0;
    for(int i=0;i<10;i++){
      cnt[i] = 0;
    }
    for(int i=9;i>=0;i--){
      if(n - t[i] >= 0 && flag==0){
	n = n - t[i];
	cnt[i]+=2;
	flag=1;
      }else if(n - t[i] >= 0 && flag==1){
	n = n - t[i];
	cnt[i]++;
      }
      if(n == 0) break;
    }
    for(int i=0;i<10;i++){
      if(cnt[i] == 1){
	cout<<t[i]<<" ";
      }else if(cnt[i] == 2){
	cout<<t[i]<<endl;
      }
    }
    
  }
  
}

Measured memory_bytes: 1160
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define INF 10e16
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll>P;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
ll cmp(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}

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

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    //int n;cin>>n;
    //vector<int>a(n);
    //for(int i=0;i<n;i++)
        //cin>>a[i];
    //int a,b;cin>>a>>b;
    int a1,a2,a3;cin>>a1>>a2>>a3;
    if(a1+a2+a3>=22)
        cout<<"bust"<<endl;
    else
        cout<<"win"<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------


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

int main() {
	int n, m;
	scanf("%d %d", &n, &m);
	vector<int> a(m);
	int hw = 0;
	for(int i = 0; i < m; i++) {
		scanf("%d", &a[i]);
		hw += a[i];
	}
	if(hw > n) {
		printf("%d\n", -1);
	}else {
		printf("%d\n", n - hw);
	}
}

Measured memory_bytes: 3772
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int l = sc.nextInt();
        int m = sc.nextInt();
        int n = sc.nextInt();
        int o = sc.nextInt();
        int p = sc.nextInt();
        int q = sc.nextInt();
        int r = sc.nextInt();
        int s[][] = new int[r][2];
        for (int u=0; u < r; u++) {
            s[u][0] = sc.nextInt();
            s[u][1] = sc.nextInt();
        }
        sc.close();
        Dice2 dice = new Dice2(l, m, n, o, p, q);
        for (int u=0; u < r; u++) {
        	System.out.println(dice.search(s[u][0], s[u][1]));
        }
    }
}
    class Dice2{
		int one;
		int two;
		int three;
		int four;
		int five;
		int six;
		int tmp;
    	Dice2(int a, int b, int c, int d, int e, int f){
    		one=a;
    		two=b;
    		three=c;
    		four=d;
    		five=e;
    		six=f;
    	}
    	int search(int a, int b){//上面・前面の順
    		if(a==one) {
    			if(b==two){
    				return three;
    			} else if(b==three){
    				return five;
    			} else if(b==four){
    				return two;
    			} else if(b==five){
    				return four;
    			}
    		} else if(a==two) {
    			if(b==one){
    				return four;
    			} else if(b==three){
    				return one;
    			} else if(b==four){
    				return six;
    			} else if(b==six){
    				return three;
    			}
    		} else if(a==three) {
    			if(b==one){
    				return two;
    			} else if(b==two){
    				return six;
    			} else if(b==five){
    				return one;
    			} else if(b==six){
    				return five;
    			}
    		} else if(a==four) {
    			if(b==one){
    				return five;
    			} else if(b==two){
    				return one;
    			} else if(b==five){
    				return six;
    			} else if(b==six){
    				return two;
    			}
    		} else if(a==five) {
    			if(b==one){
    				return three;
    			} else if(b==three){
    				return six;
    			} else if(b==four){
    				return one;
    			} else if(b==six){
    				return four;
    			}
    		} else if(a==six) {
    			if(b==two){
    				return four;
    			} else if(b==three){
    				return two;
    			} else if(b==four){
    				return five;
    			} else if(b==five){
    				return three;
    			}
    		}
    		return 0;
    	}
    	void print(){
    		System.out.println(one);
    	}

    }



Measured memory_bytes: 26356
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		int n;

		n = new java.util.Scanner(System.in).nextInt();

		switch (n%10) {
		case 0:
		case 1:
		case 6:
		case 8:
			System.out.println("pon");
			break;

		case 2:
		case 4:
		case 5:
		case 7:
		case 9:
			System.out.println("hon");
			break;

		case 3:
			System.out.println("bon");
			break;
		}
	}

}


Measured memory_bytes: 35756
N = int(input())
jp = 0
bt = 0.0
btrate = 380000.0
for i in range(N):
    money = list(input().split())
    if money[1] == "JPY":
        jp += int(money[0])
    else:
        bt += float(money[0])*btrate
print(str(float(jp) + bt))

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
char G[1000][1000];
int N;

int next(int i){ return ((N-i-1)+N)%N;}

bool getState(int i, int j){
  return  G[i][j] == G[i][next(j)] &&
    G[i][j] == G[next(i)][j] &&
    G[i][j] == G[next(i)][next(j)];
}

int getInit(){
  int dcnt = 0;
  for ( int i = 0; i < N/2; i++ ){
    for ( int j = 0; j < N/2; j++ ){
      if (!getState(i, j)) dcnt++;
    }
  }
  return dcnt;
}

int main(){
  int C, dcnt, ans = 0;
  cin >> C >> N;
  for ( int i = 0; i < N; i++ ){
    for ( int j = 0; j < N; j++ ){
      cin >> G[i][j];
    }
  }
  
  dcnt = getInit();
  if (dcnt == 0 ) ans++;
  for ( int i = 0; i < C-1; i++ ){
    int k, r, c; cin >> k;
    for ( int j = 0; j < k; j++ ){
      cin >> r >> c; r--; c--;
      bool pre = getState(r, c);
      G[r][c] = G[r][c]=='1'?'0':'1';
      bool post = getState(r, c);
      if ( !pre && post ) dcnt--;
      else if ( pre && !post ) dcnt++;
    }
    if ( dcnt == 0 ) ans++;
  }
  
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 4060
import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
    	int n = Integer.parseInt(s);
        if(n < 1000){
          System.out.println("ABC");
        } else {
          System.out.println("ABD");
        }
  }
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define fi first
#define se second
#define pb push_back
#define mk make_pair

using namespace std;
typedef long long ll;
ll mod = 998244353;
vector<ll> m;

int main() {
	fastio;
	ll n,a,b;
	cin>>n>>a>>b;
	m.resize(n);
	for(ll i=0;i<n;i++){
		cin>>m[i];
	}
	ll lo = 0, hi = 1e10;
	ll ans = hi;
	while(lo<=hi){
		ll mid = (hi+lo)/2;
		ll c = 0;
		for(ll i=0;i<n;i++){
			if(mid*b<m[i]){
				ll r = m[i]-mid*b;
				c += (r+a-b-1)/(a-b);
			}
		}
		
		if(c<=mid){
			ans = mid;
			hi = mid-1;
		}
		else{
			lo = mid+1;
		}
		
	}
	
	cout<<ans<<"\n";
	
}






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

struct Tuple
{
  long long value;
  long long weight;
  char type;
  long long data;
  string name;
};
bool cmp(Tuple a,Tuple b)
{
    if(a.value!=b.value)return a.value<b.value;
    else if(a.weight!=b.weight)return a.weight<b.weight;
    else if(a.type!=b.type)return a.type<b.type;
    else if(a.data!=b.data)return a.data<b.data;
    else return a.name<b.name;
}
int main()
{
    int n;
    cin>>n;
    vector<Tuple>v(n);
    for(int i=0;i<n;i++)
    {
        cin>>v[i].value>>v[i].weight>>v[i].type>>v[i].data>>v[i].name;
    }
    sort(v.begin(),v.end(),cmp);
    for(int i=0;i<n;i++)
    {
        cout<<v[i].value<<" "<<v[i].weight<<" "<<v[i].type<<" "<<v[i].data<<" "<<v[i].name<<endl;
    }
    return 0;
}



Measured memory_bytes: 12964
#include <iostream>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
#include <complex>

using namespace std;
typedef long long ll;


typedef complex<double> xy_t;
double dot_product(xy_t a, xy_t b) { return (conj(a)*b).real(); }
double cross_product(xy_t a, xy_t b) { return (conj(a)*b).imag(); }

typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする

vector<int> G[100005];
std::vector<P> tree[100010];

int dx[9]={1,0,-1,0,1,1,-1,-1,0};
int dy[9]={0,1,0,-1,1,-1,-1,1,0};

#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define re(i,a,b) for(i=a;i<=b;i++)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl;

ll i,j,k,ii,jj;
ll n,m,sum,num;
ll ans=0;
ll a,b,c,d,e,f,g,h,w;
ll start,end;
ll x[500005],y[500005],z[500005];
bool flag;


int main(){
    cin>>n>>m>>a>>b;
    for(i=0;i<n;i++){
        cin>>x[i];
    }
    for(i=0;i<m;i++){
        cin>>y[i];
    }
    for(i = a+1;i<=b;i++){
        flag = false;
        for(j=0;j<n;j++){
            if(x[j] >= i){
                flag = true;
                break;
            }
        }
        if(flag)continue;
        for(j=0;j<m;j++){
            if(y[j] < i){
                flag = true;
                break;
            }
        }
        if(!flag){
            p("No War");
            return 0;
        }
    }
    p("War");
    
    return 0;
    
}



Measured memory_bytes: 11004
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int read() {
	int x=0, f=1; char ch=' ';
	while(!isdigit(ch)) {ch=getchar(); if(ch=='-') f=-1;}
	while(isdigit(ch)) x=(x<<3)+(x<<1)+(ch^48), ch=getchar();
	return x*f;
}
int a[1005], n, k, sum;
int main() {
	cin>>n>>k;
	for(int i=1;i<=n;i++) a[i]=read();
	sort(a+1, a+n+1);
	for(int i=1;i<=k;i++) sum+=a[i];
	cout<<sum;
}


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

using namespace std;

int main(void){
    int n;
    cin >> n;
    vector<int> v(n);
    for(int i = 0; i < n; i++)
        cin >> v[i];

    int s1, s2, ans = INT_MAX;
    for(int i = 0; i < n; i++){
        s1 = accumulate(v.begin(), v.begin() + i, 0);
        s2 = accumulate(v.begin() + i, v.end(), 0);
        ans = min(ans, abs(s1 - s2));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B;
    cin >> A >> B;
    cout << (B + A - 3) / (A - 1) << endl;
    return 0;
}

Measured memory_bytes: 256
S = input()

def is_keyence_str(S):
    for i in range(len(S) + 1):
        for j in range(i, len(S) + 1):
            r = S[:i] + S[j:]
            # print(i, j, r)
            if r == "keyence":
                return True
    return False

if is_keyence_str(S):
    print("YES")
else:
    print("NO")

Measured memory_bytes: 2940
// In the Name of God

#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>

using namespace std;

#define	ll long long
#define ull unsigned long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define sz(a) int(a.size())
#define all(v) v.begin(), v.end()
#define bpc(v) __builtin_popcountll(v)
#define itr iterator
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define per(i, a, b) for (int i = a; i >= b; --i)
#define ub upper_bound
#define lb lower_bound

const int N = 2e5 + 5;
const int mod = 1e9 + 7;
const ll inf = 1e18 + 1;
const double eps = 1e-15;
const int pw = 257;

int n;
ll a, b, sum, suma, sumb, ans = inf;
vector<pair<ll ,int> > v;

int main() {
	#ifdef Madi
	freopen(".in", "r", stdin);
	freopen(".out", "w", stdout);
	#endif
	                                            	
	ios_base :: sync_with_stdio(false); cin.tie(NULL);
    
    cin >> n;
    rep(i, 1, n) {
    	cin >> a >> b;
    	v.pb(mp(a, i));
    	v.pb(mp(b, i));
    	suma += a;
    	sumb += b;
    }

    sort(all(v));

    set<int> s;
    rep(i, 0, n - 1)
    	sum += v[i].fi, s.insert(v[i].se);

	if (sz(s) != n)
		ans = sum;

	rep(i, n, n + n - 1) {
//		if (v[i])
		ll res = sum;
		if (v[n - 1].se == v[i].se)
			res -= v[n - 2].fi;
		else
			res -= v[n - 1].fi;
		res += v[i].fi;
		ans = min(ans, res);
	}

	cout << min(min(suma, sumb), ans);

	#ifdef Madi
    cerr << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif
	return 0;
}

Measured memory_bytes: 8940