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

using namespace std;

int t[110];

int main()
{
    int n,a,b,ta,tb;
    cin >> n;
    for(int i = 1;i <= n * (n - 1)/2;i++){
        cin >> a >> b >> ta >> tb;
        if(ta > tb)t[a] += 3;
        if(ta < tb)t[b] += 3;
        if(ta == tb){
            t[a]++;
            t[b]++;
        }
    }
    for(int i = 1;i <= n;i++){
            int cnt = 1;
            for(int j = 1;j <= n + 1;j++){
                if(t[i] < t[j])cnt++;
            }
    cout << cnt << endl;
        }

    return 0;
}

Measured memory_bytes: 1160
#include <iostream>
using namespace std;
int num[101],n,k;
int main()
{
	int ans=0;
	cin>>n>>k;
	for(int j=1;j<=n;j++) cin>>num[j];
	for(int j=1;j<=n;j++)
	    if(num[j]>k-num[j])
	        ans+=(k-num[j])*2;
	    else 
	        ans+=num[j]*2;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool PN(int x) {
  if (x <= 1) return false;
  if (x == 2) return true;
  for (int i = 2; i < sqrt(x) + 1; i++) if (x % i == 0) return false;
  return true;
}

void solve(){
  char a, b; cin >> a >> b;
  if(a == b) cout << 'H' << endl;
  else cout << 'D' << endl;
  
}

int main(){
  solve();
  return 0;
}

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

int main() {
    int N;
    int W;
    cin >> N >> W;
    vector<vector<int>> dp(N + 1, vector<int>(1e5 + 1, 1e9 + 1));
    dp[0][0] = 0;
    vector<int> weight(N + 1, 0);
    vector<int> value(N + 1, 0);
    
    int temp_w, temp_v;
    for (int i = 1; i < N + 1; i++) {
        cin >> temp_w >> temp_v;
        weight[i] = temp_w;
        value[i] = temp_v;
    }
    for (int i = 1; i < N + 1; i++) {
        for (int j = 0; j < 1e5 + 1; j++) {
            if (j - value[i] >= 0)
                // min(品物を選ばない場合の重量, 品物を選ぶ場合の重量 + 余った価値で最小の重量)
                dp[i][j] = min(dp[i - 1][j], weight[i] + dp[i - 1][j - value[i]]);
            else
                dp[i][j] = dp[i - 1][j];
        }
    }
    int ans = 100000;
    while (dp[N][ans] > W){
        ans -= 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 43388
mod = 10 ** 9 + 7

N, *E = map(int, open(0).read().split())
E = sorted((e, 1 if i < N else -1) for i, e in enumerate(E))

res = 1
cnt = 0
for _, delta in E:
    if cnt * delta < 0:
        res *= abs(cnt)
        res %= mod
    cnt += delta

print(res)

Measured memory_bytes: 25948
#include <iostream>
#include <stdio.h>
#include <math.h>
using namespace std;

int main(void)
{
	double x1, y1, x2, y2, dist;

	cin >> x1 >> y1 >> x2 >> y2;

	dist = sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));

	printf("%.8f\n", dist);

	return 0;
}

Measured memory_bytes: 1236
n=int(input())
p=list(map(int, input().split()))
A=int(0)
for i in range(1,n-1):
    q=[p[i-1],p[i],p[i+1]]
    r=sorted(q)
    if q[1]==r[1]:
        A+=1
    else:
        continue
print(A)


Measured memory_bytes: 3060
import java.io.*;
import java.util.*;

public class Main {
    static PrintWriter out = new PrintWriter(System.out);
    static Scanner sc = new Scanner(System.in);
    static BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    long mod = 1000000000+7;
    long[] frac, inv;
    public static void main(String[] args) throws IOException {
        Main main = new Main();
//        main.solve();
        out.println(main.solve());
        out.flush();
    }
    long solve() throws IOException {
        int n = sc.nextInt();
        long[] a = new long[n];
        long maxi = 0;
        for(int i=0;i<n;i++) {
            a[i]= sc.nextLong();
            maxi = Math.max(maxi, a[i]);
        }
        if(maxi==0) return 0;
        long odd_rec = 0;
        for(int i=60; i>=0;i--){
            int cnt = 0;
            long mask = 1L<<i;
            for(long num:a){
                if((num&mask)>0) cnt++;
            }
            if(cnt%2==1) odd_rec |= mask;
        }
        long antimask = ~odd_rec;
        for(int i=0;i<n;i++) a[i]&=antimask;
        // only the bits where even_number of 1's are kept
        TreeSet<Long> set = new TreeSet<>(Collections.reverseOrder());
        long[] line_base = new long[61];
        for(long c:a){
            long backup = c;
            for(int i=60;i>=0;i--){
                long mask = 1L<<i;
                if((mask&backup)==0) continue;
                if(line_base[i]==0){
                    line_base[i] = backup;
                    set.add(backup);
                    break;
                } else{
                    backup ^= line_base[i];
                }
            }
        }
        long ans = 0;
        for(long b:set){
            if((ans^b) > ans) ans = ans^b;
        }
        return 2*ans+odd_rec;
    }
}

Measured memory_bytes: 59484
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String line = scanner.nextLine();
        String[] values = line.split(" ");
        int H = Integer.parseInt(values[0]);
        int A = Integer.parseInt(values[1]);
        if (H % A == 0) {
            System.out.println(H / A);
        } else {
            System.out.println( ((H / A) + 1) );
        }
    }
}

Measured memory_bytes: 22996
#include <iostream>
#include <vector>
#include <iterator>
using namespace std;

void bubbleSort(vector<int>::iterator first, vector<int>::iterator last);
void showArray(vector<int>::const_iterator first, vector<int>::const_iterator last);

int main() {
    vector<int> vec(3,0);
    cin >> vec[0] >> vec[1] >> vec[2];
    bubbleSort(vec.begin(), vec.end());
    return 0;
}

// バブルソート
void bubbleSort(vector<int>::iterator first, vector<int>::iterator last) {
  int count = 0;
  // ソートを実施
  for(auto e = first; e != last; ++e) {
    for(auto i = last - 1; i != e; --i) {
      auto j = i;
      advance(j, -1);
      if(*i < *j) {
        iter_swap(i, j);
      }
    }
  }
  showArray(first, last);
}

// 配列要素の表示
void showArray(vector<int>::const_iterator first, vector<int>::const_iterator last) {
  for(auto e = first; e != last; ++e) {
    if (e == last-1) cout << *e;
    else cout << *e << ' ';
  }
  cout << endl;
}



Measured memory_bytes: 3116
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(N: int, W: "List[str]"):
    already_spoken = []
    flag = True
    for i, w in enumerate(W):
        if w in already_spoken:
            flag = False
        if i > 0:
            if not W[i-1][-1] == W[i][0]:
                flag = False
        already_spoken.append(w)
    if flag == True:
        print(YES)
    else:
        print(NO)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    W = [ next(tokens) for _ in range(N) ]  # type: "List[str]"
    solve(N, W)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {
	
	public static class Result implements Comparable<Result>{
		int number, score;

		public Result(int number, int score) {
			super();
			this.number = number;
			this.score = score;
		}

		@Override
		public int compareTo(Result o) {
			if(this.score != o.score){
				return o.score - this.score;
			}else{
				return this.number - o.number;
			}
		}
		
		public String toString(){
			return this.number + " " + this.score;
		}
	}
	
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);

		while (true) {

			final int m = sc.nextInt();

			if (m == 0) {
				break;
			}
			
			ArrayList<Result> result = new ArrayList<Result>();

			for (int tt = 0; tt < m; tt++) {
				boolean[] is_strike = new boolean[10];
				boolean[] is_spare = new boolean[10];
				int[] count_score = new int[21];
				int[] frame_score = new int[10];
				int[] sum_score = new int[10];
				
				final int number = sc.nextInt();

				for (int frame = 0; frame < 10; frame++) {
					if (frame != 9) {
						final int score_1 = sc.nextInt();
						count_score[frame * 2] = score_1;

						if (score_1 == 10) {
							is_strike[frame] = true;
							frame_score[frame] = score_1;
							continue;
						}

						final int score_2 = sc.nextInt();
						count_score[frame * 2 + 1] = score_2;

						if (score_1 + score_2 == 10) {
							is_spare[frame] = true;
						}
						
						frame_score[frame] = score_1 + score_2;
					} else {
						final int score_1 = sc.nextInt();
						count_score[frame * 2] = score_1;

						final int score_2 = sc.nextInt();
						count_score[frame * 2 + 1] = score_2;

						if (score_1 == 10 || score_1 + score_2 == 10) {
							final int score_3 = sc.nextInt();
							count_score[frame * 2 + 2] = score_3;
							frame_score[frame] = score_1 + score_2 + score_3;
						} else {
							frame_score[frame] = score_1 + score_2;
						}
					}
				}
				
				//System.out.println(Arrays.toString(count_score));
				
				for (int frame = 0; frame < 10; frame++) {
					sum_score[frame] = (frame == 0 ? 0 : sum_score[frame - 1]) + frame_score[frame];
					
					if (is_spare[frame] || is_strike[frame]) {
						sum_score[frame] += count_score[(frame + 1) * 2];

						if (is_strike[frame]) {
							if (is_strike[frame + 1]) {
								sum_score[frame] += count_score[(frame + 2) * 2];
							} else {
								sum_score[frame] += count_score[(frame + 1) * 2 + 1];
							}
						}
					}
				}
				
				//System.out.println(Arrays.toString(sum_score));
				
				result.add(new Result(number, sum_score[9]));
			}
			
			
			
			Collections.sort(result);
			
			for(Result res : result){
				System.out.println(res);
			}
		}

	}
}

Measured memory_bytes: 26240
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MOD 998244353
#define MAX 100
#define INF 800000000

int main(){
  int N;
  cin>>N;
  vector<ll> A(N),B(N);
  vector<pair<ll,ll>> sum(N);
  for(int i=0;i<N;i++){
    cin>>A.at(i)>>B.at(i);
    sum.at(i).first=A.at(i)+B.at(i);
    sum.at(i).second=A.at(i);
  }
  sort(sum.begin(),sum.end());
  reverse(sum.begin(),sum.end());
  ll ans=0;
  for(int i=0;i<N;i++){
    if(i%2==0){
      ans+=sum.at(i).second;
    }else{
      ans-=sum.at(i).first-sum.at(i).second;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3328
n, y = map(int, input().split())
A, B, C = -1, -1, -1
for i in range(n+1):
  for j in range(n-i+1):
    c = n-i-j
    total = 10000*i + 5000*j + 1000*c
    if total == y:
      A = i
      B = j
      C = c
print(A, B, C)


Measured memory_bytes: 3060
str = gets.chomp
gets.to_i.times do
  n = gets.chomp.split
  f = n[1].to_i
  l = n[2].to_i
  case n[0]
  when 'replace'
    str[f..l] = n[3]
  when 'reverse'
    str[f..l] = str[f..l].reverse
  when 'print'
    puts str[f..l]
  end
end

Measured memory_bytes: 6152
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#include <map>

using namespace std;

typedef pair<int, int> P;

bool exist[2048][2048];
int x1[1024], y1[1024], x2[1024], y2[1024];
vector<int> xs, ys;
map<int, int> convX, convY;

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


int main()
{
	int X, Y, N;
	
	while (scanf("%d %d", &X, &Y) && X){
		scanf("%d", &N);
		
		for (int i = 0; i < N; i++){
			scanf("%d %d %d %d", x1 + i, y1 + i, x2 + i, y2 + i);
			xs.push_back(x1[i]); xs.push_back(x2[i]);
			ys.push_back(y1[i]); ys.push_back(y2[i]);
		}
		
		xs.push_back(0); xs.push_back(X - 1);
		ys.push_back(0); ys.push_back(Y - 1);
		
		sort(xs.begin(), xs.end());
		sort(ys.begin(), ys.end());
		
		xs.erase(unique(xs.begin(), xs.end()), xs.end());
		ys.erase(unique(ys.begin(), ys.end()), ys.end());
		
		for (int i = 0; i < xs.size(); i++) convX[xs[i]] = i;
		for (int i = 0; i < ys.size(); i++) convY[ys[i]] = i;
		
		memset(exist, 0, sizeof(exist));
		
		for (int i = 0; i < N; i++){
			for (int y = convY[y1[i]]; y < convY[y2[i]]; y++){
				for (int x = convX[x1[i]]; x < convX[x2[i]]; x++){
					exist[y][x] = true;
				}
			}
		}
		
		int ret = 0;
		
		for (int y = 0; y <= convY[Y - 1]; y++){
			for (int x = 0; x <= convX[X - 1]; x++){
				if (!exist[y][x]){
					exist[y][x] = true;
					queue<P> q;
					
					for (q.push(P(y, x)); q.size(); q.pop()){
						P x = q.front();
						for (int i = 0; i < 4; i++){
							int ny = x.first + dy[i], nx = x.second + dx[i];
							if (0 <= ny && ny <= convY[Y - 1] &&
									0 <= nx && nx <= convX[X - 1] &&
										exist[ny][nx] == false){
								exist[ny][nx] = true;
								q.push(P(ny, nx));
							}
						}
					}
					ret++;
				}
			}
		}
		printf("%d\n", ret);
	}
	return (0);
}

Measured memory_bytes: 5312
#include <cstdio>
#include <algorithm>

using namespace std;

int a[7];

int main() {
    int i;
    long long ans = 0, sum1 = 0, sum2 = 0;
    
    for (i = 0; i < 7; i++) scanf("%d", &a[i]);
    
    ans += a[1];
    
    sum1 += a[0] / 2 * 2;
    sum1 += a[3] / 2 * 2;
    sum1 += a[4] / 2 * 2;
    
    if (a[0] > 0 && a[3] > 0 && a[4] > 0) {
        sum2 += 3;
        
        a[0]--;
        a[3]--;
        a[4]--;
        
        sum2 += a[0] / 2 * 2;
        sum2 += a[3] / 2 * 2;
        sum2 += a[4] / 2 * 2;
    }
    
    printf("%lld\n", ans + max(sum1, sum2));
    
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <numeric>
#include <limits>
using namespace std;

int main(void) {
	int n;
	string s, t, s2, t2;

	cin >> n >> s >> t;

	for (int i = n-1; i >= 0; i--) {
		for (int j = 0; j <= i; j++) {
			s2 += s[n - i - 1 + j];
			t2 += t[j];
		}
		if (s2 == t2) {
			t.erase(t.begin(), t.begin() + i+1);
			s += t;
			cout << s.size() << endl;
			return 0;
		}
		t2.clear();
		s2.clear();
	}
	s += t;
	cout << s.size() << endl;
	return 0;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>bool chmin(T&a,const T&b){return a>b?(a=b,1):0;}
template<class T>bool chmax(T&a,const T&b){return a<b?(a=b,1):0;}


int nextInt() { int x; scanf("%d", &x); return x;}

const int MAX_N = 100000 + 10;
vector<int> g[MAX_N];
int color[MAX_N];

bool comp = false;

void dfs(int v, int prev, int c) {
  if (color[v] == 0) {
    color[v] = c;
    for (int u : g[v]) if (u != prev) {
      dfs(u, v, c * -1);
    }
  } else {
    if (color[v] != c) {
      comp = true;
      throw 1;
    }
  }
}

int main2() {
  int N = nextInt();
  int M = nextInt();
  REP(i, N) g[i].clear();
  REP(i, M) {
    int a = nextInt() - 1;
    int b = nextInt() - 1;
    g[a].push_back(b);
    g[b].push_back(a);
  }

  memset(color, 0, sizeof(color));
  try {
    comp = false;
    dfs(0, -1, +1);
  } catch (int e) {

  }
  ll ans = 0;
  if (comp) {
    ans = (ll)N * (N - 1) / 2 - M;
  } else {
    ll A = 0;
    ll B = 0;
    REP(i, N) if (color[i] == 1) A++; else B++;
    ans = A*B - M;
  }

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

int main() {
  for (;!cin.eof();cin>>ws) main2();
  return 0;
}



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

int main() {
   int x1,y1,x2,y2;
   cin >> x1 >> y1 >> x2 >> y2;
   cout << x2-y2+y1 << ' ' << y2 + x2 - x1 << ' ' << x1-y2+y1 << ' ' << y1+x2-x1 << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<ll,int> P;
typedef pair<ll,ll> p;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
static const int MAX_SIZE = 1 << 17; //segment tree のサイズ。この実装では2べきにする必要がある。 2^17 ≒ 1.3 * 10^5

int main(){
  int N;
  ll C,x[110000],v[110000],T[110000],H[110000],temp=0;
  cin>>N>>C;
  for(int i=1;i<=N;i++){
      cin>>x[i]>>v[i];
  }
  x[N+1]=C; v[N+1]=0;
  x[0]=0; v[0]=0;
  for(int i=0;i<=N+1;i++){
      temp+=v[i];
      if(i==0) T[i]=v[i]-x[i];
      else T[i]=max(T[i-1],temp-x[i]);
  }
  temp=0;

  for(int i=N+1;i>=0;i--){
      temp+=v[i];
      if(i==N+1) H[i]=v[i]-(C-x[i]);
      else H[i]=max(H[i+1],temp-(C-x[i]));
  }
  ll ans=0;
  ans=max(ans,max(H[0],T[N+1]));
  temp=0;
  for(int i=0;i<=N;i++){
      temp+=v[i];
      ans=max(ans,temp-x[i]*2+H[i+1]);
  }
  temp=0;
  for(int i=N+1;i>=1;i--){
      temp+=v[i];
      ans=max(ans,temp-(C-x[i])*2+T[i-1]);
  }
  cout<<ans<<endl;


}



Measured memory_bytes: 3584
#include <stdio.h>
int main(){
  int i;
  char s[12];
  scanf("%s",s);
  for(i=0;i<4;i++)printf("%c",s[i]);
  printf(" ");
  for(i=4;i<12;i++)printf("%c",s[i]);
  printf("\n");
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <cassert>
#include <memory>
#include <stack>
#include <set>
#include <map>
#include <cctype>
#include <climits>
#include <list>

#define MAX_SIZE 100000000
#define MOD 1000000007
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

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

  int N; cin>>N;
  bool odd = true;
  if(N % 2 == 0) {
    odd = false;
  }
  list<int> even_i_lst, odd_i_lst;


  for(int i=0; i<N; i++) {
    int a; cin>>a;

    if(odd) {
      if(i % 2 == 0) {
        even_i_lst.push_front(a);
      } else {
        odd_i_lst.push_back(a);
      }
    } else {
      if(i % 2 == 0) {
        even_i_lst.push_back(a);
      } else {
        odd_i_lst.push_front(a);
      }
    }
  }

  vector<int> merge_lst;
  if(odd) {
    for(auto v: even_i_lst) {
      merge_lst.push_back(v);
    }
    for(auto v: odd_i_lst) {
      merge_lst.push_back(v);
    }
  } else {
    for(auto v: odd_i_lst) {
      merge_lst.push_back(v);
    }
    for(auto v: even_i_lst) {
      merge_lst.push_back(v);
    }
  }

  for(int i=0; i < (int)merge_lst.size(); i++) {
    if(i != (int)merge_lst.size() - 1) {
      cout << merge_lst[i] << " ";
    } else {
      cout << merge_lst[i] << endl;
    }
  }
}


Measured memory_bytes: 9336
import numpy as np
from scipy.sparse.csgraph import floyd_warshall

N,M,L=map(int,input().split())
INF = 1 << 31
dist=np.array([[INF for _ in range(N)] for _ in range(N)])

for i in range(N):
  dist[i][i]=0
  
for i in range(M):
  a,b,c=map(int,input().split())
  a-=1
  b-=1
  dist[a][b]=c
  dist[b][a]=c

dist = floyd_warshall(dist)

for i in range(N):
  for j in range(N):
    if dist[i][j]<=L:
      dist[i][j]=1
    else:
      dist[i][j]=INF

dist = floyd_warshall(dist)
dist[dist==INF]=0
#dist=dist.astype(int)
#print(dist)

Q=int(input())
ans=[0]*Q
for q in range(Q):
  s,t=map(int,input().split())
  s-=1
  t-=1
  ans[q]=int(dist[s][t]-1)

for a in ans:
  print(-1 if a==INF else a)



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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const int MOD = 1000000007;

int main() {
  int n;
  cin >> n;
  int t, a;
  cin >> t >> a;
  int ans;
  double diff = 100000000000;
  rep(i, n) {
    int h;
    cin >> h;
    if (diff > abs(a - t + h * 0.006)) {
      diff = abs(a - t + h * 0.006);
      ans = i + 1;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;

int main(){
  ll N;cin>>N;
  vector<ll> a(3*N);
  ll i,j,k;
  rep(i,3*N){
    cin>>a[i];
  }
  /*
  //O(n^2)の解法
  if(N>1000) return -1;
  ans = -(ll)INF*INF;
  vector<ll> pre,aft;
  for(i=N;i<=2*N;i++){
    pre.clear();aft.clear();
    ll tmp = 0;
    rep(j,i){
      pre.pb(a[j]);
    }
    for(j=i;j<3*N;j++){
      aft.pb(a[j]);
    }
    SORT(pre);
    SORT(aft);
    ll x = pre.size();
    ll y = aft.size();
    for(j=x-1;j>=x-N;j--){
      tmp += pre[j];
    }
    rep(j,N){
      tmp -= aft[j];
    }
    // cout<<tmp<<endl;
    ans = max(ans,tmp);
  }
  cout<<ans<<endl;
  */
  //O(nlogn)の解法
  ll ans = -(ll)INF*(ll)INF;
  priority_queue<ll,vector<ll>,greater<ll> > que1;
  priority_queue<ll> que2;
  vector<ll> b(N+1),c(N+1);
  rep(i,N){
    b[0] += a[i];
    que1.pu(a[i]);
  }
  for(i=2*N;i<3*N;i++){
    c[0] += a[i];
    que2.pu(a[i]);
  }
  //priority_queueを利用してb,cを更新していく
  for(i=N;i<2*N;i++){
    que1.pu(a[i]);
    ll tmp1 = que1.top();
    que1.pop();
    b[i-N+1] = max((ll)0,a[i]-tmp1)+b[i-N];
  }
  for(i=2*N-1;i>=N;i--){
    que2.pu(a[i]);
    ll tmp2 = que2.top();
    que2.pop();
    c[2*N-i] = min((ll)INF,a[i]-tmp2)+c[2*N-i-1];
  }
  rep(i,N+1){
    // cout<<i<<" "<<b[i]<<" "<<c[N-i]<<endl;
    // cout<<ans<<endl;
    ans = max(ans,b[i]-c[N-i]);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 6516
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;

int main()
{
    int n, a[105];
    scanf("%d", &n);
    for(int i = 0; i < n; ++i)
    {
        scanf("%d", &a[i]);
    }
    sort(a, a+ n);
    cout << (a[n - 1] - a[0]) << endl;
    return 0;
}


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

int main(void) {
    int N,K;cin>>N>>K;
    int mi = 1e9;
    for (int bit = 0; bit < (1 << N); bit++) {
        int cur = 1;
        for (int i = 0; i < N; i++) {
            if ((bit>>i)&1) cur *= 2;
            else cur += K;
        }
        if (mi > cur) mi = cur;
    }
    cout << mi << endl;
    return 0;
}

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

using namespace std;

const long long INF = 1000000000000000000;
long long n;
int a, b, c, d;
map<long long, long long> memo;

long long rec(long long x) {
    if (x == 0) return 0;
    if (x == 1) return memo[1];
    if (memo.count(x)) return memo[x];
    long long res = INF;
    if (n <= (INF / d)) res = x * d;
    if (x % 5 == 0) {
        res = min(res, rec(x / 5) + c);
    } else if (x % 5 == 1) {
        res = min(res, rec(x / 5) + c + d);
    } else if (x % 5 == 2) {
        res = min(res, rec(x / 5) + c + d + d);
    } else if (x % 5 == 3) {
        res = min(res, rec((x / 5) + 1) + c + d + d);
    } else if (x % 5 == 4) {
        res = min(res, rec((x / 5) + 1) + c + d);
    }
    if (x % 3 == 0) {
        res = min(res, rec(x / 3) + b);
    } else if (x % 3 == 1) {
        res = min(res, rec(x / 3) + b + d);
    } else if (x % 3 == 2) {
        res = min(res, rec((x / 3) + 1) + b + d);
    }
    if (x % 2 == 0) {
        res = min(res, rec(x / 2) + a);
    } else if (x % 2 == 1) {
        res = min(res, rec(x / 2) + a + d);
        res = min(res, rec((x / 2) + 1) + a + d);
    }
    memo[x] = res;
    return res;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t;
    cin >> t;
    for (int i = 0; i < t; i++) {
        cin >> n;
        cin >> a >> b >> c >> d;
        memo.clear();
        memo[0] = 0;
        memo[1] = d;
        cout << rec(n) << '\n';
    }
    return 0;
}

Measured memory_bytes: 4420
N,M = map(int,input().split())

Peaks = list(map(int,input().split()))

ans =[1]*N

for i in range(M):
    a,b = map(int,input().split())
    a=a-1
    b=b-1

    if Peaks[a]>Peaks[b]:
        ans[b]=0
    elif Peaks[a]<Peaks[b]:
        ans[a]=0
    else:
        ans[a]=0
        ans[b]=0

print(sum(ans))


Measured memory_bytes: 20144
from itertools import combinations
from bisect import *
def max2(x,y):
    return x if x > y else y
N = int(input())
L = list(map(int, input().split()))
L.sort()
res = 0
for i, j in combinations(range(N), 2):
    a, b = L[i], L[j]
    res += max2(bisect_left(L, a+b) -1 - j, 0)
print(res)

Measured memory_bytes: 74512
while True:
    m, nl, nu = map(int, input().split())
    if m == 0:
        break

    p = [int(input()) for i in range(m)]
    gap = ans = 0
    for n in range(nl, nu + 1):
        if p[n - 1] - p[n] >= gap:
            gap = p[n - 1] - p[n]
            ans = n
    print(ans)


Measured memory_bytes: 5624
#include<stdio.h>
int main(void){
    int a, b, c;
    int t;
    scanf("%d %d %d", &a, &b, &c);
    if(a>b){
        t=a;
        a=b;
        b=t;
    }
    if(b>c){
        t=b;
        b=c;
        c=t;
    }
    if(a>b){
        t=a;
        a=b;
        b=t;
    }
    printf("%d %d %d\n", a, b, c);
    return 0;
}


Measured memory_bytes: 2104
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <tuple>
#define INF 100000000
#define MOD 1000000007
using namespace std;
int main(void){
  char str[15];
  cin>>str;
  int N=strlen(str);
  int max=0;
  int count=0;
  for(int i=0;i<N;i++){
      for(int j=i;j<N;j++){
          count=0;
          for(int k=i;k<=j;k++){
              if(str[k]=='A'||str[k]=='T'||str[k]=='G'||str[k]=='C'){count++;}
          }
          if(count>max&&count==j-i+1){max=count;}
      }
  }
  cout<<max;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include<algorithm>
#include<sstream>
#include<iomanip>


using namespace std;

typedef long long ll;

const ll MOD_CONST = 1000000007;
const string ACGT = "ACGT";
int n;

bool ok(string last4) {
	string s1 = last4.substr(0, 3);
	string s2 = last4.substr(1, 3);
	
	if (s1 == "AGC" || s2 == "AGC") {
		return false;

	}
	if (s1 == "GAC" || s2 == "GAC") {
		return false;

	}
	if (s1 == "ACG" || s2 == "ACG") {
		return false;

	}

	if (last4[0] == 'A' && last4[2] == 'G' && last4[3] == 'C') {
		return false;
	}
	if (last4[0] == 'A' && last4[1] == 'G' && last4[3] == 'C') {
		return false;
	}

	return true;
}

int main() {

	cin >> n;

	map<string, ll> m;
	
	for (int b = 0; b < (1 << (2 * 3));b++) {
		string s;
		for (int i = 0; i < 3;i++) {
			s += ACGT[((b >> (2 * i)) & 3)];
			
		}
		if (ok(s)) {
			m[s]++;
		}
	}

	for (int i = 3; i < n;i++) {
		map<string, ll> new_m;
		for (auto it = m.begin();it != m.end(); it++) {
			for (int j = 0; j < 4;j++) {
				string s = it->first + ACGT[j];
				if (ok(s)) {
					new_m[s.substr(1, 3)] += it->second;
					new_m[s.substr(1, 3)] %= MOD_CONST;
				}
			}
		}
		m = new_m;
	}
	
	ll sum = 0;
	for (auto it = m.begin();it != m.end(); it++) {
		sum = (sum + it->second) % MOD_CONST;
	}
	cout << sum << endl;

}


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

#define rep(i,n) for(int i = 0; i < n; i++)
#define Rep(i,n) for(int i = 1; i <= n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
template<class T> using V = vector<T>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
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; }



int main(){
    int n;
    cin >> n;
    set<char> st;
    rep(i,n) {
        char c;
        cin >> c;
        st.insert(c);
    }
    if(sz(st) == 3) cout << "Three" << endl;
    if(sz(st) == 4) cout << "Four" << endl;
}

Measured memory_bytes: 3628
N = int(input())
ans = [N]
tmp=N
count=1
flag=True
while flag:
  count+=1
  if tmp%2==0:
    tmp=tmp/2
  else:
    tmp=3*tmp+1
  # print(tmp)
  if tmp in ans:
    flag=False
    break
  ans.append(tmp)
print(count)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string S;
    cin>>S;
   if (S[5] - '0' > 0 || S[6] - '0' > 4)
    {
        cout<<"TBD"<<endl;
    }
   else
   {
       cout<<"Heisei"<<endl;
   }
   return 0;
}


Measured memory_bytes: 256
class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.size = [1] * n
        self.rank = [0] * n
        self.edge = [0] * n

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def is_saturated(self, x):
        x = self.find(x)
        return self.edge[x] == self.size[x]

    def get_size(self, x):
        return self.size[self.find(x)]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        self.edge[x] += 1
        if x == y:
            return

        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self.size[y] += self.size[x]
            self.edge[y] += self.edge[x]
        else:
            self.par[y] = x
            self.size[x] += self.size[y]
            self.edge[x] += self.edge[y]
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

n, h, w = [int(item) for item in input().split()]

UF = UnionFind(h+w)
arc = []
for i in range(n):
    r, c, a = [int(item) for item in input().split()]
    r -= 1; c -= 1
    c += h
    arc.append([a, r, c])
arc.sort(reverse=True)

ans = 0
for a, r, c in arc:
    if not UF.is_saturated(r) or not UF.is_saturated(c):
        UF.union(r, c)
        ans += a

print(ans)


Measured memory_bytes: 35860
#include <stdlib.h>
#include <stdio.h>
#define min(a,b) a<=b?a:b
int main()
{
    int h,w,i,j,cnt,cnt1,flag;
    char s[500][500];
    scanf("%d %d\n",&h,&w);
    for(i=0;i<h;i++){
        scanf("%s",s[i]);
        
    }
    for(i=0;i<h;i++){
        cnt=0;
        for(j=0;j<w;j++){
            if(s[i][j]=='.'){
                cnt++;
            }
            
            if(cnt==w){
                for(j=0;j<w;j++){
                    s[i][j]='x';
                }
            }
        }
    }
    for(j=0;j<w;j++){
        cnt1=0;
        for(i=0;i<h;i++){
            if(s[i][j]=='.'||s[i][j]=='x'){
            cnt1++;    
            }
            if(cnt1==h){
                for(i=0;i<h;i++){
                    s[i][j]='x';
                }
            }
        }
    }
    for(i=0;i<h;i++){
        flag=0;
        for(j=0;j<w;j++){
            if(s[i][j]!='x'){
                printf("%c",s[i][j]);
                flag=1;
            }
        }
        if(flag==1){
            printf("\n");
        }
    }
    return 0;
}


Measured memory_bytes: 256
from heapq import heappop, heappush

def dijkstra1(g, source):
    # O(ElogV)

    n = len(g)
    inf = float("inf") # 高速化のためにはfloat("inf")ではないほうがいい
    dist = [inf] * n
    dist[source] = 0
    q = [(0, source)]

    while q:
        cost, u = heappop(q)
        if dist[u] < cost:
            continue
        for c, v in V[u]:
            if dist[v] > dist[u] + c:
                dist[v] = dist[u] + c
                heappush(q, (dist[v], v))

    return dist

def dijkstra2(g, source):
    n = len(V)
    inf = float("inf") # 高速化のためにはfloat("inf")ではないほうがいい
    used = [False]*n
    dist = [inf]*n
    dist[0] = 0
    
    for _ in range(n):
        c1, u = min([(dist[i], i) for i in range(n) if not used[i]])
        used[u] = True
        for c2, v in V[u]:
            if v==u: continue
            dist[v] = min(dist[v], c1+c2)
    return dist


if __name__ == "__main__":
    n = int(input())
    V = [[] for _ in range(n)]

    for _ in range(n):
        u, k, *vc = map(int, input().split())
        for i in range(0, 2*k, 2):
            v, c = vc[i], vc[i+1]
            V[u].append((c, v))

    d = dijkstra2(V, 0)
    for i, j in enumerate(d):
        print(i, j)



Measured memory_bytes: 6224
#include<iostream>

#define endl '\n'

using namespace std;

const int MAXN=103,MAXK=1e5+3;
int stones[MAXN];
bool dp[MAXK];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,k;
    cin>>n>>k;
    for(int i=0;i<n;++i){
        cin>>stones[i];
    }
    for(int i=0;i<=k;++i){
        for(int i2=0;i2<n and stones[i2]<=i;++i2){
            if(!dp[i-stones[i2]]){
                dp[i]=true;
            }
        }
    }
    cout<<(dp[k] ? "First" : "Second")<<endl;
return 0;
}

Measured memory_bytes: 384
string = input()
flg = True
for k, i in enumerate(string):
    if k % 2 == 0:
        if i not in ['R', 'U', 'D']:
            flg = False
    else:
        if i not in ['L', 'U', 'D']:
            flg = False
print('Yes') if flg else print('No')

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

int main(){
  int N, M;

  // Redカードを配列に格納
  cin >> N;
  vector<string> red(N);
  for(int i = 0; i < N; i++)
    cin >> red.at(i);

  // Blueカードを配列に格納 
  cin >> M;
  vector<string> blue(M);
  for(int i = 0; i < M; i++)
    cin >> blue.at(i);

  int result = 0;
  for(int i = 0; i < N; i++){
    // Redカードの同じ単語の数を加算
    int cnt = 0;
    for(int j = 0; j < N; j++){
      if(red[i] == red[j]){
        cnt++;
      }
    }
    // Blueカードの同じ単語の数を減算
    for(int j = 0; j < M; j++){
      if(red[i] == blue[j]){
        cnt--;
      }
    }
    // 同じ単語の数の最大値を算出
    result = max(result, cnt);
  }

  cout << result;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
// #define int ll
using namespace std;
const int INF (1 << 30);
const ll LLINF (1LL << 55LL);
const int MOD = 1000000007;
const int MAX = 510000;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    string s,t;
    cin>>s>>t;
    ll ans=0;
    rep(i,(ll)s.size()){
        if(s[i]==t[i]) ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
/*input
9
*/
#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long
#define mod 1000000007
#define inf 1000000000000000001
#define all(c) c.begin(),c.end()
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define sz(a) int((a).size())
#define pb push_back
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())     
#define rep(i,j,n) for(ll i=j;i<n;i++)
#define mp make_pair
#define N 998244353
#define PI acos(-1.0)
//if (s.find('R') != std::string::npos)
//s.replace(s.find("10"), sizeof("10") - 1, "");
using namespace std;

int main()
{
  // added the two lines below 
  ios_base::sync_with_stdio (false); 
  cin.tie(NULL);
  cout.tie(0);
  
  ll n;
  cin>>n;
  ll arr[n];
  rep(i,0,n) cin>>arr[i];
  ll sum=0,ans=INT_MAX,s1=0;
  rep(i,0,n) sum+=arr[i];
  for(int i=0;i<n-1;i++){
    s1+=arr[i];
    sum=sum-s1;
    //cout<<s1<<' '<<sum<<endl;
    ans=min(ans,abs(sum-s1));
    sum+=s1;
  }
  cout<<ans;
  }

Measured memory_bytes: 256
#  --*-coding:utf-8-*--

def main():
    N = int(input())
    A = map(int, input().split())
    X = list(map(lambda a: a[1],
                 sorted((int(a), i+1) for i, a in enumerate(A))))

    print(' '.join(map(str, X)))




if __name__ == '__main__':
    main()


Measured memory_bytes: 23480
#include<stdio.h>
#include<string.h>
int main() {
  char S[10];
  scanf("%s", S);
  if (strcmp(S, "SUN") == 0) {
    printf("7\n");
  }
  else if (strcmp(S, "MON") == 0) {
    printf("6\n");
  }
  else if (strcmp(S, "TUE") == 0) {
    printf("5\n");
  }
  else if (strcmp(S, "WED") == 0) {
    printf("4\n");
  }
  else if (strcmp(S, "THU") == 0) {
    printf("3\n");
  }
  else if (strcmp(S, "FRI") == 0) {
    printf("2\n");
  }
  else if (strcmp(S, "SAT") == 0) {
    printf("1\n");
  }
  return 0;
}

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

struct Work {
    int time;
    int deadLine;

    bool operator < (const Work &a) {

        if(deadLine == a.deadLine) 
            return time < a.time;
        
        return deadLine < a.deadLine;

    }

};

int main() {

    int n;
    cin >> n;

    vector<Work> w(n);

    for(int i = 0; i < n; ++i)
        cin >> w[i].time >> w[i].deadLine;

    sort(w.begin(), w.end());

    int time = 0;
    int i;
    for(i = 0; i < n; ++i) {

        time += w[i].time;
        if(time > w[i].deadLine)
            break;

    }

    if(i == n)
        cout << "Yes" << endl;
    else
    {
        cout << "No" << endl;
    }
    

    return 0;

}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define int long long
#define f first
#define s second
using namespace std;
int32_t main(){
    ios::sync_with_stdio(0),cin.tie(0);
    string s,t;
    cin >> s >> t;
    int ok=1;
    if(t.size()!=s.size()+1)ok=0;
    for(int i=0;i<s.size();i++){
    	if(s[i]!=t[i])ok=0;
    }
    if(ok)cout << "Yes";
    else cout << "No";
}

Measured memory_bytes: 3608
# クエリが何回か飛んでくる→累積和か?

# 1回の実技試験での最大移動回数は、H*W/1 = 90000→愚直に計算すると無理。

# Dが実技試験によらず一定なので、移動後のマスから移動前のマスは分かる。

# 最初に各マスについて座標を調べて
# 次に移動前のマスとのマンハッタン距離を調べる
# しかし毎回の試験の魔力を愚直に計算すると、やはり90000程度が掛かって無理。

# P_i = i%Dからiまで移動して来るのに必要な魔力（i<=Dなら0）
# とすれば、毎回のクエリにはP_R - P_Lを出せばよく、定数時間で求まる

h, w, d = list(map(int, input().split()))

masu = h * w
h_coord = [-1] * masu  # 座標は0-indexで取る
w_coord = [-1] * masu

for i in range(h):
    temp = list(map(int, input().split()))
    for j in range(w):
        num = temp[j]
        h_coord[num-1] = i
        w_coord[num-1] = j

distance_sum = [0] * masu
for i in range(masu):
    if i < d:
        pass
    else:
        distance_sum[i] = distance_sum[i-d] + abs(h_coord[i] - h_coord[i-d]) + abs(w_coord[i] - w_coord[i-d])

q = int(input())

for qi in range(q):
    l, r = list(map(int, input().split()))
    print(distance_sum[r-1] - distance_sum[l-1])
    


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

int main(){
  int w, h, x, y;
  cin >> w >> h >> x >> y;
  bool odda = false;
  if(w%2 && h%2) odda =true;
  ll ans = (ll)w*(ll)h/2;
  int a=0;
  if(w%2==0 && w/2==x && h%2==0 && h/2==y) a=1;
  if(odda) cout << ans << ".5 0" << endl;
  else cout << ans << " " << a << endl;
}

Measured memory_bytes: 256
/*****Be Name Khoda*****/

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

#define F first
#define S second
#define Size(x) ((int)x.size())
#define All(x) x.begin() , x.end()

using namespace std;
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	string s , t;
	cin >> s;
	reverse(All(s));
	t = s;
	reverse(All(s));
	if(t == s)
		return cout << "Yes" , 0;
	cout << "No";
}

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

#define pb push_back
#define mod 1000000007
typedef int integer;
#define int long long
using namespace std;

int powmod(int a, int b) {
    int res = 1;
    a %= mod;
    assert(b >= 0);
    for (; b; b >>= 1) {
        if (b & 1)res = res * a % mod;
        a = a * a % mod;
    }
    return res;
}

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

const integer NN = 200005;
int ar[NN];
int n, m, k;
string s;

bool pal(int i, int j){
    while (i < j){
        if (s[i] != s[j]) return false;
        i++; j--;
    }
    return true;
}


integer main() {
    ios_base::sync_with_stdio(false);

    cin >> s;
    n = s.length();
    bool ans = pal(0, n-1) && pal(0, (n-1)/2 - 1) && pal((n+3)/2 - 1, n-1);
    cout << (ans ? "Yes" : "No") << endl;
//    for (int i = 0; i < n; i++){
//        cin >> ar[i];
//    }
}


Measured memory_bytes: 256
import sys


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    s = ni()
    mod = 10 ** 9 + 7
    ans = [0] * 2001
    ans[0] = 1
    for i in range(3, s + 1):
        ans[i] = (ans[i - 1] + ans[i - 3]) % mod
    print(ans[s])


if __name__ == '__main__':
    main()


Measured memory_bytes: 9212
cnt=0
a,s,d=map(int,input().split())
if a==s==d:
    if a%2==0:print(-1)
    else:print(0)
    exit()
while a%2==s%2==d%2==0:
    a,s,d=(s+d)//2,(a+d)//2,(a+s)//2
    cnt+=1
print(cnt)

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

int main(){
	int n;
	cin >> n;
	int sum = 0;
	for(int i = 1; i <= n; i += 2){
		int counter = 0;
		for(int j = 1; j <= i; j++){
			if(i % j == 0)counter++;
		}
		if(counter == 8)sum++;
	}
	cout << sum << endl;
}

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

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


Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int x, y, a, r;

  scanf("%d%d", &x, &y);

  if(x > y){
    a = x;
    x = y;
    y = a;
  }
  r = y % x;

  while(r != 0){
    y = x;
    x = r;
    r = y % x;
  }

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

  return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
typedef long long ll;
using namespace std;
int main(void){
    int a,b;cin>>a>>b;
    rep1(i,100000){
        int A=(double)i*0.08;
        int B=(double)i*0.1;
        if(A==a&&b==B){
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;
}



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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

int n;
int a[16][16];
int ans=0;

void dfs(int idx, vi m)
{
    if (idx==n){
        int cnt=0;
        rep(i,n){
            if (m[i]==0) continue;
            bool h=true;
            rep(j,n){
                if (m[j] != a[i][j] && a[i][j]!=-1) h=false;
            }
            if (h) cnt++; else return;
        }
        ans = max(ans, cnt);
        return;
    }
    m[idx] = 0;
    dfs(idx+1,m);
    m[idx] = 1;
    dfs(idx+1,m);
}

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>n;
    rep(i,16)rep(j,16){
        a[i][j] = -1;
    }
    rep(i,n){
        int A; cin>>A;
        rep(j,A){
            int x, y; cin>>x>>y;
            a[i][x-1] = y;
        }
    }
    vi m(n, -1);
    dfs(0,m);
    cout<<ans<<endl;
    return 0;
}


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

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <math.h>
#include <map>

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n)   FOR(i,0,n)
#define RREP(i,n)   RFOR(i,0,n)

const double INF = 1e+09;
const int MOD = 1e9+7;

using namespace std;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {if (v.empty()) {ostr << "{ }"; return ostr;}
    ostr << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) {ostr << ", " << *itr;}
    ostr << "}";
    return ostr;}

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 main(void){
  ios::sync_with_stdio(false);

  int n;
  cin >> n;
  vector<int> h(n);
  REP(i, n){cin >> h[i];}

  vector<int> dp(n+100);
  REP(i, n+100) dp[i] = INF;
  dp[0] = 0;
  dp[1] = abs(h[1] - h[0]);

  REP(i, n){
    chmin(dp[i+1], dp[i] + abs(h[i] - h[i+1]));
    chmin(dp[i+2], dp[i] + abs(h[i+2] - h[i]));
  }

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


  return 0;
}



Measured memory_bytes: 1024
import numpy as np

ls = [int(input()) for _ in range(5)]


a=0
for h in ls:
    if h%10 == 0:
        pass
    else:
        re =(h//10+1)*10-h
        if re>=a:
            a = re


time = 0
for i in ls:
    if i%10 == 0:
        time += i
    else:
        time += (i//10+1)*10

time -= a
print(time)

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

using namespace std;
typedef long long ll;
const int maxn = 2e5 + 5;
const int MOD = 2019;

char s[maxn];
int cnt[2019];

int main() {
    scanf("%s", s + 1);
    int n = strlen(s + 1);
    int x = 0, pw = 1;
    for (int i = n; i >= 1; i--) {
        x = (x + (s[i] - '0') * pw) % MOD;
        pw = pw * 10 % MOD;
        cnt[x]++;
    }
    ll res = 1ll * (cnt[0] + 1) * cnt[0] / 2;
    for (int i = 1; i < MOD; i++) {
        if (cnt[i] > 1) res += 1ll * cnt[i] * (cnt[i] - 1) / 2;
    }
    printf("%lld\n", res);
    return 0;
}

Measured memory_bytes: 3964