akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    ll K;
    cin >> K;
    ll a = 0;
    rep(i, K + 10) {
        a *= 10;
        a += 7;
        a %= K;
        if(a == 0) {
            output(i + 1);
            return 0;
        }
    }
    
    output(-1);
    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define unless(flg) if ( !(flg) )
#define read cin<<
#define echo cout<<
#define fin <<'\n'
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
#define cinf(n,x) for(int UNCH=0;UNCH<(n);UNCH++) cin >> x[UNCH];
#define fcin(n,x) for(int UNCH=1;UNCH<=(n);UNCH++) cin>> x[UNCH];
#define memmin(x) memset((x),-1,sizeof((x)))
#define memzer(x) memset((x), 0,sizeof((x)))
#define meminf(x) memset((x),0x3f,sizeof((x)))
#define int long long
typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 1000000009;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>T abs(T &x){return x<0 ? -x : x;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}



signed main(){

  int n,a,b;
  string str;
  int h[]={0,100,1,2,3,4,5,6,7,8,9,10,12,13};
  cin >>a >> b;
  if(a==b) cout <<"Draw\n";
  else if(h[a] < h[b]) cout <<"Bob\n";
  else cout <<"Alice\n";
  return 0;
}



struct xyz{ xyz(){ cin.tie(0), ios::sync_with_stdio(false); cout <<fixed<<setprecision(12);};}xyzzy;



Measured memory_bytes: 256
import java.util.Scanner;

class Main{
  public static void main(String[] args){
    Scanner scan=new Scanner(System.in);
    String a="ABC";
    String b=scan.next();
    if(a.equals(b)){
      System.out.println("ARC");
    }else{
      System.out.println("ABC");
    }
  }
}

Measured memory_bytes: 35708
#include <bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
const int INF=999999;
int ans;
int main(){
 string h;
cin>>h;
for(int i=0;i<4;++i){
  if(h[i]=='2') ++ans;
}
cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,m,k;
  cin>>n>>m>>k;
  vector<int> a(n);
  vector<int> b(m);
  for(int i=0;i<n;i++)cin>>a[i];
  for(int i=0;i<m;i++)cin>>b[i];
  long long time=0;
  for(int i=0;i<m;i++)time+=b[i];
  int j=m;
  int ans=0;
  for(int i=0;i<n+1;i++){
    while(j>0 && time>k){
      j--;
      time-=b[j];
    }
    if(time>k)break;
    ans=max(ans,i+j);
    time+=a[i];
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 4824
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main(){
	int m, min, max;
	while(cin >> m >> min >> max, m || min || max){
		vector<int> data(m);
		for(int i = 0; i < m; i++){//input
			cin >> data[i];
		}

		pair<int, int> a = make_pair(0, 0);
		for(int i = min; i <= max; i++){
			int tmp = data[i-1] - data[i];
			
			if(tmp >= a.second){
				a.first = i;
				a.second = tmp;
			}
		}

		cout << a.first<< endl;
	}

	return 0;
}


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

public class Main{

	public static void main(String[] args) throws IOException{
		// TODO Auto-generated method stub
		
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
       
		
	    int stoneCount = Integer.parseInt(reader.readLine());
        String str[] = reader.readLine().split(" ");
	    int stones[] = new int[stoneCount];
	    
	    for(int i=0;i<stoneCount; i++) stones[i] = Integer.parseInt(str[i]);
	    
	     int dp[]  = new int[stoneCount + 1];
	     
	     for(int i=0; i<=stoneCount; i++) dp[i] = -1;
	     
	    int minimumIncurred = solve(stones, 0, stoneCount, dp);
	    
	    System.out.println(minimumIncurred);
	    
	    

	}
	
	public static int solve(int stones[], int i, int stoneCount, int dp[])
	{
		
		if(i==stoneCount-1)
			return 0;
		
		if(dp[i] != -1)
			return dp[i];
		int first = Integer.MAX_VALUE;
		int second = Integer.MAX_VALUE;
		if(i+1<stoneCount) 
		first = Math.abs(stones[i] - stones[i+1])+solve(stones, i+1, stoneCount, dp);
		if(i+2<stoneCount)
		second = Math.abs(stones[i] - stones[i+2])+ solve(stones, i+2, stoneCount, dp);
		dp[i] = Math.min(first, second);
		return Math.min(first, second);	
	}

}


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

int n, u, k, v;
int d[101], f[101];
pair<int, vector<int> > G[101];

int ti = 1;

void dfs(int id) {
	if (d[id]) return ;
	d[id] = ti ++;

	vector<int>& adj = G[id].second;
	for (int i=0; i<(int)adj.size(); ++i) {
		dfs(adj[i]);
	}
	f[id] = ti ++;
}

int main() {
	cin >> n;
	for (int i=0; i<n; ++i) {
		cin >> u >> k;
		G[u].first = u;
		while (k --) {
			cin >> v;
			G[u].second.push_back(v);
		}
	}
	for (int i=1; i<=n; ++i) {
		dfs(i);
		cout << i << " " << d[i] << " " << f[i] << endl;
	}
	return 0;
}

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define MOD         (1000000007LL)

using LL  = long long;
// }}}

int main() {
    std::ios::sync_with_stdio(false);
    int n, x;cin >> n >> x;
    if(x == 2*n-1 || x == 1){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
        if(n == 2){
            for(int i=1;i<=3;i++){
                cout << i << endl;
            }
        }else{
            vector<int> ans;
            for(int i=1;i<=2*n-1;i++){
                if(x == 2 && x-1 <= i && i <= x+2) continue;
                if(x != 2 && x-2 <= i && i <= x+1) continue;
                ans.push_back(i);
            }
            for(int i=0;i<n-2;i++){
                cout << ans[i] << endl;
            }
            if(x == 2){
                cout << x+1 << endl;
                cout << x << endl;
                cout << x-1 << endl;
                cout << x+2 << endl;
            }else{
                cout << x-1 << endl;
                cout << x << endl;
                cout << x+1 << endl;
                cout << x-2 << endl;
            }
            for(int i=n-2;i<2*n-1-4;i++){
                cout << ans[i] << endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define pb push_back
#define all(v) v.begin(), v.end()
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    int N,K,X,Y;
    cin>>N>>K>>X>>Y;
    if(N<=K) cout<<N*X<<endl;
    else cout<<K*X+(N-K)*Y<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int digitsum(int N)
{
  if(N == 0)
    return 0;
  else
    return ((N % 10) + digitsum(N / 10));

}

int hjd(int N)
{
  if(N % digitsum(N) == 0)
    return 1;
  else
    return 0;
}

int main()
{
  int N;
  scanf("%d",&N);
  switch(hjd(N)){
  case 0 :
    printf("No\n");
    break;
  case 1 :
    printf("Yes\n");
    break;
  default :
    printf("Error\n");
    break;
  }
  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int main(void)
{
	int r,c,a[101][101]={0},i,j;
	scanf("%d%d",&r,&c);
	for(i=0;i<r;i++){
		for(j=0;j<c;j++){
			scanf("%d",&a[i][j]);
			a[i][c]+=a[i][j];
		}
	}
	for(i=0;i<c;i++){
		for(j=0;j<r;j++)a[r][i]+=a[j][i];
		a[r][c]+=a[r][i];
	}
	for(i=0;i<=r;i++){
		for(j=0;j<=c;j++){
			if(j!=0)printf(" ");
			printf("%d",a[i][j]);
		}
		puts("");
	}
	return 0;
}


Measured memory_bytes: 2124
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
#include<iomanip>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60


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

	ll N, K; cin >> N >> K;
	ll ans = 0;

	for (ll i = K + 1; i <= N; i++) {
		ll quo = N / i;
		ll rem = N % i;

		ll cnt = quo * (i - K);
		if (K != 0) cnt += max(0LL, rem - K + 1);
		else cnt += rem;

		//cout << i << " : " << cnt << endl;
		ans += cnt;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int min(int a,int b)
{
	if(a<=b)
	return a;
	else
	return b;
}
int main()
{
	int A,B,C,D;
	cin>>A>>B>>C>>D;
	cout<<min(A,B)+min(C,D);
	return 0;
} 

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

int solve(int n,vector<string> s){
    vector<vector<int>> g(n,vector<int>(n,0));
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(i==j) continue;
            for(int k=s[i].size();k>=0;k--){
                if(s[i].substr(k,s[i].size()-k)==s[j].substr(0,s[i].size()-k)){
                    g[i][j]=s[j].size()-(s[i].size()-k);
                }
            }
        }
    }

    const int INF=100000;
    vector<vector<int>> dp(n,vector<int>(1<<n,INF));
    for(int i=0;i<n;i++) dp[i][1<<i]=s[i].size();

    for(int bit=0;bit<(1<<n);bit++){
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                dp[j][bit|(1<<j)]=min(dp[j][bit|(1<<j)],dp[i][bit]+g[i][j]);
            }
        }
    }
    int res=INF;
    for(int i=0;i<n;i++) res=min(res,dp[i][(1<<n)-1]);
    return res;
}
int main(){
    int n;
    while(cin>>n,n){
        vector<string> s(n);
        for(int i=0;i<n;i++) cin>>s[i];
        vector<int> discard(n,false);
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                if(i==j) continue;
                for(int k=0;k+s[i].size()<=s[j].size();k++){
                    if(s[j].substr(k,s[i].size())==s[i]) discard[i]=true;
                }
            }
        }
        vector<string> ts;
        for(int i=0;i<n;i++) if(!discard[i]) ts.push_back(s[i]);
        int tn=ts.size();
        cout<<solve(tn,ts)<<endl;
    }
    return 0;
}


Measured memory_bytes: 3932
s = input()
k = int(input())
c = 0
d = 0
a = []
s += "A"
for i in range(len(s)-1):
    if (s[i] == s[i+1]):
        c += 1
    else:
        a.append(c+1)
        d += 1
        c = 0
c = 0
if s[0] != s[len(s)-2]:
    for i in range(d):
        c += a[i]//2
    print(int(c*k))
elif d == 1:
    print(int(a[0]*k//2))
else:
    for i in range(d):
        c += a[i]//2
    c = c*k - (k-1)*(a[0]//2 + a[d-1]//2 - (a[0] + a[d-1])//2)
    print(int(c))

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


void solve(long long N, long long K, std::vector<long long> p){
    double ans = 0;
    double acc = 0;
    for(int i=0;i<K;++i)acc += (1+p[i])/2.0;
    ans = acc;
    for(int i=K;i<N;++i)
    {
        acc +=(1+p[i])/2.0;
        acc -= (1+p[i-K])/2.0;
        ans = max(ans,acc);
    }
    printf("%.7f\n",ans);
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> p(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&p[i]);
    }
    solve(N, K, std::move(p));
    return 0;
}


Measured memory_bytes: 1792
#![allow(non_snake_case)]
#![allow(unused_imports)]
use ascii::AsciiChar;
use ascii::AsciiStr;
use itertools::Itertools as _;
use permutohedron::LexicalPermutation as _;
use petgraph::algo::dijkstra;
use petgraph::algo::min_spanning_tree;
use petgraph::data::FromElements;
use petgraph::graph::NodeIndex;
use petgraph::graph::UnGraph;
use petgraph::unionfind::UnionFind;
use proconio::fastout;
use proconio::input;
use proconio::marker::Chars;
use proconio::marker::Usize1;
use std::cmp::max;
use std::cmp::min;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::VecDeque;
use superslice::Ext as _;

#[fastout]
fn main() {
    input! {
        N: usize,
        Ss: [Chars; N],
    }

    // 元から文字列に入っているABをカウントしておく
    let mut ans: usize = 0;
    for vec in Ss.iter() {
        for i in 1..vec.len() {
            if vec[i - 1] == 'A' && vec[i] == 'B' {
                ans += 1;
            }
        }
    }

    let BAs: Vec<Vec<char>> = Ss
        .clone()
        .into_iter()
        .filter(|s| s[0] == 'B' && s[s.len() - 1] == 'A')
        .collect();
    let BXs: Vec<Vec<char>> = Ss
        .clone()
        .into_iter()
        .filter(|s| s[0] == 'B' && s[s.len() - 1] != 'A')
        .collect();
    let XAs: Vec<Vec<char>> = Ss
        .clone()
        .into_iter()
        .filter(|s| s[0] != 'B' && s[s.len() - 1] == 'A')
        .collect();
    // let others: Vec<Vec<char>> = Ss
    //     .clone()
    //     .into_iter()
    //     .filter(|s| s[0] != 'B' && s[s.len() - 1] != 'A')
    //     .collect();

    let mut XAs_rest = XAs.len();
    let mut BXs_rest = BXs.len();
    let mut BAs_rest = BAs.len();

    // まず、XAとBXの小さいほうに合わせて消費
    let smaller = min(XAs_rest, BXs_rest);
    ans += smaller;
    XAs_rest -= smaller;
    BXs_rest -= smaller;

    let bigger_rest = max(XAs_rest, BXs_rest);
    if smaller > 0 && bigger_rest == 0 {
        // 最初でぴったり消費できた場合
        // BA同士でくっつける
        let BAs_comb = if BAs_rest >= 2 { BAs_rest - 1 } else { 0 };
        ans += BAs_comb;
        BAs_rest = if BAs_rest >= 1 { 1 } else { 0 };

        // BAのかたまりをXA-BXに挟み込んで消勝することができる
        if BAs_rest > 0 {
            ans += 1;
        }
    } else {
        // まだ余っている場合

        // BA同士でくっつける
        let BAs_comb = if BAs_rest >= 2 { BAs_rest - 1 } else { 0 };
        ans += BAs_comb;
        BAs_rest = if BAs_rest >= 1 { 1 } else { 0 };

        if bigger_rest > 0 && BAs_rest > 0 {
            ans += 1
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 4040
#include <bits/stdc++.h>
#define rep(i, N) for (int i = 0; i < N; i++)
using namespace std;
int main()
{
    string s, t;
    cin >> s >> t;
    vector<char> S(s.size()), T(t.size());

    rep(i, s.size())
    {
        S[i] = s[i];
    }
    rep(i, t.size())
    {
        T[i] = t[i];
    }
    sort(S.begin(), S.end());
    sort(T.begin(), T.end());
    reverse(T.begin(), T.end());
    int i = 0;
    while (i < min(S.size(), T.size()))
    {
        if (S[i] < T[i])
        {
            cout << "Yes" << endl;
            return 0;
        }
        else
        {
            if (S[i] == T[i])
            {
                i++;
            }
            else
            {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    if (s.size() < t.size())
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];
    int ans = 0;
    for (int i=0; i<n; i+=2) {
        if (a[i]%2==1) ++ans;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3628
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<algorithm>
using namespace std;

long long h,m,ans,temp;
long long s[3];
int main()
{
	cin>>h>>m;
	if(h%3==0||m%3==0)
	{
		cout<<0<<endl;
		return 0;
	}
	ans=min(h,m);
	for(long long i=1;i<=h;i++)
	{
		temp=m/2;
		s[0]=i*temp;
    	s[1]=i*(m-temp);
    	s[2]=(h-i)*m;
    	sort(s,s+3);
		ans=min(ans,s[2]-s[0]);
	}
	for(long long i=1;i<=m;i++)
	{
		temp=h/2;
		s[0]=i*temp;
    	s[1]=i*(h-temp);
    	s[2]=(m-i)*h;
    	sort(s,s+3);
		ans=min(ans,s[2]-s[0]);
	}
	cout<<ans<<endl;
	return 0; 
} 

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define pb push_back
#define jizz ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define F first
#define S second
#define MP make_pair
#define ET cout << "\n"
#define MEM(i,j) memset(i,j,sizeof i)
#define ALL(v) v.begin(),v.end()
#define DB(a,s,e) {for(int i=s;i<e;++i) cout << a[i] << " ";ET;}
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

int main()
{
	ll k,a,b,ans=1;
	cin >> k >> a >> b;
	if(a>=b-1)
		return cout << k+1 << "\n",0;
	if(ans<a)
	{
		if(a-ans<=k-2) k-=a-ans,ans=a;
		else ans+=k,k=0;
	}
	if(!k)
		return cout << ans << "\n",0;
	if(k&1)
		ans+=(b-a)*(k/2)+1;
	else
		ans+=(b-a)*(k/2);
	cout << ans << "\n";
}

Measured memory_bytes: 256
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False
"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

h,w = m()
n = onem()

a = l()

po = [[0 for i in range(w)] for j in range(h)]


co = 0

for i in range(h):
    if i % 2 == 0:
        for j in range(w):
            if a[co] == 0:
                co += 1
            po[i][j] = co + 1
            a[co] -= 1
    else:
        for j in range(w-1,-1,-1):
            if a[co] == 0:
                co += 1
            po[i][j] = co + 1
            a[co] -= 1

for i in range(h):
    print(jo(po[i]))









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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int N, W;
int v[101], w[101];
int dp[102][10002];

int main() {
    cin >> N >> W;
    rep(i, N) {
        cin >> v[i] >> w[i];
    }
    for (int i = 0; i < N; ++i) {
        for (int cap = 0; cap <= W; ++cap) {
            if (cap < w[i]) dp[i+1][cap] = dp[i][cap];
            else dp[i+1][cap] = max(dp[i][cap], dp[i][cap-w[i]]+v[i]);
        }
    }
    cout << dp[N][W] << endl;
    return 0;
}



Measured memory_bytes: 7000
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
  int N, M;
  cin >> N;
  vector<string> s(N, "");
  vector<string> tmp(N, "");
  for (int i = 0; i < N; i++) {
    cin >> s[i];
  }
  tmp = s;

  sort(tmp.begin(), tmp.end());
  tmp.erase(unique(tmp.begin(), tmp.end()), tmp.end());
  vector<int> sum(tmp.size(), 0);

  cin >> M;
  vector<string> t(M, "");
  for (int i = 0; i < M; i++) {
    cin >> t[i];
  }
  for (int i = 0; i < tmp.size(); i++) {
    for (int j = 0; j < N; j++) {
      if (tmp[i] == s[j])
        sum[i]++;
    }
  }
  for (int i = 0; i < tmp.size(); i++) {
    for (int j = 0; j < M; j++) {
      if (tmp[i] == t[j])
        sum[i]--;
    }
  }
  sort(sum.begin(), sum.end(), greater<int>());
  if (sum[0] > 0)
    cout << sum[0];
  else
    cout << 0;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
int INF = 1e9 +7;
signed main(){
    int n,k,a,b;
    cin >>n>>k;
    vector<int> k0;
    k0.push_back(k);
    int t=1;
    while(k>=(1<<t)){
        if(k&(1<<t))k0.push_back((k -(1<<t))|((1<<t)-1));
       // cerr<<(1<<t)<<' ';
        t++;
    }
    int ans[k0.size()]={};

    //for(int i=0;i<k0.size();i++)cerr<<k0[i]<<' ';
    for(int i=0;i<n;i++){
        cin >>a>>b;
        for(int j=0;j<k0.size();j++)if((k0[j]|a)<=k0[j])ans[j]+=b;
       
    }
    int ansa=ans[0];
   // cerr<<ansa;
    for(int i=1;i<k0.size();i++){
        ansa=max(ansa,ans[i]);
      //  cerr<<ans[i];
    }
    cout <<ansa;




    return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N; cin >> N;
    vector<ll> a(N); rep(i, N){cin >> a.at(i);}
    ll tmp = 0;

    vector<ll> acc_sum(N);
    rep(i, N){
        tmp += a.at(i);
        acc_sum.at(i) = tmp;
    }

    ll ans = INF;
    rep(i, N - 1){
        ll x = abs(2 * acc_sum.at(i) - tmp);
        ans = (ans > x) ? x : ans;
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 6332
<?php
$nl=(int)trim(fgets(STDIN));

$node=array($nl);

for($i=0;$i<$nl;$i++){
	$node[$i]=array('ca'=>-1,'cb'=>-1,'pa'=>-1,'si'=>-1,'dg'=>0);
}

for($i=0;$i<$nl;$i++){
	$ls=explode(' ',trim(fgets(STDIN)));#lines
	$id=(int)array_shift($ls);
	$ca=(int)array_shift($ls);
	$cb=(int)array_shift($ls);

	if($ca!=-1){
		++$node[$id]['dg'];#degree
		$node[$id]['ca']=$ca;#left

		$node[$ca]['pa']=$id;#parent
		$node[$ca]['si']=$cb;#sibling
	}
	if($cb!=-1){
		++$node[$id]['dg'];#degree
		$node[$id]['cb']=$cb;#right

		$node[$cb]['pa']=$id;
		$node[$cb]['si']=$ca;
	}
}

$root=-1;
for($i=0;$i<$nl;$i++){
	if($node[$i]['pa']==-1){
		$root=$i;
		break;
	}
}

printf("Preorder\n");
prtw($root);
printf("\nInorder\n");
intw($root);
printf("\nPostorder\n");
pstw($root);
printf("\n");

function pstw($id){
	global $node;
	$ni=$node[$id];
	if($ni['ca']!=-1){pstw($ni['ca']);}
	if($ni['cb']!=-1){pstw($ni['cb']);}
	printf(" %d",$id);
}

function intw($id){
	global $node;
	$ni=$node[$id];
	if($ni['ca']!=-1){intw($ni['ca']);}
	printf(" %d",$id);
	if($ni['cb']!=-1){intw($ni['cb']);}
}

function prtw($id){
	global $node;
	$ni=$node[$id];
	printf(" %d",$id);
	if($ni['ca']!=-1){prtw($ni['ca']);}
	if($ni['cb']!=-1){prtw($ni['cb']);}
}

Measured memory_bytes: 15540
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.NoSuchElementException;
import java.util.PriorityQueue;

public class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        long sum = 0;
        int n = sc.nextInt();
        for (int i = 1; i <=n; i++) {
            if(i % 3 != 0 && i % 5 != 0){
                sum += i;
            }
        }
        System.out.println(sum);
    }


    private static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;

        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }

        private int readByte() {
            if (hasNextByte())
                return buffer[ptr++];
            else
                return -1;
        }

        private static boolean isPrintableChar(int c) {
            return 33 <= c && c <= 126;
        }

        public boolean hasNext() {
            while (hasNextByte() && !isPrintableChar(buffer[ptr]))
                ptr++;
            return hasNextByte();
        }

        public String next() {
            if (!hasNext())
                throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while (isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }

        public long nextLong() {
            if (!hasNext())
                throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while (true) {
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if (b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }

        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
                throw new NumberFormatException();
            return (int) nl;
        }

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

}


Measured memory_bytes: 32596
#include<cstdio>
#include<string>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<complex>

using namespace std;

typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;

#define rep(i,j) for(int i=0;i<(j);i++)
#define reps(i,j,k) for(int i=j;i<=k;i++)
#define in(i,j,k) ((i)>=(j)&&(i)<=(k))
#define INF (1<<28)
#define pb(i) push_back(i)
#define fs first
#define sc second

const char dx[]={0,1,0,-1},dy[]={1,0,-1,0};

int main(){
	int m,n;
	while(cin >> m >> n){
		if(!m)break;
		vector<int> v(m);
		rep(i,m)v[i]=i+1;
		int cnt = 0;
		reps(i,1,n){
			string s;
			cin >> s;
			if(v.size()==1)continue;
			char tmp[128];
			sprintf(tmp,i%15?i%5?i%3?"%d":"Fizz":"Buzz":"FizzBuzz",i);
			if(strcmp(tmp,s.c_str())!=0){
				std::vector<int>::iterator it = v.begin()+cnt;
				v.erase(it);cnt--;
//		rep(i,v.size())printf("%d%c",v[i],i==v.size()-1?'\n':' ');
			}
			cnt = (cnt+1)%v.size();
		}
		rep(i,v.size())printf("%d%c",v[i],i==v.size()-1?'\n':' ');
	}	
	return 0;
}

Measured memory_bytes: 1232
import itertools


N = int(input())
P =list(map(int, input().split())) 
Q =list(map(int, input().split())) 

nums = [0] * N
for i in range(N):
    nums[i] = i+1

count = 1
for i in itertools.permutations(nums):
    if (list(i)==P):
        c1 = count
    if (list(i)==Q):
        c2 = count
    count +=1

print(abs(c2-c1))

Measured memory_bytes: 3064
#include <cstdio>
#include <vector>
#include <algorithm>

int N;

int main(){

    while(1){
start:
        scanf("%d",&N);

        if(N == 0)break;
        int cnt = 0;
        bool flag = false;

        for(int i=0;i<N;i++){
            int tmp;
            scanf("%d",&tmp);
            if(tmp != 0)cnt++;
            if(tmp > 1) flag = true;
        }
        if(N == 1 && flag){
            printf("2\n");
            goto start;
        }
        if(!flag){
            printf("NA\n");
            goto start;
        }

        int ans = cnt + 1;

        printf("%d\n",ans);
    }
    return 0;
}

Measured memory_bytes: 1040
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n, ans = 0;
  cin >> n;
  vector<int> a(2*n);
  for (int i = 0; i < 2*n; i++) cin >> a[i];
  sort(a.begin(), a.end());
  for (int i = 0; i < 2*n; i += 2) ans += a[i];
  cout << ans << endl;
}

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

typedef long long LL;

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

int main() {
    int a, b;
    cin >> a >> b;
    int res = 6;
    cout << res/(a*b) << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n);++i)
using namespace std;
using ll = long long; 
using P = pair<int,int>;
using vv = vector<vector<ll> >;
template <class _t> inline bool chmax (_t& a,_t b){if(a<b){a=b;return true;}return false;} template <class _t> inline bool chmin (_t& a,_t b){if(a>b){a=b;return true;}return false;}

const int INF = 2147483647;
const int max_N = 1000000000;
const long long inf = 1ll << 60;
const long long mod = 1000000007;

int dx[4] = {1,0,-1,0};
int dy[4] = {0,-1,0,1};
int main(){
    string s; cin >> s;
    ll sum = 0;
    for(int i=0;i<s.size();i++){
        sum += s[i]-'0';
        sum %= 9;
    }
    if(sum%9 == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3728
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  while(cin>>n,n){
    int a[n],d=1<<30;
    for(int i=0;i<n;i++)cin>>a[i];
    sort(a,a+n);
    for(int i=1;i<n;i++)d=min(d,a[i]-a[i-1]);
    cout<<d<<endl;
  }
  return 0;
}


Measured memory_bytes: 3028
#include <iostream>
#include <cstring>
#include <stdlib.h>
using namespace std;
int a[100],count=0;
void swap(int x,int y){
	int tmp;
	tmp=a[y];
	a[y]=a[x];
	a[x]=tmp;
	count++;
}
int main(int argc, char *argv[]) {
	int n,i,j;
	memset(a,0,sizeof(a));
	cin>>n;
	for(i=0;i<n;i++){
		cin>>a[i];
	}
	for(i=0;i<n;i++){
		for(j=n-1;j>i;j--){
			if(a[j]<a[j-1])
				swap(j,j-1);
		}
	}
	for(i=0;i<n;i++){
		if(i!=n-1)
			cout<<a[i]<<" ";
		else
			cout<<a[i]<<endl;
	}
	cout<<count<<endl;
	return 0;
}


Measured memory_bytes: 3084
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
// const ll RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
// gp_hash_table<int, int> table;

#define ll long long int
#define vii vector< ll >
#define pb push_back
#define pii pair<ll,ll>
#define all(x) x.begin(),x.end()
#define S second
#define F first
#define ins insert
#define ld long double
#define lp(l,r) for(i=l;i<=r;++i)

#define lpj(l,r) for(j=l;j<=r;++j)
#define lpr(l,r) for(i=r;i>=l;--i)
#define lprj(l,r) for(j=r;j>=l;--j)

#define swap(a,b){ auto _t=a;a=b,b=_t;}
#define flush() cout.flush()
#define popcount __builtin_popcount



// typedef __int128 bign;


#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define MD          1000000007
#define M 			3000
#define LN 			14
#define fftmod      998244353
#define EPS         (double)1e-10

ll md=MD;
ll inf=1e18;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); 


inline ll exp(ll a,ll b){ll r=1LL;while(b>0){if(b&1){r=r*(a%md);r=(r+md)%md;}b/=2;a=(a%md)*(a%md);a=(a+md)%md;}return (r+md)%md;}
ll gcd(ll a,ll b){if(b==0)return a;if(a==0)return b;return gcd(b,a%b);}
inline ll poww(ll a,ll b){ll r=1LL;while(b>0){if(b&1)r=r*a;b/=2;a=a*a;}return (ll)r;}

using cd=complex<double>;
const double PI=acos(-1);

inline ll rand(ll l,ll r){
	return l+rng()%(r-l+1);
}



int main(){


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

   // ifstream fin("input.txt");ofstream fout("outut.txt");
    ll t,i,j,m,n,s,z,k,p,T;string s1,s2;ll q;ll x,y;
    cin>>s1;
    map<char,ll> mp;
    for(i=0;i<s1.size();++i){
        mp[s1[i]]++;
    }
    if(mp.size()>2){
        cout<<"No";
        return 0;
    }

    for(auto x:mp)if(x.S>2){cout<<"No"; return 0;}
        cout<<"Yes";



    return 0;
}


Measured memory_bytes: 256
package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	var H, W, K int
	fmt.Sscanf(scanner.Text(), "%d %d %d", &H, &W, &K)

	var dp [][]int
	dp = make([][]int, H+1)
	for i := 0; i < len(dp); i++ {
		dp[i] = make([]int, W+1)
	}

	dp[0][1] = 1
	for h := 0; h < H; h++ {
		for w := 1; w <= W; w++ {
			if dp[h][w] == 0 {
				continue
			}
			// no
			dp[h+1][w] = (dp[h+1][w] + dp[h][w]*allComb(w-2)*allComb(W-w-1)) % 1000000007

			if w > 1 {
				// left
				dp[h+1][w-1] = (dp[h+1][w-1] + dp[h][w]*allComb(w-3)*allComb(W-w-1)) % 1000000007
			}
			if w < W {
				// right
				dp[h+1][w+1] = (dp[h+1][w+1] + dp[h][w]*allComb(w-2)*allComb(W-w-2)) % 1000000007
			}
		}
	}

	/*
		for i := 1; i <= H; i++ {
			fmt.Print(i, " : ")
			for k := 1; k <= W; k++ {
				fmt.Print(dp[i][k], ",")
			}
			fmt.Println()
		}
	*/

	fmt.Println(dp[H][K])
}

func allComb(size int) int {
	if size < 0 {
		return 1
	}
	if size == 0 {
		return 1
	}
	if size == 1 {
		return 2
	}
	a := allComb(size - 2)
	b := allComb(size - 1)
	return a + b
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const ll mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};


int main(){
    int N,K;
    cin >> N >> K;
    ll a[N];
    rep(i,N) cin >> a[i];

    ll ans = 1000000000000;
    for(int bit=0; bit < (1<<N); bit++) {
	vector<bool> ch;
	int num = 0;
	ll pre = 0;
	ll tmp = 0;
	rep(i,N) {
	    if(bit & (1<<i)) {
		ch.push_back(true);
		num++;
	    }
	    else ch.push_back(false);
       	}
	if(num<K) continue;

	rep(i,N) {
	    if(ch[i]) {
		if(pre >= a[i]) {
		    pre++;
		    tmp += pre - a[i];
		}
	    }
	    pre = max(pre,a[i]);
	}
	ans = min(ans,tmp);
    }
    cout << ans << endl;
					 
    
    return 0;
}



Measured memory_bytes: 3604
/* be name khoda */

// #define stream_enable
#define long_enable
#include <iostream>
#include <algorithm>
#include <cstring>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;

#ifdef stream_enable
#define cin sss
#endif
#ifdef long_enable
typedef long long int ll;
#else
typedef int ll;
#endif

typedef pair<ll, ll> pii;
typedef pair<pii, ll> ppi;
typedef pair<ll, pii> pip;
typedef vector<ll> vi;
typedef vector<pii> vpii;

const ll MOD = 1000000007;
const long long BIG = 1446803456761533460;
const int Big = 336860180;

#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()

#define debug(x) cout << #x << " -> " << (x) << endl
#define debug2(x, y) cout << #x << ' ' << #y << " -> " << (x) << ' ' << (y) << endl
#define debug3(x, y, z) cout << #x << ' ' << #y << ' ' << #z << " -> " << (x) << ' ' << (y) << ' ' << (z) << endl
#define debug4(x, y, z, t) cout << #x << ' ' << #y << ' ' << #z << ' ' << #t << " -> " << (x) << ' ' << (y) << ' ' << (z) << ' ' << (t) << endl
#define debugp(x) cout << #x << " -> " << "(" << (x).F << ", " << (x).S << ")" << endl
#define debuga(x, n) cout << #x << " -> "; fori (i1_da, n) { cout << (x)[i1_da] << ' '; } cout << endl
#define debugap(x, n) cout << #x << " ->\n"; fori (i1_dap, n) { cout << "(" << (x)[i1_dap].F << ", " << (x)[i1_dap].S << ")\n"; } cout << endl
#define debugaa(x, n, m) cout << #x << " ->\n"; fori (i1_daa, n) { fori (i2_daa, m) { cout << (x)[i1_daa][i2_daa] << ' '; } cout << '\n'; } cout << endl
#define debugav(x, n) cout << #x << " ->\n"; fori (i1_dav, n) { fori (i2_dav, (x)[i1_dav].size()) { cout << (x)[i1_dav][i2_dav] << ' '; } cout << '\n'; } cout << endl
#define debugia(x, n) cout << #x << " ->\n"; fori (i1_dia, n) { cout << i1_dia << " : " << (x)[i1_dia] << '\n'; } cout << endl

#define forifrom(i, s, n) for(ll i = (s); i < (n); ++i)
#define forirto(i, n, e) for(ll i = (n) - 1; i >= (e); --i)
#define fori(i, n) forifrom (i, 0, n)
#define forir(i, n) forirto (i, n, 0)

#define smin(a, b) a = min(a, (b))
#define smax(a, b) a = max(a, (b))

#define Add(a, b) a = ((a) + (b)) % MOD
#define Mul(a, b) a = (1LL * (a) * (b)) % MOD

stringstream sss;

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

const ll maxn = 100010;

ll I, O, T, J, L, S, Z;

void MAIN() {

    cin >> I >> O >> T >> J >> L >> S >> Z;
    ll s = 0;
    if (I && J && L && I % 2 + J % 2 + L % 2 >= 2) {
        --I, --J, --L;
        s += 3;
    }
    s += I / 2 * 2 + O + J / 2 * 2 + L / 2 * 2;
    cout << s << '\n';

}

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

int main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cout << fixed << setprecision(10);
    sss << R"(
2 1 1 0 0 0 0

    )";
    MAIN();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <bitset>
#include <vector>

using namespace std;

int n;
int a, b;

void dfs(vector<int>& ans, int a, int b, int cn, int mask) {
    if (cn == 1) {
        ans.push_back(a);
        ans.push_back(b);
        return;
    }

    int c, d;

    for (int i = 0; i < n; i++) {
        if (!(mask & (1 << i)) && ((a ^ b) & (1 << i))) {
            c = i;
            break;
        }
    }

    for (int i = 0; i < n; i++) {
        if (!(mask & (1 << i)) && i != c) {
            d = i;
            break;
        }
    }

    dfs(ans, a, a ^ (1 << d), cn - 1, mask + (1 << c));
    dfs(ans, a ^ (1 << c) ^ (1 << d), b, cn - 1, mask + (1 << c));
}

int main() {

    cin >> n >> a >> b;

    int tmp = a;
    int cnt_a, cnt_b;

    while (tmp) {
        if (tmp & 1) cnt_a++;
        tmp >>= 1;
    }

    tmp = b;
    while (tmp) {
        if (tmp & 1) cnt_b++;
        tmp >>= 1;
    }

    if ((cnt_a % 2) == (cnt_b % 2)) {
        cout << "NO";
        return 0;
    }

    cout << "YES" << endl;
    vector<int> ans;
    dfs(ans, a, b, n, 0);

    for (int i : ans) cout << i << ' ';
}

Measured memory_bytes: 1656
#include <stdio.h>

int main(void){
  
  long long N;
  long long M;
  
  scanf("%lld %lld", &N, &M);
  
  long long ans;
  
  
  
  
  if( N*2 < M ){
    ans = N;
    M -= N*2;
    ans += (M/4);
  }
  
  else{
    ans = M/2;
  }
  
  
  printf("%lld\n", ans);
  
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include <algorithm>
#include <string>
#include <utility>
#include <set>
#include <map>
#include<cmath>
#include <queue>
#include <numeric>
#include <cassert>

using lli = long long int;
lli inf = 1000000007;
using namespace std;

void solve()
{
	string w;
	cin >> w;
	map<char, int> dic;
	for (int i = 0; i < w.length(); i++) {
		if (dic.count(w[i]) == 0)dic[w[i]] = 0;
		dic[w[i]]++;
	}
	bool flag = true;
	for (auto e : dic) {
		if (e.second % 2 == 1)flag = false;
	}
	cout << (flag ? "Yes" : "No") << endl;
}

int main()
{
	solve();
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;

public class Program
{
    public static void Main(string[] args)
    {
        // 整数の入力
        int a = int.Parse(Console.ReadLine());
        // スペース区切りの整数の入力
        string[] input = Console.ReadLine().Split(' ');
        List<int> list = new List<string>(input).ConvertAll(int.Parse);

        int min=int.MaxValue;
        int calc;
        for(int i = 1; i < 100; i++)
        {
            calc = 0;
            foreach(int value in list)
            {
                calc += (value - i) * (value - i);
            }
            if (calc < min) min = calc;
        }
        //出力
        Console.WriteLine(min);
    }
}


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

///******************************** C o n t a i n e r ********************************///

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

///*********************************** C o n s t ***********************************///

const int       N=1e6+3;
const double    PI = acos(-1);
const ll        MOD=1000000007;                 ///1e9+7
ll dx[] = {+1, 0, -1, 0, +1, +1, -1, -1};
ll dy[] = {0, +1, 0, -1, +1, -1, +1, -1};

///********************************** M a r c o ***********************************///

#define pb push_back
#define F first
#define S second
#define test int tc; cin>>tc; while(tc--)
#define forn(i,n) for(i=0;i<n;i++)
#define rforn(i,n) for(i=n-1;i>=0;i--)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(x) x.size()
#define el <<'\n'
#define sp <<' '
#define print(a) {for(auto x:a)cout<<x<<" ";cout<<endl;}
#define mem(a,b) memset(a, b, sizeof(a))
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sqr(a) (a)*(a)

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(0); cout.setf(ios::fixed,ios::floatfield);

///*********************************** F u n c t i o n ***********************************///

ll powmod(ll a,ll b){ll p=MOD;a%=p;if(!a) return 0;ll pr=1;while(b>0){if(b&1){pr*=a;pr%=p;--b;}a*=a;a%=p;b/=2;}return pr;}
bool isPrime(ll n){ if(n<=1)return false;if(n<=3)return true;if(n%2==0 or n%3==0)return false;for(ll i=5;i*i<=n;i+=6){if(n%i==0 or n%(i+2)==0)return false;}return true;}
void seive(bool a[]){ll mx=sqrt(N),ii,jj;for(ii=3;ii<=mx;ii+=2)if(!a[ii])for(jj=ii*ii;jj<=N;jj+=2*ii)a[jj]=true;}
void numofdiv(ll a[]){ll mx=sqrt(N),ii,jj;for(ii=1;ii<=mx;ii++){for(jj=ii*ii;jj<=N;jj+=ii){if(jj==ii*ii) a[jj]++; else a[jj]+=2;}}}
void sumofdiv(ll a[]){ll mx=sqrt(N),ii,jj;for(ii=1;ii<=mx;ii++){for(jj=ii*ii;jj<=N;jj+=ii){if(jj==ii*ii) a[jj]+=ii; else a[jj]+=ii+jj/ii;}}}

///**************************************************** C o d e ****************************************************///
///-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=///



void _case()
{
    long double a,b;
    cin>>a>>b;
    b*=1000;
    a*=b;
    a/=1000;
    cout<<(ll) a el;

}

main()
{
        _case();

}


///Thank you.


///Brainless_Loco Terminates Here!


Measured memory_bytes: 3736
fun main() {
    val (h, m) = readLine()!!.split(" ").map { it.toInt() }
    var sList = Array<String>(h) { i -> "" }
    for (i in 0 until h) {
        sList[i] = readLine()!!
    }

    val answerList = Array<String>(h) { i -> ""}

    for (i in 0 until h) {
        var answer = ""
        for (j in 0 until m) {
            var count = 0
            if (sList[i][j] == '#') {
                answer += "#"
                continue
            }

            if (i - 1 >= 0) {
                if (j - 1 >= 0) {
                    if (sList[i - 1][j - 1] == '#') {
                        count += 1
                    }
                }

                if (sList[i - 1][j] == '#') {
                    count += 1
                }

                if (j + 1 <= m - 1) {
                    if (sList[i - 1][j + 1] == '#') {
                        count += 1
                    }
                }
            }

            if (j - 1 >= 0) {
                if (sList[i][j - 1] == '#') {
                    count += 1
                }
            }

            if (j + 1 <= m - 1) {
                if (sList[i][j + 1] == '#') {
                    count += 1
                }
            }

            if (i + 1 <= h - 1) {
                if (j - 1 >= 0) {
                    if (sList[i + 1][j - 1] == '#') {
                        count += 1
                    }
                }

                if (sList[i + 1][j] == '#') {
                    count += 1
                }

                if (j + 1 <= m - 1) {
                    if (sList[i + 1][j + 1] == '#') {
                        count += 1
                    }
                }
            }
            answer += count.toString()
        }
        answerList[i] = answer
    }

    for (x in answerList) {
        println(x)
    }
}


Measured memory_bytes: 38376
#include <iostream>
#include <cstdio>

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

  for (int i = 1; i < b + 1; i++) {
    if (c == a * i % b) {
      printf("YES\n");
      return 0;
    }
  }

  printf("NO\n");
  return 0;
}


Measured memory_bytes: 256