akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do { (t*=10)+=ch-'0'; ch=getchar(); } while ('0'<=ch&&ch<='9'); t*=f;
}
const int maxn=(1e5)+10;
int n,m,in[maxn],tot;
int head[maxn],to[maxn];
int nxt[maxn],d[maxn],dp[maxn],ans;
queue<int> q;
void add(int x,int y) {
	tot++; nxt[tot]=head[x];
	head[x]=tot; to[tot]=y;
}
int main() {
	//freopen("1.txt","r",stdin);
	read(n); read(m);
	int x,y;
	while (m--) {
		read(x); read(y);
		add(x,y); in[y]++;
	}
	for (int i=1;i<=n;i++) if (!in[i]) q.push(i);
	tot=0;
	while (!q.empty()) {
		int u=q.front(); q.pop(); d[++tot]=u;
		for (int i=head[u],v;i;i=nxt[i]) {
			v=to[i]; in[v]--;
			if (!in[v]) q.push(v);
		}
	}
	for (int i=tot;i>=1;i--) {
		int u=d[i];
		for (int j=head[u];j;j=nxt[j])
			dp[u]=max(dp[u],dp[to[j]]);
		dp[u]++;
		ans=max(ans,dp[u]);
	}
	printf("%d\n",ans-1);
	return 0;
}

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

int main(void) {
  int a,b;
  cin >> a >> b;
  if(a%3==0 || b%3==0 || (a+b)%3==0)
    cout << "Possible" << endl;
  else cout << "Impossible" << endl;

  return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int x;
    cin>>x;
    if(x<1200) {
        cout<<"ABC\n";
    }
    else {
        if(x<2800) {
            cout<<"ARC\n";
        }
        else {
            cout<<"AGC\n";
        }
    }
    return 0;
}
/**

**/


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define str to_string
#define endl "\n"
#define PI 3.141592653589
using namespace std;
using lint = long long;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

//AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC
int main(){
    int n;cin>>n;
    cout<<(n-2)*180<<endl;
}


Measured memory_bytes: 3588
/**
 * Created by hiramekun at 20:55 on 2019-09-07.
 */
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template<class T>
istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template<class T>
ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    ll n;
    cin >> n;
    vl a(n), b(n), c(n - 1);
    cin >> a;
    cin >> b;
    cin >> c;
    rep(i, n) a[i]--;

    ll ans = 0;
    ll pre = -2;
    rep(i, n) {
        ans += b[a[i]];
        if (a[i] == pre + 1) ans += c[pre];
        pre = a[i];
    }
    cout << ans << '\n';
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define ss(x) scanf("%s",x)
#define mod 1000000007
#define bitcount __builtin_popcountll
#define ll long long
#define pb push_back
#define pi pair<int,int>
#define pii pair<pi,int>
#define mp make_pair
bool cmp(int x, int y)
{
	return x>y;
}
int main()
{
	int i,j,k;
	int n,arr[205];
	sd(n);
	for(i=0;i<2*n;i++)
		sd(arr[i]);
	sort(arr,arr+2*n,cmp);
	int ans=0;
	for(i=1;i<2*n;i+=2)
		ans+=arr[i];
	printf("%d\n",ans );
	return 0;
}

Measured memory_bytes: 256
'use strict';
function Main(stdin){
  const input = stdin.trim().split(/\r?\n/g);
  const N = Number(input[0].split(' ')[0]);
  const K = Number(input[0].split(' ')[1]);
  let P = input[1] .split(' ').map(str => Number(str));
  P.sort(((a, b) => a - b));
  let sum = 0;
  for(let i = 0; i < K; i++){
      sum += P[i];
  }
  console.log(sum);
}

// 固定
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29756
n = int(input())
dp = [[0 for _ in range(3)] for __ in range(n)]

for i in range(n):
  tmp = list(map(int, input().split()))
  if i == 0:
    dp[i] = tmp
    continue
  for j in range(3):
    for k in range(3):
      if j == k: continue
      dp[i][k] = max(dp[i][k], dp[i-1][j] + tmp[k])

print(max(dp[n-1]))

Measured memory_bytes: 24396
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abc161_b
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] kazu = Console.ReadLine().Split(' ');
            int N = int.Parse(kazu[0]);
            int M = int.Parse(kazu[1]);
            string[] hyou = Console.ReadLine().Split(' ');
            int[] A = new int[N];
            double sou = 0;

            for (int i = 0; i < N; i++)
            {
                A[i] = int.Parse(hyou[i]);
                sou += A[i];
            }

            int count = 0;

            for(int i = 0; i < N; i++)
            {
                if(A[i] < sou / (4 * M))
                {
                    
                }
                else
                {
                    count++;
                }
            }

            if(count >= M)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
            Console.Read();
        }
    }
}


Measured memory_bytes: 27488
def check(str1,str2):
    al = [[] for i in range(26)]
    # 同じアルファベットでインデックスをまとめる
    for i in range(len(str1)):
        index = ord(str1[i]) - 97
        al[index].append(i)
    # str1[i] == str1[j] => str2[i] == str2[j] のチェック
    for l in al:
        note = [str2[i] for i in l]
        if len(list(set(note))) > 1:
            global ans 
            ans = "No"
            break

S = input(); T = input()
ans = "Yes"
check(S,T); check(T,S)
print(ans)

Measured memory_bytes: 13124
import java.util.Scanner

import scala.annotation.tailrec
import scala.collection.mutable.ArrayBuffer
import scala.math._

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val writer = new java.io.PrintWriter(System.out)
    writer.println(solve(sc))
    writer.flush()
  }

  case class LightBulb(switches: Seq[Int], condition: Int)

  def solve(sc: Scanner): String = {
    val (n, m, lightbulbs) = parseInput(sc)
    debug(n, m, lightbulbs)

    var countOfAllOn = 0
    getSwitchPatterns(n).foreach { sp =>
      val countOfOn = lightbulbs.foldLeft(0) { (acc, lightbulb) =>
        if (sp.zipWithIndex.filter { case (_, i) => lightbulb.switches.contains(i) }.map(_._1).sum % 2 == lightbulb.condition) {
          acc + 1
        } else {
          acc
        }
      }
      if (countOfOn == lightbulbs.size) countOfAllOn += 1
    }
    countOfAllOn.toString
  }

  def getSwitchPatterns(n: Int): Vector[ArrayBuffer[Int]] = {
    @tailrec
    def dfs(list: Vector[(ArrayBuffer[Int], Int)], n: Int): Vector[(ArrayBuffer[Int], Int)] = {
      if (n > 0) {
        list.foreach { case (buf, i) =>
          buf += floor(i / (pow(2, n) / 2) % 2).toInt
        }
        dfs(list, n - 1)
      } else list
    }

    val initialList = (0 until pow(2, n).toInt).map(i => (ArrayBuffer.empty[Int], i)).toVector
    dfs(initialList, n).map(_._1)
  }

  def parseInput(sc: Scanner) = {
    val (n, m) = (sc.nextInt(), sc.nextInt())
    val switchesList = (0 until m).map { _ =>
      val k = sc.nextInt()
      Vector.fill(k)(sc.nextInt() - 1)
    }
    val conditionList = Vector.fill(m)(sc.nextInt())
    val lightbulbs = (0 until m).foldLeft(ArrayBuffer.empty[LightBulb]) { (acc, i) =>
      acc += LightBulb(switchesList(i), conditionList(i))
      acc
    }.toVector
    (n, m, lightbulbs)
  }

  private def debug(x: Any): Unit = {
    if (System.getenv("LOCAL_DEBUG") != null) println(x)
  }
}


Measured memory_bytes: 37612
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner in = new java.util.Scanner(System.in);
		String A = in.nextLine();
		
		int len = A.length();
		System.out.println(A.substring(0,1) + (len-2) + A.substring(len-1,len));
	
		
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define MD 1000000007
#define INF 1ll<<60
typedef pair<ll, ll> P;
template <typename T>
std::string tostr(const T &t){std::ostringstream os;os << t;return os.str();}
int dx[4]={1, 0, -1, 0}, dy[4]={0, 1, 0, -1};

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


Measured memory_bytes: 256
#include <iostream>
using namespace std;
static const int N = 100;

int main(){
  int M[N][N];
  int n,u,k,v;
  cin >> n;
  for(int i = 0;i < n;i++){
    for(int j = 0;j < n;j++) M[i][j] = 0;
   }
   for(int i = 0;i < n;i++){
     cin >> u >> k;
     u--;
     for(int j = 0;j < k;j++){
       cin >> v;
       v--;
       M[u][v] = 1;
     }
   }
   for(int i = 0;i < n;i++){
     for(int j = 0;j < n;j++){
       if(j) cout << " ";
       cout << M[i][j];
     }
     cout << endl;
   }
   return 0;
}



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

int main() {
	int q;
	cin >> q;
	for (; q > 0; q--) {
		ll a, b;
		cin >> a >> b;
		if (a * b <= 2) {
			cout << 0 << endl;
			continue;
		}
		if (a > b) {
			ll t = a;
			a = b;
			b = t;
		}
		ll r = sqrt(a * b);
		ll x = r + (r == a), y = r + 1 + (r + 1 == b);
		while (x * y >= a * b) {
			if (x < y || (x - 1 == a && x == 2)) {
				if (y - 1 != b) {
					y -= 1;
				} else if (y > 2) {
					y -= 2;
				} else {
					break;
				}
			} else {
				if (x - 1 != a) {
					x -= 1;
				} else {
					x -= 2;
				}
			}
		}
		// cerr << x << " " << y << endl;
		cout << (x - (a < x)) + (y - 1 - (b < y)) << endl;
	}
	return 0;
}


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

using namespace std;

#define NO 1
#define BLACK 2
#define WHITE 3

struct S{
	int cnt;
	string res;
};
int main(){

	int n, m, p;
	int map[9][9][9];
	int x, y;
	int turn;
	int cnt;
	S ans;
	int dx[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1 };
	int dy[] = { 1, 1, 1, 0, 0, 0, -1, -1, -1, 1, 1, 1, 0, 0, -1, -1, -1, 1, 1, 1, 0, 0, 0, -1, -1, -1 };
	int dz[] = { 0, 1, -1, 0, 1, -1, 0, 1, -1, 0, 1, -1, 1, -1, 0, 1, -1, 0, 1, -1, 0, 1, -1, 0, 1, -1 };

	while (1){

		cin >> n >> m >> p;
		if (n == 0 && m == 0 && p == 0) break;

		for (int i = 0; i <= n+1; i++){
			for (int j = 0; j <= n+1; j++){
				for (int k = 0; k <= n+1; k++){
					map[i][j][k] = NO;
				}
			}
		}

		ans.res = "Draw";
		turn = BLACK;

		for (int i = 0; i < p; i++){
			cin >> x >> y;
			if (ans.res == "Draw"){
				for (int j = 1; j < 9; j++){
					if (map[j][y][x] == NO){
						map[j][y][x] = turn;
						for (int k = 0; k < 26; k++){
							cnt = 1;
							for (int l = 1;; l++){
								if (map[j + dz[k] * l][y + dy[k] * l][x + dx[k] * l] != turn) break;
								cnt++;
							}
							for (int l = 1;; l++){
								if (map[j - dz[k] * l][y - dy[k] * l][x - dx[k] * l] != turn) break;
								cnt++;
							}
							if (cnt >= m){
								ans.cnt = i + 1;
								if (turn == BLACK) ans.res = "Black";
								else ans.res = "White";
							}
						}
						break;
					}
				}
			}
			if (turn == BLACK) turn = WHITE;
			else turn = BLACK;
		}
		if (ans.res == "Draw") cout << ans.res << endl;
		else cout << ans.res << " " << ans.cnt << endl;
	}

	return 0;
}

Measured memory_bytes: 1208
H,W = list(map(int, input().split()))
C = ["" for i in range(H)]

for i in range(H):
    C[i] = input()

for i in range(H * 2):
    Ca = ""
    for j in range(W):
        Ca += C[(((i+1)+1)//2)-1][j]
    print(Ca)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1e9+7;

#define vec     vector<int>
#define vecll   vector<ll>
#define vec2    vector<vector<int>>
#define vec2ll  vector<vector<ll>>
#define vpair   vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>

#define rep(i,n)         for(int i=(int)0; i<(int)n; i++)
#define REP(i,m,n)       for(int i=(int)m; i<(int)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define prt(var)         cout << var << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(var)      rep(i,var.size()){cout << var[i] << " ";} cout << "\n"

//----------------------------------------------------------------
ll dp[101][4][4][4]={};

bool is_ok(int i, int j, int k, int l){
  if ((j==0 && k==1 && l==2)
    ||(j==1 && k==0 && l==2)
    ||(j==0 && k==2 && l==1)
    ||(i==0 && k==1 && l==2)
    ||(i==0 && j==1 && l==2)){
      return false;
    } else {
      return true;
    }
}

int main(void) {
  int n;
  cin >> n;

  rep(i,4){
    rep(j,4){
      rep(k,4){
        if(is_ok(9,i,j,k)){
          dp[3][i][j][k]=1;
        } else {
          dp[3][i][j][k]=0;
        }
      }
    }
  }

  REP(m,4,101){
    rep(i,4){
      rep(j,4){
        rep(k,4){
          rep(l,4){
            if(is_ok(l,i,j,k)) dp[m][i][j][k]+=dp[m-1][l][i][j];
            dp[m][i][j][k]%=MOD;
          }
        }
      }
    }
  }

  ll ans=0;
  rep(i,4){
    rep(j,4){
      rep(k,4){
        ans+=dp[n][i][j][k];
        ans%=MOD;
      }
    }
  }

  prt(ans);

}


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

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

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

vector<deque<int>> a;
set<pii> q;

void f(int s){
	int rtn = -1, alt = a[s].front();
	if(sz(a[s])==0) return;
	if(a[alt].front() != s) return;
	else{
		q.emplace(min(s, alt), max(s, alt));
		return;
	}
}

int main()
{

	cin.tie(0); ios_base::sync_with_stdio(false);
	int n; 
	cin >>n;
	
	a = vector<deque<int>>(n, deque<int>(n-1));
	rep(i, n) rep(j, n-1){
		cin >> a[i][j]; a[i][j]--;
	}

	rep(i, n) f(i);
	
	ll ans =0;
	
	while(sz(q)){
		ans++;
		set<pii> cur;
		swap(q, cur);
		for(auto z: cur){
			a[z.first].pop_front();
			a[z.second].pop_front();
		}
		for(auto z: cur){
			f(z.first);
			f(z.second);
		}
	}
	rep(i, n) if(sz(a[i])) {puts("-1"); return 0;}
	
	cout << ans <<"\n";
}


Measured memory_bytes: 4608
#include "bits/stdc++.h"
using namespace std;
#define INF (1<<30)
#define LINF (1LL<<60);
typedef long long ll;
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
int H, W, N;

int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	cin >> H >> W >> N;
	vector<int> a(N+1);
	for (int i = 1; i <= N;i++) cin >> a[i];
	vector<vector<int>> c(H + 2, vector<int>(W + 2, -1));
	for (int i = 1; i <= H;i++)for (int j = 1; j <= W;j++) c[i][j] = 0;
	int dir = 0;
	int n = 1;
	int cnt = 0;
	int x, y; x = y = 1;
	while (cnt != H*W) {
		c[x][y] = n;
		a[n]--;
		if (a[n] == 0) {
			n++;
		}

		int nx = x + dx[dir], ny = y + dy[dir];
		if (c[nx][ny] != 0) {
			dir = (dir + 1) % 4;
			nx = x + dx[dir], ny = y + dy[dir];
		}
		x = nx; y = ny;
		cnt++;
	}

	for (int i = 1; i <= H;i++) {
		for (int j = 1;j <= W;j++) {
			cout << c[i][j] << " ";
		}
		cout << endl;
	}
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

int Start[100];
int s[100];
int End[100];
int v[100];

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

	int N;
	cin >> N;
	for(int i = 0; i < N; i++) {
		int M, D;
		cin >> M >> D >> v[i] >> s[i];
		Start[i] = 30 * (M - 1) + D;
		End[i] = Start[i] + v[i] - 1;
	}

	int ans = 1e9;
	for(int i = 0; i < 360; i++) {
		int x = 0;
		for(int j = 0; j < N; j++) {
			if(Start[j] <= i && i <= End[j]) {
				x = max(x, s[j]);
			}
			else if(Start[j] <= i + 360 && i + 360 <= End[j]) {
				x = max(x, s[j]);
			}
			else {
				int t = 1e9;
				t = min({ t, abs(Start[j] - i), abs(End[j] - i) });
				t = min({ t, abs(Start[j] + 360 - i), abs(End[j] + 360 - i) });
				t = min({ t, abs(Start[j] - 360 - i), abs(End[j] - 360 - i) });
				x = max({ x, s[j] - t });
				/*if(i < Start[j]) {
					int t = s[j] - min(Start[j] - i, i + 360 - End[j]);
					x = max(x, t);
					}
					else {
					int t = s[j] - min(i - End[j], Start[j] + 360 - i);
					x = max(x, t);
					}*/
			}
		}

		ans = min(ans, x);
	}
	cout << ans << endl;
}

Measured memory_bytes: 3136
object Main extends App{
val List(n,m) = readLine.split(" ").map(_.toInt).toList
var cnt = m
var map = scala.collection.mutable.HashMap.empty[Int,(Int,Int)]
while(cnt != 0){
    val List(p_str,s) = readLine.split(" ").toList
    val p = p_str.toInt
    if(!map.contains(p)){ // mapにpが存在しない時
        if(s == "AC") map += (p -> (0,1))
        else map += (p -> (1,0))
    }else{// mapにpが存在する時
        val e = map.get(p).get
        if(s == "AC" && e._2 == 0){
            map.update(p,(e._1,1))
        }else if(s == "WA" && e._2 == 0){
            map.update(p,(e._1 + 1,0))
        }else{            
        }
    }    
    cnt -= 1
}
var ac,wa = 0
map.foreach{
    case(k,v) =>
    if(v._2 == 1){
        ac += 1
        wa += v._1
    }
}
println(ac + " " + wa)
}

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

#define INITIAL_VALUE ((1 << 31) - 1)
#define OUT_LINE_SIZE 11

int *a;
int N;

inline int min(int a, int b) {
    return a < b ? a: b;
}

int _find(int m, int n, int i, int l, int r) {
    if (m >= r || l >= n)
        return INITIAL_VALUE;
    if (m <= l && r <= n)
        return a[i];
    return min(_find(m, n, i*2, l, (l+r)>>1),
               _find(m, n, i*2+1, (l+r)>>1, r));
}

void find(int s, int t) {
    printf("%d\n", _find(s, t+1, 1, 0, N));
}

void update(int i, int x) {
    i += N;
    a[i] = x;
    while (i) {
        i = i >> 1;
        a[i] = min(a[i*2], a[i*2+1]);
    }
}


int main() {
    int n, q, com, x, y, i;
    void (*f[2])(int, int);
    char *outbuf;

    f[0] = update;
    f[1] = find;

    scanf("%d %d", &n, &q);
    for (i = 1, N = 1<<1; n > N; ++i, N = 1<<i);
    
    a = (int*)malloc(sizeof(int) * N * 2);
    for (i = 0; i < N*2; i++) {
        a[i] = INITIAL_VALUE;
    }

    outbuf = (char*)malloc(sizeof(char) * OUT_LINE_SIZE * q);
    setvbuf(stdout, outbuf, _IOFBF, OUT_LINE_SIZE * q);
    
    for (; q--;) {
        scanf("%d %d %d", &com, &x, &y);
        f[com](x, y);
    }

    free(a);

    return 0;
}

Measured memory_bytes: 1680
a = int(input())
b = int(input())
c = int(input())
n = int(input())

cnt = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if 500*i + 100*j + 50*k == n:
                cnt += 1
print(cnt)

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

// UnionFind
// @0214sh7 さんのライブラリ(https://github.com/0214sh7/library/)(+α)を使っています
class unionfind {
 private:
  std::vector<int> UF, rank;

 public:
  std::vector<int> size;
  void init(int N) {
    UF.clear();
    rank.clear();
    size.clear();
    for (int i = 0; i < N; i++) {
      UF.push_back(i);
      rank.push_back(0);
      size.push_back(1);
    }
  }

  int root(int k) {
    if (UF[k] == k) {
      return k;
    } else {
      UF[k] = root(UF[k]);
      return UF[k];
    }
  }

  bool same(int p, int q) { return root(p) == root(q); }

  void unite(int P, int Q) {
    int p = root(P);
    int q = root(Q);
    if (p == q) return;
    if (rank[p] < rank[q]) std::swap(p, q);
    UF[q] = p;
    if (rank[p] == rank[q]) rank[p]++;
    size[p] += size[q];
  }
};

int main(){
  // 入力
  int n, m;
  cin >> n >> m;

  // UnionFind構築
  unionfind uf;
  uf.init(n);
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    uf.unite(a - 1, b - 1);
  }

  // 連結部分の大きさの最大が答え
  int ans = 0;
  for (int i = 0; i < n;i++){
    ans = max(ans, uf.size[i]);
  }

  // 出力
  cout << ans << endl;
}


Measured memory_bytes: 5864
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>

typedef long long LL;

const int MAXN = 1e5 + 10;
int n, sz, f;
LL b[50], x[MAXN], y[MAXN];

inline void print(LL x, LL y) {
	for (int i = 1; i <= sz; ++i) {
		if (labs(x) > labs(y)) {
			if (x > 0) putchar('R'), x -= b[i];
			else putchar('L'), x += b[i];
		} else {
			if (y > 0) putchar('U'), y -= b[i];
			else putchar('D'), y += b[i];
		}
	}
}

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) scanf("%lld%lld", x + i, y + i), f |= 1 << (x[i] + y[i] & 1);
	if (f == 3) return puts("-1"), 0;
	for (int i = 35; ~i; --i) b[++sz] = 1LL << i;
	if (f & 1) b[++sz] = 1;
	printf("%d\n", sz);
	for (int i = 1; i <= sz; ++i) printf("%lld%c", b[i], " \n"[i == sz]);
	for (int i = 1; i <= n; ++i) print(x[i], y[i]), puts("");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mp make_pair
// #define pb push_back
#define ll long long
#define endl "\n"
using namespace std;
#define mod (long long)(1e9+7)
ll par[200005];
ll find(ll x){
	if(par[x]<0) return x;
	return (par[x]=find(par[x]));
}
void union1(ll x,ll y){
	ll x1=find(x);
	ll y1=find(y);
	if(x1!=y1){
		if(par[x1]<par[y1]){
			par[x1]+=par[y1];
			par[y1]=x1;
		}
		else{
			par[y1]+=par[x1];
			par[x1]=y1;
		}
	}
}
void solve(){
	ll n,m;
	cin>>n>>m;
	memset(par,-1,sizeof(par));
	for(ll i=0;i<m;i++){
		ll x,y;
		cin>>x>>y;
		union1(x,y);
	}
	ll c=0;
	for(ll i=1;i<=n;i++){
		c=max(c,abs(par[find(i)]));
	}
	cout<<c<<endl;
}

int main() {
	ll t=1;
	//cin>>t;
	while(t--){
		solve();
	}
}




Measured memory_bytes: 5192
#include<stdio.h>
int main()
{
	int n;
	char s[102];
	scanf("%d%s", &n, s);
	int count[30];
	int i, j;
	for (i = 0; i < 30; i++)
		count[i] = 0;
	for (i = 0; i < n; i++)
		count[s[i] - 'a']++;
	int c[30];
	for (i = 0; i < 30; i++)
		c[i] = 0;
	int ans = 0, x = 0;
	for (i = 0; i < n; i++)
	{
		if (c[s[i] - 'a'] == 0)
		{
			c[s[i] - 'a']++;
			count[s[i] - 'a']--;
			if (count[s[i] - 'a'] > 0)
				x++;
		}
		else
		{
			c[s[i] - 'a']++;
			count[s[i] - 'a']--;
			if (count[s[i] - 'a'] == 0)
				x--;
		}
		if (ans < x)
			ans = x;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  vector<int> t(999);
  t.at(0) = 1;
  for(int i=1; i<999;i++){
    t.at(i) = t.at(i-1)+i+1;
  }
  cout << t.at(b-a-2)-a << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main (){

    char a[4];
    char b[4];
    char c[4];
    char D[4];


    scanf("%s %s %s",a,b,c );

    D[0] = a[0];
    D[1] = b[1];
    D[2] = c[2];
    D[3] = '\0';

    puts(D);




return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <cctype>
#include <iostream>
#include <string>
#include <map>

using namespace std;

static map<string,int>    lis;
static const char       * e;

static int nanikaka ( void );

static int
term (
  void
  )
{
  int res = -1;

  if ( *e == '(' )
  {
    ++e;
    res = nanikaka ( );
    ++e;
  }
  if ( isupper ( *e ) )
  {
    const char * b = e++;
    map<string,int>::iterator it;
    string s;

    while ( islower ( *e ) ) ++e;
    s.assign ( b, e - b );

    it = lis.find ( s );
    if ( it != lis.end ( ) )
    {
      res = it->second;
    }
  }

  return ( res );
}

static int
nanikaka (
  void
  )
{
  int res = 0;

  for ( ; ; )
  {
    int pwr;
    int ret;

    if ( *e == '\0' || *e == ')' ) break ;

    ret = term ( );
    if ( ret < 0 ) return ( ret );
    for ( pwr = 0; isdigit ( *e ); ++e )
    {
      pwr = ( pwr * 10 ) + ( *e - '0' );
    }
    res += ret * ( pwr ? pwr : 1 );
  }

  return ( res );
}

/** Application main entry point. */
int
main (
  int     argc,
  char  * argv[ ]
  )
{
  string ln;

  for ( ; ; )
  {
    char s[ 16 ];
    int  d;

    getline ( cin, ln );
    if ( ln == "END_OF_FIRST_PART" ) break ;

    sscanf ( ln.c_str ( ), "%s %d", s, &d );
    lis[ s ] = d;
  }

  for ( ; ; )
  {
    int res;

    getline ( cin, ln );
    if ( ln == "0" )  break ;

    e = ln.c_str ( );
    res = nanikaka ( );
    if ( res < 0 )
    {
      puts ( "UNKNOWN" );
    }
    else
    {
      printf ( "%d\n", res );
    }
  }

  return ( 0 );
}

Measured memory_bytes: 0
#include <algorithm>
#include <iostream>
#include <cstring>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define PB push_back
#define MP make_pair
#define LL long long 
const int INF = 1145141919;
 
int main(){
  while (1){
    int n;
    int deta[100003];
    cin >> n;
    if (n == 0) return 0;
    FOR (i, 1, n + 1){
      cin >> deta[i];
      if (i % 2 == 0 && deta[i] != deta[i-1]){
	for (int j = i - 1; i > 0; j--){
	  if (deta[j] == deta[i]) break;
	  deta[j] = deta[i];
	}
      }
    }
    int ans = 0;
    FOR (i, 1, n + 1){
      if (deta[i] == 0){
	ans++;
      }
    }
    cout << ans << endl;
  }
}

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

#define M 1046257
#define NIL (-1)
#define L 14

char H[M][L];


int getChar(char ch) {
  if ( ch == 'A' ) return 1;
  else if ( ch == 'C' ) return 2;
  else if ( ch == 'G' ) return 3;
  else if ( ch == 'T' ) return 4;
  return 0;
}


long long getKey(char str[]) {
  long long sum =0, p = 1, i;
  for(i=0;i<strlen(str);i++) {
    sum += p*(getChar(str[i]));
    p*= 5;
  }
  return sum;
}

int h1(int key){ return key % M; }
int h2(int key){ return 1 + (key % (M-1)); }

int find(char str[]) {
  long long key, i, h;
  key = getKey(str); 
  for(i=0; ;i++) {
    h = (h1(key) + i*h2(key)) %M;
    if( strcmp(H[h],str) == 0) return 1;
    else if ( strlen(H[h]) == 0 ) return 0;
  }
  return 0;
}

int insert(char str[]) {
  long long key, i, h;
  key = getKey(str);
  for(i=0; ; i++) {
    h = (h1(key) + i * h2(key)) %M;
    if(strcmp(H[h],str) == 0) return 1;
    else if(strlen(H[h]) == 0) {
      strcpy(H[h],str);
      return 0;
    }
  }
  return 0;
}

int main(void) {
  int i, n;
  char str[L], com[9];
  for(i=0;i<M;i++) H[i][0] = '\0';
  scanf("%d",&n);
  for(i=0;i<n;i++) {
    scanf("%s %s",com,str); 
    if(com[0] == 'i') {
      insert(str);
    } else {
      if(find(str)){
        printf("yes\n");
      } else {
        printf("no\n");
      }
    }
  }
  return 0;
}


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

using namespace std;

#define vit vector<int>::iterator
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define forn(i, n) for(int i = 0; i < int(n); i++)
#define fr first
#define sc second
#define skip continue
#define PI 3.14159265

typedef unsigned long long ull;
typedef long long ll;
typedef unsigned int ui;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<bool> vb;

const int INF = 1e9 + 5;
const int MAXN = 3e6 + 123;

void faster(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
bool cmp(const string& a, const string& b) {
	return (a + b) < (b + a);
}

vector<int> Reversed(const vector<int>& s){
   vector<int> d = s;
   reverse(all(d));
   return d;
}

void solve(){
    int n;
    cin >> n;
    vi v(n);
    int sum = 0;
    for(int i = 0; i < n; i++){
        cin >> v[i];
        sum += v[i];
    }
    ll cnt = 0, t = sum / n;
    for(int i = 0; i < n; i++){
        cnt += (v[i] - t)*(v[i] - t);
    }
    ll cnt1 = 0;
    t = sum / n + 1;
    for(int i = 0; i < n; i++){
        cnt1 += (v[i] - t)*(v[i] - t);
    }
    cout << min(cnt, cnt1);
}

// ."ww"w"".ww"""...ww"".

int main(){
    //freopen("lepus.in","r",stdin);
    //freopen("lepus.out","w",stdout);
    //faster();
    int n=1;
    //cin>>n;
    while(n--){
    solve();
    //cout << endl;
    }
    //fclose(stdout);
}


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

int main()
{
  long long n;
  cin>>n;
  if(n==0) return printf("0"),0;
  string x="";
  while(n!=0)
  {
    int rem=n%(-2);
    n=n/(-2);
    if(rem<0)
    {
      rem+=2;
      n++;
    }
    if(rem) x+='1';
    else x+='0';
  }
  for(int i=x.size()-1;i>=0;i--) cout<<x[i];
  return 0;
}

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

int main(){
	int n,k;
	cin >> n >> k;
	vector<int> b(n,1);
	for(int i=0; i<k;i++){
		int d;
		cin >> d;
		for(int j=0;j<d;j++){
			int tmp;
			cin>> tmp;
			b[tmp-1] = 0;
		}
	}
	int sum = 0;
	for(int j=0;j<n;j++) sum += b[j];
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 5e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll N;
    cin >> N;
    vl A(N);
    rep(i, N) cin >> A[i];

    ll ans = 1, od = 1;
    rep(i,N){
        if(A[i]%2==0){
            od *= 2;
        }
        ans *= 3;
    }
    cout << ans - od << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
    long long int N,M;
     
    long long int modfact(long long int n)
    {
      long long int result=1;
      if(n == 0 || n == 1)
        return 1;
      else
        for(;n>0;n=n-1){
          result = (result *n) % 1000000007;
        }
      return result;
    }
    int main()
    {
      long long int tmp;
      scanf("%lld %lld",&N,&M);
      if(N < M){
        tmp = N;
        N = M;
        M = tmp;
      }
      if(N - M == 0 || N-M == 1){
      if((N+M)%2)
        printf("%lld\n",(modfact(N)*modfact(M))%1000000007);
      else
        printf("%lld\n",(2*modfact(N)*modfact(M))%1000000007);
      }else
        printf("%d\n",0);
      return 0;
    }

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <cstdlib>  
#include <algorithm>
#include <string>

using namespace std;
 
int main() {
    string a,b;
    cin >> a;
    b = a;
    int kazu;
    reverse(a.begin(), a.end() );
    for(int i = 0;i<a.length();i++){
      if(a[i] != b[i]){
         kazu++;
      }         
    }
    cout<<kazu/2;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		//sort(all(vi S)) sort(all(string S))

typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int INF = 1e9;

int a,b,n,x,y;
bool table[20][20];
int dp[20][20];
int main() {

	while(1){
		cin>>a>>b;
		if(a == 0 && b == 0)break;
		cin>>n;
		rep(i,20)rep(j,20){
			table[i][j] = true;
			dp[i][j] = 0;
		}
		rep(i,n){
			cin>>x>>y;
			x--;y--;
			table[x][y] = false;
		}
		dp[0][0] = 1;
		rep(i,a)rep(j,b){
			if(table[i][j]){
				dp[i+1][j] += dp[i][j];
				dp[i][j+1] += dp[i][j];
			}
		}
		cout<<dp[a-1][b-1]<<endl;
	}
}


Measured memory_bytes: 2988
def I(): return int(input())
def LI(): return list(map(int,input().split()))
def MI(): return map(int,input().split())

n,m = MI()
a = LI()
a.sort()
a.reverse()
ki = sum(a)/(4*m)
if a[m-1] < ki:
    print("No")
else:
    print("Yes")


Measured memory_bytes: 3060
// 2009à\IE J[hQ[
#include <iostream>
#include <vector>

using namespace std;

typedef vector< vector<int> > graph;

graph g;
vector<int> match;
vector<bool> visit;

bool search(int u){
	if(u<0) return true;
	for(int i=0;i<g[u].size();i++){
		int next = g[u][i];
		if(visit[next]) continue;
		visit[next] = true;
		if(search(match[next])){
			match[u] = next, match[next] = u;
			return true;
		}
	}
	return false;
}

int maximumMatch(int L, int R){
	int res = 0;
	match.assign(L+R, -1);
	for(int i=0;i<L;i++){
		visit.assign(L+R, false);
		res += search(i);
	}
	return res;
}

int gcd(int a, int b){ return b==0 ? a : gcd(b, a%b); }

int main(){
	int m, n;
	int blue[500], red[500];
	while(cin >> m >> n){
		if(!(m||n)) break;
		for(int i=0;i<m;i++) cin >> blue[i];
		for(int i=0;i<n;i++) cin >> red[i];
		g.assign(m+n, vector<int>());
		for(int i=0;i<m;i++)
			for(int j=0;j<n;j++)
				if(gcd(blue[i],red[j])!=1){
					g[i].push_back(j+m);
					g[j+m].push_back(i);
				}
		cout << maximumMatch(m,n) << endl;
	}
}

Measured memory_bytes: 2924
#include <bits/stdc++.h>
#define all(a) (a).begin(), (a).end()
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
ll const MOD = 1e9+7;
ll const INF = 1e18;
using namespace std;

int main(){
    int n, m;
    cin >> n;

    vector<int> t(n);
    int sum = 0;

    for(auto& i : t){
        cin >> i;
        sum += i;
    }

    cin >> m;
    REP(i, m){
        int p, x;
        cin >> p >> x;
        cout << sum - t[p-1] + x << endl;
    }

    return 0;
}

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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 1145141919454519;

int main() {

    ll A, B, C;
    cin >> A >> B >> C;

    map<ll , ll> mp;

    mp[A]++;
    mp[B]++;
    mp[C]++;

    if(mp[5] == 2 && mp[7] == 1) cout << "YES" << endl;
    else cout << "NO" << endl;

}

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

const int MAX_N = 100005;

int n;
int a[3];
int n_test;

int solve() {
    int res[MAX_N][3] = {{0}};
    scanf("%d", &n);

    for(int i = 1; i <= n; ++i) {
        for(int j = 0; j < 3; ++j) {
            scanf("%d", a + j);
            res[i][j] = 0;
            for(int k = 0; k < 3; ++k) {
                if (k == j) continue;
                res[i][j] = max(res[i][j], res[i - 1][k] + a[j]);
            }
        }
        //for(int j = 0; j < 3; ++j) printf("%d ", res[i][j]);
        //printf("\n");
    }
    int ans = 0;
    for(int i = 0; i < 3; ++i) ans = max(ans, res[n][i]);
    return ans;
}

int main() {
    n_test = 1;
    //scanf("%d", &n_test);
    for(int i = 0; i < n_test; ++i) printf("%d\n", solve());
    return 0;
}

Measured memory_bytes: 1408
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<stdlib.h>
#include<cassert>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=500000004;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
int v[110000];
int main(){
	int a;scanf("%d",&a);
	deque<pair<int,int> >Q;
	Q.push_front(make_pair(1,1));
	while(Q.size()){
		int at=Q.front().first;
		int cost=Q.front().second;
		Q.pop_front();
		if(v[at])continue;
		v[at]=1;
		if(at==0){
			printf("%d\n",cost);return 0;
		}
		if(!v[(at*10)%a]){
			Q.push_front(make_pair(at*10%a,cost));
		}
		if(!v[(at+1)%a]){
			Q.push_back(make_pair((at+1)%a,cost+1));
		}
	}
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
//int num[100000];
int main(){
	int x=0,y=0,z=0;long long a=0,b=0,c=0;
//	char m,n,p;
	scanf("%lld%lld%lld",&a,&b,&c);
	if(b>0){
	
	long long d=b+c;
	long long res=((long long)a/d)*b;
	long long m=a-(res/b*d);
	if(m<=b)res+=m;else res+=b;
	printf("%lld",res);
}else printf("%lld",0);}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int Maxn=25;
int n,p[Maxn],ans;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&p[i]);
	for(int i=2;i<n;i++)
		if((p[i]>p[i-1])+(p[i]>p[i+1])==1) ans++;
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a;i<(int)b;++i)
int main(){
    int n;cin>>n;
    vector<int> v(n);
    rep(i,n)cin>>v[i];
    vector<int> m(n);
    int minv=1e9;
    rep(i,n){
        minv=min(minv,v[i]);
        m[i]=minv;
    }
    int cnt=0;
    rep(i,n)if(v[i]<=m[i])cnt++;
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

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

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int s = sc.nextInt();
		String ans = "";
		StringBuilder sb = new StringBuilder(ans);
		for(int i = 0 ; i < n ; i++) {
			if(i < k)
				sb.append(" " + s);
			else {
				if(s < 1000000000) {
					sb.append(" " + (s + 1));
				}
				else {
					sb.append(" " + 121313);
					}
			}
		}

		sc.close();
		System.out.println(sb.toString());

	}
}



Measured memory_bytes: 48396
#include <iostream>
#include <string.h>

using namespace std;
typedef pair<int, int> P;
int dx[] = {0, 1, 0, -1};
int dy[] = {-1, 0, 1, 0};
bool field[104][104];

void solve()
{
	int n;
	cin >> n;
	for(int i = 0; i < n; ++i)
	{
		memset(field, 1, sizeof(field));
		int num;
		cin >> num;
		for(int j = 0; j < num + 4; ++j)
		{
			field[0][j] = false;
			field[num + 3][j] = false;
		}
		for(int j = 1; j < num + 4; ++j)
		{
			field[j][0] = false;
			field[j][num + 3] = false;
		}
		P pos;
		pos.first = 2;
		pos.second = num + 1;
		int count = num;
		int step = 0;
		field[pos.second][pos.first] = false;
		while(count)
		{
			while(2 <= pos.first && pos.first < (num + 2) && 2 <= pos.second && pos.second < (num + 2))
			{
				if(field[pos.second + 2 * dy[step]][pos.first + 2 * dx[step]] == false)
				{
					break;
				}
				pos.first += dx[step];
				pos.second += dy[step];
				field[pos.second][pos.first] = false;
			}
			step = (step + 1) % 4;
			count--;
		}
		for(int j = 2; j < num + 2; ++j)
		{
			for(int k = 2; k < num + 2; ++k)
			{
				field[j][k] == true ? cout << ' ' : cout << '#';
			}
			cout << endl;
		}
		if(i != n - 1)
		{
			cout << endl;
		}
	}
}

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

Measured memory_bytes: 0
#include <iostream>
#include <complex>
#include <cmath>
#include <cstdio>
using namespace std;
typedef complex<double> xy_t;
xy_t P[110];

double cross_product(xy_t a , xy_t b){
	return (conj(a)*b).imag();
}

int main(){
	int i,n;
	double x,y,area;
	scanf("%d\n",&n);
	for(i=0;i<n;i++){
		scanf("%lf %lf\n",&x,&y);
		P[i]= xy_t(x,y);
	}//読み込み

	double areasum = 0.0;
	for(i=2;i<n;i++){
		area = cross_product(P[i]-P[0],P[i-1]-P[0])/2;
		areasum += area;
	}

	areasum = fabs(areasum);
	printf("%.1f\n",areasum);
	return 0;	

}

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

#define mod 1000000007

using namespace std;
using ll = long long;

void solve() {
    int sum = 0;
    int n;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    sort(a, a+n);
    int temp = 0;
    int count = 0;
    for(int i = 0; i < n; i++){
        if(a[i] != temp){
            if(count % 2 != 0){
                sum++;
            }
            count = 0;
            count++;
            temp = a[i];
        }else{
            count++;
        }
    }
    if(count % 2 != 0){
        sum++;
    }
    cout << sum << endl;
}

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

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

int main()
{
int i;
char S[ 10 ];

	cin >> S;

	i = 0;
	if( S[ 0 ] == '1' ) i++;
	if( S[ 1 ] == '1' ) i++;
	if( S[ 2 ] == '1' ) i++;

	cout << i << endl;

	return 0;
}


Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define fore(x, c) for(auto &&x : c)
#define rep(i, a, n) for(int i = a, i##len = (int)(n); i < i##len; ++i)
#define rrep(i, a, n) for(int i = (int)(n - 1); i >= a; --i)
#define sz(c) ((int)c.size())
#define contains(c, x) (c.find(x) != end(c))
#define inseg(l, x, r) ((l) <= (x) && (x) < (r))
#define dump(...)
#define pb push_back
#define eb emplace_back
#define _ 0
const signed INF_ = 1001001001; const long long INF = 1001001001001001001LL;
const int DX[9] = {0,1,0,-1,1,1,-1,-1,0}, DY[9] = {-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os, const vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is, vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
  is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a, const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a, const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap = priority_queue<T, deque<T>, greater<T>>;
struct before_main_function {
  before_main_function() {
      cin.tie(nullptr); ios::sync_with_stdio(0);
      cout << setprecision(15) << fixed;
  }
} before_main_function;
// clang-format on
//------------------8<------------------------------------8<--------------------

signed main() {
  int N;
  cin >> N;
  vvi G(N);
  rep(i, 0, N - 1) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    G[a].pb(b);
    G[b].pb(a);
  }

  vi color(N, -1);
  auto dfs = [&](auto self, int v, int p) -> void {
    for (int w : G[v]) {
      if (w == p) continue;
      color[w] = color[v] ^ 1;
      self(self, w, v);
    }
  };
  color[0] = 0;
  dfs(dfs, 0, -1);

  dump(color);

  vector<vector<int>> num(3);
  rep(i, 1, N + 1) { num[i % 3].pb(i); }
  auto get = [&](int i) {
    if (sz(num[i]) == 0) i = 0;
    int ret = num[i].back();
    num[i].pop_back();
    return ret;
  };

  vector<int> ans(N, -1);
  int n0 = count(all(color), 0);
  int n1 = N - n0;
  if (min(n0, n1) <= N / 3) {
    int mn;
    if (min(n0, n1) == n0) {
      mn = 0;
    } else {
      mn = 1;
    }

    rep(i, 0, N) {
      if (color[i] == mn) {
        ans[i] = get(0);
      } else {
        if (sz(num[1]))
          ans[i] = get(1);
        else
          ans[i] = get(2);
      }
    }
  } else {
    rep(i, 0, N) {
      if (ans[i] != -1) continue;
      if (color[i] == 0) {
        if (sz(num[1]))
          ans[i] = get(1);
        else
          ans[i] = get(0);
      }
    }
    rep(i, 0, N) {
      if (ans[i] != -1) continue;
      if (color[i] == 1) {
        if (sz(num[2]))
          ans[i] = get(2);
        else
          ans[i] = get(0);
      }
    }
  }
  cout << ans << endl;
  return (0 ^ _ ^ 0);
}



Measured memory_bytes: 20456
#include<stdio.h>
int main(void)
{
    int a,b,d=0,r=0;
    double f=0;
    scanf("%d %d",&a,&b);
    d=a/b;
    r=a%b;
    f=(double)a/(double)b;
    printf("%d %d %lf\n",d,r,f);
    return 0;
}

Measured memory_bytes: 636
#include<bits/stdc++.h>
using namespace std;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int a,b,c,k;
	cin>>a>>b>>c>>k;
	int ans=a;
	if(k<=a)
		ans=k;
	if(k>(a+b)){
		k-=(a+b);
		ans-=k;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(long long i = 0; i < (n); ++i)
#define ll long long
#define P pair<ll,ll>
#define all(v) (v).begin(),(v).end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

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

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

int main() {
    int h,w;
    while(1){
        cin>>h>>w;
        if(h==0 && w==0){
            break;
        }
        for(int i=0;i<h;i++){
            if(i==0||i==h-1){
                for(int j=0;j<w;j++){
                    cout<<"#";
                }
                cout<<endl;
                continue;
            }
            for(int j=0;j<w;j++){
                if(j==0){
                    cout<<"#";
                }else if(j==w-1){
                    cout<<"#"<<endl;
                }else{
                    cout<<".";
                }

            }
        }
        cout<<endl;
    }
}


Measured memory_bytes: 3080