akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;


template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)


int main() {
	ll H, W;
	std::cin >> H >> W;

	vector<string> s(H);
	vector<vector<bool>> isVisited(H, vector<bool>(W, false));
	ll cnt_balck = 0;
	rep(i, 0, H) {
		std::cin >> s[i];
		rep(j, 0, W) {
			if (s[i][j] == '#') {
				cnt_balck++;
				isVisited[i][j] = true;
			}
		}
	}

	const vector<pair<ll, ll>> mov = { {1,0},{0,1},{-1,0},{0,-1} };

	queue<pair<ll, ll>> q;
	q.push({ 0LL,0LL });
	isVisited[0][0] = true;
	ll cnt_white = 1;
	while (!q.empty()) {
		cnt_white++;
		queue<pair<ll, ll>> r;
		while (!q.empty()) {
			auto h = q.front().first;
			auto w = q.front().second;
			q.pop();
			rep(i, 0, 4) {
				auto next_h = h + mov[i].first;
				auto next_w = w + mov[i].second;
				if (next_h == H - 1 && next_w == W - 1) {
					std::cout << H * W - cnt_white - cnt_balck << endl;
					return 0;
				}
				else if (0 <= next_h && next_h < H && 0 <= next_w && next_w < W && !isVisited[next_h][next_w]) {
					r.push({ next_h,next_w });
					isVisited[next_h][next_w] = true;
				}
			}
		}
		q = r;
	}

	std::cout << -1 << endl;


	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
ll mod =1000000007;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX*/                      int gcd(ll a,ll b){return b?gcd(b,a%b):a;}
/*"lcm"   MIN*/                      int lcm(ll a,ll b){return a*b/gcd(a,b);}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
int main(){
int n;
string s;
cin >> n >> s;
if(n>=3200)cout<<s<<endl;
else cout<<"red"<<endl;
}





Measured memory_bytes: 764
#include <iostream>
#include <cstdio>
#define REP(i, a, n) for(int i = ((int) a); i < ((int) n); i++)
using namespace std;

int N, K, T, U, V, L, D;
int p[10000];

int main(void) {
  cin >> N >> K >> T >> U >> V >> L;
  REP(i, 0, L + 1) p[i] = 0;
  REP(i, 0, N) {
    cin >> D;
    p[D] = 1;
  }

  int d = 0;
  int cnt = 0;
  int s = 0;

  REP(i, 0, L) {
    if(p[i] == 1) {
      if(cnt != 0 && s < K) s++;
      else cnt = T * V;
    } else if(cnt == 0 && s > 0) s--, cnt = T * V;
    if(cnt > 0) d++, cnt--;
  }

  printf("%.8lf\n", (double) d / V + (double) (L - d) / U);

  return 0;
}

Measured memory_bytes: 3252
MOD = 10**9+7
n, m = map(int, input().split())
X = list(map(int ,input().split()))
Y = list(map(int ,input().split()))
X.sort()
Y.sort()
xx, yy = 0, 0
for i in range(n):
    xx += X[i]*i
    xx -= X[i]*(n-i-1)
for i in range(m):
    yy += Y[i]*i
    yy -= Y[i]*(m-i-1)
print(xx*yy%MOD)


Measured memory_bytes: 24372
def MAP(): return list(map(int,input().split()))
def INT(): return int(input())
def FLOAT(): return float(input())
MOD = 10**9+7

n = INT()
d = MAP()
ans=0

for i in range(n-1):
    for j in range(i+1,n):
        ans+=d[i]*d[j]

print(ans)

Measured memory_bytes: 3060
#include<iostream>
//#include<bits/stdc++.h>
#include<cmath>
#include<string>
#include<cstdio>
#include<cstring>
#include<queue>
#define pq priority_queue
#define Pi acos(-1.0)
using namespace std;
#define MOD 1000000007
int n;
int ans=0;
bool life[10];
vector <int> v[10];
int dfs(int x,int pre)
{
    if(x==n)
        ans++;
    for(int i=0;i<v[pre].size();i++)
    {
        if(!life[v[pre][i]])
        {
            life[v[pre][i]]=1;
            dfs(x+1,v[pre][i]);
            life[v[pre][i]]=0;
        }
    }
}
int main()
{
    int m,a,b;
    cin>>n>>m;
    while(m--)
    {
        scanf("%d%d",&a,&b);
        v[a].push_back(b);
        v[b].push_back(a);
    }
    life[1]=1;
    dfs(1,1);
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 256
MOD = 10**9+7
n = int(input())
s = input()
p = input()
ans = 0
f = 0
i = 0
while i < n:
    if i > n:break
    if s[i] == p[i]:
        if i == 0:
            ans = 3
        else:
            if f == 1:
                ans *= 1
            else:
                ans *= 2
        f = 0
    else:
        if i == 0:
            ans = 6
        else:
            if f == 1:
                ans *= 3
            else:
                ans *= 2
        f = 1
        i += 1
    i += 1
    ans %= MOD
print(ans%MOD)


Measured memory_bytes: 38408
import sys
from collections import defaultdict

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

# 一番後ろの色を(赤に)固定した上で、もらうDPに書き換え
def main():
    md = 10 ** 9 + 7
    n, m = MI()
    rtol = defaultdict(list)
    for _ in range(m):
        l, r, x = MI()
        rtol[r].append([l, x])
    dp = [[0] * (n + 1) for _ in range(n + 1)]
    dp[0][0] = 1
    for k in range(1, n + 1):
        for i in range(k - 1):
            dp[i][k - 1] = dp[k - 1][i] = sum(dp[i][:k - 1]) % md
        for l, x in rtol[k]:
            if x == 1:
                for i in range(l, k):
                    for j in range(k):
                        dp[i][j] = dp[j][i] = 0
            if x == 2:
                for i in range(l, k):
                    for j in range(i + 1, k):
                        dp[i][j] = dp[j][i] = 0
                for i in range(l):
                    for j in range(i + 1):
                        dp[i][j] = dp[j][i] = 0
            if x == 3:
                for i in range(l):
                    for j in range(k):
                        dp[i][j] = dp[j][i] = 0

    # p2D(dp)
    print(sum(sum(dr) for dr in dp) * 3 % md)

main()


Measured memory_bytes: 5484
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <climits>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <functional>
#include <set>
#include <numeric>
#include <stack>
#include <utility>
#include <time.h>
#include <iterator>
#include <random>
//#include "util.h"

using namespace std;
typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<bool> vbool;
typedef vector<string> vstr;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

//呪文
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const pair<_KTy, _Ty>& m) { cout << "{" << m.first << ", " << m.second << "}"; return ostr; }
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const map<_KTy, _Ty>& m) { if (m.empty()) { cout << "{ }"; return ostr; } cout << "{" << *m.begin(); for (auto itr = ++m.begin(); itr != m.end(); itr++) { cout << ", " << *itr; } cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const vector<_Ty>& v) { if (v.empty()) { cout << "{ }"; return ostr; }	cout << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const set<_Ty>& s) { if (s.empty()) { cout << "{ }"; return ostr; } cout << "{" << *(s.begin()); for (auto itr = ++s.begin(); itr != s.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _KTy, typename _Ty> istream& operator >> (istream& istr, pair<_KTy, _Ty>& m) { cin >> m.first >> m.second; return istr; }
template <typename _Ty> istream& operator >> (istream& istr, vector<_Ty>& v) { for (size_t i = 0; i < v.size(); i++) cin >> v[i]; return istr; }
ll modpow(ll n, ll p, ll m) { ll result = 1; while (p > 0) { if (p & 1) result = (result * n) % m; p >>= 1; n = (n * n) % m; } return result; }
template <typename _Ty> _Ty ipow(_Ty x, _Ty n) { _Ty ret = _Ty(1); for (_Ty i = _Ty(0); i < n; i++) ret *= x; return ret; }
#define PI 3.14159265358979323846
#define EPS 1e-8
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define all(x) (x).begin(), (x).end()
#define fake false




int main()
{
	//clock_t start, end;
	//start = clock();

	string S;
	while (true) {
		cin >> S;
		if (S == "0") break;

		int sum = 0;
		for (int i = 0; i < S.size(); i++) {
			sum += (S[i] - '0');
		}
		cout << sum << endl;
	}

	//end = clock();
	//printf("%d msec.\n", end - start);

	return 0;
}



Measured memory_bytes: 3140
#include <bits/stdc++.h>
using namespace std;
int main(){
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(0);
	int n, k; cin >> n >> k;
    string s; cin >> s;

    int g=0;
    for(int i=0; i<n-1; ++i){
        if(s[i]!=s[i+1]) ++g;
    }
    
    int ans=n-1-g+2*min({k,g/2});
    if(k-g/2>0 && g%2==1) ++ans;
    cout << ans << endl;
}

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

using ll=long long; 

void solve(){
	int n;
	cin>>n;
	int x;
	cin>>x;
	vector<int> m(n);
	for(int i=0; i<n; i++)cin>>m[i];
	int ans=n;
	int sum=accumulate(m.begin(), m.end(), 0);
	x-=sum;
	ans+=(x/(*min_element(m.begin(), m.end())));
	cout<<ans<<endl;
}

signed main(){
	//while(1)
	solve();
}

Measured memory_bytes: 256
using namespace std;
#include<bits/stdc++.h>
#define BEGIN ios_base::sync_with_stdio(0);cin.tie(0);
#define END return EXIT_SUCCESS;
#define FOR(I,A,B) for((I)=(A);(I)<(B);(I)++)
#define REP(I,N) FOR((I),0,(N))
#define UP(I,A,B) for((I)=(A);(I)<=(B);(I)++)
#define DW(I,A,B) for((I)=(A);(I)>=(B);(I)--)
#define IN(P) cin>>(P)
#define IN2(P1,P2) cin>>(P1)>>(P2)
#define IN3(P1,P2,P3) cin>>(P1)>>(P2)>>(P3)
#define INS(I,N,V) REP((I),(N)) cin>>(V[I])
#define INS2(I,N,V1,V2) REP((I),(N)) cin>>(V1[I])>>(V2[I]);
#define INS3(I,N,V1,V2,V3) REP((I),(N)) cin>>(V1[I])>>(V2[I])>>(V3[I]);
#define OUT(P) cout<<(P)<<endl
#define OUT2(P1,P2) cout<<(P1)<<" "<<(P2)<<endl
#define OUT3(P1,P2,P3) cout<<(P1)<<" "<<(P2)<<" "<<(P3)<<endl
#define OUTS(I,N,V) REP((I),(N)) cout<<(V[i])<<endl
#define ALL(C) (C).begin(),(C).end()
#define RALL(C) (C).rbegin(),(C).rend()
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}

int H,W,i;
string a[100];
inline void solve(){
  IN2(H,W);
  INS(i,H,a);
  REP(i,W+2)cout<<"#";
  cout<<endl;
  REP(i,H)cout<<"#"<<a[i]<<"#"<<endl;
  REP(i,W+2)cout<<"#";
  cout<<endl;
}

int main(int argc,char**argv){
  BEGIN
  solve();
  END
}


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

const int MAXN = 305;
bool dp[100005][2];
int a[MAXN],n;

int dfs(int k,int t)
{
    if(dp[k][t]>0)return dp[k][t];
    int ans = 0 ;
    for(int i=1;i<=n;i++)
    {
        if(k>=a[i]) ans |= !dfs(k-a[i],!t);
    }
    return dp[k][t] = ans;
}

int main()
{
    int k;
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
    }
    if(dfs(k,0)==false) printf("Second\n");
    else printf("First\n");
    return 0;

}


Measured memory_bytes: 5120
A = input()
B = input()
C = input()
D = input()
E = input()


l = [A, B, C, D, E]
l2 = list()

# check min 1 keta

m = -1

for x in l:
    t = int(x) % 10
    if t == 0:
        l2.append(int(x))
    else:
        l2.append((int(x) + 10) // 10 * 10)

l3 = [int(x) % 10 for x in l]
l3 = [x for x in l3 if x != 0]

if len(l3) == 0:
    print(sum(l2))
else:
    print(sum(l2) - 10 + min(l3))

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

}


Measured memory_bytes: 3588
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
class JNum{
	static constexpr uint64_t mod = 1000000007;
	uint64_t num;
public:
	JNum(uint64_t x):num(x%mod){}
	JNum operator+(const JNum& j)const{
		return (num + j.num)%mod;
	}
	JNum operator*(const JNum& j)const{
		return (num * j.num)%mod;
	}
	void operator+=(const JNum& j){
		num += j.num;
		num %= mod;
	}
	void operator*=(const JNum& j){
		num *= j.num;
		num %=mod;
	}
	uint64_t out()const{return num;}
};
using namespace std;
template<typename T>
void get(T& t){cin >> t;}
int main(void){
	int N,M,K;
	get(N);get(M);get(K);
	for(int i=0;i<=N;i++){
		for(int j=0;j<=M;j++){
			int black=i*M + j * N - 2 * j * i;
			if(black == K){cout<<"Yes"<<endl;exit(0);}
		}
	}
	cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
#define sz(x) x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define V vector<int>
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;
}

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 50;

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))

int n, m;
bool G[210][210];
int res = 0;
V comp;
bool seen[210];

void dfs(int v) {
	seen[v] = true;
	rep(nv, n) {
		if (seen[nv] || !G[v][nv])continue;
		dfs(nv);
	}
	comp.push_back(v);
}

bool check(V cp) {
	int v = cp.size();
	int E = 0;
	rep(i, cp.size()) {
		rep(j, cp.size()) {
			if (i == j)continue;
			if (G[cp[i]][cp[j]])E++;
		}
	}
	if (E / 2 == v - 1)return true;
	else return false;
}

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	V a(n); rep(i, n)cin >> a[i];
	int now = 0;
	rep(i, n) {
		now ^= a[i];
	}
	if ((now^now) == now)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 1024
import java.io.*;
import java.util.*;
public class Main {
   public static void main(String args[]) {
       int n = 0;
       int w = 0;
       int CULS = 2;
       int[][] arr = null;
       try (Scanner scanner = new Scanner(System.in)) {
           n = scanner.nextInt();
           w = scanner.nextInt();
           arr = new int[n][CULS];
           for (int i=0; i < n; i++) {
               for(int j = 0; j < CULS; j++) 
                arr[i][j] = scanner.nextInt();
           }
       }
       long[][] dp = new long[n + 1][w +1];
       for(int i = 1; i <= n; i++) {
           for(int j = 1; j <= w; j++) {
               dp[i][j] =dp[i-1][j];
               if(j - arr[i - 1][0] >= 0)
                    dp[i][j] = Math.max(dp[i][j], dp[i-1][j - arr[i - 1][0]] + arr[i - 1][1]);
           }
       }
       System.out.println(dp[n][w]);
   }
}

Measured memory_bytes: 127444
#include <iostream>
#include <vector>
#include <algorithm>
#include <tuple>

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<long long> score(n);
    long long ans = 0;
    for(auto&& i : score){
        long long a, b;
        cin >> a >> b;
        ans -= b;
        i = a + b;
    }
    sort(rbegin(score), rend(score));
    for(int i = 0; i < n; i += 2){
        ans += score[i];
    }
    cout << ans << "\n";
}

Measured memory_bytes: 1024
import sys
import numpy as np


def weight(n, hh):
    if n == 1:
        return 0
    if n == 2:
        return np.abs(hh[1] - hh[0])
    if n == 3:
        return min(np.abs(hh[2] - hh[1]) + np.abs(hh[1]-hh[0]), np.abs(hh[2] - hh[0]))
    else:
        weights = np.zeros(n).astype(int)
        weights[0] = 0
        weights[1] = np.abs(hh[1] - hh[0])
        weights[2] = min(np.abs(hh[2] - hh[1]) + np.abs(hh[1] - hh[0]), np.abs(hh[2] - hh[0]))

        for k in range(3, n):
          weights[k] = min(weights[k-2] + np.abs(hh[k] - hh[k-2]), weights[k-1]+ np.abs(hh[k] - hh[k-1]))
        return weights[n-1]


n = int(input())
svals = input()
hh = np.array(list(map(int, svals.rstrip(' ').split(' '))))
print(weight(n, hh))


Measured memory_bytes: 38776
from decimal import Decimal
from math import pi, atan
a,b,x = map(Decimal, input().split())

thre = a*a*b / Decimal(2.0)
if x >= thre:
    d = 2*b - 2*x / (a*a)
    theta = 180.0 / pi * atan(d / a)
    print(theta)
else:
    d = 2* x / (a*b)
    theta = 180.0 / pi * atan(b / d)
    print(theta)


Measured memory_bytes: 5076
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<string>
#include<unordered_map>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j,k
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define sort(a) sort(a.begin(),a.end())
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define sizeoof(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
ll ans=0;llfor;///////////////////////////////////////////////////////////
int main(){
 ll w,s,t;
 sc(w);sc(s);sc(t);
 ll a=min(s,t);ll b=max(s,t);
 ans=min(abs(b+w-a),abs(b-a-w));
 
 if(b<=a+w&&a<=b+w)ans=0;
 pr(ans);
return 0;}

Measured memory_bytes: 3612
#include <bits/stdc++.h> 
using namespace std;
#define ll long long 
#define f(i, a, b) for(ll i=a;i<b;i++)
#define fi(i, a, b) for(ll i=b-1;i>=a;i--)
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define ml map<ll,ll> 
#define pll pair<ll,ll>

const ll M = (ll)(1e9 +7);
 
vector<vl> mul(vector<vl> m1, vector<vl>m2)
{
   ll n = m1[0].size();
   vector<vl> ans(n,vl(n,0));
   f(i,0,n)
   f(j,0,n)
   f(k,0,n)
   {
      ans[i][j]+=(m1[i][k]*m2[k][j]);
      ans[i][j]%=M;
   }

   return ans;
}

vector<vl> pow(vector<vl> mat, ll k)
{
   if(k==1)
   return mat;

   ll r = k/2;
   ll n = mat[0].size();

   vector<vl> m1 = pow(mat,r);
   m1 = mul(m1,m1);
   if(k%2==1)
   {
      m1 = mul(m1,mat);
   }
   // cout<<k<<"\n";
   // f(i,0,n)
   // f(j,0,n)cout<<m1[i][j];
   // cout<<"\n";

   return m1;
}


void solve()
{
   ll n,k;
   cin>>n>>k;
   vector<vector<ll>> mat(n,vector<ll>(n));
   f(i,0,n)
   f(j,0,n)cin>>mat[i][j];

   vector<vl> ans = pow(mat,k);
   ll num=0;
   f(i,0,n)
   f(j,0,n)
   {
      num+=ans[i][j];
      num%=M;
   }
   cout<<num<<"\n";

}

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

Measured memory_bytes: 1664
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))


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

    int n;
    cin >> n;

    vs64 dp(n, 0);
    rep (i, n - 1)
    {
        int a, b;
        cin >> a >> b;
        --a, --b;
        if (a > b) swap(a, b);
        dp[b] -= a + 1;
    }

    dp[0] = 1;
    s64 ans = dp[0];
    for (int i = 1; i < n; ++i)
    {
        dp[i] += dp[i - 1] + i + 1;
        ans += dp[i];
    }

    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 4764
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
const array<pair<int,int>,4> fd{make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

int main(){
  int n;cin>>n;int c[500], s[500], f[500];rep(i,n-1)cin>>c[i]>>s[i]>>f[i];
  rep(i,n){
    int time = 0;
    repd(j,i,n-1){
      repd(k,time,INF){
        if(k >= s[j] && k%f[j] == 0){
          time = k+c[j];
          break;
        }
      }
    }
    cout << time << endl;
  } 
}


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

namespace AtC
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            long N = long.Parse(str[0]);
            long M = long.Parse(str[1]);
            string[] str2 = Console.ReadLine().Split(' ');
            long[] A = new long[N];
            for (long i = 0; i < N; i++) A[i] = long.Parse(str2[i]);
            long[] B = new long[M];
            long[] C = new long[M];
            for(long i = 0; i < M; i++)
            {
                string[] str3 = Console.ReadLine().Split(' ');
                B[i] = long.Parse(str3[0]);
                C[i] = long.Parse(str3[1]);
            }

            Array.Sort(A);
            Array.Sort(C,B);
            Array.Reverse(B);
            Array.Reverse(C);

            long cnum = C[0];
            long bnum = B[0];
            long countA = 0;
            long countBC = 0;
            while (true)
            {
                if (cnum > A[countA])
                {
                    A[countA] = cnum;
                    countA++;
                    bnum--;
                }
                else break;

                if (countA == N) break;

                if(bnum == 0)
                {
                    countBC++;
                    if (countBC == M) break;
                    bnum = B[countBC];
                    cnum = C[countBC];
                }
            }

            //for (long i = 0; i < N; i++)  Console.WriteLine(A[i]);
            long ans = 0;
            for (long i = 0; i < N; i++) ans += A[i];
            Console.WriteLine(ans);
            Console.ReadLine();
        }
        private static void Change(long[] array, long a, long b)
        {
            long tmp = array[a];
            array[a] = array[b];
            array[b] = tmp;
        }
    }
}


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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 1005

int n;

int main()
{
    _FastIO;
    int k;
    cin >> k;
    string s;
    cin >> s;
    n = s.size();
    for(int i = 0; i < min(n , k); i++){
        cout << s[i];
    }
    if(k < n)
        cout << "...";
    return 0;
}


Measured memory_bytes: 3652
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<vector>
 
using namespace std;
int MOD=1000000007;

int main(){
    int N,K,ans=0;
    cin >> N >> K;
    int A[N+10]={};
    for(int i=0; i<N; i++){
        int x; cin >> x;
     A[x]++;
    }
    sort(A,A+N,greater<int>());
    for(int i=K; i<=N; i++){
        ans+=A[i];
    }
    cout << ans << endl;
	}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>
#include<functional>
#include<vector>
#include<set>
#include<queue>
#include<list>
#include<stdio.h>
#include<stdlib.h>
#include<map>
#include<cstdio>
#include <iomanip>

#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

typedef long long ll;

using namespace std;

bool getNumOfDivsor(int N) {
	
	int ans = 0;

	for (int i = 1; i*i< N; ++i) {
		if (N%i == 0) {
			ans += 2;
		}
	}

	return ans==8;

}

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

	int ans = 0;
	for (int i = 1; i <= n; i+=2) {
		if (getNumOfDivsor(i)) {
			++ans;
		}
	}

	cout << ans << endl;

	return 0;

}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

// topologically sort the directed graph
// 0-indexed

struct TopologicalSort {
    int n;
    vector<set<int>> G;
    vector<bool> used;
    vector<int> indeg, p;

    TopologicalSort(int size) : n(size), G(n), used(n), indeg(n), p(0) {}

    void addEdge(int s, int t) { G[s].insert(t); }
    void bfs(int s) {
        queue<int> q;
        q.push(s);
        used[s] = 1;
        while (!q.empty()) {
            int v = q.front();
            q.pop();
            p.push_back(v);
            for (int u : G[v]) {
                indeg[u]--;
                if (indeg[u] == 0 && !used[u]) {
                    used[u] = 1;
                    q.push(u);
                }
            }
        }
    }
    // returns topologically sorted nodes
    vector<int> build() {
        fill(used.begin(), used.end(), 0);
        fill(indeg.begin(), indeg.end(), 0);
        for (int i = 0; i < n; ++i) {
            for (int v : G[i])
                indeg[v]++;
        }
        for (int i = 0; i < n; ++i) {
            if (indeg[i] == 0 && !used[i])
                bfs(i);
        }
        return p;
    }
};

int main() {
    int n, m;
    cin >> n >> m;
    string s;
    cin >> s;
    TopologicalSort tp(4 * n);
    vector<vector<int>> edges(4 * n);
    for (int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        if (s[a] == 'A' && s[b] == 'A') {
            tp.addEdge(a, b + n);
            tp.addEdge(b, a + n);
        } else if (s[a] == 'A' && s[b] == 'B') {
            tp.addEdge(a + n, b + 2 * n);
            tp.addEdge(b + 3 * n, a);
        } else if (s[a] == 'B' && s[b] == 'A') {
            tp.addEdge(b + n, a + 2 * n);
            tp.addEdge(a + 3 * n, b);
        } else if (s[a] == 'B' && s[b] == 'B') {
            tp.addEdge(a + 2 * n, b + 3 * n);
            tp.addEdge(b + 2 * n, a + 3 * n);
        }
    }
    auto sorted = tp.build();
    if (sorted.size() == 4 * n)
        cout << "No"
             << "\n";
    else
        cout << "Yes"
             << "\n";
    return 0;
}

Measured memory_bytes: 80880
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));
		int n = Integer.parseInt(br.readLine());
		int[][] tower1 = {{0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0}};
		int[][] tower2 = {{0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0}};
		int[][] tower3 = {{0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0}};
		int[][] tower4 = {{0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0}};
		for (int i = 0; i < n; i++) {
			int[] line = convertInt(br.readLine().split(" "));
			switch (line[0]) {
				case 1:
					tower1[line[1] - 1][line[2] - 1] += line[3];
					break;
				case 2:
					tower2[line[1] - 1][line[2] - 1] += line[3];
					break;
				case 3:
					tower3[line[1] - 1][line[2] - 1] += line[3];
					break;
				case 4:
					tower4[line[1] - 1][line[2] - 1] += line[3];
					break;
			}
		}
		print(tower1);
		System.out.println("####################");
		print(tower2);
		System.out.println("####################");
		print(tower3);
		System.out.println("####################");
		print(tower4);
	}

	private static void print(int[][] two_array) {
		int cnt = 0;
		for (int[] array : two_array) {
			for (int i : array) {
				cnt++;
				System.out.print(" " + i);
			}
			System.out.println("");
		}
	}

	private static int[] convertInt(String[] strArray) {
		int len = strArray.length;
		int[] intArray = new int[len];
		for (int i = 0; i < len; i++) {
			intArray[i] = Integer.parseInt(strArray[i]);
		}
		return intArray;
	}
}

Measured memory_bytes: 24808
S = list(str(input()))
flgA = 0
flgB = 0
for i in range(3):
    if S[i] == 'A':
        flgA = 1
    elif S[i] == 'B':
        flgB =1

if flgA == 1 and flgB ==1:
    print('Yes')
else:
    print('No')


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


void solve(long long n, std::vector<long long> p){
    int cnt = 0;
    for(int i = 1;i < n-1;i++){
        if((p[i-1] > p[i] && p[i] > p[i+1]) || (p[i-1] < p[i] && p[i] < p[i+1])){
            cnt++;
        }
    }
    cout<<cnt<<endl;
}

int main(){
    long long n;
    scanf("%lld",&n);
    std::vector<long long> p(n);
    for(int i = 0 ; i < n ; i++){
        scanf("%lld",&p[i]);
    }
    solve(n, std::move(p));
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
// #include <limits>
//auto std::numeric_limits<float>::infinity() { return __builtin_huge_valf(); }
using namespace std;

int main()
{
    //A
    /*
    string S;
    cin >> S;
    if (S == "AAA" || S == "BBB")
        cout << "No" << endl;
    else
        cout << "Yes" << endl;
        */
    //B?
    /*
    long long N, A, B, C;
    cin >> N >> A >> B;
    if (N <= A)
        cout << N << endl;
    else if (A == 0)
        cout << 0 << endl;
    else
    {
        C = N / (A + B);
        cout << C << endl;
        if (N - (A + B) * C <= A)
            cout << A * C + N - (A + B) << endl;
        else
            cout << A * (C + 1) << endl;
    }
    */
    //C
    /*
    int A, B;
    cin >> A >> B;
    float c;
    c = A / 0.08;
    if ((int)(10 * c) % 10 == 0)
    {
        if (floor(c * 0.1) == B)
        {
            cout << (int)c << endl;
        }
        else
            cout << -1 << endl;
    }
    else
    {
        if (floor((c + 1) * 0.1) == B)
            cout << (int)c << endl;
        else
            cout << -1 << endl;
    }
    */
    //Cやり直し
    int A, B;
    cin >> A >> B;
    for (int i = 1; i <= 1009; i++)
    {
        if (int(i * 0.08) == A && int(i * 0.1) == B)
        {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}


Measured memory_bytes: 384
//#include<bits/stdc++.h>
#include<set>
#include<map>
#include<list>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<complex>
#include<sstream>
#include<iostream>
#include<fstream>
#include<algorithm>
#include<numeric>
#include<utility>
#include<functional>
#include<stdio.h>
#include<assert.h>
#include<memory.h>
#include<bitset>
#include<stdio.h>
#include <cstdio>
#include <cstring>
#include <string>


using namespace std;

#define ld long double
#define ll long long
#define ff first
#define ss second
#define sz(a) (int)a.size()
#define mem(a, b) memset((a), (b), sizeof(a))
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define pii pair<int ,int >
#define pll pair<ll ,ll >
#define mp make_pair
#define vi vector<int >
#define vii vector<pii>
#define vvi vector < vi >
#define vll vector < ll >
#define vllll vector < pll >
#define vvll vector < vll >
#define forn(i,n) for(int i=0;i<(n);i++)
#define fori(i,s,e) for(int i=s,i<n;i++)
#define qi  queue <int >
#define qll  queue <ll >
#define in_r(x,y,n,m) (x>=0 && x<n && y>=0 && y<m)
#define maxn 1000009


void fast(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
}

const ll MOD = 1e9 + 7;
const double EPS = (1e-8);
const int OO = (int) 1e9 + 7;
const ll OOO = (ll) 1e15 + 7;
double const PI = 3.1415926535897932384626433832795;
const int mxn = 100009;
char c1, c2, c3, c4;
string s, s1, s2, s3;
ll   n, m, k, t, q, a, b, c, d, e, x, y, z; ll sol = 0;




int main(){
	fast();
	

	cin >> s >> s1;
	n = sz(s);
	m = sz(s1);
	if (m != n + 1) return cout << "No\n",0;
	for (int i = 0; i < n; i++) if (s[i] != s1[i]) return cout << "No\n", 0;
	cout << "Yes";

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


Measured memory_bytes: 3656
#include<iostream>
using namespace std;
int main()
{
   
    int a;
    cin >> a;
    
    int b;
    cin >> b;
    int c ;
    cin >> c;
    int d;
    d=a-b;
    
    while(d>=c){
    d=d-c;
    }
    
    
    cout << d << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        String answer = ""; //何も入れない場合でも""を付けないといけない
        int length = line.length();
        char a;
        for(int i=0; i<length; i++){
            a = line.charAt(i);  //文字列名.charAt(i)は文字列のi番目の文字を引っ張ってくる
            if(Character.isLowerCase(a) == true){   //文字aが小文字ならtrueを返す関数。==は省略可能
                answer += Character.toUpperCase(a);
            }else{
                answer += Character.toLowerCase(a);
            }
        }
        System.out.println(answer);
        sc.close();
    }
}


Measured memory_bytes: 31348
s = input()
K = int(input())

cnt = 0
tmp = 0
lst = []
tmp_s = "zzz"

if(len(s)>= 5):
    for i in range(len(s)-4):
        if(tmp_s >= s[i:(i+5)]):
            tmp_s = s[i:(i+5)]

    for j in range(len(tmp_s)):
        for k in range(j+1, len(tmp_s)+1):
            if(tmp_s[j:k] not in lst):
                lst.append(tmp_s[j:k])
        
    lst.sort()
    print(lst[K-1])
else:
    for i in range(len(s)):
        for j in range(i+1, len(s)+1):
            if(s[i:j] not in lst):
                lst.append(s[i:j])
    lst.sort()
    print(lst[K-1])

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

void solve(int n){
    int m=2*n+5;
    vector<int> isprime(m,1);
    isprime[0]=isprime[1]=false;
    int ans=0;
    rep(i,m){
        if(!isprime[i])continue;
        if(i>n&&i<=2*n)++ans;
        for(int j=2*i;j<m;j+=i)isprime[j]=false;
    }
    cout<<ans<<endl;
}
int main(){
    int n;
    while(cin>>n,n!=0)solve(n);
    return 0;
}


Measured memory_bytes: 4284
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>

using namespace std;

/////////////         modの計算

int mod = 1000000007;

long long mod_adjust(long long a) {//	余りをとる(0～mod-1に調整する)
	if (a > mod) {
		return a % mod;
	}
	if (a < 0) {
		a *= -1;
		a %= mod;
		return mod - a;
	}
	return a;
}
int mod_adjust(int a) {//	余りをとる(0～mod-1に調整する)
	return (int)mod_adjust((long long)a);
}
int mod_add(int a, int b) {//	足し算
	a = mod_adjust(a), b = mod_adjust(b);
	long long k = a % mod; k += b % mod; k %= mod;
	return (int)k;
}
int mod_sub(int a, int b) {//	引き算
	return mod_add(a, -b);
}
int mod_multi(int a, int b) {//	掛け算
	long long k = mod_adjust((long long)a); k *= mod_adjust((long long)b); k %= mod;
	return (int)k;
}

int main() {
	int N, M; cin >> N >> M;

	bool* a = new bool[N];
	for (int i = 0; i < N; i++) {
		a[i] = false;
	}
	for (int i = 0; i < M; i++) {
		int x; cin >> x;
		a[x] = true;
	}

	long* dp = new long[N + 1];
	dp[0] = 1;
	for (int i = 1; i <= N; i++) {
		if (a[i] == true) { dp[i] = 0; continue; }
		dp[i] = dp[i - 1];
		if (i > 1) { dp[i] = mod_add(dp[i], dp[i - 2]); }
	}

	cout << dp[N] << endl;
	return 0;
}


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

int main(){
	int n=0,m=0;
	
	cin >> n >> m;
	int A[n+1][m+1];
	int b[m+1];
	int c[n+1];

//?????????
	for(int k=1;k<=m;k++){
		for(int i=1;i<=n;i++){
			A[i][k]=0;
		}
	}
	for(int k=1;k<=m;k++){
		b[k]=0;
	}
	for(int i=1;i<=n;i++){
		c[i]=0;
	}
	

	for(int i=1;i<=n;i++){
		for(int k=1;k<=m;k++){
			cin >> A[i][k];
		}
	}

	for(int i=1;i<=m;i++){
		cin >> b[i];
	}

	for(int i=1;i<=n;i++){
		for(int k=1;k<=m;k++){
			c[i] += A[i][k]*b[k];
		}
	}

//?¢??????¨
	// for(int i=1;i<=n;i++){
	// 	for(int k=1;k<=m;k++){
	// 		cout << A[i][k] << " ";
	// 	}
	// 	cout << endl;
	// }
	// for(int i=1;i<=n;i++){
	// 	cout << b[i] << endl;
	// }
	for(int i=1;i<=n;i++){
		cout << c[i] << endl;
	}




return 0;
}

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

int main() {
  long X,a,b,ans;
  cin >> X;
  a = X / 500;
  b = (X - 500*a) / 5;
  ans = 1000*a + 5*b;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
using namespace std;

typedef pair < int, int > P;
priority_queue < P > que;

int data[1111111];

int solve(int a, int b){

  data[a] += b;
  que.push( P(data[a], -a) );

  for(;;){
    a = -que.top().S;
    b = que.top().F;

    if(b == data[a]) break;
    que.pop();
  }
  
  cout << a << " " << b << endl;
}

int main(){

  int n, q, a, b;
  cin >> n >> q;

  for(;q--;){
    cin >> a >> b;
    solve(a, b);
  }

}

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

int main()
{
    int s;
    cin>>s;
    set<int> kishyutsu;
    int ai = s;
    kishyutsu.insert(ai);
    int m;
    for (int i = 1; i < 1000001; i++)
    {
        if (ai % 2 == 0)
        {
            ai = ai / 2;
        }
        else
        {
            ai = 3 * ai + 1;
        }
        if (kishyutsu.count(ai) != 0)
        {
            m = i+1;
            break;
        }
        kishyutsu.insert(ai);
    }
    cout << m << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)


char op2char(int op) {
  if (op == 1)
    return '+';
  return '-';
}
int main() {
  int A, B, C, D;
  char c[4];
  REP(i, 4) {
    cin >> c[i];
  }
  A = (int)(c[0] - '0');
  B = (int)(c[1] - '0');
  C = (int)(c[2] - '0');
  D = (int)(c[3] - '0');

  REP(i, 2) {
    int op1 = -2*i+1;
    REP(j, 2) {
      int op2 = -2*j+1;
      REP(k, 2) {
        int op3 = -2*k+1;
        if (A + (op1 * B) + (op2 * C) + (op3 * D) == 7) {
          cout << A << op2char(op1) << B << op2char(op2) << C << op2char(op3) << D << "=7" << endl;
          return 0;
        }
      }
    }
  }
  return 0;
}




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

using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;

struct Trie {
    Trie *next[2];

    Trie() { next[0] = next[1] = NULL; }
};

void insert(const char *s, Trie *t) {
    for (int i = 0; s[i]; i++) {
        int c = s[i] - '0';
        if (!t->next[c]) t->next[c] = new Trie;
        t = t->next[c];
    }
}

vector<ll> g;
int N;
ll L;

void calc(Trie *t, int d) {
    int cnt = 0;
    if (t->next[0] != NULL) {
        calc(t->next[0], d + 1);
        cnt++;
    }
    if (t->next[1] != NULL) {
        calc(t->next[1], d + 1);
        cnt++;
    }
    if (cnt == 1 && L - d > 0) {
        ll sz = L - d;
        int k = 0;
        while (sz % 2 == 0) {
            sz /= 2;
            k++;
        }
        g.push_back(1LL << k);
    }
}

int main() {
    cin >> N >> L;
    Trie *t = new Trie;
    for (int i = 0; i < N; i++) {
        string s;
        cin >> s;
        insert(s.c_str(), t);
    }
    calc(t, 0);
    ll ans = 0;
    for (int i = 0; i < g.size(); i++) {
        ans ^= g[i];
    }
    if (ans == 0) {
        cout << "Bob" << endl;
    } else {
        cout << "Alice" << endl;
    }
}

Measured memory_bytes: 9276
import java.io.*;
import java.math.*;
import java.util.*;
public class Main {
	public static void main(String[] args) { 
		/*
		 * */
		FastScanner I = new FastScanner(); //Input
		OutPut O = new OutPut(); //Output
		int N = I.nextInt();
		int[][] a = new int[N][2];
		for (int i = 0; i < N; i++) {
			a[i][0] = I.nextInt();
			a[i][1] = I.nextInt();
		}
		boolean good=false;
		for (int i = 0; i < N; i++) {
			int cnt = 0;
			for (int j = i; j < min(i+3,N); j++) {
				if (a[j][0]==a[j][1]) cnt++;
			}
			if (cnt==3) good=true;
		}
		O.pln(good?"Yes":"No");
	}
	public static double max(double a, double b) {return Math.max(a, b);}
	public static double min(double a, double b) {return Math.min(a, b);}
	public static long min(long a, long b) {return Math.min(a,b);}
	public static long max(long a, long b) {return Math.max(a,b);}
	public static int min(int a, int b) {return Math.min(a,b);}
	public static int max(int a, int b) {return Math.max(a,b);}
	public static long abs(long x) {return Math.abs(x);}
	public static long ceil(long num, long den) {long ans = num/den; if (num%den!=0) 
	ans++; return ans;}
	public static long GCD(long a, long b) {
		if (a==0||b==0) return max(a,b);
		return GCD(min(a,b),max(a,b)%min(a,b));
	}
	public static long FastExp(long base, long exp, long mod) {
		long ans=1;
		while (exp>0) {
			if (exp%2==1) ans*=base;
			exp/=2;
			base*=base;
			base%=mod;
			ans%=mod;
		}
		return ans;
	}
	public static long ModInv(long num,long mod) {return FastExp(num,mod-2,mod);}
	public static int pop(long x) { //Returns number of bits within a number
		int cnt = 0;
		while (x>0) {
			if (x%2==1) cnt++;
			x/=2;
		}
		return cnt;
	}
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		int nextInt() {return Integer.parseInt(next());}
		long nextLong() {return Long.parseLong(next());};
		double nextDouble() {return Double.parseDouble(next());}
	}
	static class OutPut{
		PrintWriter w = new PrintWriter(System.out);
		void pln(double x) {w.println(x);w.flush();}
		void pln(boolean x) {w.println(x);w.flush();}
		void pln(int x) {w.println(x);w.flush();}
		void pln(long x) {w.println(x);w.flush();}
		void pln(String x) {w.println(x);w.flush();}
		void pln(char x) {w.println(x);w.flush();}
		void pln(StringBuilder x) {w.println(x);w.flush();}
		void pln(BigInteger x) {w.println(x);w.flush();}
		void p(int x) {w.print(x);w.flush();}
		void p(long x) {w.print(x);w.flush();}
		void p(String x) {w.print(x);w.flush();}
		void p(char x) {w.print(x);w.flush();}
		void p(StringBuilder x) {w.print(x);w.flush();}
		void p(BigInteger x) {w.print(x);w.flush();}
		void p(double x) {w.print(x);w.flush();}
		void p(boolean x) {w.print(x);w.flush();}
	}
}

Measured memory_bytes: 25716
#include <bits/stdc++.h>
#include <vector>
#include <queue>
#include <set>
#include <iostream>
#include <iomanip>
using namespace std;
typedef long long LL;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)

int main(){
    int N;
    cin >> N;
    vector<LL> A(N);
    REP(i,N)cin>>A[i];

    sort(A.begin(), A.end(), greater<LL>());

    LL W = -1;
    LL H = -1;
    bool isWfixed = false;
    FOR(i,1,N){
        if(A[i] == A[i-1] && isWfixed==false){
            W = A[i];
            isWfixed = true;
            i++;
            continue;
        }

        if(A[i] == A[i-1] && isWfixed==true){
            H = A[i];
            break;
        }
    }

    LL S = W*H;
    if(W<0 || H<0){
        cout << 0 << endl;
    }else{
        cout << S << endl;
    }

    return 0;


}

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

int main(){
  int A, B;
  cin >> A >> B;
  
  if (A <= 5){
    cout << 0 << endl;
  }
  else if (6 <= A && A <= 12){
    cout << B / 2 << endl;
  }
  else{
    cout << B << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s, t;
    cin >> s >> t;
    for (int i = 0; i < s.length(); i++)
        if (s[i] != t[i] && cout << "No\n")
            return 0;
    cout << "Yes\n";
    return 0;
}

Measured memory_bytes: 3596
import sys
from bisect import bisect_left
sys.setrecursionlimit(1000000)
INF = pow(10, 10)

changed = []
input = sys.stdin.readline
N = int(input())
A = [int(a) for a in input().split()]
Edge = [[] for _ in range(N)]
for _ in range(N-1):
    u, v = map(int, input().split())
    Edge[u-1].append(v-1)
    Edge[v-1].append(u-1)
LIS = [INF] * N

def dfs(i, pre, Ans):
    changeID = bisect_left(LIS, A[i])
    changed.append((changeID, LIS[changeID]))
    LIS[changeID] = min(A[i], LIS[changeID])
    #print(i, LIS)
    #print(changed)
    Ans[i] = bisect_left(LIS, INF) 
    for nextN in Edge[i]:
        if nextN != pre: dfs(nextN, i, Ans)
    backID, backV = changed.pop()
    LIS[backID] = backV
    return 0

def solve():
    Ans = [1] * N
    dfs(0, 0, Ans)
    print("\n".join(map(str, Ans)))
    
    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 237776