akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cctype>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cctype>
#include<cstring>
#include<utility>
const int inf=0x7fffffff;
typedef long long int ll;
using namespace std;
char s[100+10];
struct DICE{
	int u,s,e,w,n,d;
	DICE (int u=0,int s=0,int e=0,int w=0,int n=0,int d=0):u(u),s(s),e(e),w(w),n(n),d(d){}
	DICE fW(){
		DICE tmp;
		tmp.s=this->s;
		tmp.n=this->n;
		tmp.e=this->d;
		tmp.w=this->u;
		tmp.u=this->e;
		tmp.d=this->w;
		return tmp;
	}
	DICE fS(){
		DICE tmp;
		tmp.s=this->u;
		tmp.n=this->d;
		tmp.e=this->e;
		tmp.w=this->w;
		tmp.d=this->s;
		tmp.u=this->n;
		return tmp;
	}
	DICE fE(){
		DICE tmp;
		tmp.s=this->s;
		tmp.n=this->n;
		tmp.e=this->u;
		tmp.w=this->d;
		tmp.d=this->e;
		tmp.u=this->w;
		return tmp;
	}
	DICE fN(){
		DICE tmp;
		tmp.s=this->d;
		tmp.n=this->u;
		tmp.e=this->e;
		tmp.w=this->w;
		tmp.d=this->n;
		tmp.u=this->s;
		return tmp;
	}
};
int main()
{
//#ifdef DEBUG
//	freopen("in", "r", stdin);
////	freopen("out", "w", stdout);
//#endif
	
	int a[6];
	for(int i=0;i<6;i++){
		scanf("%d", &a[i]);
	}
	DICE dice(a[0],a[1],a[2],a[3],a[4],a[5]);
	scanf("%s", s);
	int len=strlen(s);
	for(int i=0;i<len;i++){
		switch(s[i]){
			case'S':dice=dice.fS();break;
			case'E':dice=dice.fE();break;
			case'W':dice=dice.fW();break;
			case'N':dice=dice.fN();break;
		}
	}
	printf("%d\n", dice.u);
	//insert code above
	return 0;
}
//aoj1_11_a.cc

Measured memory_bytes: 1188
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stdlib.h>
#include <map>
#include <cmath>
#define MOD_P 1000000007
#define MOD_Q 998244353
#define PI 3.14159265358979
#define ll long long
using namespace std;

int main()
{
	int x;
	cin >> x;

	printf("%s", x < 30 ? "No" : "Yes");
	return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld  = long double;
using pll = pair<ll, ll> ;
using pld = pair<ld, ld>;
const int INF=1e9+7;
const ll LINF=1LL<<60;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld EPS = 1e-9; //微調整用（EPSより小さいと0と判定など）

//MODINT
//変数名.nでint型の数値を受け取る
struct mint {
    int n;
    mint(int n_ = 0) : n(n_) {}
};
 
mint operator+(mint a, mint b) { a.n += b.n; if (a.n >= MOD) a.n -= MOD; return a; }
mint operator-(mint a, mint b) { a.n -= b.n; if (a.n < 0) a.n += MOD; return a; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }

int ii() { int x; scanf("%d", &x); return x; }
long long il() { long long x; scanf("%lld", &x); return x; }
string is() { string x; cin >> x; return x; }
char ic() { char x; cin >> x; return x; }
void oi(int x) { printf("%d ", x); }
void ol(long long x) { printf("%lld ", x); }
void od(double x) { printf("%.15f ", x); }
void os(const string &s) { printf("%s ", s.c_str()); }
auto op = [&](auto p) -> void{ cout << p; };
auto ov = [&](auto vec) -> void{ cout << vec; };
void br() { putchar('\n'); }
 
#define gcd __gcd //llは受け取ってくれない
int lcm(int a, int b){return a / gcd(a, b) * b;}
#define ALL(a) a.begin(),a.end() //sort(ALL(vec));
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define PB push_back
#define SZ(x) ((int)(x).size) //size()がunsignedなのでエラー避けに

// coutによるpairの出力（空白区切り）
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << p.first << " " << p.second;}
// coutによるvectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
	int len = v.size();
	for (int i = 0; i < len; ++i) {
		s << v[i]; if (i < len - 1) s << " "; //"\t"に変えるとTabで見やすく区切る
	}
	return s;
}
// coutによる多次元vectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
	int len = vv.size();
	for (int i = 0; i < len; ++i) {
		s << vv[i] << endl;
	}
	return s;
}

//最大値、最小値を更新する。aよりbのが大きい（小さい）か等しければaを更新してtrueを返す。そうでなければ何もせずfalseを返す chmax(nowmax,x);
template<typename T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<typename T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}

// ----- template end ---- //
 
// ------- library ------- //



// ----- library end ----- //



int main() {


  vector<ll> vals(5);
  rep(i, 5) vals[i] = il();

  ll k = il();

  os(vals[4]-vals[0]>k ? ":(" : "Yay!");

  
// -- main() end -- //
}


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

int main(){
    int a,b;
    cin >> a >> b;

    int ans=0;
    if(a<b){
        for(int i=0;i<b;i++){
            ans = ans*10 + a;
        }
        cout << ans << endl;
        return 0;
    }
    for(int i=0;i<a;i++){
        ans = ans*10 + b;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

template <class T>inline T updmax(T& a, T b) {return a = max(a, b);}
template <class T>inline T updmin(T& a, T b) {return a = min(a, b);}

struct edge{
	int from, to, idx;
	edge(int from, int to, int idx):from(from), to(to), idx(idx){}
};
using node = vector<edge>;
using graph = vector<node>;
void addedge(graph &g, int from, int to, int idx, bool bidirectional = false){
	g[from].emplace_back(edge(from, to, idx));
	if(bidirectional)g[to].emplace_back(edge(to, from, idx));
}


class Solution {
public:
	void dfs(graph &g, int u, vector<int> &ans, int c, vector<bool> &visit){
		int x = 0;
		visit[u] = true;
		for(int i = 0; i < g[u].size(); i++){
			if(visit[g[u][i].to])continue;
			if(x == c)x++;
			ans[g[u][i].idx] = x;
			dfs(g, g[u][i].to, ans, x,visit);
			x++;
		}
	}

	void solve(){
		int n;
		cin >> n;
		graph g(n);
		for(int i=0; i < n-1; i++){
			int a, b;
			cin >> a >> b;
			a--, b--;
			addedge(g, a, b, i, true);
		}
		vector<int> ans(n-1, -1);
		vector<bool> visit(n);
		int k = 0;
		for(int i=0; i < n; i++)k = updmax(k, (int)g[i].size());
		cout << k << "\n";
		dfs(g, 0, ans, -1, visit);
		for(int i=0; i<n-1; i++)cout << ans[i] + 1 << "\n";		
	};
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	Solution solution;
	solution.solve();
	return 0;
}

Measured memory_bytes: 7424
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 100010;

int main(){
    int h, w;
    scanf("%d%d", &h, &w);
    int cnt = 0;
    rep(i, h)rep(j, w){
        char c;
        scanf(" %c", &c);
        cnt += (c == '#');
    }
    puts(cnt == h+w-1 ? "Possible" : "Impossible");
}

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

#define rep(i,n) for(int i = 0;i<n;i++)
#define cint(a) int a; cin >> a;
#define cstr(str) string str; cin >> str;
#define vv(Type, n,m,d)vector<vector<Type>> vv(n, vector<Type>(m, d));

using namespace std;
using ll = long long;

const ll mod = 1e9 + 7;

int main(void) {

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

	int n; cin >> n;
	vector<ll> a(n);
	bool zero = false;
	rep(i, n) { cin >> a[i]; 
	if (a[i] == 0) zero = true;
	}
	
	ll large = 1e18;
	
	sort(a.rbegin(), a.rend());
	ll ans = 1;
	rep(i, n) {
		if (ans > large / a[i]) {
			ans = -1;
			break;
		}
		ans *= a[i];
	}
	

	if (zero) ans = 0;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3964
#include <iostream>
static const int INFNTY = 1e9 + 1;
using namespace std;

int main(){
  int n, k;

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

  int dp[n];
  for (int i = 0; i < n; i++) {
    dp[i] = INFNTY;
  }
  int j;
  int cost;
  dp[0] = 0;
  dp[1] = abs(h[1] - h[0]);
  for (int i = 2; i < n; i++) {
    for (int j = 1; (j <= i) && (j <= k); j++) {
      dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
    }
  }
  cout << dp[n-1] << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define int long long 
const int N=2e5+4;
const int mod=1e9+7;
const int INF=1e9+7;
int dp[301][301];
void warshall_floyd(int n){
    for(int k=0;k<n;k++){
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                dp[i][j]=min(dp[i][j],dp[i][k]+dp[k][j]);
            }
        }
    }
}
void solve(){
    memset(dp,0,sizeof dp);
    int n,m,l; cin>>n>>m>>l;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(i!=j){
                dp[i][j]=INF;
            }
        }
    }
    for(int i=0;i<m;i++){
        int a,b,c; cin>>a>>b>>c;
        a--;
        b--;
        dp[a][b]=c;
        dp[b][a]=c;
    }
    warshall_floyd(n);
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(i==j){
                continue;
            }
            if(dp[i][j]<=l){
                dp[i][j]=1;
            }
            else{
                dp[i][j]=INF;
            }
        }
    }
    warshall_floyd(n);
    int q; cin>>q;
    for(int i=0;i<q;i++){
        int s,t; cin>>s>>t;
        s--;
        t--;
        if(dp[s][t]==INF){
            cout<<"-1"<<endl;
        }
        else{
            cout<<dp[s][t]-1<<endl;
        }
    }
}   
int32_t main(){
    // ios_base::sync_with_stdio(false);cin.tie(NULL);
    int tt; 
    tt=1;
    // cin>>tt;
    for(int t=1;t<=tt;t++){
        solve();
    }
} 
/*

3 2 5
1 2 3
2 3 3
2
3 2
1 3

*/

Measured memory_bytes: 4316
// Problem : C - Skill Up
// Contest : AtCoder - AtCoder Beginner Contest 167
// URL : https://atcoder.jp/contests/abc167/tasks/abc167_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#define int long long
#define fastio                      \
  ios_base::sync_with_stdio(false); \
  cin.tie(0);                       \
  cout.tie(0);
#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define db1(x) cout << #x << "=" << x << endl
#define db2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z)                                                       \
  cout << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z \
       << endl
#define dbp(x) \
  cout << #x << "= {" << (x.first) << ", " << (x.second) << "}" << endl;
#define dbv(v)                         \
  {                                    \
    cout << #v << " : ";               \
    for (auto x : v) cout << x << ' '; \
    cout << endl;                      \
  }
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define rep2(i, a, b) for (int i = a; i >= b; i--)
#define die(x) return cout << x << '\n', 0;

using namespace std;

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

int32_t main() {
  fastio;
  //  freopen("input.txt", "r", stdin);
  //  freopen("output.txt", "w", stdout);
  int testcases;
  testcases = 1;
  // cin>>testcases;

  while (testcases--) {
    int n, m, x;
    cin >> n >> m >> x;
    vector<int> c(n);
    vvi a(n, vi(m));
    rep(i, 0, n - 1) {
      cin >> c[i];
      rep(j, 0, m - 1) cin >> a[i][j];
    }
    bool flag = false;
    int mn = INT_MAX;
    for (int mask = 1; mask < (1 << n); mask++) {
      int cs = 0;
      bool valid = true;
      vi know(m, 0);
      for (int i = 0; i < n; i++) {
        if (mask & (1 << i)) {
          cs += c[i];
          rep(j, 0, m - 1) { know[j] += a[i][j]; }
        }
      }
      rep(j, 0, m - 1) {
        if (know[j] < x) {
          valid = false;
        }
      }
      if (valid) {
        flag = true;
        mn = min(mn, cs);
      }
    }
    if (flag) {
      cout << mn << '\n';
    } else {
      die(-1);
    }
  }

  return 0;
}


Measured memory_bytes: 3612
#include <cstdio>
#include <algorithm>
#include <queue>
#include <vector>

using namespace std;
typedef long long LL;

#define re register
#define gc getchar
#define digit(x) (x >= '0' && x <= '9')

int read()
{
	int x = 0, f = 1; char c = getchar();
	while (!digit(c)) {if (c == '-') f = -1; c = gc();}
	while (digit(c)) x = (x << 3) + (x << 1) + c - '0', c = gc();
	return x * f;
}

const int N = 2005;
const LL inf = 0x3f3f3f3f3f3f3f3f;

int n, x;
int a[N];
int sk[N << 1], pos[N << 1], tp, tl;

inline int P(int x, int y)
{
	if (x < y) return y - x;
	return y - x + n;
}

int main()
{
	n = read(); x = read();
	
	for (re int i = 1; i <= n; i++)
		a[i] = read();
	
	LL ans = inf;
	for (re int i = 0; i < n; i++)
	{
		tl = tp = 0;
		LL tmp = 0;
		for (re int j = i; j >= 1; j--)
		{
			while (tl < tp && sk[tp - 1] >= a[n - j + 1]) tp--;
			sk[tp] = a[n - j + 1], pos[tp++] = n - j + 1;
		}
		for (re int j = 1; j <= n; j++)
		{
			while (tl < tp && P(pos[tl], j) > i) tl++;
			while (tl < tp && sk[tp - 1] >= a[j]) tp--;
			sk[tp] = a[j], pos[tp++] = j;
			tmp += sk[tl];
		}
		ans = min(ans, tmp + 1ll * i * x);
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 1616
#include <stdio.h>
int main (void)
{
  int n = 0;
  int d = 0;
  int a;
  int b;
  
  scanf("%d%d",&n,&d);
  
  for (a=0;(2*d+1)*a<n;a++){
    b=a;
  }
  
  printf("%d",b+1);
  
  return 0;
}

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

using namespace std;

typedef long int lint;
typedef long long int llint;

#define INF 2147483647
#define LINF 92233720370000000000

int n, k;
int h[110000], dp[110000];

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

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

    for (int i = 1; i < n; i++) {
        dp[i] = dp[i - 1] + abs(h[i] - h[i - 1]);
        for (int j = 2; j <= k; j++) {
            if (i - j >= 0)
                dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
        }
    }

    cout << dp[n - 1] << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
  
/* 選択ソート (0オリジン) */
int selectionSort(int A[], int N) {
  int i, j, t, sw = 0, mini;
  for(i=0; i<N-1; i++) {
    mini = i;
    for(j=i; j<N; j++) {
      if(A[j] < A[mini]) mini = j;
    }
  
    t = A[i];
    A[i] = A[mini];
    A[mini] = t;
  
    if(i != mini) sw++;
  }
  return sw;
}
  
int main(void) {
  int A[100], N, i, sw;
  scanf("%d", &N);
  for(i=0;i<N;i++) scanf("%d",&A[i]);
  
  sw = selectionSort(A,N);
  
  for(i=0;i<N;i++) {
    if(i>0) printf(" ");
    printf("%d",A[i]);
  }
  printf("\n");
  printf("%d\n", sw);
  
  return 0;
}


Measured memory_bytes: 2756
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int day = sc.nextInt();
    int choco = sc.nextInt();
    int totalChoco = 0;
    for (int i = 0; i < n; i++) {
      int player = sc.nextInt();
      int div = day / player;
      if (day % player == 0) {
        totalChoco += div;
      } else {
        totalChoco += (div + 1);
      }
    }
    System.out.println(totalChoco + choco);
  }
}

Measured memory_bytes: 23764
/*
                IftekharMd.Shishir
                Dept. of Information and Communication Engineering
                University of Rajshahi
*/

#include<bits/stdc++.h>

#define ll  long long
#define ull  unsigned long long
#define ld  long double
#define f(i,n)  for(i=0;i<n;i++)
#define F(i,n)  for(i=n-1;i>=0;i--)
#define fa(i,a,b)  for(i=a;i<=b;i++)
#define Fa(i,a,b)  for(i=a;i>=b;i--)
#define printArray(i,a,n)  f(i,n)cout<<a[i]<<" "; cout<<endl;
#define printSet(a)  for(auto setData:a) cout<<setData<<" ";cout<<endl;
#define printMap(a)  for(auto mapData:a) cout<<mapData.first<<" "<<mapData.second<<endl;
#define printVector(a)  for(auto vectorData:a)cout<<vectorData<<" ";cout<<endl;
#define printLinkedList()  temp=head;while(temp){cout<<temp->data<<" ";temp=temp->post;} cout<<endl;

#define pb(x)  push_back(x)
#define all(a)  a.begin(),a.end()
#define rall(a)  a.rbegin(),a.rend()
#define sor(a)  sort(a.begin(),a.end())
#define rev(a)  reverse(a.begin(),a.end())
#define mem(a,x)  memset(a,x,sizeof(a))
//[ ll *it; it = maxElement(a,a+n); ]

#define bs  binary_search
#define lb  lower_bound
#define ub  upper_bound
#define mp  make_pair
#define txtIO  freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define txtTest freopen("C:/Users/Iftekhar/Documents/what/input.txt", "r", stdin);
#define FastIO  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);ios::sync_with_stdio(0);
#define TestCase  ll t;cin>>t;while(t--)
#define points(x)  fixed<<setprecision(x)
#define scd(a,x,y)  a/__gcd(x,y);
#define nl  cout<<endl;
#define done  return 0

const ld PI= 3.14159265358979323846264338327950288;  //2*acos(0.0);
const long long MOD= 1000000007;
const long long MAX = 32000;

// stringstream demo(str);  demo >> x;
// stringstream demo;  demo << x;  name=demo.str();

using namespace std;

vector<ll> adv[1000006];

void sieve_all_divisors (ll n)
{
    ll i,j;
    for(i=1;i<=n;i++)for(j=i;j<=n;j+=i)adv[j].pb(i);
}

int main()
{
        FastIO;
        //txtTest;
        ll n,i,cnt=0,flag=0,sum=0;
        cin>>n;
        sieve_all_divisors(n-1);
        for(i=1;i<=n;i++) sum+=adv[i].size();
        cout<< sum<<endl;
        done;
}

Measured memory_bytes: 184156
#include<stdio.h>
#include<string.h>
int main(){
    char w[16],t[1024];
    int cnt,flag,i,j,tmp;
    scanf("%s",w);
    cnt=0;
    while(1){
        scanf("%s",t);
        if(!strcmp(t,"END_OF_TEXT"))break;
        i=0;
        for(i=0;i<strlen(t);i++)if('A'<=t[i]&&t[i]<='Z')t[i]+='a'-'A';
        tmp=strlen(t)-strlen(w)+1;
        for(i=0;i<tmp;i++){
            if(i==0||t[i]==' '){
                if(i==0)i--;
                if(!strncmp(t+i+1,w,strlen(w))&&(t[i+1+strlen(w)]==' '||t[i+1+strlen(w)]=='\0'))cnt++;
                if(i==-1)i++;
            }   
        }
    }
    printf("%d\n",cnt);
    return 0;
}


Measured memory_bytes: 2040
#include<bits/stdc++.h>
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<vector>
#include<stdio.h>
using namespace std;
#define ll long long
#define rep(i,a,b) for(int i=a;i<b;i+=1)
#define vi vector<int>
#define vii vector<vector<int> >
#define all(c) (c).begin(),(c).end()
#define pb push_back
void solve()
{
   int h,w;
   cin>>h>>w;
   int n,x;
  vector<int> v;
  cin>>n;
  rep(i,1,n+1)
  {
    cin>>x;
    while(x--)
    {
      v.pb(i);
    }
  }
  //cout<<v.size();
  sort(v.begin(),v.end());
  int i,j,c;
  for(int i=0;i<h;i++)
  {
     if(i%2)
     {
       for(j=i*w;j<i*w+w;j++)
         cout<<v[j]<<" ";
     }
     else
     {
       for(j=i*w+w-1;j>i*w-1;j--)
         cout<<v[j]<<" ";
     }
     cout<<"\n";
  }
}
int main()
{
    ll t=1;
    //cin >>t;
    while(t--)
        solve();

}


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

class Solution
{
    static void Main()
    {
        var vals = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        int a = vals[0];
        int b = vals[1];
        int c = vals[2];

        int diff = a;
        if (a == b)
        {
            diff = c;
        }
        else if (a == c)
        {
            diff = b;
        }

        Console.WriteLine(diff);
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;

constexpr auto M = 998244353L;

int64_t pow2(int64_t p) {
  if (p == 0) {
    return 1;
  }
  auto pp = pow2(p / 2);
  return ((p%2)?2:1) * pp * pp % M;
}

main() {
  int64_t n;
  cin >> n;
  
  vector<int64_t> x(n), y(n);
  for (auto i : irange(0L, n)) {
    cin >> x[i] >> y[i];
  }
  
  vector<vector<unordered_set<int64_t>>> lines(n, vector<unordered_set<int64_t>>(n));
  for (auto i : irange(0L, n)) {
    for (auto j : irange(i + 1, n)) {
      lines[i][j].insert(i);
      lines[i][j].insert(j);
      // y = (y2 - y1) / (x2 - x1) * (x - x1) + y1
      // (y - y1) * (x2 - x1) = (y2 - y1) * (x - x1)
      for (auto k : irange(0L, n)) {
        if (k == i || k == j) continue;
        if ((y[k] - y[i]) * (x[j] - x[i]) != (y[j] - y[i]) * (x[k] - x[i])) {
          continue;
        }
        if (k < j) {
          lines[i][j].clear();
          break;
        }
        lines[i][j].insert(k);
      }
    }
  }
  
  uint64_t ans = pow2(n);
  ans += M - 1; // empty set
  ans += n * (M - 1); // one size set
  ans %= M;
  // cerr << ans << endl;
  for (auto i : irange(0L, n)) {
    for (auto j : irange(0L, n)) {
      if (lines[i][j].empty()) {
        continue;
      }
      auto m = lines[i][j].size();
      ans += (pow2(m) - 1 - m) * (M - 1);
      ans %= M;
      // cerr << i << "," << j << " " << m << " " << pow2(m) - 1 - m << " " << ans << endl;
    }
  }
  
  cout << ans << endl;
}

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

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

#define m0(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
#define rep(i, n) for(int i = 0; i < (n); i++)
#define asort(x) sort(all(x));
#define dsort(x, t) sort(x.begin(), x.end(), greater<t>());
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define MINS(m, s) m.insert(make_pair(s, 1));
#define MFIN(m, s) m.find(s) != m.end()
#define INF (1 << 29)
const int mod = 1000000007;

int main() {
    ll k;
    cin >> k;

    if(k % 2 == 0 || k % 5 == 0) {
        cout << -1 << endl;
        exit(0);
    }

    ll x = 7 % k;
    for(ll i = 1;; i++) {
        if(x == 0) {
            cout << i << endl;
            exit(0);
        }
        x = (x * 10) % k;
        x = (x + 7) % k;
    }

    return 0;
}

Measured memory_bytes: 3620
#include<algorithm>
#include <iostream>
#include <math.h>
#include <cstdio>
#include <string.h>
using namespace std;
int main(void){
	long long int x,i,j,ans=0;
	cin>>x;
  	
	for(i=1;i<=x;i++){
		for(j=2;j<=10;j++){
			if(pow(i,j)>x)break;
			if(pow(i,j)<=x){
              long long int t=pow(i,j);
				ans=max(ans,t);
           
			}
		}
	}
  cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
S,T = input(),input()

convert = dict()

bl = True
for s,t in zip(S,T):
  if s in convert and convert[s] != t:
    bl = False
    break
  convert[s] = t

# 変換先の重複チェック
after = convert.values()
if len(after) != len(set(after)):
  bl = False

print('Yes' if bl else 'No')

Measured memory_bytes: 3632
#include <iostream>
using namespace std;
int main(void){
    int x,y;
    while(true){
        cin >> x >> y;
        if(x == 0 && y == 0){break;}
        if(x>y){
            cout << y << " " << x << endl;
        }else{
            cout << x << " " << y << endl;
            }
    }
    
}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
int n,a,b;
char str[1000000];
int main(){
  scanf("%d %s",&n,str);
  for(int i=0;i<n;i++){
    if(str[i]=='<')a++;
    else break;
  }
  reverse(str,str+n);
  for(int i=0;i<n;i++){
    if(str[i]=='>')b++;
    else break;
  }
  printf("%d\n",n-min(a,b));
  return 0;
}

Measured memory_bytes: 3324
n = int(input())
s = ['.'] * n
for i in range(n):
    s[i] = str(input())

m = int(input())
t = ['.'] * m
for i in range(m):
    t[i] = str(input())

ans = 0
for i1 in range(n):
    score = 0
    for i2 in range(n):
        if s[i1] == s[i2]:
            score += 1
    for j in range(m):
            if s[i1] == t[j]:
                score -= 1
    if ans <= score:
        ans = score

print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

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

  int a, b, c;
  cin >> a >> b >> c;
  int k;
  cin >> k;

  int ans = (a + b + c) - max(a, max(b, c)) + 
    (1 << k) * max(a, max(b, c));

  cout << ans << endl;

  return 0;
}


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

using namespace std;

const int ms = 5e2 + 17;
int c[ms], s[ms], f[ms], answer[ms];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin >> n;

    for(int i = 1; i <= n - 1; ++i)
    {
        cin >> c[i] >> s[i] >> f[i];
    }

    answer[n] = 0;

    for(int i = 1; i < n; ++i)
    {
        int temp = s[i] + c[i];
        for(int j = i + 1; j < n; ++j)
        {
            if(temp >= s[j])
            {

                if(temp % f[j] != 0)
                    temp += f[j] - (temp % f[j]);

                temp += c[j];

            }
            else
            {
                temp = s[j] + c[j];
            }

        }

        answer[i] = temp;
    }

    for(int i = 1; i <= n; ++i)
        cout << answer[i] << '\n';


}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long f[500005],n,m;
int main()
{
	cin>>n>>m;
	f[0]=1,f[1]=m-n;
	for(int i=2;i<=n;i++)
		f[i]=((m+i-n-1)*f[i-1]+(i-1)*f[i-2])%1000000007;
	for(int i=m-n+1;i<=m;i++)
		f[n]=(f[n]*i)%1000000007;
	cout<<f[n];
}

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

int main() {
    int n;
    cin>>n;
    ll ans=1LL<<60,res;
    vector<int> a(n);
    rep(i,n) cin>>a[i];
    sort(a.begin(),a.end());
    for (int i=a[0]; i<=a[n-1]; i++) {
        res=0;
        rep(j,n) {
            res+=pow(i-a[j],2);
        }
        ans=min(ans,res);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  char c[a][a];
  char d[b][b];
  for(int i=0;i<a;i++){
    for(int j=0;j<a;j++){
      cin>>c[i][j];
    }
  }
  for(int i=0;i<b;i++){
    for(int j=0;j<b;j++){
      cin>>d[i][j];
    }
  }
  int e;
  for(int i=0;i<a-b+1;i++){
    for(int j=0;j<a-b+1;j++){
      if(d[0][0]==c[i][j]){
        e=0;
        for(int k=0;k<b;k++){
          for(int l=0;l<b;l++){
            if(d[k][l]==c[i+k][j+l])
              e++;
            if(e==b*b){
              cout<<"Yes";
              return 0;
            }
          }
        }
      }
    }
  }
  cout<<"No";
}

Measured memory_bytes: 384
#ifdef _MSC_VER
#include <__msvc_all_public_headers.hpp>
#undef min
#undef max
#else
#define NDEBUG
#include <bits/stdc++.h>
#endif

using namespace std;
using large = long long;

int main()
{
    string s;
    cin >> s;
    auto sum = 0LL;
    for (auto ch : s)
        sum += (ch - '0');

    cout << (sum % 9 == 0 ? "Yes":"No") << endl;
    return 0;
}


Measured memory_bytes: 3700
#include<bits/stdc++.h>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define loopb(i,a,b) for(int i=a;i>=b;i--)
#define loopm(i,a,b,step) for(int i=a;i<b;i+=step)
#define loopbm(i,a,b,step) for(int i=a;i>=b;i-=step)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define init(arr,val) memset(arr,val,sizeof(arr))
#define INF 1000000007
#define MOD 1000000007
#define BINF 1000000000000000001
#define int long long int
#define double long double

using namespace std;

int dp[1005][1005][8];
int a[1005][8];
bool visited[1005][1005][8];

int go(int n,int k,int idx)
{

	if(n<0)
	{
		if(k!=0) return -BINF;
		else return 0;
	}
	
	
	else if(visited[n][k][idx]==true) return dp[n][k][idx];
	else if(k==0) return 0;
	else
	{
		visited[n][k][idx]=true;
		dp[n][k][idx]=max(go(n-1,k,idx),go(n-1,k-1,idx)+a[n][idx]);
		return dp[n][k][idx];
	}
}


#undef int
int main()
{
#define int long long int
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
   // freopen("input.txt","r",stdin);
 int n;
 cin>>n;
 int m;
 cin>>m;
 int x[n],y[n],z[n];
 loop(i,0,n) cin>>x[i]>>y[i]>>z[i];
 
 int X[n][8],Y[n][8],Z[n][8];
 
loop(i,0,8)
{
	loop(j,0,n)
	{
		if(i%2==0) X[j][i]=x[j];
		else X[j][i]=-x[j];
		if(i==0 or i==1 or i==4 or i==5) Y[j][i]=y[j];
		else Y[j][i]=-y[j];
		if(i==0 or i==1 or i==2 or i==3) Z[j][i]=z[j];
		else Z[j][i]=-z[j];
	}
}



loop(i,0,8)
{
	loop(j,0,n)
	{
		a[j][i]=X[j][i]+Y[j][i]+Z[j][i];
	}
}

int ans=-BINF;

loop(i,0,1005)
{
	loop(j,0,1005)
	{
		loop(k,0,8){ dp[i][j][k]=-BINF; visited[i][j][k]=false;}
	}
}

loop(i,0,8)
{
	int curr=go(n-1,m,i);
	ans=max(ans,curr);
}
 cout<<ans;
 
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)

const int N_MAX = 100000 + 1;
int n;
int a[N_MAX];

bool input() {
  if (cin >> n) {
    rep (i, n) cin >> a[i];
    return true;
  }
  return false;
}

int solve() {
  int l[n];
  int lc = 1;
  l[0] = a[0]; 
  rep (i, n) {
    if (l[lc - 1] < a[i]) l[lc++] = a[i];
    auto it = lower_bound(l, l + lc, a[i]);
    if (it != l + lc) *it = a[i];
  }
  return lc;
}

int main() {
  while (input()) {
    cout << solve() << endl;
  }
  return 0;
}

Measured memory_bytes: 1936
import numpy as np
from functools import *
import sys
sys.setrecursionlimit(100000)



def acinput():
    return list(map(int, input().split(" ")))


def II():
    return int(input())

K,N=acinput()

A=acinput()
A.append(A[0]+K)
B=np.array(A)+K
#A.extend(B)
a=np.array(A)

print(K-np.max(a[1:]-a[:-1]))


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

int cnt[101010];
string ans[101010];

int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  
  int N,M; cin>>N>>M;
  vector<pair<int,pair<int,int>>> V(M);
  rep(i,M){
    int P,Y; cin>>P>>Y;
    V[i]={Y,{P,i}};
  }
  sort(V.begin(),V.end());
  for(auto& P:V){
    int p=P.second.first, x=++cnt[p], i=P.second.second;
    string xx=to_string(x),pp=to_string(p);
    string tmp="";
    rep(j,6-pp.length()) tmp+='0';
    tmp+=pp;
    rep(j,6-xx.length()) tmp+='0';
    tmp+=xx;
    ans[i]=tmp;
  }
  rep(i,M) cout<<ans[i]<<endl;
  return 0;
}


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

// Begin {{{
using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0; i < (n); ++i)
#define reps(i, b, e) for (i64 i = (b); i <= (e); ++i)
#define repr(i, b, e) for (i64 i = (b); i >= (e); --i)
#define var(Type, ...) Type __VA_ARGS__; input(__VA_ARGS__)

#ifdef DEBUG
#define dump(...) dump_(#__VA_ARGS__, __VA_ARGS__);
#else
#define dump(...)
#endif

using i64 = int_fast64_t;
using pii = pair<i64, i64>;

template <class A, class B>
inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }

template <class A, class B>
inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

// input
void input() {}
template <class Head, class... Tail>
void input(Head&& head, Tail&&... tail) {
  cin >> head;
  input(forward<Tail>(tail)...);
}

// outs
void outs() {}
template <class Head, class... Tail>
void outs(Head&& head, Tail&&... tail) {
  cout << head << " \n"[sizeof...(tail)==0];
  outs(forward<Tail>(tail)...);
}

template <class T>
void outs(vector<T> &vec) { for (auto &e : vec) cout << e << " \n"[&e==&vec.back()]; }

template <class T>
void outs(vector<vector<T>> &df) { for (auto &vec : df) OUTS(vec); }

// outl
void outl() {}
template <class Head, class... Tail>
void outl(Head&& head, Tail&&... tail) {
  cout << head << "\n";
  outl(forward<Tail>(tail)...);
}

template <class T>
void outl(vector<T> &vec) { for (auto &e : vec) cout << e << "\n"; }

// outn
void outn() {}
template <class Head, class... Tail>
void outn(Head&& head, Tail&&... tail) {
  cout << head;
  outn(forward<Tail>(tail)...);
}

template <class T>
void outn(vector<T> &vec) { for (auto &e : vec) cout << e; }

// dump
template <class T>
void dump_(const char *s, T&& x) {
  clog << '{';
  while(*s != '\0') clog << *(s++);
  clog << ": " << x << '}' << "\n";
}

template <class Head, class... Tail>
void dump_(const char *s, Head&& head, Tail&&... tail) {
  clog << '{';
  while(*s != ',') clog << *(s++);
  clog << ": " << head << "}, ";
  for (++s; !isgraph(*s); ++s);
  dump_(s, forward<Tail>(tail)...);
}
// }}} End

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

  var(int, N, K);
  var(string, s);

  int cnt = 0;
  rep(i, N - 1) {
    if (s[i] == s[i+1]) ++cnt;
  }

  outl(min(cnt + 2 * K, N - 1));

  return 0;
}


Measured memory_bytes: 512
#include <cstdio>
#include <algorithm>
#include <iostream>
using namespace std;
#define X first
#define Y second
typedef long long LL;
typedef pair<int, int> pii;
const int N = 1e5 + 100;

pii a[N];
LL ans[N];
int main() {
    int n;
    cin >> n;
    for(int i = 1; i <= n; i ++) {
        scanf("%d", &a[i].X);
        a[i].Y = -i;
    }
    sort(a + 1, a + 1 + n, greater<pii>() );
    LL sum = 0;
    for(int now = 1, nxt = now; now <= n; now = nxt) {
        while(nxt <= n && a[nxt].Y <= a[now].Y) sum += a[nxt ++].X,
        ans[-a[now].Y] = sum - (nxt - 1) * 1LL * a[nxt].X;
        sum -= ans[-a[now].Y]; 
    }
    for(int i = 1; i <= n; i ++) 
        printf("%lld\n", ans[i]);
}



Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &&x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define INSEG(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_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) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) 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,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(false);
        cout << setprecision(15) << fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

map<int, int> factorize(int a) {
    map<int, int> ret;
    for(int i = 2; i * i <= a; i++) {
        int cnt = 0;
        while (a % i == 0) a /= i, cnt++;
        if (cnt != 0) ret[i] = cnt;
    }
    if (a != 1) ret[a] = 1;
    return ret;
}

int bin_pow(int a, int b) {
    int ret = 1;
    while (b > 0) {
        if (b & 1) ret = (ret * a);
        a = (a * a);
        b >>= 1;
    }
    return ret;
}

signed main() {
    int N, P;
    cin >> N >> P;
    auto f = factorize(P);

    int ans = 1;
    FORE(p, f) {
        ans *= bin_pow(p.first, p.second / N);
    }
    cout << ans << endl;
    return (0^_^0);
}



Measured memory_bytes: 256
N = int(input())
S, T = [0] * N, [0] * N
for i in range(N):
    S[i], t = input().split()
    T[i] = int(t)
X = input()

sleep = False
total = 0
for s, t in zip(S, T):
    if s == X:
        sleep = True
        continue
    elif sleep:
        total += t
print(total)

Measured memory_bytes: 3064
#include<stdio.h>
int main()
{
	long long x,y;
	scanf("%lld",&y);
	x=y;
	int sum=0;
	while(x>0)
	{
		sum=sum+x%10;
		x=x/10; 
	}
	if(y%sum==0)
		printf("Yes\n");
	else
		printf("No\n");
	
	
	return 0;
}

Measured memory_bytes: 128
using System;
namespace 令和{
    class ABC{
        static void Main(){
            string[] n_k = Console.ReadLine().Split();
            int n = int.Parse(n_k[0]);
            int k = int.Parse(n_k[1]);
            char[] s = Console.ReadLine().ToCharArray();
            if(s[k-1]=='A'){s[k-1] = 'a';
            }else if(s[k-1]=='B'){
s[k-1] = 'b';
            }else{
s[k-1] = 'c';
            }
            Console.WriteLine(new String(s));
            
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(),x.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T&a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T&a,T b){if(a>b){a=b;return 1;}return 0;}
using ll = long long;
using P = pair<int,int>;

int n,m,k;
string s,t;

int main() {
  cin >> k;
  vector<int>v(32);
  v={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  cout <<v[k-1] << endl;
}

Measured memory_bytes: 256
import java.util.*;

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

        int n = scan.nextInt();
        for(int i = 0; i < n; i++) {
            int a = scan.nextInt();
            if(a % 2 == 0 && !(a % 3 == 0 || a % 5 == 0)) {
                System.out.println("DENIED");
                scan.close();
                return;
            }
        }
        System.out.println("APPROVED");

        scan.close();
        return;
    }
}

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

int main(){
  int n;
  std::cin >> n;
  vector<int> f(1e6 + 1, 0);
  int a, b, ans = 0;
  for (int i = 0; i < n; i++) {
    std::cin >> a >> b;
    f[a - 1]++;
    f[b]--;
  }
  for (int i = 1; i <= 1e6; i++)f[i] += f[i - 1];
  for (int i = 0; i <= 1e6; i++) {
    ans = max(ans, (i <= f[i])?i:0);
  }
  std::cout << ans << std::endl;
  return 0;
}

Measured memory_bytes: 4964
#include <bits/stdc++.h>
using namespace std;
typedef long long 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; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

int main(){
    int N; cin >> N;
    vector<int> a(N);
    int first=0;
    int second=0;
    int cnt = 0;

    for(int i=0; i<N; ++i){
        cin >> a[i];
        if(a[i] > first){
            second = first;
            first = a[i];
        }
        else if(a[i] > second){
            second = a[i];
        }
    }

    for(int i=0; i<N; ++i){
        if(a[i] == first) cout << second << endl;
        else cout << first << endl;
    }


}

Measured memory_bytes: 2432
#include<iostream>
using namespace std;
int main(){
char c;
int i[10],v1,v2,k;
double d1,d2,dd;
while(cin>>i[0]){
for(k=1;k<10;k++)cin>>c>>i[k];
cin>>c>>v1>>c>>v2;
d2=0,dd=0;
for(k=0;k<10;k++)dd+=i[k];
d1=dd/(v1+v2)*v1;
for(k=0;k<10;k++){
d2+=i[k];
if(d2>=d1)break;
}
cout<<k+1<<endl;
}
return 0;
}

Measured memory_bytes: 1160
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

N = str(input())

if N[-1] in ['2','4','5','7','9']:
    print('hon')
elif N[-1] in ['3']:
    print('bon')
else:
    print('pon')

Measured memory_bytes: 65572
import sys

inputLine=input()
K=int(inputLine)

runrunNumberList=[]
runrunNumberCount=0
for i in range(10):
    runrunNumberList.append(str(i))
    if i != 0:
        runrunNumberCount += 1
    if runrunNumberCount == K:
        result = i
        print(result)
        sys.exit()

startPoint=0
endPoint=len(runrunNumberList)


while(True):
    for i in range(10):
        for j in range(startPoint, endPoint):
            
            if abs( int(i) - int( runrunNumberList[j][0] ) ) <= 1:
                runrunNumberList.append( str(i) + runrunNumberList[j] )

                if i != 0:
                    runrunNumberCount += 1

                if runrunNumberCount == K:
#                    print(runrunNumberList)
                    result = int( str(i) + runrunNumberList[j] )
                    print(result)
                    sys.exit()

    startPoint = endPoint
    endPoint = len(runrunNumberList)




Measured memory_bytes: 10776
#include <stdio.h>
#include <stdlib.h>
 
typedef struct node{
  int key;
  struct node *p;
  struct node *l;
  struct node *r;
}Node1;
typedef struct node  *Node;
Node root = NULL;
 
Node createNode(){
  Node z = malloc(sizeof(struct node));
  z->l = NULL;
  z->r = NULL;
  z->p = NULL;
  z->key = 0;
  return z;
}
 
int insert(int key){
   
  Node z = createNode();
  Node y = NULL;
  Node x = root;
  z->key = key;
   
  while(x != NULL){
    y = x;
    if(z->key < x->key) x = x->l;
    else x = x->r;
  }
  z->p = y;
  if(y == NULL) root = z;
  else if(z->key < y->key) y->l = z;
  else y->r = z;
}
   
void inorder(Node p){
     
  if(p != NULL){
    inorder(p->l);
    printf(" %d",p->key);
    inorder(p->r);
  }
}
 
void preorder(Node p){
  if(p != NULL){
    printf(" %d",p->key);
    preorder(p->l);
    preorder(p->r);
  }
}
 
int main(void){
 
  int i,key,n;
  char str[20];
 
  scanf("%d",&n);
 
  for(i=0;i<n;i++){
    scanf("%s",str);
 
    if(str[0] == 'i'){
      scanf("%d",&key);
      insert(key);
    }
    else if(str[0] == 'p'){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}



Measured memory_bytes: 25172
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
const ll INF = (ll)1e18 + 1;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    
    string s; cin >> s;
    int n=0;
    rep(i, s.length()){
        n += s[i] - '0';
    }
    
    if(n%9==0){
        cout << "Yes" << ln;
    }else{
        cout << "No" << ln;
    }
    
    return 0;
}

Measured memory_bytes: 3752
#!python

iim = lambda: map(int, input().rstrip().split())

def resolve():
    N, M, X = iim()
    S = [tuple(iim()) for i in range(N)]

    M1 = M+1
    mx = float("inf")
    ans = mx
    for i in range(1, 2**N):

        sx = [0]*(M1)
        for j in range(N):
            if i & (1<<j) == 0:
                continue

            for k, x in enumerate(S[j]):
                sx[k] += x

        if all(si >= X for si in sx[1:]):
            ans = min(ans, sx[0])

    if ans == mx:
        ans = -1
    print(ans)



if __name__ == "__main__":
    resolve()


Measured memory_bytes: 9244
import java.util.*;
import static java.lang.System.*;
 
public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		boolean P = false;
		boolean W = false;
		boolean G = false;
		boolean Y = false;
		int n = sc.nextInt();
		String s;
		for (int i=0; i<n; i++) {
			s = sc.next();
			if (s.equals("P")) {P=true;}
			else if (s.equals("W")) {W=true;}
			else if (s.equals("G")) {G=true;}
			else {Y=true;}
		}
		int count = 0;
		if (P==true) {count++;}
		if (W==true) {count++;}
		if (G==true) {count++;}
		if (Y==true) {count++;}
		out.println(count==4?"Four":"Three");
	}
}

Measured memory_bytes: 23252
// AOJ 0294 Catch a Thief
// 2018.2.14 
// Lengauer-Tarjan algorithm? 

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX   100002
#define QSIZE 150000
#define MAGIC 150

int rank[MAX], m[MAX];
int parent[MAX], vertex[MAX];
int semi[MAX], dom[MAX];
int **b_to, b_hi[MAX];
int *g_to[MAX], g_hi[MAX], _g_hi[MAX];
int *r_to[MAX], r_hi[MAX], _r_hi[MAX];
int *q, top;

int find(int v) { int r;		// union set
	if (rank[v] == v) return v;
	r = find(rank[v]);
	if (semi[m[v]] > semi[m[rank[v]]]) m[v] = m[rank[v]];
	return rank[v] = r;
}
int eval(int v) { find(v); return m[v]; }
void link(int x, int y) { rank[y] = x; }

void tree(int n)
{
	int i, j, k, w, u, v;
	
	for (i = 1; i <= n; i++) rank[i] = m[i] = i;

	k = 1, q[0] = 1, top = 1;
	while (top) {
		v = q[--top];
		if (semi[v]) continue;
		semi[v] = k;
		vertex[k++] = v;
		i = g_hi[v]; while (i--) {
			u = g_to[v][i];
			if (!semi[u]) parent[u] = v, q[top++] = u;
		}
	}
	free(q);

	b_to = malloc(n * sizeof(int *));
	b_to[1] = malloc(25000 << 2), b_to[1][0] = 0, u = 25000;
	for (i = 2; i <= n; i++) {
		b_to[i] = malloc(MAGIC << 2);
		b_to[i][0] = u, u += MAGIC;
	}

	for (i = n; i > 1; i--) {
		w = vertex[i];
		for (j = 0; j < r_hi[w]; j++) {
			v = r_to[w][j], u = eval(v);
			if (semi[u] < semi[w]) semi[w] = semi[u];
		}
		v = vertex[semi[w]];
		b_to[v][b_hi[v]++] = w;
		u = parent[w], link(u, w);
		for (j = 0; j < b_hi[u]; j++) {
			v = b_to[u][j];
			k = eval(v);
			dom[v] = (semi[k] < semi[v])? k: u;
		}
	}
//	free(b_to);

	for (i = 2; i <= n; i++) {
		w = vertex[i];
		if (dom[w] != vertex[semi[w]]) dom[w] = dom[dom[w]];
	}
}

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int main()
{
	int n, m, i, s, t, Q, r;
	
	n = in(), m = in();

	i = m << 2; if (i < QSIZE) i = QSIZE;
	q = malloc(i << 2);
	top = 0; for (i = 0; i < m; i++) {
		s = in(), t = in();
		q[top++] = s, q[top++] = t;
		_g_hi[s]++, _r_hi[t]++;
	}
	for (i = 1; i <= n; i++) {
		g_to[i] = malloc(_g_hi[i] << 2);
		r_to[i] = malloc(_r_hi[i] << 2);
	}
	top = 0; for (i = 0; i < m; i++) {
		s = q[top++], t = q[top++];
		g_to[s][g_hi[s]++] = t;
		r_to[t][r_hi[t]++] = s;
	}

	tree(n);

	Q = in();
	while (Q--) {
		r = in();
		if (dom[r] == 1) printf("%d\n", r);
		else             printf("%d\n", dom[r]);
	}
	return 0;
}


Measured memory_bytes: 74160
#include<iostream>

using namespace std;

int main(void) {
  long long n, a[5];
  cin >> n;
  long long min = 1000000000000001;
  for (long long i = 0; i < 5; i++) {
    cin >> a[i];
    if (a[i] < min) min = a[i];
  }
  cout << ((n - 1) / min) + 5 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
 
using namespace std;
int main()
{
    unsigned int L, R;
 
    cin >> L >> R;
 
    unsigned long mn = 2 * 1000000000;
	int ci, cj;
	ci = 0;
    for ( int si = L; si < R; si ++ ) {
		cj = 0;
		for ( int sj = si+1; sj <= R; sj ++ ) {
//            cout << si << " " << sj << " ";
            unsigned long ijmod = ((unsigned long)si * (unsigned long)sj )% 2019;
//            cout << ijmod << endl;
            if ( ijmod < mn ) mn = ijmod;

			cj ++;
			if ( cj == 2019 ) break;
       }
	   ci ++;
	   if ( ci == 2019 ) break;
    }    
 
    cout << mn << endl;
 
    return 0;
}



Measured memory_bytes: 256
s = list(input())
f = 0
for i in range(len(s)):
  if i % 2 == 0:
    if not(s[i] == "R" or s[i] == "U" or s[i] == "D"):
      f = 1
  else:
    if not(s[i] == "L" or s[i] == "U" or s[i] == "D"):
      f = 1
if f == 0:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060