akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main()
{
    string s; cin>>s;
    int res=s.size();
    set<char> chars(begin(s), end(s));
    if (chars.size()==1) return cout<<0<<endl, 0;

    for(auto& c: chars) {
        auto S=s;
        for(bool done=false; !done; ) {
            done=true;
            string T;
            int n=S.size();
            for(int i=0; i+1<n; ++i) {
                if (S[i]==c || S[i+1]==c)
                    T+=c;
                else {
                    T+=S[i];
                    done=false;
                }
            }
            S=T;
        }
        res=min<int>(res, s.size()-S.size());
    }
    cout<<res<<endl;
}

Measured memory_bytes: 256
using System;

public class hello
{
    public static void Main()
    {
        while (true)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var n = int.Parse(line[0]);
            var m = int.Parse(line[1]);
            var k = int.Parse(line[2]);
            if (n == 0 && m == 0 && k == 0) break;
            var amax = n * m;
            var dp = new long[n, amax + 1];
            for (int i = 1; i <= m; i++) dp[0, i] = 1L;
            for (int i = 1; i < n; i++)
                for (int j = 1; j <= m; j++)
                    for (int L = 1; L <= amax; L++)
                    {
                        var ww = dp[i - 1, L];
                        if (ww != 0)
                            dp[i, j + L] += dp[i - 1, L];
                    }
            var res = getAns(dp, n, m, k);
            Console.WriteLine(res);
        }
    }
    public static double getAns(long[,] dp, int n, int m, int k)
    {
        var a0 = n * m + 1;
        var minus = 0L;
        var sum = 0L;
        for (int i = 0; i < a0; i++)
        {
            var te = (long)(i - k);
            if (te <= 0) minus += dp[n - 1, i];
            else if (te == 1) sum += dp[n - 1, i] + minus;
            else sum += te * dp[n - 1, i];
        }
        return (double)sum / Math.Pow(m, n);
    }
}


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

int main(){
  int64_t x;
  cin >> x;
  int64_t ans=0;
  ans=x/11;
  ans*=2;
  int mod=x%11;
  if(mod>0){
    if(mod<=6){
      ans++;
    }else{
      ans+=2;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
s = input()
n = len(s)
t = [0] * n
r = 1
l = 1
for i in range(n - 1):
    if s[i] == "R":
        if s[i + 1] == "R":
            r += 1
        else:
            m = i
    if s[i] == "L":
        if s[i + 1] == "L":
            l += 1
        else:
            t[m] += int((r + 1) / 2) + int(l / 2)
            t[m + 1] += int((l + 1) / 2) + int(r / 2)
            r = 1
            l = 1
t[m] += int((r + 1) / 2) + int(l / 2)
t[m + 1] += int((l + 1) / 2) + int(r / 2)
for i in range(0, n - 1):
    print(t[i], end = " ")
print(t[n - 1])

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

#define B begin()
#define E end()
#define I iterator
using pii = pair < int , int >;
using vi = vector < int >;
using llu = unsigned long long int;
using ll = long long int;
/*

//ofstream cout ("op.txt");
//ifstream fin("inp.in");
int main ()
{
    ll n;
    fin >> n;
    vector <ll> vec(n);
    ll val;
    for ( int i = 0 ; i < n ; i ++ ){
        fin >> val;
        vec[i] = val;
    }
    sort ( vec.B , vec.E , greater<ll>() );
    ll ansa = 0 , ansb = 0 ;
    ansa = vec[0];
    for ( int i = 1; i < n ; i++ ){
        if ( ansb < ansa )
            ansb += vec[i];
        else
            ansa += vec[i];
    }
    cout << max( ansa , ansb ) - min( ansa , ansb );
    return 0;
}
*/
int main()
{
    int n;
    cin >> n;
    vi a(n+1) , b(n+1) , c(n + 1);
    for ( int i = 1 ; i <= n; i++ )
        cin >> a[i];
    for ( int i = 1 ; i <= n ; i++ )
        cin >> b[i];
    for ( int i = 1 ; i < n ; i++ )
        cin >> c[i];
    int sum = 0; int prev = -1;
    for ( int i = 1 ; i <= n ; i++ ){
        sum += b[ a[i] ];
        if ( a[i] - prev == 1 ) sum += c[prev];
        prev = a[i];
    }
    cout << sum;
    return 0;
}




Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#define int long long
#define ll getchar();getchar();return 0;
using namespace std;
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n%i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int gcd(int x, int y) {
	int ans;
	for (int i = (min(x, y)); i >= 1; i--) {
		if (x%i == 0 && y%i == 0) {
			ans = i;
			break;
		}
	}
	return ans;
}
int yakusuunowa(int n) {
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		if (n%i == 0)ans += i;
	}
	return ans;
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int ketanowa(int n) {
	int cnt = 0, sum = 0;
	for (int i = 10; i <= n * 10; i *= 10) {
		if (i == 10)cnt += n % i;
		else sum += (n%i - n % (i / 10)) / (i / 10);
	}
	return cnt + sum;
}
double a[114];
signed main() {
	double n,cnt=0,inf=100000000000,ans;
	cin >> n;
	for (int i = 0; i < n; i++)cin >> a[i];
	for (int i = 0; i < n; i++) {
		cnt += a[i];
	}
	for(int j=0;j<n;j++){
		if (abs(cnt/n - a[j]) < inf) {
			inf = abs(cnt/n - a[j]);
			ans = j;
		}
	}
	cout << ans << endl;
	ll
}

Measured memory_bytes: 256
#include<stdio.h>

void BubbleSort(int *);
int BinarySearch(int *,int);
int n,q;

int main(){
  int C[100000];
  int T[50000];
  int i,j,a,c=0;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d ",&C[i]);
  }
  scanf("%d",&q);
  for(j=0;j<q;j++){
    scanf("%d",&T[j]);
  }

  /*BubbleSort(&T[0]);*/
     
  for(j=0;j<q;j++){
    a = BinarySearch(&C[0],T[j]);
    c+=a;
  }

 
  printf("%d\n",c);

  return 0;
}

/*void BubbleSort(int * A){
  int i,j,swap;

  for(i=0;i<q;i++){
    for(j=q-1;j>0;j--){
      if(A[j]<A[j-1]){
	swap=A[j-1];
        A[j-1]=A[j];
        A[j]=swap;
      }
    }
  }
  }*/
 

int BinarySearch(int * A, int key){
  int left,right,mid; 
 
  left=0;
  right=n;

  while(left<right){
    mid=(left+right)/2;
    if(key==A[mid]) return 1;
    if(key>A[mid]) left=mid+1;
    else  right=mid;
  }
  return 0;
}
  

Measured memory_bytes: 1188
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
  #include "_DEBUG.hpp"
#endif
#define int long long
const int INF = 1LL << 60;

template<class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template<class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template<class T, class V>
typename enable_if<is_class<T>::value == 0>::type fill(T &t, const V &v) {
  t = v;
}
template<class T, class V>
typename enable_if<is_class<T>::value != 0>::type fill(T &t, const V &v) {
  for (auto &e : t) fill(e, v);
}
// auto v = make_vec<int>(h, w);
// fill(v, 0);

signed main(){

  int H, W; cin >> H >> W;
  int sx, sy; cin >> sy >> sx;
  int gx, gy; cin >> gy >> gx;
  sx--, sy--, gx--, gy--;

  vector<string> s(H);
  for(int i = 0; i < H; i++){
    cin >> s[i];
  }

  auto dp = make_vec<int>(H, W);
  fill(dp, INF);
  dp[sy][sx] = 0;

  struct S{
    int y, x, d;
    bool operator<(const S& p) const {
      return d < p.d;
    }
    bool operator>(const S& p) const {
      return d > p.d;
    }
  };
  priority_queue<S,vector<S>,greater<S>> q; //最小値
  q.push({sy, sx, 0});
  while(!q.empty()){
    auto p = q.top(); q.pop();
    int y = p.y, x = p.x, d = p.d;
    if(dp[y][x] > d) continue;
    int dy[4] = {1, 0, -1, 0}, dx[4] = {0, 1, 0, -1};
    for(int i = 0; i < 4; i++){
      int ny = y + dy[i];
      int nx = x + dx[i];
      if(ny < 0 || H <= ny || nx < 0 || W <= nx) continue;
      if(s[ny][nx] == '.' && dp[ny][nx] > dp[y][x]){
        dp[ny][nx] = dp[y][x];
        q.push({ny, nx, d});
      }
    }

    for(int i = -2; i <= 2; i++){
      for(int j = -2; j <= 2; j++){
        int ny = y + i;
        int nx = x + j;
        if(ny < 0 || H <= ny || nx < 0 || W <= nx) continue;
        if(s[ny][nx] == '.' && dp[ny][nx] > d + 1){
          dp[ny][nx] = d + 1;
          q.push({ny, nx, d + 1});
        }
      }
    }
  }

  int ans = dp[gy][gx];
  if(ans == INF) ans = -1;
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 13672
// Best practice

#include<bits/stdc++.h>

#define int         long long
#define pb          push_back
#define pf          emplace_front
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define pii 		pair<int,int>
#define psi 		pair<string,int>
#define vi 			vector<int>
#define vpii  		vector<pii>
#define vvi 		vector<vi>
#define sz(x)	    (int)(x).size()
#define x           first
#define y           second
#define endl        '\n'
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MOD         1000000007
#define hell        998244353
#define prec(n) 	fixed<<setprecision(n)
#define in(x) 		scanf("%d", &x)
#define echo(x)		printf("%d", x)
#define inf 		(int)(1e18)
#define ini(a, i) 	memset(a, i, sizeof(a))
#define output(x)   cout << (x ? "YES" : "NO")<<endl;
using namespace std;

#define debug(vec) cout<<(#vec)<<" : [ "; for (auto& i: vec) cout<<i<<" "; cout<< "]" << endl
#define debugp(vec) cout<<(#vec)<<" : [ "; for (auto& i: vec) cout<<"("<<i.x<<","<<i.y<<")"<<" "; cout<< "]" << endl
#define trace(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);cout << endl; }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << "[" << *it << ": " << a << "]\t";
    err(++it, args...);
}

// const int dx[4] = { -1, 1, 0, 0};
// const int dy[4] = {0, 0, -1, 1};
// int dX[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
// int dY[] = { -1, 0, 1, -1, 1, -1, 0, 1 };


// Code from Here -------------------------------------------------------------------------------

void solver(){
	int n;
	cin >> n;
	int x = 1000-(n)%1000;
	if(x==1000)x=0;
	cout << x << endl;
}

signed main() {
	tezz


	int t=1;
	// cin >> t;
	while(t--)solver();

	return 0;
}  


Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;

int n,m,tmp,t;
multiset<int> s;
int main(){ _;
  cin>>n;
  REP(i,n){
    cin>>tmp;
    s.insert(tmp);
  }
  cin>>m;
  REP(i,m){
    cin>>t;
    auto it=s.find(t);
    if(it==s.end()){
      cout<<"NO"<<endl;
      return 0;
    }
    s.erase(it);
  }
  cout<<"YES"<<endl;
}


Measured memory_bytes: 9600
#include<cstdio>
#include<iostream>
#include<map>
#include<set>
#include<vector>
#include<cstring>
#include<cassert>
#include<sstream>
#include<cmath>
#include<algorithm>
#include<queue>	
#include<limits>
#include<ctime>
#include<stack>	
#include<bits/stdc++.h>
#include<string>
#include<stdlib.h>
#include<stdio.h>
	
typedef long long ll;
using namespace std;
const ll x=1000000007;
int mod(ll a){
	return a%x;
}

int main() {
	string s;
	cin>>s;
	ll maks1=0,maks2=0;
	for(int i=0;i<s.size();i++){
		if(i%2==0 and s[i]=='1'){
			maks1++;
		}
		if(i%2==1 and s[i]=='0'){
			maks1++;
		}
		if(i%2==0 and s[i]=='0'){
			maks2++;
		}
		if(i%2==1 and s[i]=='1'){
			maks2++;
		}
	}
	cout<<s.size()-max(maks1,maks2);
}


Measured memory_bytes: 3736
import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class Main {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);
	static boolean debug = false;

	static boolean solve() {
		String s = in.nextLine();
		if (s.equals(".")) return false;

		int a = 0, b = 0;
		ArrayDeque<Integer> stack = new ArrayDeque<>();
		for (int i=0; i<s.length()-1; i++) {
			if (s.charAt(i) == '(') {
				a++;
				stack.add(0);
			} else if (s.charAt(i) == ')') {
				a--;
				if (a < 0 || b < 0) {
					out.println("no");
					return true;
				}
				if (stack.pollLast() != 0) {
					out.println("no");
					return true;
				}
			} else if (s.charAt(i) == '[') {
				b++;
				stack.add(1);
			} else if (s.charAt(i) == ']') {
				b--;
				if (a < 0 || b < 0) {
					out.println("no");
					return true;
				}
				if (stack.pollLast() != 1) {
					out.println("no");
					return true;
				}
			}
		}

		if (a == 0 && b == 0) {
			out.println("yes");
		} else {
			out.println("no");
		}

		return true;
	}

	public static void main(String[] args) {
		debug = args.length > 0;
		long start = System.nanoTime();

		while(solve());
		out.flush();

		long end = System.nanoTime();
		dump((end - start) / 1000000 + " ms");
		in.close();
		out.close();
	}

	static void dump(Object... o) { if (debug) System.err.println(Arrays.deepToString(o)); }
}

Measured memory_bytes: 45804
#include<stdio.h>
#include<math.h>
 
int main(int argc, char* argv[])
{
  double a, b, c, h;
 
  scanf("%lf %lf %lf", &a, &b, &c);
  h = b*sin(c*3.1415926535/180);
  printf("%.5lf\n", a*h/2);
  printf("%.5lf\n", a+b+sqrt((a*a+b*b)+(-2*a*b*(cos(c*3.1415926535/180)))));
  printf("%.5lf\n", h); 

  return(0);
}

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

using namespace std;

int main(void) {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	string S, T, U;
	cin >> S >> T;
	int A, B;
	cin >> A >> B>>U;
	if (U == S) {
		cout << A - 1 << " " << B;
	}
	else cout << A << " " << B - 1;
	return 0;
}

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

const int N = 3001;
int g[N][N];
int64_t dp[N][N][4];
int R, C, K;

int64_t go(int x, int y, int cnt) {
    if (x == R || y == C) return 0;
    if (dp[x][y][cnt] != -1) return dp[x][y][cnt];
    if (cnt == 3) return dp[x][y][cnt] = max(go(x, y + 1, cnt), 
                                             go(x + 1, y, 0));
    return dp[x][y][cnt] = max({go(x, y + 1, cnt + 1) + g[x][y], 
                                go(x + 1, y, 0) + g[x][y], 
                                go(x, y + 1, cnt), 
                                go(x + 1, y, 0)});
}

int32_t main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    cin >> R >> C >> K;
    for (int i = 0; i < K; i++) {
        int x, y, v; cin >> x >> y >> v;
        x--, y--;
        g[x][y] = v;
    }
    memset(dp, -1, sizeof dp);
    cout << go(0, 0, 0);
    return 0;
}

Measured memory_bytes: 321020
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
    /*#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif*/
        

fast();
//ll t;cin>>t;while(t--)
{
    ll a,b,c,x,y,n=3;
    cin>>a>>b>>c>>x>>y;
    ll arr[3];
    arr[0]=a*x + b*y;
    arr[1]=max(x,y)*2*c;
    if(x==y)
    {
      arr[2]=arr[1];
    }
    else if(x<y)
    {
      ll ans=x*2*c;
      ll temp=y-x;
      ans+=(temp*b);
      arr[2]=ans;
    }
    else if(y<x)
    {
      ll ans=y*2*c;
      ll temp=x-y;
      ans+=(temp*a);
      arr[2]=ans;
    }
    sort(arr,arr+n);
    cout<<arr[0]<<endl;
}
return 0;
}

Measured memory_bytes: 256
n = int(input())
para = [i for i in map(int,input().split())]
ans = 0
for i in range(1,n-1):
    if max(para[i-1],para[i],para[i+1]) != para[i] and min(para[i-1],para[i],para[i+1])!= para[i]:
        ans += 1
    else:
        pass
print(ans)

Measured memory_bytes: 3060
import java.util.*;
public class Main{
	public static void main(String args[]) {
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		int W[]=new int[N];
		int S[]=new int[2];
		int result=0;
		for(int i=0;i<N;i++) {
			W[i]=sc.nextInt();
			result+=W[i];
		}
		sc.close();
		for(int T=0;T<(N-1);T++){
			S[0]=S[1]=0;
			for(int k=0;k<=T;k++) {
				S[0]+=W[k];
			}
			for(int l=T+1;l<=(N-1);l++) {
				S[1]+=W[l];
			}
			if(Math.abs(S[0]-S[1])<result) {
				result=Math.abs(S[0]-S[1]);
			}
		}
		System.out.println(result);
	}
}

Measured memory_bytes: 23124
#include<stdio.h>
int selectionSort(int A[],int N){
 int i,j,t,sw=0,minj;
 for(i=0;i<N-1;i++){
  minj=i;
  for(j=i;j<N;j++){
   if(A[j]<A[minj])minj=j;
  }
  t=A[i];A[i]=A[minj];A[minj]=t;
  if(i!=minj)sw++;
 }
 return sw;
}
int main(){
 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%d\n",sw);
 return 0;
}


Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep1(i, n) for(int i=1; i<=(int)(n); i++)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> wi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<vs> ws;
const ll INF=1LL << 60;
const ll MOD=1e9+7;

char chchar(int num){
  char c='5';
  if(num==0)c='0';
  else if(num==1)c='1';
  else if(num==2)c='2';
  else if(num==3)c='3';
  else if(num==4)c='4';
  else if(num==5)c='5';
  else if(num==6)c='6';
  else if(num==7)c='7';
  else c='8';
  return c;
}

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

  int h, w;
  cin >> h >> w;
  char s[h+2][w+2];
  rep(i, h+2)rep(j, w+2)s[i][j]=='.';
  rep1(i ,h)rep1(j, w)cin >> s[i][j];

  int cnt;
  char ans[h][w];
  rep1(i, h){
    rep1(j, w){
      cnt=0;
      if(s[i][j]=='#'){
        ans[i][j]='#';
        continue;
      }
      if(s[i+1][j]=='#')cnt++;
      if(s[i+1][j+1]=='#')cnt++;
      if(s[i+1][j-1]=='#')cnt++;
      if(s[i-1][j]=='#')cnt++;
      if(s[i-1][j+1]=='#')cnt++;
      if(s[i-1][j-1]=='#')cnt++;
      if(s[i][j+1]=='#')cnt++;
      if(s[i][j-1]=='#')cnt++;
      char c=chchar(cnt);
      ans[i][j]=c;
    }
  }

  rep1(i, h){
    rep1(j, w){
      cout << ans[i][j];
    }
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define int long long int
int dp[105][100005];
int w[105];
int v[105];
int n,mx;
int f(int ind,int rem){
	//cout<<ind<<" "<<rem<<"\n";
	if(rem<0) return 100000000000;
	if(ind==n+1){
		if(rem==0) return 0;
		else return 10000000000;
	}
	if(dp[ind][rem]>0) return dp[ind][rem];
	int res=100000000000;
	res = min(res,f(ind+1,rem));
	res = min(res,f(ind+1,rem-v[ind])+w[ind]);
	return dp[ind][rem]=res;
}

int32_t main(){
	cin>>n>>mx;
	int mv=0;
	for(int i=1;i<=n;i++){
		cin>>w[i]>>v[i];
		mv = max(mv,v[i]);
		fill(dp[i],dp[i]+100005,-1);
	}
	for(int i=n*mv+1;i>=0;i--){
		int a = f(1,i);
		//cout<<i<<" "<<a<<"\n";
		if(a<=mx){
			cout<<i;
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 79488
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <complex>
#include <bitset>
#include <functional>

using namespace std;
using ll=long long int;
const int INF = 1e9;

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> a(n, vector<int>(m));
    for (auto &v: a) for (auto &e: v) {
        cin >> e;
        e--;
    }

    int ans = INF;
    vector<bool> use(m, true);
    for (int t = 0; t < m; ++t) {
        vector<int> cnt(m, 0);
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < m; ++j) {
                if (use[a[i][j]]) {
                    cnt[a[i][j]]++;
                    break;
                }
            }
        }
        int mi = max_element(cnt.begin(), cnt.end()) - cnt.begin();
        ans = min(ans, cnt[mi]);
        use[mi] = false;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace At
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Reads();
            if (input[0][input[0].Length-1].ToString() == input[1][0].ToString())
            {
                if (input[1][input[1].Length-1].ToString() == input[2][0].ToString())
                {
                    WriteLine("YES");
                    return;
                }
            }
            WriteLine("NO");
        }

        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 11092
//******\\
**udc321**	 
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<queue>
#include<map>
#include<set>
#define ll long long
#define fr(e,r,v) for(int e=r;e<v;e++)
#define bc(e,r,v) for(int e=r;e>v;e--)
#define all(n) (n.begin(),n.end())
#define ft first
#define sd second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define mpr make_pair
#define db  double
using namespace std;

ll mod=1000000007;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

/*pair(sort and all) implementation and upper bound implementation*/
int main()
{
	ll n;
	cin>>n;
	ll a[n],b[n],c[n];
	fr(j,0,n)
	{
		cin>>a[j]>>b[j]>>c[j];
		if(j>0)
		{
			a[j]+=max(b[j-1],c[j-1]);
			b[j]+=max(a[j-1],c[j-1]);
			c[j]+=max(a[j-1],b[j-1]);
		}

	}
	cout<<max(max(a[n-1],b[n-1]),c[n-1]);

}









Measured memory_bytes: 5860
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;

  vector<int> assistant(N);


  for(int i=1; i<N; i++) {
    int boss;
    cin >> boss;
    assistant.at(boss -1) += 1;
  }


  for(int i=0; i<N; i++) {
    cout << assistant.at(i) << endl;
  }

  return 0;
}


Measured memory_bytes: 4048
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC(T, v) static_cast<T>(v)
#define SI(v) SC(int, v.size())
#define SL(v) SC( LL, v.size())
#define RF(e, v) for(auto & e: v)
#define ei else if
#define UR assert(false)

// ---- ----

vector<int> v(6);

int main() {
	inc(i, 6) { cin >> v[i]; }
	
	bool ans = true;
	inc1(i, 4) { ans &= (count(ALL(v), i) <= 2); }
	
	cout << (ans ? "YES" : "NO") << endl;
	
	return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
py = [list(map(int, input().split())) + [i] for i in range(m)]
py.sort()

ans = []
for i in range(m):
    p = py[i][0]
    y = py[i][1]
    key = py[i][2]
    if i == 0:
        ans.append([p, 1, key])
    elif i >= 1:
        if ans[i - 1][0] == p:
            ans.append([p, ans[i - 1][1] + 1, key])
        else:
            ans.append([p, 1, key])

ans = sorted(ans, key=lambda x: x[2])
for i in range(m):
    print(format(ans[i][0], '06'), end='')
    print(format(ans[i][1], '06'))


Measured memory_bytes: 39060
#include<iostream>
#include<vector>
#include<string>
#include<set>

int main(){
    std::string S;
    int K;
    std::cin >> S >> K;
    
    // 長さは高々Kなのでそこまで調べれば十分
    std::set<std::string> st;
    for(int i = 0; i < S.size(); i++){
        for(int length = 1; length <= K; length++){
            if(i + length - 1 >= S.size()) continue;
            st.insert(S.substr(i, length));
        }
    }

    auto iter = st.begin();
    for(int i = 0; i < K - 1; i++) iter++;
    std::cout << *iter << std::endl;
    
    return 0;
}


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


int main(void){
    string A,B;
    cin >> A >> B;

    if(A.size()>B.size()){
        cout << "GREATER" << endl;
        return 0;
    }
    else if(A.size()<B.size()){
        cout << "LESS" << endl;
        return 0;
    }
    else{
        for(int i=0; i<A.size(); i++){
            if(A[i]>B[i]){
                cout << "GREATER" << endl;
                return 0;
            }
            else if(A[i]<B[i]){
                cout << "LESS" << endl;
                return 0;
            }
        }
    }

    cout << "EQUAL" << endl;
    return 0;
}

Measured memory_bytes: 256
import math

n, m = map(int, input().split())
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

if n > 1 and m > 1:
  print(combinations_count(n, 2) + combinations_count(m, 2))
elif n > 1:
  print(combinations_count(n, 2))
elif m > 1:
  print(combinations_count(m, 2))
else:
  print(0)

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

using namespace std;

const long long INF = 1e18;

int main(){
  int N, M;
  cin >> N >> M;
  
  vector<pair<long long, pair<int, int>>> edge(M);
  for(int e = 0; e < M; e++){
    int a, b;
    long long c;
    cin >> a >> b >> c;
    --a; --b;
    edge[e] = {c, {a, b}};
  }
  
  vector<long long> score(N, -INF);
  score[0] = 0;
  
  bool inf = false;
  
  for(int i = 0; i < N; i++){
    for(int e = 0; e < M; e++){
      int a = edge[e].second.first, b = edge[e].second.second;
      long long c = edge[e].first;
      
      if(score[a] + c > score[b]){
        if(i == N - 1 && b == N - 1){
          inf = true;
          break;
        }
        score[b] = score[a] + c;
      }
    }
  }
  
  if(inf) cout << "inf" << endl;
  else cout << score[N - 1] << endl;
  
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

// 提出時にclass Main に書き換え
public class Main {
	public static void main(String[] args)  {
		// 標準入力を受け取る
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt(); // int xを受け取る
		sc.close(); // 標準入力を終了

		if (x == 0) {
			// xが0
			System.out.println(1);
		} else {
			System.out.println(0);
		}
	}

}

Measured memory_bytes: 35720
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <stack>
#include <functional>
#include <queue>
#include <cmath>
#include <set>
#include <map>

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vi vector<int>
#define INF (int)1e933
#define INFL 1e18
#define MOD 1e9+7
#define pb push_back
#define MP make_pair
typedef long long int ll;
typedef std::pair<int,int> pii;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

using namespace std;

int main() {
    int n,h;
    int ans=0;
    cin>>n>>h;
    int amax=0;
    vector<int> b(n);
    rep(i,0,n){
        int x;
        cin>>x>>b[i];
        amax=max(amax,x);
    }
    Sort(b);
    int index=b.size()-1;
    while(b[index]>=amax&& index>=0){
        h-=b[index];
        index--;
        ans++;
        if(h<=0){
            cout<<ans<<endl;
            return 0;
        }
    }
    if(h%amax==0)cout<<ans+(h/amax)<<endl;
    else cout<<ans+(h/amax)+1<<endl;
    
    return 0;
}


Measured memory_bytes: 640
import math

def get_cos(m, h):
  a_deg = h*30 + m/2
  b_deg = m*6
  deg = min(abs(a_deg - b_deg), abs(360 - a_deg + b_deg))
  cos = math.cos(math.radians(deg))
  
  return cos

if __name__ == '__main__':
  a, b, h ,m = map(int,input().split())
  print(math.sqrt(a*a + b*b - 2*a*b*get_cos(m, h)))

Measured memory_bytes: 9516
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define all(x) x.begin(),x.end()
#define all(x) x.begin(),x.end()
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
 
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

//
int main(void) {
    int A,B,C;
    cin >> A >> B >> C;
    int ans = min(B/A,C);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

 int main(void)
 {
 	int x;
 	scanf("%d",&x);
 	int p=(int)sqrt(x);
 	while(1){
 		int t=p*(p+1)/2;
 		if(t>=x){
 			printf("%d\n",p);
 			return 0;
 		}
 		p++;
 	}
 	return 0;
 }

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define mod 1000000007
#define inf 1000000000000000007
#define eps 0.000001
#define pi 3.141592653589793
#define pii pair<int , int>
#define pdd pair<ld,ld>
#define pll pair<ll,ll>
#define ff first
#define ss second
#define vii vector<int>
#define vpl vector<pll>
#define vll vector<ll>
#define sti stack <int>
#define stll stack <ll>
#define mseti set <ll>
#define msetd multiset <ll, greater <ll> >
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound 
#define stp setprecision(20)//use fixed before stp
#define endl '\n'
ll  dfs(vll v[],ll e[],ll ans[],ll q,ll m)
{
    e[q]=1;
    ll a=1;
    for(auto i:v[q])
    {
        if(e[i]==1)
            continue;
        a*=dfs(v,e,ans,i,m);
        a%=m;
    }
    ans[q]=a;
    return(a+1);
}
void dfs_2(vll v[],ll e[],ll ans1[],ll ans[],ll q,ll m)
{
    e[q]=1;
    ll val=(ans1[q]);
    val%=m;
    for(ll i=0;i<v[q].size();i++)
    {
        if(e[v[q][i]]==1)
            continue;
        ans1[v[q][i]]*=val;
        val*=(ans[v[q][i]]+1);
        val%=m;
    }
    val=1;
    for(ll i=v[q].size()-1;i>=0;i--)
    {
        if(e[v[q][i]]==1)
            continue;
        ans1[v[q][i]]*=val;
        ans1[v[q][i]]++;
        ans1[v[q][i]]%=m;;
        val*=(ans[v[q][i]]+1);
        val%=m;
    }
    for(auto i:v[q])
    {
        if(e[i]==1)
            continue;
        dfs_2(v,e,ans1,ans,i,m);
    }
}
int main()
{  
    FAST
    ll n,m;
    cin>>n>>m;
    ll x,y;
    vll v[n+1];
    ll e[n+1]={0};
    ll ans[n+1];
    ll ans1[n+1];
    for(ll i=1;i<n;i++)
    {
        cin>>x>>y;
        v[x].pb(y);
        v[y].pb(x);
    }
    x=dfs(v,e,ans,1,m);
    for(ll i=0;i<=n;i++)
    {
        e[i]=0;
        ans1[i]=1;
    }
    dfs_2(v,e,ans1,ans,1,m);
    for(ll i=1;i<=n;i++)
    {
        cout<<(ans1[i]*ans[i])%m<<endl;
    }
}


Measured memory_bytes: 14720
#include <iostream>

using namespace std;

int main()
{
    string s;
    cin>>s;
    int i,x=0;
    for(i=0;s[i];i++)
    {
        x=x+s[i]-'0';
    }
    if(x%9==0)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3716
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
set<int >st;

int main(){


int x, k;
cin>>x>>k;
st.insert(k);
long long t=k;
for(int i=0;i<x-1;i++){
k=k-1;
    st.insert(k);
    t=t+1;
    st.insert(t);

}


for(auto it=st.begin();it!=st.end();it++) cout<<*it <<"  ";


return 0;

}



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

//const long double PIL = 3.141592653589793238462643383279502884L;
//const double PI = 3.14159265358979323846;

#define sz(a) (int)((a).size())
#define all(c) (c).begin(), (c).end()
#define debug(v) {for (auto z : v) {cerr << z << ' ';} cerr << endl;}

using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vll = vector<long long>;
using vii = vector<pair<int,int>>;

const ll MOD = 1e9 + 7;

int main() {
	//~ ios::sync_with_stdio(0);
	//~ cin.tie(0);
	int n; scanf("%d", &n);
	vi deg(n+1);
	for (int i = 2; i <= n; i++) {
		int x; scanf("%d", &x);
		deg[x]++;
	}
	for (int i = 1; i <= n; i++) printf("%d\n", deg[i]);
}


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

int N,M,Q;
vector<long long> a,b,c,d;

long long score(const vector<int> &A){
  ll res=0;
  for(int i=0;i<Q;i++)if( A[b[i]]-A[a[i]]==c[i]) res+=d[i];
  return res;
}

long long dfs(vector<int> &A) {
    if (A.size() == N) {
        return score(A);
    }

    long long res=0;
    int prev_last = (A.empty() ? 1 : A.back());
    for (int v = prev_last; v <= M; ++v) {
        A.push_back(v);
        res=max(res,dfs(A));
        A.pop_back();
    }
    return res;
}

int main(){
  
  cin>>N>>M>>Q;
  a.resize(Q);  b.resize(Q);  c.resize(Q);  d.resize(Q);

  rep(i,Q){

    cin>>a[i]>>b[i]>>c[i]>>d[i];
    --a[i]; --b[i];
    
  }
  
  vector<int> A;
  cout<<dfs(A)<<endl;
  
}




Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define eb emplace_back
 
typedef long long ll;
 
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	int N; cin >> N;
	
	vector<ll> damm(N);
	for (auto &e : damm) {
		cin >> e;
	}
	
	ll pm_sum = 0;
	for (int i=0; i<N-1; i++) {
		if (i % 2 == 0) {
			pm_sum += damm[i];
		} else {
			pm_sum -= damm[i];
		}
	}
	pm_sum += damm.back();
	vector<ll> res(N);
	res.front() = pm_sum;
	for (int i=1; i<N; i++) {
		res[i] = (damm[i-1]-res[i-1]/2)*2;
	}
	
	for (auto &e : res) {
		cout << e << " ";
	}
	
}


Measured memory_bytes: 2944
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

// reference: http://ir5.hatenablog.com/entry/20171209/1512821837

struct Scanner<'a> {
    cin: StdinLock<'a>,
}
 
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }
 
    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }
 
    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}

use std::mem;
use std::cmp;

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let a: i32 = sc.read();
    let v: i32 = sc.read();
    let b: i32 = sc.read();
    let w: i32 = sc.read();
    let t: i32 = sc.read();
    let d: i32;
    let dv: i32;
    if a > b {
        d = a - b;
    } else {
        d = b - a;
    }
    if v > w {
        dv = v - w;
        if (d + dv - 1) / dv <= t {
            println!("{}", "YES");
        } else {
            println!("{}", "NO");
        }
    } else {
        println!("{}", "NO");
    }
}

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

int main() {
  int64_t n,a,b,c;
  cin >> n >> a >> b;
  c = n%(a+b);
  if(c<=a) { 
    cout << n/(a+b)*a+c <<endl;
  }
  else {
    cout << n/(a+b)*a+a <<endl;
  }
}

Measured memory_bytes: 256
from itertools import groupby
from collections import deque


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def ilen(v):
    return sum(1 for _ in v)


def solve():
    N, K = read_ints()
    S = input()
    counts = deque([])
    zeroes = 0
    total = 0
    max_total = 0
    for k, v in groupby(S):
        if k == '0':
            zeroes += 1
        this_count = ilen(v)
        total += this_count
        counts.append((k, this_count))
        while zeroes > K:
            k, count = counts.popleft()
            total -= count
            if k == '0':
                zeroes -= 1
        max_total = max(max_total, total)
    return max_total


if __name__ == '__main__':
    print(solve())


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

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n){
    cin >> a[i];
  }
  
  sort(a.begin(), a.end());
  
  if(a[0] == 0) {
      cout << 0 << endl;
      return 0;
  }
  
  const ll max = 1e18;
    
  
  ll res = 1;
     
  rep(i, n){
      if(max/res < a[i]){
          res = -1;
          break;
      }
    
      res *= a[i];  
  }
  
  cout << res << endl;
    
  return 0;
}


Measured memory_bytes: 4052
X, N = map(int, input().split())
if N == 0:
  print(X)
else:
  P = list(map(int, input().split()))
  c_list = []
  for p in P:
    if p-1 not in P:
      c_list.append(p-1)
    if p+1 not in P:
      c_list.append(p+1)
  c_list.sort()
  ans = c_list[0]
  for c in c_list:
    if abs(c-X) < abs(ans-X):
      ans = c
  print(ans)

Measured memory_bytes: 9192
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <math.h>
using namespace std;
int main() {
	int h, w, n, x, y, a;
	bool  ans[110][110] = {};
	cin >> h >> w >> n;
	for (int i = 0; i < n; i++) {
		cin >> x >> y >> a;
		if (a == 1) for (int j = 0; j < 110; j++)for (int k = 0; k < x; k++) ans[j][k] = 1;
		if (a == 2) for (int j = 0; j < 110; j++)for (int k = x; k < 110; k++) ans[j][k] = 1;
		if (a == 3) for (int j = 0; j < y; j++) for (int k = 0; k < 110; k++) ans[j][k] = 1;
		if (a == 4) for (int j = y; j < 110; j++) for (int k = 0; k < 110; k++) ans[j][k] = 1;
	}
	int yojo = 0;
	for (int i = 0; i < w; i++) for (int j = 0; j < h; j++) if (!ans[i][j])yojo++;
	cout << yojo << endl;
	return 0;
}


Measured memory_bytes: 256
## abc070d: Transit Tree Path

from collections import deque

n = int(input())

T = [{} for _ in range(n)]
for _ in range(n-1):
    v1,v2,d = map(int, input().split())
    T[v1-1][v2-1] = d
    T[v2-1][v1-1] = d

q,k = map(int, input().split())

visit = [False]*n
depth = [0]*n
que = deque()
que.append(k-1)
while que:
    p = que.popleft()
    visit[p] = True
    for c in T[p].keys():
        if visit[c]: continue
        depth[c] = depth[p] + T[p][c]
        que.append(c)

for _ in range(q):
    v1,v2 = map(int, input().split())
    print(depth[v1-1]+depth[v2-1])

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

using namespace std;

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

#define int ll

const ll mod = 1e9 + 7;


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

	cout << x+x*x+x*x*x << endl;

	return 0;
}


Measured memory_bytes: 3580
// ABC127_B
#include <iostream>
#include <string>
#include <vector>
#include <iterator>  // std::prev(iter, n) n 個分デクリメントしたイテレータ
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;
using ll = long long;

#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define MIN(vec) min_element(vec.begin(), vec.end())  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(vec.begin(), vec.end())
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(vec.begin(), vec.end(), 0LL)  // 0 は初期値
#define pll pair<ll, ll>
#define F first
#define S second
const ll INF = 1LL<<60;  // 10^18（const int inf   = 1<<29;）

int main() {
    // input(sunippets: inpv, inpn, inps)
    ll A, B, C;
    cin >> A >> B >> C;
    
    // calculation
    ll out = A*C - B;
    REP(i, 10) {
        cout << out << "\n";
        out = A*out - B;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<set>
#include<queue>
#include<string>
using namespace std;

int main()
{
    string s, t;
    cin >> s >> t;
    for (int i = 0; i < (int)s.size(); i++) {
        if (s[i] != t[i]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}



Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
#define int int64_t
#define rep(i, a, b) for(int i = a; i < b; ++i)

main() {
    int k, ans, BOUND = 1e7;
    cin >> k;
    int cur = 7, deg = 1, cnt = 1;
    while (cur % k && cnt < BOUND) {
        deg *= 10;
        cnt++;
        cur += 7 * deg;
        cur %= k;
        deg %= k;
    }
    if (cur % k) {
        ans = -1;
    } else {
        ans = cnt;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3636
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;

int main()
{
  int n;
  cin >> n;
  ll a[n];
  int left, right, mid;
  if (n % 2 == 0) {
    left = n / 2 - 1;
    right = n / 2;
  } else {
    left = n / 2;
    right = n / 2 + 1;
  }
  for (int i = 0; i < n; i++) {
    if (n % 2 == 0) {
      if (i % 2 == 0) {
        cin >> a[right];
        right++;
      } else {
        cin >> a[left];
        left--;
      }
    } else {
      if (i % 2 == 0) {
        cin >> a[left];
        left--;
      } else {
        cin >> a[right];
        right++;
      }
    }
  }
  for (int i = 0; i < n; i++) cout << a[i] << " ";
  cout << endl;
}


Measured memory_bytes: 3712
# a brute bitch
from bisect import bisect_right
def comb (n,s):
    capt = []; ind = n; 
    stp = n+1; boo = ""
    while bk[0] < 1:
        if bk[ind] < s:
            boo += dip[bk[ind]];
            bk[ind]+=1; 
            if ind + 1 == stp:
                if '7' in boo and '3' in boo and '5' in boo:
                    capt.append(int(boo)); 
                boo = boo[:len(boo)-1];
            ind += 1 if ind + 1 < stp else 0
        else: bk[ind] = 0;ind -= 1; boo = boo[:len(boo)-1]
    return bisect_right(capt,int(val))
val = input()
bk = [0]*(len(val)+1); dip = ['3','5','7']
print(comb(len(val),3))

Measured memory_bytes: 10080
<?php
$input = trim(fgets(STDIN));
// echo $input, PHP_EOL;
$arr_input = str_split($input);

if($arr_input[0] == $arr_input[1] || $arr_input[1] == $arr_input[2] || $arr_input[2] == $arr_input[3]){
  echo "Bad",PHP_EOL;
}else{
    echo "Good",PHP_EOL; 
  

}
?>


Measured memory_bytes: 4604
#include<iostream>
using namespace std;
int main(void)
{
    int a,b,fl;
    while(cin>>a>>b)
    {
        fl=0;
        for(int i=1;fl==0;i++)
        {
            if(a%i==0&&b%(a/i)==0)
            {
                cout<<a/i<<" ";
                fl++;
            }
            else;
        }
        fl=0;
        for(int i=1;fl==0;i++)
        {
            if((a*i)%b==0)
            {
                cout<<a*i<<endl;
                fl++;
            }
            else;
        }
    }
    return 0;
}


Measured memory_bytes: 3064
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <assert.h>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <stdlib.h>
#include <math.h>
#include <string>
#include <time.h>
#include <string.h>
#include <queue>
#include <complex>
#include <iomanip>
#include <stack>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
ll mod=1e9+7;
double eps=1e-7;
ll exp(ll x,ll y){if(y<0) return 0; ll ret=1;for(;y;y>>=1,x=(x*x)%mod){if(y&1)ret=(ret*x)%mod;}return ret;}
ull pexp(ull x,ull y){if(y<0) return 0; ull ret=1; for(;y;y>>=1,x=(x*x)){if(y&1)ret=(ret*x);}return ret;}
ll gcd(ll x,ll y){if(!x||!y) return x+y; return x%y==0?y:gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll bsum(ll u,ll b){ll ret=0;if(u<b)return u;while(u){ret+=u%b;u/=b;}return ret;}
ll prival(ll u,ll p){ll cn=0;while(u%p==0){cn++;u=u/p;}return cn;}
ll minv(ll a,ll b){return 1<a?b-minv(b%a,a)*b/a:1;}
ll extm(ll a,ll b){ll ret=0;while(a!=0){if(a%2==1){ret+=b;ret%=mod;}a>>=1;b=(2*b)%mod;}return ret;}   
ll eaphi(ll x){ll t=x,ret=x,i;for(i=2;i*i<=x;i++){if(t%i==0){ret-=ret/i;while(t%i==0) t/=i;}}if(t!=1) ret-=ret/t;return ret;}
ll eadivc(ll x){ll ret=0;ll i;for(i=1;i*i<=x;i++){if(x%i==0 && i*i!=x) ret+=2;if(x%i==0 && i*i==x) ret+=1;}return ret;}
ll eadivs(ll x){ll ret=0;ll i;for(i=1;i*i<=x;i++){if(x%i==0 && i*i!=x) ret+=i+x/i;if(x%i==0 && i*i==x) ret+=i;}return ret;}
ll ndig(ll x, ll b){ll ret=0;while(x){x/=b; ret++;}return ret;}
ll rev(ll n, ll b){ll ret=0;while(n){ret=b*ret+n%b; n/=b;}return ret;}
ll sq(ll x){ll t=(ll)sqrt(x); for(ll i=t-2 ; i<=t+2 ; i++) if(i*i==x) return abs(i); return -1;}
ll extexp(ll x,ll y){if(y<0) return 0; ll ret=1;for(;y;y>>=1,x=extm(x,x)){if(y&1)ret=extm(ret,x);}return ret;}
bool isprime(ll x){if(x<=1) return false; for(ll i=2;i*i<=x;i++){if(x%i==0){return false;}}return true;}
ll w, h, ans=1e18;

ll gv_1(ll u, ll v)
{
	if(v%3==0) return 0;
	return u;
}

ll gv_2(ll u, ll v)
{
	ll i, ret=1e18;
	for(i=0 ; i<=u ; i++)
	{
		ll S=i*v;
		ll T_1=(u-i)*((v+1)/2);
		ll T_2=(u-i)*(v/2);
		ret=min(ret,max(S,max(T_1,T_2))-min(S,min(T_1,T_2)));
	}
	return ret;
}

int main(void)
{
	cin>>h>>w;
	ans=min(ans,gv_1(h,w));
	ans=min(ans,gv_2(h,w));
	ans=min(ans,gv_1(w,h));
	ans=min(ans,gv_2(w,h));
	cout<<ans; return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
    int num,a,b,c,d[10001],i,j,temp,cal,price;
    scanf("%d%d%d%d",&num,&a,&b,&c);
    for (i=0; i<num; i++) scanf("%d",&d[i]);
    for (i=0; i<num-1; i++) {
        for (j=0; j<num-1-i; j++) {
            if (d[j]<d[j+1]) {
                temp=d[j];
                d[j]=d[j+1];
                d[j+1]=temp;
            }
        }
    }
    cal=c,price=a;
    for (i=0; i<num; i++) {
        if (1.0*cal/price<1.0*(cal+d[i])/(price+b)) {
            cal+=d[i];
            price+=b;
        } else {
            break;
        }
    }
    printf("%d\n",cal/price);
    return 0;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
ll mod=1e9+7;			
	   
int main() {
			fast
			// #ifndef ONLINE_JUDGE
			// freopen("input.txt","r",stdin);
			// freopen("output.txt","w",stdout);
			// #endif

			ll t;
			t=1;
			while(t--)
			{
				ll n;
				cin>>n;
				string s="";
				while(n)
				{
					ll x=n%26;

					if(x==0)
					{
						s+="z";
						n/=26;
						n-=1;
					}	
					else
					{
						char y=x-1+'a';
						s+=y;
						n/=26;
					}
					
				}
				reverse(s.begin(),s.end());
				cout<<s;
                
			}
			return 0;
		 }	


Measured memory_bytes: 3616