akhauriyash/Code-Regression huggingface dataset:
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)

	var max, sum int
	for _, c := range s {
		if c == 'A' || c == 'C' || c == 'G' || c == 'T' {
			sum++
		} else {
			sum = 0
		}
		if max < sum {
			max = sum
		}
	}
	fmt.Println(max)
}


Measured memory_bytes: 512
n,m = (int(x) for x in input().split())
A = [input().split() for i in range(n)]
b = [int(input()) for i in range(m)]

for i in range(n):
    x = 0
    for j in range(m):
        x += int(A[i][j]) * b[j]
    print(x)


Measured memory_bytes: 6260
n = int(input())
a = list(map(int,input().split()))
dp = [[0 for _ in range(n)] for j in range(n)]
for i in range(n):
    dp[i][i] = a[i]

for dist in range(1,n):
    for i in range(n-dist):
        j = i + dist
        dp[i][j] = max(a[i]-dp[i+1][j],a[j]-dp[i][j-1])

print(dp[0][n-1])

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


ll MOD = 1000000007;

int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   ll t;
   t = 1;
   //cin >> t;
   while(t--)
   {
      ll n,m;
      cin >> n >> m;

      ll i;
      ll beg = 1;
      ll endo = n;
      for(i=0;i<m;i++)
      {
         
         if(i%2 == 0)
         {
            cout << beg << " " << beg+(m-i) <<endl;
            beg++;
         }
         else
         {
            cout << endo-(m-i) << " " << endo << endl;

            endo--;

         }

      }

      
   }
   return 0;
}

Measured memory_bytes: 3656
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int X;
    cin >> X;
    if (X >= 30) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3644
n,q = map(int,input().split(" "))
s = input()
counter = 0
ac_num = []
ac_num.append(0)

for i in range(1,n):
    if (s[i]=="C") & (s[i-1]=="A"):
        counter = counter + 1
    ac_num.append(counter)

rng = [0,0]
result = []

for i in range(q):
    rng[0],rng[1] = map(int,input().split(" "))
    result.append(ac_num[rng[1]-1]-ac_num[rng[0]-1])

for i in result:
    print(i)


Measured memory_bytes: 10220
#include <iostream>
#include <vector>
#include <set>
#include <deque>
#include <map>
#include <iomanip>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <utility>
using namespace std;
int ky[8] = {-1,1,-2,2,-2,2,-1,1}; 
int kx[8] = {-2,-2,-1,-1,1,1,2,2};
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int ddy[8] = {-1,0,1,-1,1,-1,0,1};
int ddx[8] = {-1,-1,-1,0,0,1,1,1};
typedef long long ll;
#define pi pair
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define rep1(i,a,b) for(int i = a; i < b; i++)
#define rep2(i,a,b) for(int i = a; i <= b; i++) 
#define INF 999999999999
const double PI = acos(-1.0); 
ll n;
ll num;
ll cnt;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    cin >> n;
    num = 26;
    cnt = 1;
    while(n > num){
        n -= num;
        num *= 26;
        cnt++;
    }

    string ans(cnt, '0');
    --n;
    for(int i = cnt - 1; i >= 0; i--){
        ans[i] = (n % 26) + 'a';
        n /= 26;
    }
    cout << ans;
    return 0;  
}

Measured memory_bytes: 3656
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <numeric>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 1000000007;

long long mod_pow(long long x, long long n) {
    long long res = 1;
    for(int i = 0;i < 60; i++){
        if(n >> i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}

template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

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

void fast_input() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int main(void) {
    int a, b, c; cin >> a >> b >> c;
    cout << min({a+b, c+b, a+c}) << endl;
}   


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

using namespace std;

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

    bool ret = true;

    for (int i = 0; i < s.size(); i++) {
        if (i % 2 == 0 && s[i] == 'L')ret = false;
        if (i % 2 == 1 && s[i] == 'R')ret = false;
    }

    cout << (ret ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>

using namespace std;

int main(int argc, char const *argv[])
{
    char s[51], t[51];
    scanf("%s\n%s\n", s, t);
    int ls, lt;
    for(int i=0; i<51; i++){
        if(s[i]=='\0'){
            ls = i;
            break;
        }
    }
    for(int i=0; i<51; i++){
        if(t[i]=='\0'){
            lt = i;
            break;
        }
    }
    if(ls<lt){
        printf("UNRESTORABLE\n");
        return 0;
    }
    for(int i=ls-lt; i>=0; i--){
        bool flag = true;
        for(int j=0; j<lt; j++){
            if(s[i+j] != '?' && s[i+j] != t[j]){
                flag = false;
                break;
            }
        }
        if(flag){
            for(int j=0; j<i; j++){
                if(s[j] == '?') s[j] = 'a';
            }
            for(int j=0; j<lt; j++){
                s[i+j] = t[j];
            }
            for(int j=i+lt; j<ls; j++){
                if(s[j] == '?') s[j] = 'a';
            }
            printf("%s\n", s);
            return 0;
        }
    }
    printf("UNRESTORABLE\n");
    return 0;
}


Measured memory_bytes: 128
//created by pyoxiao on 2020/04/04
#include<bits/stdc++.h>
#define LL long long
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define CL(a, b) memset(a, b, sizeof(a))
using namespace std;
const int mod = 1e9 + 7;
LL fpow(LL a, LL b, LL p = mod){LL ans = 1; a %= p; while(b) {if(b & 1) ans = ans * a % p; b >>= 1; a = a * a % p;} return ans;}
LL gcd(LL a, LL b){return b == 0 ? a : gcd(b, a % b);}
const int N = 1e5 + 7;
int k;
queue<LL> q;
void solve() {
    scanf("%d", &k);
    for (int i = 1; i <= 9; i ++) q.push(i);
    while (q.size()) {
        LL cur = q.front(); q.pop(); k --;
        if (k == 0) {
            cout << cur << '\n'; 
            return;
        }
        if (cur % 10 != 0) q.push(cur * 10 + cur % 10 - 1);
        q.push(cur * 10 + cur % 10);
        if (cur % 10 != 9) q.push(cur * 10 + cur % 10 + 1);
    }
}
int main() {
    int T = 1;
    // scanf("%d", &T);
    while(T --) 
        solve();
    return 0;
}

Measured memory_bytes: 1792
#! /usr/bin/env python3

n = int(input())

x = [int(i) for i in input().split()]

sorted_x = sorted(x)

before_half = sorted_x[n//2 - 1]
after_half = sorted_x[n//2]

for i in range(n):
    if x[i] <= before_half:
        print(after_half)
    else:
        print(before_half)


Measured memory_bytes: 25228
#include <stdio.h>
#include <math.h>
int main(){
  int x[4],ans;
  for(int i=0;i<5;i++){
    scanf("%d", &x[i]);
    if(x[i]==0){
      ans = i;
      break;
    }
  }
  printf("%d", ans+1);
  return 0;
}

Measured memory_bytes: 1712
#include<bits/stdc++.h>
using namespace std;
int main(){
  vector<string> vec;
  int N,L; cin>>N>>L;
  for(int i=0;i<N;i++){
    string s; cin>>s;
    vec.push_back(s);
  }
  sort(vec.begin(),vec.end());
  string ans="";
  for(int i=0;i<N;i++) ans+=vec[i];
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
// Problem : C - Step
// Contest : AtCoder - AtCoder Beginner Contest 176
// URL : https://atcoder.jp/contests/abc176/tasks/abc176_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization ("unroll-loops")

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define fo(i,n)         for(int i=0;i<n;i++)
#define Fo(i,k,n)       for(int i=k;i<n;i++) 
#define endl            "\n"
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define vec(x)          vector<x>
#define matrix(x)       vector<vector<x>>
#define sz(x)           (int)x.size()
#define mem(a,b)        memset(a, b, sizeof a)
#define vii             vector<pair<int,int>>
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define gcd(a,b)        __gcd(a,b)
#define lcm(a,b)        (a*(b/gcd(a,b)))
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define MOD             998244353
#define deb(x)          cerr <<#x<<" = "<<x<<"\n"
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define all(v)          v.begin(),v.end()
#define rep(i,a,b)      for (int i = a; i<b; ++i)
#define len(s)          s.length()
#define watch(x)        cout << #x << " = " << x << endl
#define trace(x)        cerr << #x << " = " << x << endl
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
 
int power(int a,int b,int m=mod)
{int ans=1;while(b>0){if(b&1)ans=(ans*a)%m;a=(a*a)%m;b>>=1;}
return ans;}

void babuBhaiya()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

const int N = 1e5+1;
const double pi = acos(-1);

void solve(){
    
	int n; cin>>n;
	int s = 0;
	vi v(n);
	fo(i,n) cin>>v[i];
	for(int i = 1;i<n;i++){
		if(v[i]<v[i-1]){
			s += (v[i-1] - v[i]);
			v[i] = v[i-1];
		}
	}
	cout<<s;
}

 
int32_t main()
{
    babuBhaiya();

    int t;

    t = 1;
    //cin>>t;

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

Measured memory_bytes: 4712
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().strip()

n = ni()
a = na()

t = []
for i in a:
    t.append(i)
    t.append(i+1)
    t.append(i-1)

import collections
ans = collections.Counter(t)
print(ans.most_common()[0][1])


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

int main() {
    int D, E;
    for (;;) {
        cin >> D >> E;
        if (D == 0 && E == 0) {
            break;
        }

        double min_d = 1010101010;
        for (int j = 0; j <= D; ++j) {
            min_d = min(min_d, abs(sqrt(j*j+(D-j)*(D-j))-E));
        }

        printf("%.12f\n", min_d);
    }

    return 0;
}

Measured memory_bytes: 3220
N = int(input())
S_list = list(map(str, input().split( )))
import collections
S_dict = collections.Counter(S_list)
S_val, S_count=zip(*S_dict.most_common())
ans_number = len(S_val)
ans = 'Three'
if ans_number == 4:
  ans = 'Four'
print(ans)

Measured memory_bytes: 3316
import sys
import numpy as np
h,w = map(int,input().split())
a = [input() for i in range(h)]
a = [list(map(int,list(a[i].replace("#","1").replace(".","0")))) for i in range(h)]

aa = np.array(a)

tate = np.sum(aa,axis=0)
yoko = np.sum(aa,axis=1)

for i in range(len(tate)-1,-1,-1):
  if tate[i] == 0:
    aa = np.delete(aa,i,1)

for i in range(len(yoko)-1,-1,-1):
  if yoko[i] == 0:
    aa = np.delete(aa,i,0)

aa = np.where(aa == 0, ".", aa)
aa = np.where(aa == '1', "#", aa)

a = aa.tolist()

for i in range(len(a)):
  print(''.join(a[i]))

Measured memory_bytes: 12776
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define LOOP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define MP make_pair
#define FR first
#define SC second
#define int long long

using namespace std;
const int MOD=1000000007;
const int INF=9000000009;
const double eps=1e-10;

int x[10]={0,0,0,0,0,0,1,1,1,2};
int y[10]={1,1,1,2,2,3,2,2,3,3};
int z[10]={2,3,4,3,4,4,3,4,4,4};

signed main(){
  int n;
  cin>>n;
  int m=0,a=0,r=0,c=0,h=0;
  REP(i,n){
    string s;
    cin>>s;
    if(s[0]=='M')m++;
    if(s[0]=='A')a++;
    if(s[0]=='R')r++;
    if(s[0]=='C')c++;
    if(s[0]=='H')h++;
  }
  int d[5];
  d[0]=m,d[1]=a,d[2]=r,d[3]=c,d[4]=h;
  int ans=0;
  REP(i,10){
    ans+=d[x[i]]*d[y[i]]*d[z[i]];
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
//@chandan
#include<bits/stdc++.h>
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n,k;
	cin>>n>>k;
	vector<int> arr(n);
	for(int i=0;i<n;i++)
		cin>>arr[i];
	sort(arr.begin(),arr.end());
	int ans=0;
	for(int i=0;i<k;i++)
		ans+=arr[i];
	cout<<ans<<"\n";
	return 0;
}


Measured memory_bytes: 3576
#include <stdio.h>
int main()
{
	int hund[5],hundkind[4];
	int winkind[5],win,lose;
	bool chek;

	scanf("%d",&hund[0]);

	while(hund[0] != 0){
		for(int i = 1; i < 5; i++){
			scanf("%d",&hund[i]);
		}

		for(int i = 1; i < 4; i++){
			hundkind[i] = 0;
		}
		chek = false;
		for(int i = 0; i < 5; i++){
			hundkind[ hund[i] ]++;
		}

		if(hundkind[1] != 0 && hundkind[2] != 0 && hundkind[3] != 0){
			for(int i = 0; i < 5; i++){
				winkind[i] = 3;
				chek = false;
			}
		}
		else if(hundkind[1] == 5 || hundkind[2] == 5 || hundkind[3] == 5){
			for(int i = 0; i < 5; i++){
				winkind[i] = 3;
				chek = false;
			}
		}
		else if(hundkind[3] != 0 && hundkind[1] != 0){
			win = 3;
			lose = 1;
			chek = true;
		}
		else{
			for(int i = 1; i < 3; i++){
				if(hundkind[i] != 0 && hundkind[i+1] != 0){
					win = i;
					lose = i+1;
					chek = true;
				}
			}
		}
		for(int i = 0; i < 5 && chek; i++){
			if(hund[i] == win){
				winkind[i] = 1;
			}
			else{
				winkind[i] = 2;
			}
		}

		for(int i = 0; i < 5; i++){
			printf("%d\n",winkind[i]);
		}

		scanf("%d",&hund[0]);
	}

	return 0;
}

Measured memory_bytes: 1028
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long 
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back 
#define mp make_pair
#define inf 2000000009
#define mod 1000000007
using namespace std;

int main()
{ 

    fast;
  
  ll a,b,c;
  cin>>a>>b>>c;

  cout<<max((ll)0,c-a+b);
  }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define mst(a,b) memset((a),(b),sizeof(a))
#define mp(a,b) make_pair(a,b)
#define pi acos(-1)
#define pii pair<int,int>
#define pb push_back
#define lowbit(x) ((x)&(-x))
const int INF = 0x3f3f3f3f;
const double eps = 1e-6;
const int maxn = 1e5 + 10;
const int maxm = 1e6 + 10;
const ll mod =  998244353;

int a[maxn],fa[maxn];

struct edge {
    int u,v,w;
    bool operator < (const edge &x)const {
        return w < x.w;
    }
}e[maxn];

int findd(int x) {
    return x == fa[x] ? x : fa[x] = findd(fa[x]);
}

struct node {
    int num,mxedge,ok;
    ll sum;
}blo[maxn];

int main() {
#ifdef local
    freopen("data.txt", "r", stdin);
//    freopen("data.txt", "w", stdout);
#endif
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i = 1; i <= n; i++) scanf("%d",&a[i]);
    for(int i = 1; i <= m; i++) scanf("%d%d%d",&e[i].u,&e[i].v,&e[i].w);
    sort(e + 1, e + 1 + m);
    for(int i = 1; i <= n; i++) {
        fa[i] = i;
        blo[i].num = blo[i].mxedge = blo[i].ok = 0;
        blo[i].sum = a[i];
    }
    int ans = 0;
    for(int i = 1; i <= m; i++) {
        int u = e[i].u, v = e[i].v, w = e[i].w;
        int fu = findd(u), fv = findd(v);
        if(fu == fv) {
            blo[fu].num++;
            blo[fu].mxedge = max(blo[fu].mxedge, w);
        } else {
            fa[fv] = fu;
            blo[fu].num += blo[fv].num + 1;
            blo[fu].mxedge = max(max(blo[fu].mxedge, blo[fv].mxedge), w);
            blo[fu].sum += blo[fv].sum;
            blo[fu].ok += blo[fv].ok;
        }

        if(blo[fu].sum >= blo[fu].mxedge) {
            ans += blo[fu].num - blo[fu].ok;
            blo[fu].ok = blo[fu].num;
        }
    }
    printf("%d\n",m - ans);
    return 0;
}


Measured memory_bytes: 4480
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long int ll;
ll p[1005],q[1005];
int main()
{
	int n;
	scanf("%d",&n);
	ll ans=0;
	for(int i=0;i<n;++i)
		scanf("%lld %lld",&p[i],&q[i]);
	ans=p[0]+q[0];
	ll lsum=p[0]+q[0],lp=p[0],lq=q[0];
	for(int i=1;i<n;++i){
 		ll tp=p[i],tq=q[i],sum=tp+tq,j=max(lsum/sum,max(lp/tp,lq/tq));
 		if(j<=0)j=1;
 		while(tp<lp || tq<lq || sum<lsum){
		 	tp=p[i]*j;
		 	tq=q[i]*j;
		 	sum=tp+tq;
		 	//printf("%lld %lld %lld\n",tp,tq,sum);
		 	++j;
 		}
 		lp=tp;lq=tq;lsum=sum;
 		ans=max(ans,lsum);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>

int main() {
    int N;
     std::cin >> N;

     int x;

     std::vector<int> V;
     V.reserve(N);
     for (int i = 0; i < N; ++i) {
         std::cin >> x;
         V.push_back(x);
     }

     std::vector<int> C;
     C.reserve(N);
     for (int i = 0; i < N; ++i) {
         std::cin >> x;
         C.push_back(x);
     }

     std::vector<int> Z;
     Z.reserve(N);
     for (int i = 0; i < N; ++i) {
         Z.push_back(std::max(V[i] - C[i], 0));
     }

     const auto ret = std::accumulate(Z.cbegin(), Z.cend(), 0);

     std::cout << ret << std::endl;
}


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

int main()
{
  int64_t N, K, ans = 0;
  cin >> N >> K;
  vector<int64_t> V(N);
  for (int i = 0; i < N; i++)
  {
    cin >> V[i];
  }
  for (int l = 0; l <= K; l++)
  {
    for (int r = 0; r <= K - l; r++)
    {
      if (l + r > N)
        continue;
      int64_t d = K - l - r, n = 0;
      vector<int64_t> S;
      for (int i = 0; i < l; i++)
      {
        n += V[i];
        S.emplace_back(V[i]);
      }
      for (int i = N - 1; i > (N - 1) - r; i--)
      {
        n += V[i];
        S.emplace_back(V[i]);
      }
      sort(S.begin(), S.end());
      for (int i = 0; i < d; i++)
      {
        if (i >= S.size() || S[i] > 0)
          break;
        n -= S[i];
      }
      ans = max(ans, n);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.root = [-1]*(n+1)
        self.rnk = [0]*(n+1)
    def Find_Root(self, x):
        if(self.root[x] < 0):
            return x
        else:
            self.root[x] = self.Find_Root(self.root[x])
            return self.root[x]
    def Unite(self, x, y):
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        if(x == y):
            return 
        elif(self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x
        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            if(self.rnk[x] == self.rnk[y]):
                self.rnk[y] += 1
    def isSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)
    def Count(self, x):
        return -self.root[self.Find_Root(x)]
N,M,K = map(int,input().split())
C = UnionFind(N)
F = [0]*(N+1)
for i in range(M):
    a,b = map(int,input().split())
    C.Unite(a,b)
    F[a]+=1
    F[b]+=1
B = [[] for i in range(N+1)]
for h in range(K):
    c,d = map(int,input().split())
    B[c].append(d)
    B[d].append(c)
A = [0]*N
for n in range(1,N+1):
    all_ = C.Count(n)
    B_cnt = 0
    for b in B[n]:
        if C.isSameGroup(n,b):B_cnt+=1
    A[n-1] = all_ - B_cnt - F[n] - 1
print(*A)

Measured memory_bytes: 29448
#include<bits/stdc++.h>
#define mxn 1000010
#define db double
#define LL long long
#define ldb long double
#define pb push_back
#define ppb pop_back
#define pf push_front
#define pii pair<int,int> 
#define mp make_pair
#define fr first
#define sc second
#define x1 faqx1
#define y1 faqy1
#define x2 faqx2
#define y2 faqy2
using namespace std;
const int inf=1e9;
int a,b,sl,fh;
int rd()
{
	sl=0;fh=1;
	char ch=getchar();
	while(ch<'0'||'9'<ch) {if(ch=='-') fh=-1; ch=getchar();}
	while('0'<=ch&&ch<='9') sl=sl*10+ch-'0',ch=getchar();
	return sl*fh;
}
int main()
{
	a=rd();b=rd();
	if(a<=9&&b<=9) printf("%d\n",a*b);
	else puts("-1");
	return 0;
}

Measured memory_bytes: 256
from itertools import accumulate

mod = 10**9 + 7

n, k = map(int, input().split())
a = list(accumulate(range(0, n+2)))

ans = 0
for m in range(k, n+2):
    min_num = a[m] - a[0]
    max_num = a[-1] - a[-(m+1)]
    ans += (max_num - min_num) + 1
print(ans % mod)


Measured memory_bytes: 19276
#include <bits/stdc++.h>
using namespace std;
const int MX = 1e3+2;
int arr[MX], crr[MX], dp[MX][1<<12];
int main() {
	ios::sync_with_stdio(0);cin.tie(0);
	memset(dp, 0x3f, sizeof dp);
	dp[0][0] = 0;
	int n, m;
	cin >> n >> m;
	for(int i=1; i<=m; i++) {
		memcpy(dp[i], dp[i-1], sizeof(dp[i]));
		int b, cur_bm = 0;
		cin >> arr[i] >> b;
		for(int j=0; j<b; j++) {
			int t;
			cin >> t;
			crr[i] |= (1<<(t-1));
		}
		cur_bm = crr[i];
		for(int bm=0; bm<(1<<n); bm++) {
			int nxt_bm = bm | cur_bm;
			dp[i][nxt_bm] = min(dp[i][nxt_bm], dp[i-1][bm] + arr[i]);
		}
	}
	int ans = dp[m][(1<<n)-1];
	cout << (ans == 0x3f3f3f3f ? -1 : ans);
}

Measured memory_bytes: 16256
n = int(input())
s = input()

r = s.count('R')
g = s.count('G')
b = s.count('B')

ans = r*g*b

for i in range(1,n//2 + 10):
    for j in range(n):
        if(j + i*2 >= n):
            break
        a,b,c = s[j],s[j+i],s[j+i*2]
        if(a!=b)&(b!=c)&(a!=c):
            ans -= 1

print(ans)

Measured memory_bytes: 68088
/*
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<limits.h>
#include<cmath>
#include<queue>
#include<stack>

#include<stdio.h>
#include<stdlib.h>

#define rep(i,n) for(ll i = 0; i < (ll)n; i++)
#define swap(a,b) a^=b;b^=a;a^=b;
#define chmax(a,b) {if(a < b) a = b;}
#define chmin(a,b) {if(a > b) a = b;}

using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;

ll factor(ll x) {
	ll ret = 1;
	ll tmp = 0;
	for (ll p = 2;;p++) {
		if (x == 1) {
			ret *= tmp + 1;
			break;
		}
		if (x % p == 0) {
			tmp += 1;
			x /= p;
			p--;
			continue;
		}
		ret *= tmp + 1;
		tmp = 0;
	}
	return ret;
}

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//Program Start

	ll N;
	cin >> N;
	ll ans = 0;

	for (ll i = 1; i <= N; i++) {
		ll ret = factor(i);
		ll tmp = ret;
		ans += i * tmp;
	}

	cout << ans << endl;



EndPoint:;

	//Program End
#ifndef DEBUG
	system("pause");
#endif // !DEBUG

	return 0;
}


*/

#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<limits.h>
#include<cmath>
#include<queue>
#include<stack>

#include<stdio.h>
#include<stdlib.h>

#define rep(i,n) for(ll i = 0; i < (ll)n; i++)
#define swap(a,b) a^=b;b^=a;a^=b;
#define chmax(a,b) {if(a < b) a = b;}
#define chmin(a,b) {if(a > b) a = b;}

using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//Program Start	

	int R;
	cin >> R;

	cout << 3.141592665f * 2.f * (double)R << endl;

EndPoint:;

	//Program End
#ifndef DEBUG
	system("pause");
#endif // !DEBUG

	return 0;
}




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

#define fi first
#define se second
#define inf 0x3f3f3f3f
#define llinf 0x3f3f3f3f3f3f3f3f

using namespace std;
using ll = long long;
using pi = pair<int, int>;
using pll = pair<ll, ll>;

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

	int k, a, b;
	cin>>k>>a>>b;
	if (a/k == b/k && a%k != 0)
		cout<<"NG";
	else
		cout<<"OK";
	cout<<'\n';
		

	return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define ull unsigned long long
using namespace std;
int main(){
	ull n;
	cin>>n;
	if(n&1){
		cout<<0;
	}else{
		ull t=10,ans=0;
		while(n/t>=1){
			ans=ans+n/t;
			t=t*5;
		}
		cout<<ans;
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String... nui) {
		
		Scanner sc = new Scanner(System.in);
		
		Set<Integer> set = new HashSet<>();
		
		int n = sc.nextInt();
		
		for (int i = 0; i < n; i++) set.add(sc.nextInt());
		
		System.out.println(set.size());
		
	}

}

Measured memory_bytes: 21844
#include<stdio.h>
int main()
{
  int n,i,j,k,v,x,cnt=0,m=0;
  int A[1000000];
  int G[1000000];
  scanf("%d",&n);
    
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
    }
    
  G[0]=1;
  for(i=1;G[i-1]<=n;i++){
    m++;
    G[i]=G[i-1]*3+1;
    if(m>100)break;
  }
  for(i=0;i<m/2;i++){
    x=G[i];
    G[i]=G[m-i-1];
    G[m-i-1]=x;
  }
    
    
  for(i=0;i<m;i++){
    for(j=G[i];j<n;j++){
      v=A[j];
      k=j-G[i];
      while(k>=0&&A[k]>v){
    A[k+G[i]]=A[k];
        k=k-G[i];
    cnt++;
      }
      A[k+G[i]]=v;
    }
  }
    
  printf("\n%d\n",m);
  for(i=0;i<m;i++){
    printf("%d ",G[i]);
  }
  printf("\n%d\n",cnt);
  for(i=0;i<n;i++){
    printf("%d\n",A[i]);
    }
  return 0;
}

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

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

const int INF = 1001001001;

void solve(){
  int h, n; cin >> h >> n;
  vector<int> dp(h+1, INF);
  dp[0] = 0;
  rep(i, n) {
    int a, b; cin >> a >> b;
    rep(j, h+1) {
      int nj = min(j+a, h);
      dp[nj]=min(dp[nj], dp[j]+b);
    }
  }

  cout << dp[h] << endl;
}

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


Measured memory_bytes: 256
#include <vector> 
#include <algorithm> 
#include <bits/stdc++.h> 
#include <stdlib.h> 
#include <stdio.h> 
#include <functional> 
#include<math.h> 
#include<cstring>
using namespace std;
int main(void){
    // Your code here!
 int H,W,N;
 cin >> H >> W >> N;
 vector<int> ans(0);
 vector<int> vec(N);
 for(int i = 0; i < N; i++) cin >> vec.at(i);
 
 
 for(int i = 0; i < N; i++){
     for(int j = 0; j < vec.at(i); j++){
         int h = i+1;
         ans.push_back(h);
     }
 }
 int count = 0;
 for(int i = 0; i < H; i++){
     int k = 0;
     for(int j = 0; j < W; j++){
         if(i % 2 == 0){
             cout << ans.at(count);
             count ++;
         }
         else{
             cout << ans.at(count + W - k - 1);
             //cout << "#" << count + W - k - 1 << endl;
             k += 2;
             count ++;
         }
         if(j == W-1){
         cout << endl;
     }
     else{
         cout << " ";
     }
     }
     
 }
 
 
 

}

Measured memory_bytes: 384
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ull = unsigned long long;

int S[110];

int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    for (int i = A; i < B; ++i) {
        ++S[i];
    }
    for (int i = C; i < D; ++i) {
        ++S[i];
    }
    int ans = 0;
    for (int i = 0; i < 110; ++i) {
        if (S[i] == 2) {
            ++ans;
        }
    }
    cout << ans << endl;
}


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

int main(){
	double a, b, c, d, e, f, x, y;

	while(scanf("%lf %lf %lf %lf %lf %lf",&a,&b,&c,&d,&e,&f)!=EOF){
		x=(c*e-b*f)/(a*e-d*b);
		y=(a*f-c*d)/(a*e-b*d);
		if(x == 0)x=0;
		if(y == 0)y=0;
		printf("%.3lf %.3lf\n",x,y);
	}

    return 0;
}



Measured memory_bytes: 3152
#![allow(unused_imports)]

use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::{i32, i64, i128, u32, u64, u128, f64};
use std::io::{stdout, Write, BufWriter};
use std::mem::{swap};
use proconio::marker::{Isize1, Usize1, Bytes, Chars};

#[proconio::fastout]
fn main() {
    proconio::input!{
        x: i32,
        y: i32,
    }
    for c in 0..=x {
        if 2 * c + 4 * (x - c) == y{
            println!("Yes");
            return;
        }
    }
    println!("No");
}


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

class UnionFind {
  vector<int> parent;
public:
  UnionFind(int n) : parent(n, -1) {}
  int root(int n) {
    return parent.at(n) < 0 ? n : root(parent.at(n));
  }
  bool same(int a, int b) {
    return root(a) == root(b);
  }
  int size(int n) {
    return -1 * parent.at(root(n));
  }
  void unite(int a, int b) {
    if (!same(a, b)) {
      if (size(a) < size(b)) swap(a, b);
      int ra = root(a);
      int rb = root(b);
      parent.at(ra) += parent.at(rb);
      parent.at(rb) = ra;
    }
  }
};

int main()
{
  int n, k, l;
  cin >> n >> k >> l;

  vector<pair<int, int>> road(k);
  vector<pair<int, int>> railway(l);

  for (int i = 0; i < k; i++) {
    int x, y;
    cin >> x >> y;
    road.at(i).first = --x;
    road.at(i).second = --y;
  }
  for (int i = 0; i < l; i++) {
    int x, y;
    cin >> x >> y;
    railway.at(i).first = --x;
    railway.at(i).second = --y;
  }

  UnionFind a(n);
  UnionFind b(n);

  for (const auto& e : road) {
    a.unite(e.first, e.second);
  }
  for (const auto& e : railway) {
    b.unite(e.first, e.second);
  }

  map<pair<int, int>, int> ans;

  for (int i = 0; i < n; i++) {
    ans[make_pair(a.root(i), b.root(i))]++;
  }
  for (int i = 0; i < n; i++) {
    cout << ans.at(make_pair(a.root(i), b.root(i))) << endl;
  }
}


Measured memory_bytes: 15104
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
 
using namespace std;
 
#define PB push_back
#define MP make_pairA
#define REP(i,n) for(int i=0;i<(n);i++)
int main()
{
    int k,n;
    cin>>k>>n;
    if(k*500>=n)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define P pair<ll,ll> 
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s,t;cin>>s;
  ll len=s.length(),l=0,r=len-1,x_to_add=0;
  bool is_possible=true;
  while(l<r) {
    if(s[l]==s[r]) {l++,r--;}
    else {
      if(s[l]=='x') {l++;x_to_add++;}
      else if(s[r]=='x') {r--;x_to_add++;}
      else {is_possible=false;break;}
    }
    if(!is_possible) break;
  }
  if(is_possible) print(x_to_add);else print(-1);
  return 0;
}

Measured memory_bytes: 512
//includes
#include<iostream>
#include<vector>
#include<set>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<map>
#include<queue>
#include<iomanip>
#include<numeric>

//macros
#define INF 1e9
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(),(a).end()
#define vecuni(a) (a).erase(unique((a).begin(),(a).end()),(a).end())
#define pb push_back
#define mp make_pair
#define eb emplace_back

//shorter types
using namespace std;
using ll = long long;
using vi = std::vector<int>;
using vc = std::vector<char>;
using vll = std::vector<long long>;
using vs = std::vector<string>;
using Pi = pair<int,int>;
using Pll = pair<ll,ll>;
using vPi = vector<Pi>;
using vPll = vector<Pll>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<ll>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;
using pqgi = priority_queue<int,vector<int>,greater<int>>;
using pqsi = priority_queue<int,vector<int>,less<int>>;
using pqgll = priority_queue<int,vector<int>,greater<int>>;
using pssll = priority_queue<int,vector<int>,less<int>>;
template<class T>
using vec = vector<T>;

//frequent functions and datas
int gcd(int a, int b){
  if (a == 0) 
    return b; 
  return gcd(b % a, a); 
}
int findGCD(vector<int> &arr, int n){
  int result = arr[0]; 
  for (int i = 1; i < n; i++) 
    result = gcd(arr[i], result); 
  return result; 
}
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; }
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << "\t";
  }
  return s;
}
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
  s << vv[i] << endl;
  }
  return s;
}
//end

int H,W;
signed main(){
  cin >> H;
  cin >> W;
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  vvc s(H,vc(W,'0'));
  rep(i,H){
    rep(j,W){
      char in;
      cin >> in;
      s[i][j] = in;
    }
  }
  bool possible = true;
  rep(i,H){
    rep(j,W){
      if(s[i][j] == '#'){
        bool ok = false;
        rep(d,4){
          if(i + dy[d] < 0 || i + dy[d] >= H){
            continue;
          }
          if(j + dx[d] < 0 || j + dx[d] >= W){
            continue;
          }
          if(s[i + dy[d]][j + dx[d]] == '#'){
            ok = true;
            break;
          }
        }
        if(!ok){
          possible = false;
          break;
        }
      }
    }
  }

  cout << ((possible)?"Yes":"No") << endl;
  return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
from itertools import accumulate
def inpl(): return tuple(map(int, input().split()))

N, C = inpl()
P = [[] for _ in range(C)]

for _ in range(N):
    s, t, c = inpl()
    P[c-1].append((2*s, 2*t))

S = [0 for _ in range(2*10**5 + 3)]
for p in P:
    if len(p) == 0:
        continue
    p2 = []
    p = sorted(p)
    s, t = p[0]
    for i in range(1, len(p)):
        if t == p[i][0]:
            t = p[i][1]
        else:
            S[s-1] += 1
            S[t+1] -= 1
            s, t = p[i]
    S[s-1] += 1
    S[t+1] -= 1

print(max(accumulate(S)))

Measured memory_bytes: 19540
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3000 + 10;
struct Pos
{
	int val , x , y;
};
Pos meilleur[MAXN][MAXN];
int main()
{
	for (int i = 0 ; i < MAXN ; i++)
	{
		for (int j = 0 ; j < MAXN ; j++)
		{
			meilleur[i][j] = {0, -1, -1};
		}
	}
	string s;
	string t;
	cin>> s >> t;
	int N = s.size();
	int M = t.size();
	for (int i = 0 ; i < N ; i++)
	{
		for (int j = 0 ; j < M ; j++)
		{
			if (meilleur[i + 1][j].val > meilleur[i + 1][j + 1].val)
			{
				meilleur[i + 1][j + 1] = meilleur[i + 1][j];
			}
			if (meilleur[i][j + 1].val > meilleur[i + 1][j + 1].val)
			{
				meilleur[i + 1][j + 1] = meilleur[i][j + 1];
			}
			if (s[i] == t[j])
			{
				if (meilleur[i][j].val + 1 > meilleur[i + 1][j + 1].val)
				{
					meilleur[i  +1][j + 1] = {meilleur[i][j].val + 1 , i , j};
				}
			}
			else
			{
				if (meilleur[i][j].val > meilleur[i + 1][j + 1].val)
				{
					meilleur[i  +1][j + 1] = meilleur[i][j];
				}
			}
		}
	}
	Pos actu = meilleur[N][M];
	vector <char> sol;
	while (actu.x != -1)
	{
		sol.push_back(s[actu.x]);
		actu = meilleur[actu.x][actu.y];
	}
	for (int i = sol.size() - 1 ; i >= 0 ; i--)
	{
		cout<<sol[i];
	}
	cout<<endl;
}

Measured memory_bytes: 106496
{-# LANGUAGE OverloadedStrings #-}
import Data.List
import qualified Data.ByteString.Char8 as B

main = breads >>= B.putStrLn . solve

solve :: [Int] -> B.ByteString
solve [r, g, b]
    | s `mod` 4 == 0 = "YES"
    | otherwise = "NO"
    where
        s = r * 100 + g * 10 + b

breads :: IO [Int]
breads = unfoldr uff <$> B.getLine
    where
        uff b = check <$> B.readInt b
        check (a, b)
            | B.null b = (a, b)
            | otherwise = (a, B.tail b)


Measured memory_bytes: 380
//Relive your past life.
//Face your demons.
//The past is never dead,it is not even past.
//The memories are not only the key to the past but...also to the future.
//coded in Rusty Lake
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define ll   long long
#define pb   push_back
#define mp   make_pair
#define orz  1000000007
using namespace std;
int n,a[200005],f[200005][18];
ll ans;
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;++i)scanf("%d",a+i),f[i][0]=a[i];
    for(int k=0;k<17;++k){
        for(int i=1;i<=n-(2<<k)+1;++i)f[i][k+1]=min(f[i][k],f[i+(1<<k)][k]);
    }
    for(int i=1;i<=n;++i){
        int l=i-1,r=i+1;
        for(int k=17;k>=0;--k){
            if(l>=(1<<k)&&f[l-(1<<k)+1][k]>=a[i])l-=1<<k;
            if(r+(1<<k)-1<=n&&f[r][k]>a[i])r+=1<<k;
        }
        ans+=a[i]*1ll*(i-l)*(r-i);
    }
    printf("%lld\n",ans);
    //system("pause");
    return 0;
}


Measured memory_bytes: 15104
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <deque>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <numeric>
using namespace std;
long long gcd(long long a, long long b){
    if(b == 0){
        return a;
    }
    return gcd(b, a%b);
}

int main(){
    long long n,m;
    cin >> n >> m;
    string ns,ms;
    cin >> ns >> ms;
    long long g = gcd(n,m);
    long long num = (n*m)/ g;
    long long ans = num;
    for(long long i=0;i<g;i++){
        if(ns[i*n/g]!=ms[i*m/g]){
            ans = -1;
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;
typedef long long ll;

int main(){
    int n;
    bool flag = true;
    cin>>n;
    vector<int> h(n);
    rep(i,n) cin>>h[i];
    for(int i=n-1;i>=1;i--){
        if(h[i-1] - h[i] > 1){
            flag = false;break;
        }
        else if(h[i] >= h[i-1]){
            continue;
        }
        else{
            h[i-1]--;
        }
    }
    if(flag) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 640
def resolve():
    '''
    code here
    '''
    N, X, T = [int(item) for item in input().split()]

    if N % X != 0:
        res = (N // X + 1) * T
    else:
        res = (N // X) * T
    print(res)

    


if __name__ == "__main__":
    resolve()


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

int a[1001];

int main()
{
int n; cin>>n;
for(int i = 0; i < 2*n; i++) cin>>a[i];
sort(a, a+2*n);
long long ans = 0;
for(int i = 0; i < n; i++) ans += a[2*i];
cout << ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <list>
using namespace std;

#define MOD 1000000007
#define p(x) cout << x << endl;
#define el cout << endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

    int a, b;
    cin >> a >> b;

    int cnt = 0;
    for(int i = a; i <= b; i++){
        string s = to_string(i);
        if(s[0] == s[4] && s[1] == s[3]){
            cnt++;
        }
    }
    p(cnt);
}


Measured memory_bytes: 256
N, M = map(int, input().split())
D = [[] for _ in range(N)]
R = [0]*M
for i in range(M):
    P, Y = map(int, input().split())
    D[P-1].append((Y,i))
for P in range(N):
    for k, p in enumerate(sorted(D[P])):
        Y, i = p
        R[i] = (P+1)*10**6+(k+1)
for r in R:
    print("{:012}".format(r))

Measured memory_bytes: 89168
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

bool Calculate(string&, int*);
int AtoiString(const string&);
bool IsCode(const char&);

int main(){
  int ans;
  string str;
  while(cin >> str){
    if(Calculate(str, &ans)) cout << ans << endl;
    else cout << "E" << endl;
  }
  return 0;
}

bool Calculate(string& str, int* ans){
  int n;
  string::iterator i, j;
  i = str.begin();
  while(1){
    j = find_if(i, str.end(), IsCode);
    const string sub_str(i, j);
    if(sub_str.size() > 4) return false;

    n = AtoiString(sub_str);
    if(i == str.begin()) *ans = n;
    else if(*(i-1) == '+') *ans += n;
    else if(*(i-1) == '-') *ans -= n;
    else if(*(i-1) == '*') *ans *= n;

    if(*ans > 9999 || *ans < 0) return false;
    if(*j == '=') return true;
    i = j + 1;
  }
}

int AtoiString(const string& s){
  int i, x, d;
  for(i=s.size()-1, x=0, d=1; i>=0; --i, d*=10)
    x += ((s[i] - 48) * d);
  return x;
}

bool IsCode(const char& c){
  if(c == '+' || c == '-' || c == '*' || c == '=') return true;
  else return false;
}

Measured memory_bytes: 1188
#define INF 10000000000
#define MOD 1000000007

#if 1   // use_templates

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <algorithm>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define rep(i, up) for (ll i = 0; i < up; ++i)
#define repp(i, up) for (ll i = 0; i <= up; ++i)
#define rrep(i, lo, up) for (ll i = lo; i < up; ++i)
#define rrepp(i, lo, up) for (ll i = lo; i <= up; ++i)
#define eep(i, lo, up) for ((i) = (lo); (i) < (up); ++(i))
#define eepp(i, lo, up) for ((i) = (lo); (i) <= (up); ++(i))


ll gcd(ll a, ll b);

ll gcd(ll a, ll b)
{
    if (a < b) {
        return gcd(b, a);
    }
    ll r;
    while (r = a % b) {
        a = b;
        b = r;
    }
    return b;
}

#endif  // end of use_templates

int main()
{
    vector<ll> a(5);
    rep(i, 5) {
        cin >> a[i];
    }
    rep(i, 5) {
        if (a[i] == 0) {
            cout << i + 1 << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#define rep(i, n) for(int i=0;i<(int)(n);++i)
template <typename T> ll gcd(T a, T b) {return b?gcd(b, a%b):a;}
template <typename T> ll lcm(T a, T b) {return a * b / gcd(a, b);};
template <typename T> inline void chmin(T &a, const T& b){if(a>b)a=b;}
template <typename T> inline void chmax(T &a, const T& b){if(a<b)a=b;}


bool isRev(string s) {
  string t = s;
  reverse(t.begin(), t.end());
  return (bool)(s ==t);
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  if (isRev(s)) {
    int n = s.size();
    string t1 = s;
    t1 = t1.substr(0, (n-1)/2);
    string t2 = s;
    t2 = t2.substr((n+1)/2, (n-1)/2);
    if (isRev(t1) && isRev(t2)) {
      cout << "Yes" << '\n';
      return 0;
    }
  }
  cout << "No" << '\n';
  return 0;
}

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

#define int long long
#define rep(i, l, r) for (int i = (int)(l); i < (int)(r); i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)x.size())
template <class T> bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T> using v = vector<T>;
using P = pair<int, int>;

/*
 *  */

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

  v<v<int>> a(n, v<int>(n));
  rep(i, 0, n) rep(j, 0, n) cin >> a[i][j];

  v<int> sum(1<<n);
  rep(s, 0, 1<<n){
    rep(i, 0, n) rep(j, i+1, n) if((s & (1<<i)) and (s & (1<<j))){
      sum[s] += a[i][j];
    }
  }

  v<int> dp(1<<n);
  rep(s, 0, 1<<n){
    for(int t = s; t > 0; t = (t-1)&s){
      chmax(dp[s], dp[s-t] + sum[t]);
    }
  }

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

  return 0;
}


Measured memory_bytes: 1280
#include<iostream>
#include<vector>

int main(){
    int n;
    
    std::cin>>n;
    
    std::vector<int> seq(n);
    
    for(int i=0; i<n;i++){
        std::cin>>seq[i];
    }
    
    for(int j=n-1; j>0; j--){
        std::cout<<seq[j]<<" ";
    }
    std::cout<<seq[0]<<std::endl;

    return 0;
}


Measured memory_bytes: 3120
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
import math
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
import sys
sys.setrecursionlimit(10000000)
#mod = 10**9 + 7
#mod = 9982443453
mod = 998244353
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
k,n = readInts()
A = readInts()
max_dist = 0
for i in range(n):
    next = (i+1)%n
    dist = A[next] - A[i]
    if dist < 0:
        dist += k
    max_dist = max(max_dist, dist)
print(k - max_dist)


Measured memory_bytes: 34680
#include <bits/stdc++.h>
#define range(i, a, n) for(int (i) = (a); (i) < (n); (i)++)
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
using namespace std;
int mod = (int)1e5;
int main(void){
    int n, m; cin >> n >> m;
    int s[n - 1];
    for(int i = 0; i < n - 1; i++) cin >> s[i];

    int sum[n];
    sum[0] = 0;
    for(int i = 1; i < n; i++){
        sum[i] = sum[i - 1] + s[i - 1];
    }

    int res = 0, cur_pos = 0;
    for(int i = 0; i < m; i++){
        int a; cin >> a;
        int next_pos = cur_pos + a;
        int diff = abs(sum[next_pos] - sum[cur_pos]);
        res += diff; res %= mod;

        cur_pos = next_pos;
    }

    cout << res << endl;

	return 0;
}

Measured memory_bytes: 3848