akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>

int Q[500];
int head,tail;

int **mat;
int n;

void adjmatrix();
void enq(int);
int deq();

int main(){
  int i,j;
  int *dist;
  int *flg;

  adjmatrix();
  dist = (int *)malloc(n * sizeof(int));
  flg = (int *)malloc(n * sizeof(int));

  for(i=0; i<n; i++){
    dist[i] = -1;
    flg[i] = 0;
  }

  enq(1);
  dist[0] = 0;
  flg[0]++;
  
  while(head != tail){
    for(j=0; j<n; j++){
      if(mat[Q[head]-1][j]==1 && flg[j]==0){
	enq(j+1);
	dist[j] = dist[Q[head]-1] + 1;
	flg[j]++;
      }
    }

    deq();
  }

  for(i=0; i<n; i++)
    printf("%d %d\n",i+1 ,dist[i]);

  for(i=0; i<n; i++)
    free(mat[i]);
  free(mat);
  free(dist);
  free(flg);
  return 0;
}

void adjmatrix(){
  int u, k;
  int *v;
  int i, j;

  scanf("%d",&n);

  mat = (int **)malloc(n * sizeof(int *));
   
  for(i=0; i<n; i++){
    mat[i] = (int *)malloc(n * sizeof(int));
    for(j=0; j<n; j++)
      mat[i][j] = 0;
  }

  for(i=0; i<n; i++){
    scanf("%d%d",&u ,&k);

    v = (int *)malloc(k * sizeof(int));

    for(j=0; j<k; j++){
      scanf("%d",&v[j]);
      mat[u-1][v[j]-1] = 1;
    }

    free(v);
  }
}

void enq(int x){
  Q[tail++] = x;
}

int deq(){
  return Q[head++];
}



Measured memory_bytes: 2112
N, K = [int(_) for _ in input().split()]
A = [int(_) for _ in input().split()]

def judge(x):
    k = 0
    for a in A:
        v = a // x
        if a % x == 0:
            v -= 1
        k += v
    return k <= K

low = 1
high = max(A)

A.sort()

while low < high - 1:
    mid = (low + high) // 2
    if judge(mid):
        high = mid
    else:
        low = mid

if judge(low):
    print(low)
else:
    print(high)


Measured memory_bytes: 30720
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {

	public static void main(String[] args) {
		Main main = new Main();
		main.reverseSequence();
		return;
	}
	
	//文字列の反転
	private void reverseSequence() {
		
		BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in)); //標準入力
		
		try {
			String inputStr = bufferedReader.readLine();
			StringBuffer stringBuffer = new StringBuffer(inputStr);
			String outputStr = stringBuffer.reverse().toString();
			System.out.println(outputStr);
		} catch (IOException e) {
			// TODO 自動生成された catch ブロック
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 16852
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;
typedef vector<string> vstring;
typedef vector<char> vchar;

typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<double, double>> vpdouble;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<bool>> vvbool;

const int c_YET = -1;
const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const ll MAX = 1e9;
const double PI = 3.14159265358979323846264338327950288;
//========================================================================



// テーブルを作る前処理
ll comb_const = 200005;
vll fac(comb_const), finv(comb_const), inv(comb_const);
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < comb_const; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
ll COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll RepeatSquaring(ll base, ll sisuu) {
	if (sisuu == 0) return 1;
	if (sisuu % 2 == 0) {
		ll t = RepeatSquaring(base, sisuu / 2) % MOD;
		return (t * t) % MOD;
	}
	return (base * RepeatSquaring(base, sisuu - 1)) % MOD;
}

ll fast_com(ll a, ll b){

	ll bunshi = 1;
	ll bunbo = 1;
	for (ll i = 1; i <= b; i++)
	{
		bunbo *= i;
		bunbo %= MOD;

		bunshi *= (a - i + 1);
		bunshi %= MOD;


	}

	ll ret = bunshi * RepeatSquaring(bunbo, MOD - 2);

	ret %= MOD;
	while (ret < 0)
	{
		ret += MOD;
	}

	return ret;

}


int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	//==================================


	ll N, A, B;
	cin >> N >> A >> B;


	COMinit();

	ll ans = RepeatSquaring(2, N) - 1 - fast_com(N, A) - fast_com(N, B);
	while (ans < 0)
	{
		ans += MOD;
	}

	cout <<ans;

	

}



Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll max_n = 3234566667;
// d: 現在のケタ数
// val: 現在の値
// all: ここに格納していく (参照型にしておく)
//vector<ll> all;
void dfs(int d, long long val, vector<long long> &all) {
  // 格納
  all.push_back(val);

  // 10 桁だったらそれ以上やらずに打ち切り
  if (d == 10) return;

  // 次の桁へ進む処理
  if(val%10 != 0)  dfs(d+1, val*10+val%10-1 , all);
  dfs(d+1, val*10+val%10, all);
  if(val%10 != 9)  dfs(d+1, val*10+val%10+1 , all);
} 

int main(){
  int k;
  cin >>  k;
  vector<ll> all(0);
  for(int i=1; i<=9; i++) dfs(1, i, all);
  
  sort(all.begin(), all.end());
  
  cout << all[k-1] << endl;
  return 0;
}


Measured memory_bytes: 5316
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,a) for(int i=0;i<(a);i++)
#define MOD 1000000007

int main(){
  int N,M;
  cin>>N>>M;
  map<int,int> mp;
  for(int i=0;i<M;i++){
    int a,b;
    cin>>a>>b;
    mp[a]++;
    mp[b]++;
  }
  for(auto m:mp){
    if(m.second%2){
      cout<<"NO"<<endl;
      return 0;
    }
  }
  cout<<"YES"<<endl;
  return 0;
}


Measured memory_bytes: 4352
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main(){
  int n;

  cin >> n;

  ll ans = 0;

  for(int i=0;i<n;i++) {
    int x;
    cin >> x;
    ans += x - 1;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
using namespace std;
typedef long long int lli;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)
int main(void)
{
    int N, M;
    cin >> N;
    vector<string> s, t;
    string x;
    for (int i = 0; i < N; i++)
    {
        cin >> x;
        s.push_back(x);
    }
    cin >> M;
    for (int i = 0; i < M; i++)
    {
        cin >> x;
        t.push_back(x);
    }
    map<string, int> a;
    for (int i = 0; i < N; i++)
    {
        a[s[i]]++;
    }
    for (int i = 0; i < M; i++)
    {
        a[t[i]]--;
    }
    int maxl = 0;
    for (map<string, int>::iterator y = a.begin(); y != a.end(); ++y)
    {
        maxl = max(maxl, a[y->first]);
    }
    cout << maxl << endl;
    return 0;
}


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

int main() {
	int N; cin >> N;
	vector<int> X(N), sortedX;
	for( int &k : X )cin >> k;
	
	sortedX = X;
	sort( sortedX.begin(), sortedX.end() );
	
	int small = sortedX[ N/2 ], big = sortedX[ N/2 - 1 ];
	for( int k : X ){
		if( k < small ) cout << small << endl;
		else if( k >= big ) cout << big << endl;
	}
}

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

int MOD=1000000007;
int vector_finder(std::vector<int> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}
int modpow(int a,int x){
  if(a<0)a+=MOD;
  int ans=1;
  while(x>0){
    if(x&1) ans=ans*a%MOD;
      a=a*a%MOD;
      x>>=1;
  }
  return ans;
}
int gyaku(int n){
    return modpow(n,MOD-2);
}
signed main() {
  int n,m;
  cin>>n>>m;
  vector<vector<int>>g(n,vector<int>(0));
  rep(i,m){
    int a,b;
    cin>>a>>b;
    a--;b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  int ans=0;
  vector<int>array(0);
  rep(i,n) array.push_back(i);
  do{
    rep(i,n-1){
      if(vector_finder(g[array[i]],array[i+1])!=1)break;
      if(i==n-2) ans++;
    }
  }while(next_permutation(array.begin()+1,array.end()));
  cout<<ans<<endl;
}


Measured memory_bytes: 3564
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let mut a: Vec<usize> = (0..n)
        .map(|_| itr.next().unwrap().parse().unwrap())
        .collect();

    let mut ans = 0;
    loop {
        let mut j = 0;
        let mut min = 200;
        while j < n && a[j] == 0 {
            j += 1;
        }
        if j == n {
            break;
        }
        let i = j;
        while j < n && a[j] > 0 {
            min = std::cmp::min(min, a[j]);
            j += 1;
        }
        for l in i..j {
            a[l] -= min;
        }
        ans += min;
    }
    println!("{}", ans)
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i, n) for(int i = 0; i<(int)(n); i++)
ll int n,m;
ll int x[1001],y[1001],z[1001];
int main(){
    int a,b;
    cin >> a >> b;
    if(a > 8 || b > 8) cout << ":(" << endl;
    else cout << "Yay!" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
#define all(x) (x).begin(), (x).end()

using namespace std;
using ll = long long;

long long ncr(int n, int r) {
    if(r > n - r) r = n - r; // because C(n, r) == C(n, n - r)
    long long ans = 1;
    int i;

    for(i = 1; i <= r; i++) {
        ans *= n - r + i;
        ans /= i;
    }

    return ans;
}
ll mod(ll a,ll b,ll m){
    if(b==0)return 1;
    if(b%2==0){
        ll y =  mod(a,b/2,m);
        return (y*y)%m;
    }
    else{
        return ((a%m)*mod(a,b-1,m))%m;
    }
}

ll modinv(ll a,ll m){
return mod(a,m-2,m);
//works only for prime m.
//else calculate phi(m)-1.
}
const ll m=1000000007;
ll fac[1000001];

void pre(){
    fac[0]=fac[1]=1;
    for(int i=2;i<=1000001;i++)
{

    fac[i]=(fac[i-1]*1LL*i)%m;
}
}

ll power(ll a,ll n){
    ll res=1;
    while(n){

    if(n%2)
        res = (res*1LL*a)%m;

        n/=2;
        a=(a*1LL*a)%m;

    }
    return res;

}

ll nCrr(ll n,ll r){


ll res= fac[n];
res = (res*1LL*power(fac[r],m-2))%m;
res= (res*1LL*power(fac[n-r],m-2))%m;
return res;

}

int main(){
    pre();
    ll s;cin>>s;
    ll p = s/3;
    ll ans=0;
    ll cur=1;
    for(ll i=1;i<=p;i++){
       ll k= s-i*3;
       //cout<<k<<endl;
       ans=(ans+nCrr(k+i-1,i-1))%m;
       // cout<<ans<<endl;
    }
    cout<<ans%m<<endl;



    return 0;
}


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

int main()
{
	int N, d[100],k=1;
	cin >> N; for (int i = 0; i < N; i++) cin >> d[i];

	for (int i = 0; i < N; i++)
	{
		for (int j = N - 1; i < j; j--)
		{
			if (d[j - 1] > d[j]) swap(d[j - 1], d[j]);
		}
	}
	for (int i = 0; i < N-1; i++) if (d[i] != d[i + 1]) k++;
	cout << k;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int h,w,n;
  cin>>h>>w>>n;
  int a[n];
  for(int i=0;i<n;i++) cin>>a[i];
  int c[h][w];
  memset(c,0,sizeof(c));
  bool f=1;
  int y=0,x=0;
  for(int i=0;i<n;i++){
    while(a[i]--){
      if(f){
	c[y][x++]=i+1;
	if(x==w){
	  y++;
	  x--;
	  f=0;
	}
      }else{
	c[y][x--]=i+1;
	if(x==-1){
	  y++;
	  x++;
	  f=1;
	}
      }
    }
  }
  assert(y==h);
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(j) cout<<" ";
      cout<<c[i][j];
    }
    cout<<endl;
  }
  return 0;
}


Measured memory_bytes: 384
#include <stdio.h>

main(){
    int N,M;
    int i,j,k;
    int minh;
    scanf("%d %d",&N,&M);

    int  D[N],C[M];
    int hirou[1000][1000]={0,};
    for(i=0;i<N;i++)
        scanf("%d",&D[i]);
    for(i=0;i<M;i++)
        scanf("%d",&C[i]);
    for(i=0;i<N;i++){
        for(j=i;j<=M-(N-i);j++){
            //printf("i,j: %d,%d\n",i,j);
            hirou[i][j]=C[j]*D[i];
            if(i){
                minh=hirou[i-1][i-1];
                for(k=i;k<j;k++)
                    if(minh>hirou[i-1][k])
                        minh=hirou[i-1][k];
                hirou[i][j]+=minh;
            }
        }
    }
    minh=hirou[N-1][N-1];
    for(i=N;i<M;i++)
        if(minh>hirou[N-1][i])
            minh=hirou[N-1][i];
    printf("%d\n",minh);

    return 0;
}

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

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

#define SIZE(x) ((ll)(x).size()) 
#define MAX(x) *max_element(ALL(x)) 
#define MIN(x) *min_element(ALL(x)) 
#define ALL(x) (x).begin(),(x).end() 

#define inf 1000000000000 
#define mod 1000000007 
#define MAXR 100000 

#define PB push_back 
#define MP make_pair 
#define F first 
#define S second 

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
    // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
bool is_prime(ll n){
    int a = sqrt(n);
    if(n == 1 || n == 2 || n == 3) return true;
    else{
        bool frag = true;
        FOR(i, 2, a+1){
            if(n % i == 0) frag = false;
        }
        return frag;
    }
}

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int d;
    cin >> d;
    vector<int> c(26), t(d), ld(26);
    vector<vector<int>> s(d, vector<int>(26));
    REP(i, 26) cin >> c[i];
    REP(i, d) REP(j, 26)cin >> s[i][j];
    REP(i, d) cin >> t[i];
    int m = 0;
    REP(i, d){
        m += s[i][t[i]-1];
        ld[t[i]-1] = i+1;
        REP(j, 26){
            m -= c[j] * (i+1-ld[j]);
        }
        cout << m << endl;
    }
}

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

int main() {
    int64_t n;
    cin >> n;
    string s;
    cin >> s;

    vector<vector<int64_t>> location(n+1, vector<int64_t>(10, n));
    for (int64_t i = n-1; i >= 0; i--) {
        for (int64_t x = 0; x <= 9; x++) location[i][x] = location[i+1][x];
        location[i][s[i]-'0'] = i;
    }

    map<string, int> ans;
    // 1: current string, 2: depth, 3: index
    queue<tuple<string, int, int>> q;
    q.emplace("", 0, 0);
    while (!q.empty()) {
        string str;
        int depth, index;
        tie(str, depth, index) = q.front(); q.pop();
        if (str.size() == 3) {
            ans[str]++;
            continue;
        }

        for (int x = 0; x <= 9; x++) {
            if (location[index][x] >= n) continue;
            q.emplace(str + (char) (x + '0'), depth+1, location[index][x]+1);
        }
    }
    
    cout << ans.size() << endl;
}


Measured memory_bytes: 3968
#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;

int dp[6010];

int main() {
	int n, s; cin >> n >> s;
	dp[0] = 1;
	for (int i = 0; i < n; i++) {
		int x; cin >> x;
		for (int j = s; j >= 0; j--) {
			dp[j + x] = (dp[j + x] + dp[j]) % mod;
			dp[j] = 2 * dp[j] % mod;
		}
	}
	cout << dp[s] << "\n";
}

Measured memory_bytes: 3544
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define P pair<ll,ll>
#define Graph vector<vector<P>>
#define fi first
#define se second
constexpr ll mod=1000000007;
constexpr ll INF=(1ll<<60);
constexpr double pi=3.14159265358979323846;
template<typename T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<typename T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}

int main(){
    ll a,b;cin>>a>>b;
    cout<<6-a-b<<endl;
    return 0;
}

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

int gcd(int a,int b)
{
   if(a==0)
   {
       return b;
   }
   return gcd(b%a,a);
    
}
int findgcd(int a,int b,int c)
{
    int ans=gcd(a,b);
    int final_ans =gcd(c,ans);
    return final_ans;
}


int main()
{
    int n; cin>>n; long long ans=0;
    for(int i=1;i<=n;i++)
    {
       for( int j=1;j<=n;j++)
       {
           for(int k=1;k<=n;k++)
           {
               ans=ans+findgcd(i,j,k);
           }
       }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3596
import java.io.BufferedReader;
import java.io.InputStreamReader;
  
public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder st = new StringBuilder();
          
        int i = 1;
          
        while(true){
            int line = Integer.parseInt(br.readLine());
            if(line == 0){
                break;
            }
              
            st.append("Case ").append(i).append(": ").append(line).append("\n");
            i++;
        }
          
        System.out.print(st);
    }
}

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

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

  int f;
  cin >> f;
  cout << (f-30)/2 << endl;

}


Measured memory_bytes: 3212
#include<iostream>
#include<cstdio>
#include<vector>
#include<queue>
#include<map>
#include<string>
#include<algorithm>
#include<functional>
#define ll long long
#define inf  999999999
#define pa pair<int,int>
#define mp make_pair
#define int long long
using namespace std;


struct Segmin{
	//       1
	//   2        3
	// 4   5   6    7
	
	
	private:
	public:
	
	// (1<<15)=32768
	// 1<<16 = 65536
	// 1<<17 = 131072
	// 1<<18 = 262144
	
	int cor=(1<<17);
	
	vector<pa> vec;
	
	void shoki1(){
		
		vec.resize(2*cor+3, mp(0,0));
		for(int i=cor;i<2*cor;i++)vec[i].second=i-cor;
	}
		void shoki2(){
			for(int i=cor-1;i>0;i--) {
				if(vec[2*i].first<=vec[2*i+1].first) vec[i]=vec[2*i];
				else vec[i]=vec[2*i+1];
			}
		}
		
	void updadd(int x,int w){
		//x 項目に w加算
		x+=cor;
		vec[x].first+=w;
		while(1){
			x/=2;
			if(x==0) break;
			if(vec[2*x].first<=vec[2*x+1].first) vec[x]=vec[2*x];
			else vec[x]=vec[2*x+1];
		}
		
	}
	
	void updchan(int x,int w){
		//x項目をwに変更
		x+=cor;
		vec[x].first=w;
		while(1){
			x/=2;
			if(x==0) break;
			if(vec[2*x].first<=vec[2*x+1].first) vec[x]=vec[2*x];
			else vec[x]=vec[2*x+1];
		}
		
	}
	// [a,b)
	// k-th node
	// k no kukanha [l,r)
	pa segmin(int a,int b,int k=1,int l=0,int r=-10){
		if(r<0)r=cor;
		
	//	cout<<a<<" "<<b<<" "<<k<<" "<<l<<" "<<r<<endl;
		
		if(a<=l && r<=b){
			return vec[k];
		}
		if(r<=a || b<=l){
			return mp((1ll<<31)-1,-1);
		}
		
		pa v1=segmin(a,b,k*2,l,(l+r)/2),v2=segmin(a,b,k*2+1,(l+r)/2,r);
		
		if(v1.first<=v2.first)return v1;
		else return v2;
	}
	
};

signed main(){
Segmin SE;
	
		int n,q;
	cin>>n>>q;
	
	SE.shoki1();
	for(int i=0;i<n;i++){
		SE.vec[i+SE.cor].first=(1ll<<31)-1;
	}
	SE.shoki2();
	
	

	
	for(int i=0;i<q;i++){
	int a,b,c;
		cin>>a>>b>>c;
		
		if(a==0)SE.updchan(b,c);
		else cout<<SE.segmin(b,c+1).first<<endl;
	
	}
	return 0;
}





Measured memory_bytes: 7036
#include<bits/stdc++.h>
using namespace std;
#define int long long

const int T=55440;

int dp[33][T];

signed main(){
  int n;
  while(cin>>n,n){
    int d[n],t[n];
    int q[111][33];
    for(int i=0;i<n;i++){
      cin>>d[i]>>t[i];
      for(int j=0;j<d[i];j++) cin>>q[i][j];
    }
    //puts("OK");
    memset(dp,0,sizeof(dp));
    for(int i=0;i<n;i++){
      //cout<<d[i]<<" "<<t[i]<<endl;
      if(__gcd(d[i],T)==1){
	for(int j=0;j<d[i];j++){
	  //cout<<q[i][j]<<endl;
	  dp[d[i]][j]+=q[i][(t[i]+j)%d[i]];
	}
	continue;
      }
      for(int j=0;j<T;j++){
	dp[0][j]+=q[i][(t[i]+j)%d[i]];
      }
    }
    //for(int i=0;i<T;i++) cout<<dp[0][i]<<endl;
    int ans=0;
    for(int i=0;i<T;i++) ans=max(ans,dp[0][i]);
    for(int i=1;i<=24;i++){
      if(__gcd(i,T)==1){
	int tmp=0;
	for(int j=0;j<i;j++) tmp=max(tmp,dp[i][j]);
	ans+=tmp;
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}

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

using namespace __gnu_pbds; 
using namespace __gnu_cxx;
using namespace std;
using ll = long long;

#define eb emplace_back
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define len(v) ((int)v.size())
#define all(v) v.begin(), v.end()
#define precision(n) fixed<<setprecision(n)

#ifdef LOCAL
    #include "debug.h"
#else
    #define debug(...) 42
#endif

void io(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);    
    #ifdef LOCAL
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
}

template<typename T> using oset = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update >;
template<typename T> using MinPriorityQueue = priority_queue <T, vector <T>, greater <T> >;
template<typename T> void done(T ans) {cout << ans << "\n"; exit(0);}


template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
  for(auto& i:x)
    input>>i;
  return input;
}
 
template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
  for(auto& i:x)
    output<<i<<' ';
  return output;
}

 

const int mod = 1e9;
const int N = 3e5 + 5;

auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
mt19937_64 mt(seed);

template <typename T>
long long myrand(T m) {
    long long mod = m;
    long long x = mt()%mod;

    return x;
}

int main() {
    io();
    int n;
    cin >> n;
    vector<int> a(n);
    cin >> a;

    map<int, int> f;

    for(int i = 0; i < n; i++) {
        f[i + 1 - a[i]]++;
    }
    ll ans = 0;
    for(int i = 0; i < n; i++) {
        ans += f[i + 1 + a[i]];
    }
    cout << ans;
}


Measured memory_bytes: 21180
#include<iostream>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	char ca,cb;
	ca=a+'0';
	cb=b+'0';
	string sa,sb;
	sa=sb="";
	for(int i=0;i<b;++i)
		sa+=ca;
	for(int i=0;i<a;++i)
		sb+=cb;
	cout<<min(sa,sb);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <float.h>
#include <limits>
#include <vector> 
#include <string.h>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define ll long long
#define asort(a) sort(a.begin(),a.end());

using namespace::std;

int jo(ll int jxo, ll int jyo){//累乗
	ll int jhogeo = 1;
	rep(jinto,0,jyo) jhogeo=jhogeo*jxo;
	return jhogeo;
}
char tobig(char toxbig){//char大文字化
  return (toxbig-0x20);
}
char tolow(char toxlow){//char小文字化
  return (toxlow+0x20);
}
int ctoi(char cctoi){//char->int
  if('0' <= cctoi && cctoi <= '9') return (cctoi-'0');
  return -1;
}
int gcd(int gcad, int gcbd) {//最大公約数
  if(gcad < gcbd) return gcd(gcbd, gcad);
  int gcrd;
  while ((gcrd=gcad%gcbd)) {
    gcad = gcbd;
    gcbd = gcrd;
  }
  return gcbd;
}
int lcm(int lcam, int lcbm){//最小公倍数
 return (lcam*lcbm)/gcd(lcam,lcbm);
}


int main(){
  int N;
  cin>>N;
  vector<int> V(N);
  vector<int> C(N);
  int ans=0;
  rep(i,0,N) cin>>V[i];
  rep(i,0,N) cin>>C[i];
  rep(i,0,N){
    if(V[i]>C[i]){
      ans+=V[i]-C[i];
    }
  }
  cout<<ans;

}
// int *p = new int[N];

//  vector<int> 変数名(要素数);
//  sort(変数名.begin(),変数名.end());//昇順ソート

// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a;
  cin >> a;
  cout << a + a*a + a*a*a << "\n";
  return 0;
}


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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

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

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 2e5 + 5;

vi vv;

void solve(){
	int k, n;
	cin >> k >> n;
	if (k == 1) {
		REP(i, 0, (n + 1) / 2) {
			printf("1 ");
		}
		putchar('\n');
		return;
	}
	if (k % 2 == 0) {
		printf("%d ", k / 2);
		REP(i, 0, n - 1) {
			printf("%d ", k);
		}
		putchar('\n');
		return;
	}
	REP(i, 0, n) {
		vv.pb((k + 1) / 2);
	}
	int cnt = n / 2;
	REP(i, 0, cnt) {
		vv[SZ(vv) - 1]--;
		if (vv[SZ(vv) - 1] == 0) {
			vv.pop_back();
		} else {
			while(SZ(vv) < n) {
				vv.pb(k);
			}
		}
	}
	REP(i, 0, SZ(vv)) {
		printf("%d ", vv[i]);
	}
	putchar('\n');
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 3568
#include<bits/stdc++.h>
typedef long long ll;
const int maxn=1e6+9;
const int mod=1e9+7;
using namespace std;
int A[20],ans;
int a[60],b[60],c[60],d[60];
int n,m,q;
void dfs(int pos)
{
//	cout<<"??"<<pos<<' '<<A[pos]<<endl;
	if(A[pos]>m||pos>n)return;
	if(pos==n)
	{
		int sum=0;
//		for(int i=1;i<=n;i++)cout<<i<<' '<<A[i]<<endl;
		for(int i=1;i<=q;i++)
		{
			if(A[b[i]]-A[a[i]]==c[i])sum+=d[i];
		}
		ans=max(ans,sum);
	}
	A[pos+1]=A[pos];
	dfs(pos+1);
	A[pos]++;
	dfs(pos);
}
int main()
{
	scanf("%d%d%d",&n,&m,&q);
	for(int i=1;i<=q;i++)scanf("%d%d%d%d",&a[i],&b[i],&c[i],&d[i]);
	A[1]=1;
	dfs(1);
	printf("%d\n",ans);
}

Measured memory_bytes: 3720
#include <iostream>
#include <math.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <stdlib.h>
#include <deque>  
#include <iomanip>

using namespace std;

#define ll long long
#define INF 1e9
#define MOD 1e9 + 7
#define rep(i, n) for(int i = 0; i < n; i++)
#define loop(i, a, n) for(int i = a; i < n; i++)
#define all(in) in.begin(), in.end()
#define MAX_N 100
#define MAX_W 10000
int dp[MAX_N + 1][MAX_W + 1];
int main(){
    //入力処理とか.
    int N, W;
    int ans = 0;
    cin >> N >> W;
    vector<int> v(N), w(N);
    for(int i = 0; i < N; i++){
        cin >> v[i] >> w[i];
    }
    for(int i = 0; i <= N; i++)for(int k = 0; k <= W; k++) dp[i][k] = 0;
    //動的計画法を用いて解く.
    //dp[i][k]: iこの中から重さがk以下になるものの中で一番価値が大きいもの.
    for(int i = 0; i < N; i++){
        for(int k = 1; k <= W; k++){
            if(k < w[i]){
                dp[i + 1][k]= dp[i][k];
            }else{
                dp[i + 1][k] = max(dp[i][k], dp[i][k - w[i]] + v[i]);
            }
        }
    }
    cout  << dp[N][W] << endl;
    return 0;
}


Measured memory_bytes: 7052
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n,a=map(int,input().split())
    X=list(map(int,input().split()))
    M=sum(X)
    dp=[[0]*(M+1) for _ in range(n+1)]
    dp[0][0]=1

    from itertools import product
    for x in X:
        ndp=[y[:] for y in dp]
        for i,m in product(range(n),range(M+1)):
            if(m+x<=M):
                ndp[i+1][m+x]+=dp[i][m]
        dp=ndp

    ans=0
    for i in range(1,n+1):
        if(i*a<=M):
            ans+=dp[i][i*a]
    print(ans)
resolve()

Measured memory_bytes: 51804
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    
    h,w,a,b=map(int,input().split())
    for hi in range(b):
        print('1'*a+'0'*(w-a))
    for hi in range(h-b):
        print('0'*a+'1'*(w-a))
    
resolve()

Measured memory_bytes: 39792
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <map>
#include <list>
#include <stdio.h>
#include <sstream>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
//ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
//ll lcm(ll x, ll y) {return x / gcd(x, y) * y;}
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const ll mod = 1e9 + 7;
const ll inf = 1LL << 60;
const long double pi = 3.14159265358979323846;

// ****************************************CODE***************************************//

ll n, a[100100][3], dp[100100][3];

int main() {
    cin >> n;
    for(int i = 0; i < n; i++) for(int j = 0; j < 3; j++) cin >> a[i][j];

    for(int i = 0; i < n; i++){
        for(int j = 0; j < 3; j++){
            for(int k = 0; k < 3; k++){
                if(j==k) continue;
                dp[i+1][k] = max(dp[i+1][k], dp[i][j] + a[i][k]);
            }
        }
    }

    ll res = 0;
    for(int i = 0; i < 3; i++){
        res = max(res, dp[n][i]);
    }

    cout << res << endl;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  string s;
  bool flag=false;
  cin>>n>>s;
  if(n%2==0){
    for(int i=0;i<n/2;i++){
      if(s[i]!=s[i+n/2]){break;}
      if(i==n/2-1){flag=true;}
      }
  }
  if(flag) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
char a[101],b[101];
int i,j,x,y;
int main()
{
	scanf("%s%s",&a,&b);
	if(strlen(a)>strlen(b)){
		puts("GREATER");
	}else if(strlen(a)<strlen(b)){
		puts("LESS");
	}else{
		for(i=0;i<strlen(a);i++){
			if(a[i]>b[i]){
				x=1;
				break;
			}else if(a[i]<b[i]){
				y=1;
				break;
			}
		}
		if(x==1){
			puts("GREATER");
		}else if(y==1){
			puts("LESS");
		}else{
			puts("EQUAL");
		}
	}
	return 0;
}

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

int main(){
	int n, temp;
	cin >> n;
	vector<int> prefix, suffix;
	int sum = 0;
	for (int i = 0; i < n; i++){
		cin >> temp;
		sum +=temp;
		prefix.push_back(sum);
	}
	for (int i = 0; i < n; i++){
		cin >> temp;
		suffix.push_back(temp);
	}
	sum=0;
	for(int i = n-1; i>=0; i--){
		sum+=suffix[i];
		suffix[i] = sum;
	}
	sum = 0;
	for(int i = 0; i<n; i++){
		sum = max(sum,prefix[i]+suffix[i]);
	}
	cout << sum;
 }


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

int main()
{
    string three_days_weather;
    int days_rain = 0, max_rain = 0;

    cin >> three_days_weather;

    for(int i = 0; i < three_days_weather.size(); i++)
    {
        if(three_days_weather[i] == 'R')
        {
            days_rain++;
        }else{
            max_rain = max(max_rain, days_rain);
            days_rain = 0;
        }

    }
    max_rain = max(max_rain, days_rain);
    cout << max_rain << endl;
    return 0;
}

Measured memory_bytes: 3556
#include <cstdio> 
#include <cstring>
#include <algorithm>
#include <map>
using namespace std;

const int mod = 1000000007;
map<long long, long long> f;

long long dp(long long n)
{
	if(f[n]) return f[n];
	return f[n] = ((dp(n>>1) + dp((n-1)>>1)) % mod + dp((n-2)>>1)) % mod;
}

int main()
{
	f[1] = 2; f[2] = 4; f[3] = 5;
	long long n;
	scanf("%lld", &n);
	printf("%lld\n", dp(n));
}
 



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>
#include <bitset>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;

template<class T> inline bool chmin(T& a,T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if (a < b) {a = b; return true;} return false;}

const ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

int main(){
  ll N, K, S; cin >> N >> K >> S;
  vector<ll> a(N);
  rep(i, K) a[i] = S;
  if (S < 1000000000){
    for (int i = K; i < N; ++i) a[i] = S + 1;
  }
  else {
    for (int i = K; i < N; ++i) a[i] = 1;
  }
  rep(i, N) cout << a[i] << " ";
  cout << endl;
}


Measured memory_bytes: 2048
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)

int main() {
  ll X;
  cin >> X;
  ll coin = 100;
  ll ans = 0;
  for (ll i = 1; true; i++) {
    coin = (ll)(coin * 1.01);
    if (coin >= X) {
      ans = i;
      break;
    }
  }

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


Measured memory_bytes: 3636
#include <iostream>
#include <iomanip>
#include <vector>
#include <valarray>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <stack>
#include <bitset>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <complex>
#include <string>
#include <sstream>

#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>

// this require C++11
//#include <unordered_set>
//#include <unordered_map>
//#include <random>

using namespace std;

#define all(c) c.begin(),c.end()
#define repeat(i,n) for(int i=0;i<static_cast<int>(n);i++)
#define debug(x) #x << "=" << (x)
#define dump(x) cerr << debug(x) << " (L:" << __LINE__ << ")"<< endl

typedef long long ll;
typedef vector<int> vi;

template<typename T>
ostream& operator<<(ostream& os,vector<T>& vec){
    typename vector<T>::iterator it,endit=vec.end();
    os << "[";
    for(it=vec.begin();it!=endit;it++){
        os << " " << *it << ",";
    }
    os << "]";
    return os;
}

template<typename T>
T input(){
    T t;cin >> t;
    return t;
}

template<typename T>
vector<T> input(const int N){
    vector<T> v(N);
    repeat(i,N) cin >> v[i];
    return v;
}



int main(){
	for(;;){
		map<char,char> convr;
		int n;
		n=input<int>();
		if(n==0)break;
		char temp1,temp2;
		repeat(i,n){
			temp1=input<char>();
			temp2=input<char>();
			convr[temp1]=temp2;
		}
		int m=input<int>();
		repeat(i,m){
			temp1=input<char>();
			if(convr.find(temp1)==convr.end())
				cout << temp1;
			else
				cout << convr[temp1];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1188
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi acos(-1)
int main(){
    string s,tems,s1,tems1,s2,tems2;
    cin>>s;
    ll d=s.size(),d1,d2,i;

    ll r=d-1,q=0;
    for(i=0;i<=d-1;i++){
        if(s[i]!=s[r]){
        q=1;
        break;
            }
        if(i==r)break;

            r-=1;
    }



    d1=(d-1)/2,d2=(d+3)/2;

    for( i=0;i<d1;i++){
        s1[i]=s[i];
    }
    for( i=d2-1;i<d;i++){
          s2[i]=s[i];
    }
    ll t=d1-1,k=0;
    for(i=0;i<=d1-1;i++){
        if(s1[i]!=s1[t]){
        k=1;
            }
        if(i==t)break;
            t-=1;
        }
    ll T=d-1,p=0;
    for(i=d2-1;i<=d-1;i++){
        if(s2[i]!=s2[T]){
        p=1;
            }
        if(i==T)break;
            T-=1;
        }
    if(q==0&&k==0&&p==0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

return 0;
}



Measured memory_bytes: 256
#include <cstdio>

int H, W, N;
int a[10010];
int c[110][110];

void solve()
{
	int i, j;
	int row=0, col=0;
	int dire=0;
	for(i=0; i<N; i++){
		for(j=0; j<a[i]; j++){
			c[row][col] = i+1;
			if(dire==0){
				col ++;
				if(col == W){
					col = W-1;
					row ++;
					dire = 1;
				}
			}
			else{
				col --;
				if(col==-1){
					col = 0;
					row ++;
					dire = 0;
				}
			}
		}
	}
	for(i=0; i<H; i++){
		for(j=0; j<W; j++)
			printf("%d ", c[i][j]);
		printf("\n");
	}
}

int main()
{
	int i;
	scanf("%d%d", &H, &W);
	scanf("%d", &N);
	for(i=0; i<N; i++)
		scanf("%d", &a[i]);
	solve();
	return 0;
}

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

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; }

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const double PI = 3.1415926535;
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;


void dfs(vector<vector<pair<int,ll>>> &graph,
 int now, int past,ll sum, vector<ll> &dist){
    dist[now]=sum;
    for(auto next:graph[now]){
       if(next.first==past)continue;
       dfs(graph, next.first, now, sum+next.second, dist);
    }
}
int main(){
   int n;
   cin >> n;
   vector<vector<pair<int,ll>>> graph(n);
   vector<ll> dist(n);
   rep(i, 0, n-1){
      int a, b;
      ll c;
      cin >> a >> b >> c;
      a--, b--;
      graph[a].push_back({b, c});
      graph[b].push_back({a, c});
   }
   int q, k;
   cin >> q >> k;
   k--;
   dfs(graph, k, -1, 0, dist);
   vector<ll>ans(q);
   rep(i, 0, q){
      int x, y;
      cin >> x >> y;
      ans[i] = dist[x-1]+dist[y-1];
   }
   rep(i, 0, q)cout<< ans[i] << endl;
   return 0;
}

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

int main() {
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;

    vector<pair<int, int>> as;
    char type = s[0];
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] == type) {
            cnt++;
        } else {
            if (cnt) as.emplace_back(type - '0', cnt);
            cnt = 1;
            type = s[i];
        }
    }
    if (cnt) as.emplace_back(type - '0', cnt);

    if (as.size() == 1) {
        if (as[0].first == 0) {
            cout << k << endl;
            return 0;
        } else {
            cout << n << endl;
            return 0;
        }
    }

    if (as[0].first == 0) {
        as.insert(as.begin(), {1, 0});
    }
    if (as.back().first == 0) {
        as.push_back({1, 0});
    }

    if (as.size() / 2 <= k) {
        cout << n << endl;
        return 0;
    }

    n = as.size();
    int sum = 0;
    for (int i = 0; i < 2 * k + 1; i++) {
        sum += as[i].second;
    }
    int ans = sum;
    for (int i = 0; 2 * k + 2 + i < n; i += 2) {
        sum -= as[i].second;
        sum -= as[i + 1].second;
        sum += as[2 * k + 1 + i].second;
        sum += as[2 * k + 2 + i].second;
        ans = max(ans, sum);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1528
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i,a) for(int i=0;i<a;i++)
using namespace std;

int main(void){
  int n;
  int in;
  int cnt[3] = {0,0,0};
  cin>>n;
  rep(i,n){
    cin>>in;
    if(in%4==0)cnt[2]++;
    else if(in%2==0)cnt[1]++;
    else cnt[0]++;
  }
  if(cnt[0]<=cnt[2] || (cnt[0]==cnt[2]+1&&!cnt[1]))cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

}

Measured memory_bytes: 256
N,M,X = [int(x) for x in input().split()]

C = [0] * N
A = [x for x in range(M)] * N

for i in range(N):
    tmp = [int(x) for x in input().split()]
    C[i] = tmp[0]
    A[i] = tmp[1:]
min = sum(C) + 1

for i in range(2**N):
    cost = 0
    ANS = [0]*M

    for j in range(N):
        if((i>>j) & 1):
            cost += C[j]
            for k in range(M):
                ANS[k] += A[j][k]

    # print("cost=",cost,"ANS=",ANS)
    ans = 1
    for j in ANS:
        if(j < X):
            ans = 0


    if(ans and cost < min):
        min = cost

# print(min)
if(min == sum(C)+1):
    print(-1)
else:
    print(min)


Measured memory_bytes: 9224
n = int(input())
a = sorted(list(map(int, input().split())))

x = n%2 + 1
for i in range(n)[n%2+2::2]:
    if a[i] != a[i+1] or a[i] - x != 2:
        print(0)
        exit()
    x = a[i]
    
print(2**(n//2) % (10**9+7))

Measured memory_bytes: 52844
s = input()
a = [chr(i) for i in range(97, 97 + 26)]

if s == "zyxwvutsrqponmlkjihgfedcba":
    print(-1)
    exit()

if len(s) != 26:
    print(s + sorted(list(set(a) - set(s)))[0])
else:
    t = s
    s = list(s)
    n = len(s)
    for i in range(n - 1)[::-1]:
        if s[i] < s[i + 1]:
            break
    for j in range(n)[::-1]:
        if s[i] < s[j]:
            s[i], s[j] = s[j], s[i]
            break
    s = s[:i + 1] + s[i + 1:][::-1]

    ans = ""
    for i, j in zip(s, t):
        ans += i
        if i != j:
            print(ans)
            exit()

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

void print_vec(vector<int> vec) {
  cout << "[";
  for (int i = 0; i < vec.size(); i++) {
    if (i) {
      cout << ", ";
    }
    cout << vec.at(i);
  }
  cout << "]...size: " << vec.size() << endl;
}

int main() {
  vector<int> abses;

  while (1) {
    int n;
    cin >> n;
    if (n == 0) {
      break;
    }

    vector<int> vec(n);
    rep(i, n) { cin >> vec.at(i); }
    int min_abs = 1001001001;

    for (int i = 0; i < n - 1; i++) {
      for (int j = i + 1; j < n; j++) {
        int current_abs = abs(vec.at(i) - vec.at(j));
        min_abs = min(min_abs, current_abs);
      }
    }

    abses.push_back(min_abs);
  }

  for (auto &&i : abses) {
    printf("%d\n", i);
  }
}



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

typedef long long ll;

int main() {
	int n; cin >> n;
	map<ll, ll>cnt; vector<ll>a(1e1, 0);
	for (int i = 0, tmp; i < n; i++) {
		cin >> tmp; cnt[tmp]++;
	}
	for (auto&& x : cnt) {
		if (x.second >= 2) {
			a.push_back(x.first); 
			if(x.second>=4)a.push_back(x.first);
		}
	}
	sort(a.rbegin(), a.rend());
	cout << a[0] * a[1] << endl;

	return 0;
}

Measured memory_bytes: 6528
#include<cstdio>
#include<vector>
#include<queue>
struct st {
	long long int x, y;//x is 1 number, y is 0 number
	bool operator<(const st&r)const {// y/x
		if (x == 0 || r.x == 0)return x > r.x;
		if (y == 0 || r.y == 0)return y < r.y;
		return r.x*y < x*r.y;
	}
};
std::vector<int> el[200100];
int n;
int p[200100];
int v[200100];
int sn[200100];
int zn[200100];
std::priority_queue<st> pq[200100];
int pqp[200100];
st d[200100];
long long int ans;
void dfs(int x) {
	for (int i = 0; i < el[x].size(); i++) {
		int y = el[x][i];
		dfs(y);
		int sa, sb;
		if (sn[y] < sn[x]) {
			sa = pqp[y];
			sb = pqp[x];
		}
		else {
			sa = pqp[x];
			sb = pqp[y];
		}
		pqp[x] = sb;
		while (pq[sa].size() > 0) {
			pq[sb].push(pq[sa].top());
			pq[sa].pop();
		}
		sn[x] += sn[y];
		zn[x] += zn[y];
	}
	sn[x]++;
	if (v[x] == 0) {
		zn[x]++;
	}
	else {
		st t;
		t.x = 1;
		t.y = zn[x];
		ans += zn[x];
		while (pq[pqp[x]].size() > 0 && t<pq[pqp[x]].top()) {
			ans += t.x*pq[pqp[x]].top().y;
			t.x += pq[pqp[x]].top().x;
			t.y += pq[pqp[x]].top().y;
			pq[pqp[x]].pop();
		}
		pq[pqp[x]].push(t);
		zn[x] = 0;
	}
}
int main() {
	scanf("%d", &n);
	for (int i = 2; i <= n; i++) {
		int x;
		scanf("%d", &x);
		el[x].push_back(i);
	}
	for (int i = 1; i <= n; i++) {
		pqp[i] = i;
		scanf("%d", &v[i]);
	}
	dfs(1);
	std::priority_queue<st> &rpq = pq[pqp[1]];
	long long int on = 0;
	while (rpq.size() > 0) {
		ans += rpq.top().y*on;
		on += rpq.top().x;
		rpq.pop();
	}
	printf("%lld", ans);
	return 0;
}


Measured memory_bytes: 41216
#include<bits/stdc++.h>
#define ll  long long
#define ff first
#define ss second
#define pb push_back
#define pp pair<ll,ll>
#define maxn 1000005
#define db double
#define mod 1000000007
using namespace std;
void solve()
{	
	ll s,w;
	cin >> s >> w;
	if(w >= s)
		cout << "unsafe";
	else cout << "safe";
}	
int main()
{
	ll t=1,i=1;
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);	
    std::cout.precision(10);
    std::cout.setf( std::ios::fixed, std:: ios::floatfield ); 
	//cin >> t;
	//cin >> n;
	while(i<=t)
	{
		solve();
		i++;
	}
	return 0;
}




Measured memory_bytes: 3640
import sys
input = sys.stdin.readline
def print_ans(S, T):
    """Test Case
    >>> print_ans("CSS", "CSR")
    2
    >>> print_ans("SSR","SSR")
    3
    """
    ans = 0
    for i in range(len(S)):
        if S[i] == T[i]:
            ans += 1
    print(ans)


if __name__ == '__main__':
    S = input().rstrip()
    T = input().rstrip()
    print_ans(S, T)

Measured memory_bytes: 3060