akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std ;
const int N = 1234567;
vector <pair<int,int> > G[N] ;
vector <int> newg[N] ;
queue <int> q ;
int f[N],son[N],id[N],dp[N] ;
bool use[N] ;
int n,m ;
inline void init(int i){
    f[i]=i;son[i]=0;id[i]=-1;use[i]=false ;
}
int find(int x){
    return (x==f[x])?x:f[x]=find(f[x]) ; 
}
inline void merge(int x,int y){
    int X=find(x),Y=find(y) ;
    if (X==Y) return ;
    if (son[X]<son[Y]) f[X]=Y ;//避免WA?RE? 小技巧 
    else {
        f[Y]=X ;
        if (son[X]==son[Y]) son[X]++ ;
    }
} 
inline int read(){
    char c;int f=1 ;
    while ((c=getchar())<'0' || c>'9') if (c=='-') f=-1 ;
    int res=c-'0' ;
    while ((c=getchar())>='0' && c<='9') res=res*10+c-'0' ;
    return res*f ; 
}
int main(){
    n=read();m=read() ;
    for (int i=1;i<=m;i++){
        int a,b,c ;
        a=read();b=read();c=read() ;
        G[c].push_back(make_pair(a,b)) ;
    }
    int cnt=n; 
    for (int i=1;i<=N;i++){
        if (G[i].empty()) continue ; //无该公司 
        for (int j=0;j<G[i].size();j++){ //初始 
            init(G[i][j].first) ;
            init(G[i][j].second) ;
        }
        for (int j=0;j<G[i].size();j++) merge(G[i][j].first,G[i][j].second) ;
        for (int j=0;j<G[i].size();j++){
            if (!use[G[i][j].first]){
                use[G[i][j].first]=true ;
                int X=find(G[i][j].first) ;
                if (id[X]==-1) id[X]=++cnt ;
                newg[G[i][j].first].push_back(id[X]) ;//该站点与公司建无向边 
                newg[id[X]].push_back(G[i][j].first) ;
            }
            if (!use[G[i][j].second]){ //同样的工作在second上再做一遍 
                use[G[i][j].second]=true ;
                int X=find(G[i][j].second) ;
                if (id[X]==-1) id[X]=++cnt ;
                newg[G[i][j].second].push_back(id[X]) ;
                newg[id[X]].push_back(G[i][j].second) ;
            }
        }
    }
    q.push(1) ;
    memset(dp,-1,sizeof(dp)) ;
    dp[1]=0; //初始在0号节点
    while(!q.empty()){ //BFS 
        int v=q.front();q.pop() ;
        for (int i=0;i<newg[v].size();i++){
            int to=newg[v][i] ;
            if (dp[to]==-1){ //还没访问 
                dp[to]=dp[v]+1 ;
                q.push(to) ;
            }
        }
    }
    if (dp[n]==-1) cout<<-1 ;
    else cout<<dp[n]/2 ;
    return 0;
}

Measured memory_bytes: 85376
def abc():
    arr=input()
    num=[int(n) for n in arr.split()]
    sum=0
    if(num[3]<=num[0]):
        sum=num[3]
    elif(num[3]>num[0] and num[3]<=num[1]):
        sum=num[0]
    elif(num[3]>num[1]):
        sum=num[0]-(num[3]-num[0]-num[1])
    print(sum)
abc()


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

using namespace std;

//#define DEBUG

#ifdef DEBUG
#define dump(i) cout << "[*] " #i " : " << i << endl;
#define debug(i) i
#else
#define dump(i)
#define debug(i)
#endif

inline void solve() {
        constexpr int MAX = 100;
        int a, b;
        cin >> a >> b;
        char grid[MAX][MAX];

        for (int i = 0; i < MAX; ++i) {
                for (int j = 0; j < MAX; ++j) {
                        grid[i][j] = i < 50 ? '.' : '#';
                }
        }

        int x = 0, y = 0;
        for (int i = 0; i < b-1; ++i) {
                grid[x][y] = '#';
                y += 2;
                if (y >= MAX) {
                        x += 2;
                        y = 0;
                }
        }

        x = MAX - 1; y = 0;
        for (int i = 0; i < a-1; ++i) {
                grid[x][y] = '.';
                y += 2;
                if (y >= MAX) {
                        x -= 2;
                        y = 0;
                }
        }

        cout << MAX << " " << MAX << endl;
        for (int i = 0; i < MAX; ++i) {
                for (int j = 0; j < MAX; ++j) {
                        cout << grid[i][j];
                }
                cout << endl;
        }
}

int main() {
        /*
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
        cout.tie(nullptr);
        //*/
#ifdef DEBUG
        clock_t _begin = clock();
#endif

        solve();

#ifdef DEBUG
        cerr << "[*] time : " << (double)(clock() - _begin) * 1000 / CLOCKS_PER_SEC << " [ms]" << endl;
#endif
        return 0;
}

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

using namespace std;

#define int long long
#define endl '\n'
#define maxn 100010
const int MOD = 1000000007;

void solve() {
    string s;
    cin >> s;

    int tp = s.size() - 8;
    cout << s.substr(0, tp);
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(a) sort(a.begin(), a.end())
#define fin(ans) cout << (ans) << endl
const int INF = 1<<30;
const ll MOD = 1000000007;

int main() {
    long long N,min=1e6,o=1e9+1;
    int a=1;
    cin >> N;
    std::map<std::string,int> salary;
    
    for (int i = 0; i < N; i++) {
        string s; cin >> s;
        salary[s]++;
    }
    
    cout << salary.size() << endl;
}

Measured memory_bytes: 19152
from bisect import bisect_left

n = int(input())
l = list(map(int, input().split()))
ans = 0

l.sort()
for i in range(n-2):
  for j in range(i+1, n-1):
    ans += bisect_left(l, l[i]+l[j]) - j - 1
print(ans)


Measured memory_bytes: 3188
#include <algorithm>
#include <climits>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>

#define int long long int
constexpr int INF = std::numeric_limits<int>::max();
constexpr int NINF = std::numeric_limits<int>::min();
using namespace std;

vector<int> calc(const string &S, char c) {
  vector<int> v(S.size() + 1, 0);
  for (int i = 0; i < S.size(); i++) {
    if (S[i] == c) {
      v[i + 1] = v[i] + 1;
    }
  }

  return v;
}

void solve() {
  string S;
  cin >> S;

  auto v = calc(S, '<');

  reverse(S.begin(), S.end());
  auto w = calc(S, '>');
  reverse(w.begin(), w.end());

  int ans = 0;
  for (int i = 0; i < v.size(); i++) {
    ans += max(v[i], w[i]);
  }
  cout << ans << endl;
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}


Measured memory_bytes: 8732
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true) {
			int n = sc.nextInt();
			if(n == 0) break;
			int []s = new int[n];
			for(int i = 0; i < n; i++) s[i] = sc.nextInt();
			int []a = ofa(s);
			int cnt = 0;
			while(!same(s, a)) {
				System.arraycopy(a, 0, s, 0, n);
				a = ofa(a);
				cnt++;
			}
			System.out.println(cnt);
			disp(s);
		}
		sc.close();
	}
	static void disp(int []a) {
		for(int i = 0; i < a.length; i++) {
			if(i == a.length - 1) {
				System.out.println(a[i]);
			}else {
				System.out.printf("%d ", a[i]);
			}
		}
	}
	static int[] ofa(int []a) {
		int l = a.length;
		int []b = new int[l];
		int []c = new int[101];
		for(int i = 0; i < l; i++) {
			c[a[i]]++;
		}
		for(int i = 0; i < l; i++) {
			b[i] = c[a[i]];
		}
		return b;
	}
	static boolean same(int []a, int []b) {
		for(int i = 0; i < a.length; i++) {
			if(a[i] != b[i]) {
				return false;
			}
		}
		return true;
	}
}


Measured memory_bytes: 35236
#include<stdio.h>
int max(int x,int y)
{
  int max=0;
  max = (x>y) ? x : y;
  return max;
}
int main()
{
  int score[2][4];
  int sum_a=0,sum_b=0;
  int i,j;
  for(i=0; i<2; i++){
       for(j=0; j<4; j++){
            scanf("%d",&score[i][j]);
            if(i==0) sum_a+=score[i][j];
            else       sum_b+=score[i][j]; 
          }
  }
 printf("%d\n",max(sum_a,sum_b)); 
return 0;
}

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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

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

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { return a * b / GCD(a, b); }

const int dy[] = {0, 1, 0, -1, -1, 1, 1, -1};
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

ll dp0[2005][2005];
ll dp1[2005][2005];

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  int n,m;
  cin>>n>>m;
  vector<ll> s(n), t(m);
  rep(i,n)cin>>s[i];
  rep(i,m)cin>>t[i];
  dp0[0][0]=1;
  rep(i,n+1)rep(j,m+1){
    (dp0[i+1][j]+=dp0[i][j])%=MOD;
    (dp1[i][j]+=dp0[i][j])%=MOD;
    (dp1[i][j+1]+=dp1[i][j])%=MOD;
    if(s[i]==t[j]) (dp0[i+1][j+1]+=dp1[i][j])%=MOD;
  }
  ll ans=dp1[n][m]%MOD;
  cout<<ans<<endl;
}


Measured memory_bytes: 63104
N=int(input())
S=[0]*(N+1)
T=[0]*4
for i in range(N):
    S[i]=input()
for i in range(N):
    if S[i]=="AC":
        T[0]+=1
    elif S[i]=="WA":
        T[1]+=1
    elif S[i]=="TLE":
        T[2]+=1
    else:
        T[3]+=1
print("AC x",T[0])
print("WA x",T[1])
print("TLE x",T[2])
print("RE x",T[3])


Measured memory_bytes: 16044
def m(L,R):
 T=[]
 for l in L[::-1]:
  while R and R[-1]>l:T+=[R.pop()]
  T+=[l]
 return R+T[::-1]
def d(A):
 l=len(A);global c;c+=l
 s=l//2;return m(d(A[:s]),d(A[s:]))if l>1 else A
c=-int(input())
print(*d(list(map(int,input().split()))))
print(c)


Measured memory_bytes: 61644
#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;

int main() {
	long long int a, b, c, k, cnt = 0;
	cin >> a >> b >> c >> k;
	if (a >= k)cout << k << endl;
	else {
		k = k - a;
		cnt = a;
		if (b >= k)cout << cnt << endl;
		else {
			k = k - b;
			cnt = cnt - k;
			cout << cnt << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3628
/*
LANG:C++
PROB:

*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include <iostream>
// #define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)


using namespace __gnu_pbds;
using namespace std;


typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update>
    ordered_set;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;
typedef unsigned long long ui64;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
const int mod=1000000007;
  i64 poww(i64 a, i64 b)
  {
    a%=mod;
    i64 res=1;
    while(b)
      {
if(b&1)res=res*a%mod;

      a=a*a%mod;
      b/=2;

      }
      return res;
  }
  i64 inv(i64 a)
  {
    return poww(a,mod-2);
  }
  void solve()
  {

string s;
cin>>s;
int m=0;
for(int i=0;i<s.size();i++)
{
	m+=(s[i]-'0');
	m%=9;
}
if(m==0)cout<<"Yes";
else cout<<"No";
  }
  
  int main()
  {
ios::sync_with_stdio(false);
    cin.tie(nullptr);
    #ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
    #endif
int t=1;
while(t--)
{
  solve();
}

    return 0;
  }


Measured memory_bytes: 3744
import java.util.*;

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

        int n = sc.nextInt();

        int a = sc.nextInt();
        long sum = a;
        int min = a;
        int max = a;

        while (--n > 0) {
            a = sc.nextInt();
            sum += a;
            if (a < min)
                min = a;
            else if (a > max)
                max = a;
        }
        System.out.printf("%d %d %d\n", min, max, sum);
    }
}

Measured memory_bytes: 41424
#include<bits/stdc++.h>
#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()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------

void _main() {
	int N, M, C;
	cin >> N >> M >> C;

	int B[20];
	for (int i = 0; i < M; i++) {
		cin >> B[i];
	}

	int ans = 0;
	for (int k = 0; k < N; k++) {
		int num = C;

		for (int j = 0; j < M; j++) {
			int A;
			cin >> A;
			num += A * B[j];
		}

		if (num > 0) {
			ans += 1;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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

int main() {
    int H, W, K;
    cin >> H >> W >> K;
    vector<string> s(H);
    REP(i, H) cin >> s[i];
    ll ans = 0;
    REP(i, 1 << H)REP(j,1 << W){
        vector<string> f(H);
        REP(k, H) f[k] = s[k];
        REP(k, H) if ((i >> k) % 2 == 0) REP(l, W) f[k][l] = '.';
        REP(k, W) if ((j >> k) % 2 == 0) REP(l, H) f[l][k] = '.';
        ll tmp = 0;
        REP(k, H)REP(l, W) if (f[k][l] == '#') tmp++;
        if (tmp == K) ans++;
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 3184
#include <cstdio> 
#include <cstdlib> 
#include <cmath> 
#include <cstring> 
#include <climits> 
#include <cfloat> 
#include <map> 
#include <utility> 
#include <set> 
#include <iostream> 
#include <memory> 
#include <string> 
#include <vector> 
#include <algorithm> 
#include <functional> 
#include <sstream> 
#include <complex> 
#include <stack> 
#include <queue> 
#include <numeric>
#include <cassert>

#define FOR(i, min, max) for (int i = (min); i < (max); ++i) 
#define FORE(i, min, max) for (int i = (min); i <= (max); ++i) 
#define REP(i, n) for (int i = 0; i < (n); ++i) 
#define REPV(vec, i) for (int i = 0; i < (int)(vec.size()); ++i) 
#define FOR_EACH(vec, it) for (typeof((vec).begin()) it = (vec).begin(); it != (vec).end(); ++it)

using namespace std; 
static const double EPS = 1e-12; 
typedef long long ll; 

int main(void)
{
    int N;
    cin >> N;
    vector<int> C(N, 0);
    REP(i, N-1) {
        int a;
        cin >> a;
        --a;
        C[a]++;
    }
    REP(i, N) {
        cout << C[i] << endl;
    }
    return 0;
}


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

int main()
{
    int d;
    cin >> d;
    if(d == 22)
    cout << "Christmas Eve Eve Eve" << endl;
    else if(d == 23)
    cout << "Christmas Eve Eve" << endl;
    else if(d == 24)
    cout << "Christmas Eve" << endl;
    else
    cout << "Christmas" << endl;
    return 0;
}


Measured memory_bytes: 256
import sys

stdin = sys.stdin

ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

N, T = rl()
A = rl()
answer = 1
profit = 0
min = A[0]
for i in range(1, N):
    if A[i] < min:
        min = A[i]
        continue
    x = A[i] - min
    if x > profit:
        answer = 1
        profit = x
    elif x == profit:
        answer += 1

print(answer)
# 40


Measured memory_bytes: 14344
def main():
    r, c = map(int, input().split())

    col_sums = [0] * c
    rows = [
        input()
        for n_r in range(r)
    ]

    for row in rows:
        row_sum = 0
        cols = map(int, row.split())
        for idx, col in enumerate(cols):
            col_sums[idx] += col
            row_sum += col

        print(row, end="")
        print("", row_sum)

    last_line = " ".join(map(str, col_sums))
    print(last_line, end="")
    print("", sum(col_sums))

if __name__ == "__main__":
    main()

Measured memory_bytes: 5636
N = int(input())
A = [int(input()) for _ in range(N)]

flag = (A[0] == 0)
ans = 0

for i in range(1, N):
    d = A[i] - A[i - 1]
    if d > 1:
        flag = False
    elif d == 1:
        ans += 1
    else:
        ans += A[i]

if flag is False:
    ans = -1

print(ans)

Measured memory_bytes: 11052
#include <stdio.h>

int main (void){
  int n,d,x,a;
  int i;
  int eaten;
  
  scanf("%d",&n);
  scanf("%d %d",&d,&x);
  
  for( i=0, eaten=0, d--; i<n; i++){
    scanf("%d",&a);
    eaten = (d - (d%a)) / a;
    
    x += eaten+1;
  }
  
  printf("%d",x);
  
  return 0;
}

Measured memory_bytes: 128
H, W = map(int, input().split())
s_tmp = [input() for i in range(H)]
s = [[0] * W for i in range(H)]
b = 0
for i in range(H):
    for j in range(W):
        if s_tmp[i][j] == '#':
            s[i][j] = -1
            b += 1
c = [(0, 0)]
i = 0
while (H - 1, W - 1) not in c:
    c_tmp = []
    i += 1
    for h, w in c:
        if h > 0 and s[h - 1][w] == 0:
            s[h - 1][w] = i
            c_tmp.append((h - 1, w))
        if h < H - 1 and s[h + 1][w] == 0:
            s[h + 1][w] = i
            c_tmp.append((h + 1, w))
        if w > 0 and s[h][w - 1] == 0:
            s[h][w - 1] = i
            c_tmp.append((h, w - 1))
        if w < W - 1 and s[h][w + 1] == 0:
            s[h][w + 1] = i
            c_tmp.append((h, w + 1))
    if len(c_tmp) == 0:
        break
    c = c_tmp
if len(c_tmp) == 0:
    print(-1)
else:
    print(H * W - b - i - 1)


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main{
    public static void main(String[]arg){
        Scanner sc = new Scanner(System.in);
        while(true){
            int m = sc.nextInt();
            int f = sc.nextInt();
            int r = sc.nextInt();
            int sum = m+f;
            if(m==-1 && f==-1 && r==-1) break;
            else if(m==-1 || f==-1 || sum<30){
                 System.out.println("F");
            }else if(sum>=80) {
                System.out.println("A");
            }else if(65<=sum && sum<80) {
                System.out.println("B");
            }else if(50<=sum && sum<65) {
                System.out.println("C");
            }else if(30<=sum && sum<50) {
                if(r>=50)System.out.println("C");
                else System.out.println("D");
            }
        }
    }
}


Measured memory_bytes: 26264
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Timers;
using System.Diagnostics;
using System.Threading;


namespace AtcoderCS
{
    class Program
    {
        static void Main(String[] args)
        {
            string[] str = Console.ReadLine().Split();
            int N = int.Parse(str[0]);
            int T = int.Parse(str[1]);
            int[] t = new int[N];
            string[] s = Console.ReadLine().Split();
            for(int i = 0; i < N; i++)
            {
                t[i] = int.Parse(s[i]);
            }
            int sum = 0;
            for (int i = 0; i < N - 1; i++)
            {
                if (T > t[i + 1] - t[i])
                    sum += t[i + 1] - t[i];
                else
                    sum += T;
            }
            sum += T;
            Console.WriteLine(sum);
        }
    }
}


Measured memory_bytes: 26116
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#define nmax_def 110000
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;

int main() {
	int A, B;
	int ans = 6;
	cin >> A >> B;
	ans -= A;
	ans -= B;
	cout << ans << endl;
	


	return 0;
}

Measured memory_bytes: 256
// بِسمِ اللہِ  الرَّحم?نِ  الرَّ حِیم
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define MOD 1000000007
#define ll long long
#define pb push_back
#define all(v) v.begin(),v.end()
#define INF 1e18
#define N 100100
#define PI 3.141592653589793238
typedef pair<ll,ll> pll;
ll power(ll a,ll b)
{
    if(b==1)return a;
    if(b==0)return 1;
    ll temp=power(a,b/2);
    ll ans=temp*temp;
    if(b&1)
        ans*=a;
    return ans;
}
ll power(ll a,ll b,ll p)
{
    a=a%p;
    if(b==1)return a;
    if(b==0)return 1;

    ll temp=power(a,b/2,p);
    ll ans=(temp*temp)%p;
    if(b&1)
        ans=(a*ans)%p;
    return ans%p;
}
ll inv(ll a,ll m)
{
    return power(a,m-2,m);
}
//code begins
bool ok(vector<ll> a,ll k,ll ans){
    for(auto it:a)
        k-=(ceil(it*1.0/ans*1.0)-1);
    return k>=0;
}
void solve(){
    ll n,k;cin>>n>>k;
    vector<ll> a(n);
    for(ll i=0;i<n;i++)cin>>a[i];
    ll low=1,high=1e9+100;
    while(low!=high){
        ll mid=(low+high)>>1;
        if(ok(a,k,mid))
            high=mid;
        else
            low=mid+1;
    }
    cout<<low<<endl;
}
signed main()
{
//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);

//    ll t;cin>>t;while(t--)
    solve();
    return 0;
}


Measured memory_bytes: 6320
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
typedef pair<double, int> P;
string s;
int n;
vector<int> id[30];
int dp[5010][5010];
int main()
{
    cin >> n;
    cin >> s;
    for (int i = n - 1; i >= 0; i--)
    {
        for (int j = n - 1; j > i; j--)
        {
            if (s[i] == s[j])
            {
                dp[i][j] = dp[i + 1][j + 1] + 1;
            }
        }
    }
    int ans = 0;
    rep(i, n)
    {
        rep(j, n)
        {
            int l = min(dp[i][j], j - i);
            ans = max(ans, l);
        }
    }
    cout << ans << endl;
}

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

int main(void)
{
    int n;
    int now, min, max;
    int i, j;
    char input[2000];
    char train[1000];

    scanf("%d", &n);

    for (i = 0; i < n; i++){
        scanf("%s", input);

        now = 500;
        min = 500;
        max = 500;
        
        for (j = 0; ; j += 3){
            train[now] = input[j];
            
            if (input[j + 1] == '\0'){
                break;
            }
            
            if (input[j + 1] == '-'){
                now++;
            }
            else {
                now--;
            }

            if (now < min){
                min = now;
            }
            if (now > max){
                max = now;
            }
        }

        for (j = min; j <= max; j++){
            printf("%c", train[j]);
        }
        
        printf("\n");

    }

    return 0;
}
        

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <string>
using namespace std;
const int maxn = 100005;
int bit[maxn];
int n;

int get_sum(int i)
{
	int ret = 0;
	while (i > 0)
	{
		ret += bit[i];
		i -= i & -i;
	}
	return ret;
}

void add(int i, int x)
{
	while (i <= n)
	{
		bit[i] += x;
		i += i & -i;
	}
}

int main(void)
{
	int op, q, a, b;
	string str;
	ios::sync_with_stdio(false);
	cin >> n >> q;
	while (q--)
	{
		cin >> op >> a >> b;
		if (op == 0)
			add(a, b);
		else
			cout << get_sum(b) - get_sum(a - 1) << endl;
	}

	return 0;
}

Measured memory_bytes: 3572
#include <vector>
#include <algorithm>
#include <cstdio>
using namespace std;
int main(){
	int n;
	scanf("%d",&n);
	vector<int>v(n),w(n);
	for(int i=0;i<n;i++)scanf("%d",&v[i]),w[i]=v[i];
	if(prev_permutation(v.begin(),v.end()))for(int i=0;i<n;i++)printf(i<n-1?"%d ":"%d\n",v[i]);
	for(int i=0;i<n;i++)printf(i<n-1?"%d ":"%d\n",w[i]);
	if(next_permutation(w.begin(),w.end()))for(int i=0;i<n;i++)printf(i<n-1?"%d ":"%d\n",w[i]);
}



Measured memory_bytes: 2768
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int k, n, m;

string s;
string t;
set<int> s1;
set<int> t1;

int add(int v, int id){
	if(id == 0){
		for(int j = v; ; j++){
			if(s1.find(j) == s1.end()){
				s1.insert(j);
				return j;
			} else{
				s1.erase(j);
			}
		}
		if(s1.find(v) == s1.end()){
			s1.insert(v);
			return v;
		}
		s1.erase(v);
		return add(v+1, 0);
	}
	if(id == 1){
		for(int j = v; ; j++){
			if(t1.find(j) == t1.end()){
				t1.insert(j);
				return j;
			} else{
				t1.erase(j);
			}
		}
		if(t1.find(v) == t1.end()){
			t1.insert(v);
			return v;
		}
		t1.erase(v);
		return add(v+1, 0);
	}
}

void process(int v, int k){
	if(k == 0) return;
	if(s1.find(v) == s1.end() || t1.find(v) == t1.end()) return;
	int next1 = *s1.upper_bound(v);
	int next2 = *t1.upper_bound(v);
	int r = min(k, min(next1,next2) - v - 1);
	if(r > 0){
		s1.erase(v);
		t1.erase(v);
		s1.insert(v + r);
		t1.insert(v + r);
		process(v+r, k-r);
		return;
	}
	if(k == 0) return;
	//if(next1 == v+1 && next2 == v+1) assert(false);
	if(next1 == v+1){
		int d = add(v,0);
		add(v,1);
		process(d, k-1);
	} else {
		add(v,0);
		int d = add(v,1);
		process(d, k-1);
	}
}
void pr(set<int> s){
	string g;
	int last = 0;
	for(int x : s){
		for(int j = last; j < x; j++){
			g += '0';
		}
		g += '1';
		last = x + 1;
	}
	reverse(g.begin(), g.end());
	cout << g << '\n';
}
int main(){
	cin.sync_with_stdio(0); cin.tie(0);
	cin >> n >> m >> k;
	cin >> s >> t;
	reverse(s.begin(), s.end());
	reverse(t.begin(), t.end());
	s.resize(1000000, '0');
	t.resize(1000000, '0');
	s1.insert(11000000);
	t1.insert(11000000);
	for(int v = 1000000; v >= 0; v--){
		if(s[v] == '0' && t[v] == '0') continue;
		if(s[v] == '1' && t[v] == '0') s1.insert(v);
		if(s[v] == '0' && t[v] == '1') t1.insert(v);
		if(s[v] == '1' && t[v] == '1'){
			s1.insert(v);
			t1.insert(v);
			process(v, k);
		}
	}
	s1.erase(11000000);
	t1.erase(11000000);
	pr(s1);
	pr(t1);
}


Measured memory_bytes: 63732
N, W = map(int, input().split())
recW = [[] for i in range(4)]
W0, W1, W2, W3 = 0, 0, 0, 0
for i in range(N):
    w, v = map(int, input().split())
    if i == 0:
        recW[0].append((w, v))
        W0, W1, W2, W3 = w, w + 1, w + 2, w + 3
    elif w == W0:
        recW[0].append((w, v))
    elif w == W0 + 1:
        recW[1].append((w, v))
    elif w == W0 + 2:
        recW[2].append((w, v))
    else:
        recW[3].append((w, v))

for i in range(4):
    recW[i] = sorted(recW[i], reverse=True)


a, b, c, d = len(recW[0]), len(recW[1]), len(recW[2]), len(recW[3])
recV0 = [0] * (a + 1)
for i in range(1, a + 1):
    recV0[i] = recV0[i - 1] + recW[0][i - 1][1]

recV1 = [0] * (b + 1)
for i in range(1, b + 1):
    recV1[i] = recV1[i - 1] + recW[1][i - 1][1]

recV2 = [0] * (c + 1)
for i in range(1, c + 1):
    recV2[i] = recV2[i - 1] + recW[2][i - 1][1]

recV3 = [0] * (d + 1)
for i in range(1, d + 1):
    recV3[i] = recV3[i - 1] + recW[3][i - 1][1]


num = 0
for i in range(a + 1):
    for j in range(b + 1):
        for k in range(c + 1):
            for l in range(d + 1):
                tmpW = W0 * i + W1 * j + W2 * k + W3 * l
                if tmpW > W:
                    continue
                else:
                    num = max(num, recV0[i] + recV1[j] + recV2[k] + recV3[l])

print(num)



Measured memory_bytes: 3192
//#include <fsociety>
#include <cmath>
#include <deque>
#include <algorithm>
#include <iterator>
#include <list>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <unordered_set>
#include <stack>
#include <string>
#include <vector>
#include <iostream>
//end of libraries ;
#define INF 99999999
#define N 3000003
#define F first
#define S second
#define pb push_back
#define ll long long
#define fcin ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;
ll n , a[N] , sum;
int main(){
fcin;
	cin >> n;
	for(int i = 1 ; i<= n ; i++){
		if(i%3 != 0 && i%5 != 0){
			a[i] = i;
		}
	}
	for(int i = 1; i<=n ; i++){
		sum+=a[i];
	}
	cout<<sum<<"\n";
}

Measured memory_bytes: 11420
import sys
sys.setrecursionlimit(100000)


def main():
    n, m, q = map(int, input().split())
    al = [None]*q
    bl = [None]*q
    cl = [None]*q
    dl = [None]*q
    for i in range(q):
        a, b, c, d = map(int, input().split())
        al[i] = a
        bl[i] = b
        cl[i] = c
        dl[i] = d
    
    def dfs(A):
        if len(A) > n:
            total = 0
            for i in range(q):
                if A[bl[i]]-A[al[i]] == cl[i]:
                    total += dl[i]
            global ans
            if total > ans:
                ans = total
            return
        A.append(A[-1])
        while A[-1] <= m:
            dfs(A[:])
            A[-1] += 1
    
    dfs([1])
    print(ans)
                
                

if __name__ == "__main__":
    ans = 0
    main()

Measured memory_bytes: 74668
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
 
using namespace std;


int MOD=1000000007;

int main(void){
    long long N,count=0,ma=0;
    cin >> N;
    long long H[N+10];
    cin >> H[0];
    for(long long i=1; i<N; i++){
        cin >> H[i];
        if(H[i-1]>=H[i]) count+=1;
        else{
            if(ma<count) ma=count;
            count=0;
        }
    }
    if(ma<count) ma=count;
    cout << ma << endl;

}


Measured memory_bytes: 1024
import java.io.BufferedInputStream;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(new BufferedInputStream(System.in));
        int m=sc.nextInt();
        int n=sc.nextInt();
        if(m==n)
            System.out.println("Yes");
        else
            System.out.println("No");

    }
}


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

int main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int n;
  cin >> n;
  vector<string> in;
  unordered_map<string, bool> vis;
  for(int i = 1; i <= n; ++i) {
    string s;
    cin >> s;
    if(vis[s]) {
      return cout << "No\n", 0;
    }
    vis[s] = true;
    if(i >= 2) {
      if(in.back().back() != s.front()) {
	return cout << "No\n", 0;
      }
    }
    in.push_back(s);
  }
  cout << "Yes\n";
}  


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

int main(){
    int n;
    cin >> n;
    vector<int> L(n);
    copy_n(istream_iterator<int>(cin), n, L.begin());

    int ma = *max_element(L.begin(), L.end());
    puts(accumulate(L.begin(), L.end(), 0) - ma > ma ? "Yes" : "No");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define DEBUG fprintf(stderr, "Passing [%s] line %d\n", __FUNCTION__, __LINE__)
#define File(x) freopen(x".in","r",stdin); freopen(x".out","w",stdout)

using namespace std;

typedef long long LL;
typedef pair <int, int> PII;
typedef pair <int, PII> PIII;

inline int gi()
{
	int f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

inline LL gl()
{
	LL f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

const int N = 200003, mod = 1000000007;

int n, m;
int a[N], ton[N];
char s[N];

int main()
{
    n = gi();
    for (int i = 2; i <= n; i+=1) a[i] = gi(), ++ton[a[i]];
    for (int i = 1; i <= n; i+=1) cout << ton[i] << endl;
    return 0;
}


Measured memory_bytes: 5016
#include <iostream>
#include <cmath>

using namespace std;

int main(){
    int N;
    cin >> N;
    long long A[N];
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }
    int max = A[1] - A[0];
    for(int i = 0; i < N - 1; i++){
        for(int j = i + 1; j < N; j++){
            if(max < abs(A[i] - A[j])) max = abs(A[i] - A[j]); 
        }
    }
    cout << max << endl;
}

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



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

using namespace std;

int main() {
	int N, K;

	cin >> N >> K;

	vector<vector<int>> A;

	vector<bool> ans(N,false);

	rep(i, K) {
		int d;
		cin >> d;
		vector<int> a(d,0);
		rep(j,d){
			cin >> a[j];
			a[j]--;
			ans[a[j]] = true;
		}
		A.push_back(a);
	}

	int a =0;
	rep(i, N) {
		if (ans[i] == false)a++;
	}

	cout << a;

	//cin >> a;

	return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
string toUpper(string a){
    string b = a;
    for(int i = 0; i < a.size();i++){
        b[i] = toupper(a[i]);
    }
    return b;
}
int main() {
    string target,source;
    cin >> target;
    target = toUpper(target);
    int cnt = 0;
    while(1){
        cin >> source;
        if(source == "END_OF_TEXT")break;
        source = toUpper(source);
        if(target == source)cnt++;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 3156
N = int(input())
pLst = [0] * N
for i in range(N):
    pLst[i] = int(input())

ans = 0
pLst.sort(reverse=True)
for i in range(1, N):
    ans += pLst[i]

ans += int(pLst[0] / 2)
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<pii>
#define vll vector<pll>
#define all(v) v.begin(),v.end()
#define N 200005

using namespace std;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
    int z,x,y;
    cin>>x>>y>>z;
    cout<<z<<' '<<x<<' '<<y;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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

const long long INF = 1LL << 60;

int gcd(int a, int b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

int main(){
  int n; cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  int g = a[0];
  rep(i, n){
    g = gcd(a[i], g);
  }

  cout << g << endl;

  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <sstream>
#include <algorithm>
#include <functional>
#include <iterator>
#include <bitset>
#include <string>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>

typedef   signed long long int slli;
typedef unsigned long long int ulli;
const slli MAX_SLLI = 0x7FFFFFFFFFFFFFFF;
const slli MIN_SLLI = 0x8000000000000000;
const ulli MAX_ULLI = 0xFFFFFFFFFFFFFFFF;
const ulli MIN_ULLI = 0x0000000000000000;

#define N_TIMES(i, n)     for (ulli i = 0;     i <  n; ++i)
#define N_TIMES_REV(i, n) for (slli i = n - 1; i >= 0; --i)

#ifdef __DEBUG__
template<typename T>
std::ostream& operator<<(std::ostream &os, const std::list<T> &list)
{
  const std::string delim = ", ";
  typename std::list<T>::const_iterator itr = list.begin();
  while (itr != list.end()) {
    os << *itr;
    ++itr;
    if(itr != list.end()) os << delim;
  }
  return os;
}

template<typename T>
std::ostream& operator<<(std::ostream &os, const std::vector<T> &v)
{
  const std::string delim = ", ";
  for (unsigned n = 0; n < v.size(); ++n) {
    os << v[n];
    if((n + 1) < v.size()) os << delim;
  }
  return os;
}
#endif

const ulli MOD = 1e+9 + 7;
const ulli MinimumCacheSize = 16;

std::vector<ulli> fact_cache;

void init_fact_cache(ulli S)
{
  S = std::max(S, MinimumCacheSize);
  
  fact_cache = std::vector<ulli>(S);
  
  fact_cache[0] = 1;
  
  for (ulli i = 1; i <= S; ++i) {
    fact_cache[i] = (i * fact_cache[i - 1]) % MOD;
  }
}

int main()
{
  ulli N, M;
  std::cin >> N >> M;
  
  init_fact_cache(std::max(N, M) + 10);
  
  ulli S = 0;
  
  if (N == M) {
    S = (fact_cache[N] * fact_cache[N]) % MOD;
    S = (S * 2) % MOD;
  } else if (N == M + 1) {
    S = (fact_cache[N] * fact_cache[M]) % MOD;
  } else if (M == N + 1) {
    S = (fact_cache[N] * fact_cache[M]) % MOD;
  } else {
    S = 0;
  }
  
  std::cout << S << std::endl;
  
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
long long a[200005], n, xsum;
int main() {
    cin >> n;
    for (int i=0; i<n; i++) {
        cin >> a[i];
        xsum^=a[i];
    }
    
    for (int i=0; i<n; i++) cout << (xsum^(a[i])) << " ";
}


Measured memory_bytes: 5132
#include <iostream>
#include <queue>
using namespace std;
typedef struct{
	int x;
	int y;
}POS;
queue <POS> q;
POS start,flag;
int map[129][129];//64?????????0??¨??????
int x,y,t,n,count,turn;

void check(){
	POS pos,next;
	flag.x=flag.y=200;
	q.push(start);
	q.push(flag);
	while(1){
		if(turn==t+1)return;
		pos=q.front();
		q.pop();

		if(pos.x==200){
			turn++;
			q.push(flag);
		}else{
			count++;
			if(pos.x>0&&pos.y>0&&map[pos.x-1][pos.y-1]==0){
				next.x=pos.x-1;
				next.y=pos.y-1;
				map[next.x][next.y]=1;
				q.push(next);
			}
			if(pos.x<128&&pos.y<128&&map[pos.x+1][pos.y+1]==0){
				next.x=pos.x+1;
				next.y=pos.y+1;
				map[next.x][next.y]=1;
				q.push(next);
			}
			if(pos.x>0&&map[pos.x-1][pos.y]==0){
				next.x=pos.x-1;
				next.y=pos.y;
				map[next.x][next.y]=1;
				q.push(next);
			}
			if(pos.y>0&&map[pos.x][pos.y-1]==0){
				next.x=pos.x;
				next.y=pos.y-1;
				map[next.x][next.y]=1;
				q.push(next);
			}
			if(pos.x<128&&map[pos.x+1][pos.y]==0){
				next.x=pos.x+1;
				next.y=pos.y;
				map[next.x][next.y]=1;
				q.push(next);
			}
			if(pos.y<128&&map[pos.x][pos.y+1]==0){
				next.x=pos.x;
				next.y=pos.y+1;
				map[next.x][next.y]=1;
				q.push(next);
			}
		}
	}
}

int main(){
	while(1){
		cin >>t >>n;
		if(!(t||n))break;
		for(int i=0;i<129;i++){
			for(int j=0;j<129;j++){
				map[i][j]=0;
			}
		}
		for(int i=0;i<n;i++){
			cin>>x>>y;
			map[x+64][y+64]=1;
		}
		cin >>start.x>>start.y;
		start.x+=64;
		start.y+=64;
		turn=0;
		count=0;
		map[start.x][start.y]=1;
		check();
		cout <<count <<endl;
		while(!q.empty())q.pop();
	}
}

Measured memory_bytes: 3196
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=32;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int r;
	scanf("%d",&r);
	double pi=acos(-1.0);
	printf("%.6f\n",2*pi*r);
	return 0;
}

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


#define	ll_int	long long int


typedef struct l_t{
	ll_int data;
	struct l_t *pre, *next;
} L_T;

L_T L;
L_T *CURSOR;


/*
insert(x): カーソルが指す要素の直前に整数xを挿入する。
操作の後、カーソルは挿入された要素を指すようになる。
*/
void Insert(ll_int data)
{
	L_T *p;

	if( (p = (L_T *)malloc(sizeof(L_T))) == NULL){
		printf("malloc error\n");
		exit(1);
	}

	p->data = data;
	p->pre = CURSOR->pre;
	p->next = CURSOR;
	CURSOR->pre->next = p;
	CURSOR->pre = p;

	CURSOR = p;
}


/*
move(d): 整数dが正の場合、カーソルを後方にdだけ移動する。
負の場合は前方にdだけ移動する。
*/
void Move(int d)
{
	L_T *p;
	int count = 0;

	if(d > 0){
	// 後ろにカーソルをずらす
		for(p = CURSOR; count != d; p = p->next)
			count++;

	}else{
	// 前にカーソルをずらす
		d = -d;
		for(p = CURSOR; count != d; p = p->pre)
			count++;
	}

	CURSOR = p;
}


/*
erase(): カーソルが指す要素を削除する。
操作の後、カーソルは削除された要素の１つ後方の要素を指すようになる。
ただし、そのような要素がない場合はENDを指すようになる。
*/
void Erase()
{
	L_T *p;

	p = CURSOR;
	CURSOR = p->next;

	p->pre->next = p->next;
	p->next->pre = p->pre;

	free(p);
}


// リストを先頭から表示
void Print_list()
{
	L_T *p;

	for(p = L.next; p != &L; p = p->next)
		printf("%lld\n", p->data);
}


int main()
{
	int q;
	int query;
	ll_int data;
	int i, j;

	// 双方向環状リスト
	L.pre = &L;
	L.next = &L;

	// カーソルの初期化
	CURSOR = &L;

	// クエリ数
	scanf("%d", &q);

	for(i = 0; i < q; i++){
		scanf("%d", &query);

		if(query == 0){
			scanf("%lld", &data);
			Insert(data);
		}else if(query == 1){
			scanf("%lld", &data);
			Move(data);
		}else if(query == 2){
			Erase();
		}
	}

	Print_list();

	return 0;
}


Measured memory_bytes: 17284
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
		while(true) {
        int m = sc.nextInt();
        int f = sc.nextInt();
        int r = sc.nextInt();
        if(m == -1 && f >= 30 || f == -1 && m >= 30 || m + f < 30 && m + f >= 0){
            System.out.println("F");
        }else if (m + f >= 80 || m >= 80 && f >= 0 || f >= 80 && m >= 0){
            System.out.println("A");
        }else if(m + f >= 65 || m >= 65 && f >= 0 || f >= 65 && m >= 0 && m + f < 80){
            System.out.println("B");
        }else if(m + f >= 50 || m >= 50 && f >= 0 || f >= 50 && m >= 0 && m + f < 65 || r >= 50){
            System.out.println("C");
        }else if(m + f >= 30 || m >= 30 && f >= 0 || f >= 30 && m >= 0  && m + f < 50){
            System.out.println("D");
        }else{
            break;
        }
        
		}
	        
    }
}


Measured memory_bytes: 26240
import sys
input = sys.stdin.readline

n = int(input())
t = 0
x = 0
y = 0

l = [tuple(map(int, input().split())) for _ in range(n)]

for t1, x1, y1 in l:
    if (abs(x1 - x) + abs(y1 - y))/(t1 - t) > 1:
        print("No")
        exit()
    if (abs(x1 - x) + abs(y1 - y))%2 != (t1 - t)%2:
        print("No")
        exit()
    x = x1
    y = y1
    t = t1

print("Yes")

Measured memory_bytes: 17312
N = int(input())
sp = []
for i in range(N):
    S, P = input().split()
    P = int(P)
    sp.append([S, P, i + 1])

sp.sort(key=lambda x: x[1],reverse=True)
sp.sort(key=lambda x: x[0])
for i in sp:
    print(i[2])


Measured memory_bytes: 3060
N,K = input().split()
S = input()

N = int(N)
K = int(K)

ans = S[:K-1]

if S[K-1] =="A":
    ans += "a"

if S[K-1] =="B":
    ans += "b"

if S[K-1] =="C":
    ans += "c"

ans += S[K:]


print (ans)

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



int main(int argc, char const *argv[])
{

#if !ONLINE_JUDGE

	freopen("in1.txt", "r", stdin);
	freopen("out1.txt", "w" , stdout);

#endif


	long n, m;
	cin >> n >> m;

	vector<pair<int, int>>vp1;
	vector<pair<int, int>>vp2;

	for (int i = 0; i < n; ++i)
	{
		int a, b;
		cin >> a >> b;
		vp1.push_back(make_pair(a, b));
	}

	for (int i = 0; i < m; ++i)
	{
		int a, b;
		cin >> a >> b;
		vp2.push_back(make_pair(a, b));
	}

	for (int i = 0; i < n; ++i)
	{
		int a = vp1[i].first;
		int b = vp1[i].second;
		int maxi = INT_MAX;
		int index;
		for (int j = 0; j < m; ++j)
		{
			if (abs(vp2[j].first - a) + abs(vp2[j].second - b) < maxi)
			{
				index = j;
				maxi = abs(vp2[j].first - a) + abs(vp2[j].second - b);
			}
		}

		cout << index + 1 << endl;





	}







	return 0;
}

Measured memory_bytes: 3580
#include <iostream>

int main(int argc, char const* argv[])
{
    int a, b, c, d, e, f;
    std::cin >> a >> b >> c >> d >> e >> f;

    double max_strength = 0;
    int ans_water = 0;
    int ans_sugar = 0;

    for (int a_i = 0; a_i * 100 * a <= f; ++a_i)
    {
        int a_sum = a_i * 100 * a;

        for (int b_i = 0; (b_i * 100 * b) + a_sum <= f; ++b_i)
        {
            int water_sum = (b_i * 100 * b) + a_sum;
            int remain = f - water_sum;

            int max_suger = water_sum / 100 * e;
            max_suger = std::min(remain, max_suger);

            for (int c_i = 0; (c_i * c) <= max_suger; ++c_i)
            {
                int tmp = max_suger - (c_i * c);
                int d_num = tmp / d;

                int amount_of_suger = (d_num * d) + (c_i * c);

                double strength = (double)(100 * amount_of_suger) /
                                 (double)(water_sum + amount_of_suger);

                if (max_strength <= strength) {
                    ans_water = water_sum + amount_of_suger;
                    ans_sugar = amount_of_suger;
                    max_strength = strength;
                }
            }
        }
    }
    std::cout << ans_water << " " << ans_sugar << std::endl;
}

Measured memory_bytes: 256