akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <string>
#include <cstring>
#include <functional>

using namespace std;

const int maxn = 52;
const int maxk = 102;
int v[maxn], f[maxn][maxk], g[maxn][maxk];

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n, k;
	cin >> n >> k;

	for (int i = 0; i < n; ++i)
		cin >> v[i];

	for (int i = 0; i <= n; ++i)
		for (int j = 0; j <= k; ++j)
			f[i][j] = g[i][j] = INT_MIN;

	f[0][0] = g[0][0] = 0;
	for (int i = 1; i <= n; ++i)
		for (int j = i; j <= min(k, 2*i); ++j) {
			if (f[i-1][j-1] != INT_MIN)
				f[i][j] = max(f[i][j], f[i-1][j-1] + v[i-1]);
			if (j > 1)
				f[i][j] = max(f[i][j], f[i-1][j-2]);

			if (g[i-1][j-1] != INT_MIN)
				g[i][j] = max(g[i][j], g[i-1][j-1] + v[n-i]);
			if (j > 1)
				g[i][j] = max(g[i][j], g[i-1][j-2]);
		}
	
	for (int i = 1; i <= n; ++i)
		f[i][0] = g[i][0] = 0;
	for (int i = 1; i <= k; ++i)
		f[0][i] = g[0][i] = 0;

	for (int i = 1; i <= n; ++i)
		for (int j = 1; j <= k; ++j) {
			f[i][j] = max(f[i][j], max(f[i-1][j], f[i][j-1]));
			g[i][j] = max(g[i][j], max(g[i-1][j], g[i][j-1]));
		}

	long long ans = 0;
	for (int i = 0; i <= n; ++i)
		for (int j = 0; j <= k; ++j)
			ans = max(ans, (long long)f[i][j] + g[n-i][k-j]);
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
typedef long long LL;
using namespace std;

const LL mod = 1e9 + 7;
const int MAXN = 1e5 + 10;
int a[MAXN];
char str[MAXN];

LL solve(int cnt) {
	LL ans = 1;
	for(int i = 0; i < cnt; ++i) {
		ans *= 2;
		ans %= mod;	
	}
	return ans;
}

int main() {
	int n, ans = 0;
	scanf("%d", &n);
	for(int i = 0; i < n; ++i) {
		scanf("%d", &a[i]);
		if(a[i] == 0) ans++;
	}
	if(ans > 1 || ans && n % 2 == 0 || !ans && n % 2) {
		puts("0");
		return 0;
	}
	sort(a, a + n);
	int cnt = unique(a, a + n) - a;
	if(n % 2) {
		if(cnt - 1 != n / 2) puts("0");
		else printf("%lld\n", solve(cnt - 1) % mod);
	}
	else {
		if(cnt != n / 2) puts("0");
		else printf("%lld\n", solve(cnt) % mod);
	}
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<pair<int, int>>>;

typedef struct edge {
    int from, to, cost;
} edge;

int main() {
    int N, M, P;
    cin >> N >> M >> P;
    vector<edge> ed(M);
    vector<bool> reachable(N);
    for(int i = 0; i < M; ++i) {
        int A, B, C;
        cin >> A >> B >> C;
        --A, --B;
        C -= P;
        ed[i].from = A;
        ed[i].to = B;
        ed[i].cost = C;
    }

    reachable[0] = true;
    for(int i = 0; i < N; ++i) {
        for(int j = 0; j < M; ++j) {
            edge tmp = ed[j];
            if(reachable[tmp.from])
                reachable[tmp.to] = true;
        }
    }

    vector<int> dist(N, -1e9);
    dist[0] = 0;
    vector<bool> plfl(N);
    bool plexist = false;
    for(int i = 0; i < N; ++i) {
        for(int j = 0; j < M; ++j) {
            edge tmp = ed[j];
            if(dist[tmp.to] < dist[tmp.from] + tmp.cost) {
                dist[tmp.to] = dist[tmp.from] + tmp.cost;
                if(i == N - 1) {
                    plexist = true;
                    plfl[tmp.from] = plfl[tmp.to] = true;
                }
            }
        }
    }

    if(plexist) {
        for(int i = 0; i < N; ++i) {
            for(int j = 0; j < M; ++j) {
                edge tmp = ed[j];
                if(plfl[tmp.from] && reachable[tmp.from])
                    plfl[tmp.to] = true;
            }
        }
    }

    if(plfl[N - 1])
        cout << -1 << endl;
    else
        cout << (dist[N - 1] < 0 ? 0 : dist[N - 1]) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
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;}

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll l; cin >> l;
    V<P<P<ll, ll>, ll> > edges;
    ll r = 0;
    while (r<=19 && (1LL<<r) <= l) r++;

    REP(i, r-1) {
        edges.push_back({{i, i+1}, 1LL<<i});
        edges.push_back({{i, i+1}, 0});
    }

    for (ll i=r-2; i>=0; i--) {
        if (l-(1LL<<i) >= (1LL<<(r-1))) {
            edges.push_back({{i, r-1}, l-(1LL<<i)});
            l -= (1LL<<i);
        }
    }

    cout << r << ' ' << edges.size() << '\n';
    REP(i, edges.size()) {
        cout << edges[i].first.first+1 << ' ' << edges[i].first.second+1 << ' ' << edges[i].second << '\n';
    }
    return 0;
}


Measured memory_bytes: 256
from bisect import bisect_left

N,M=map(int,input().split())
A=list(map(int,input().split()))
A=sorted(A)

change=[tuple(map(int,input().split())) for _ in range(M)]
change=sorted(change,key=lambda x: x[1],reverse=True)
change2=[]
count=0
for i in range(M):
  b,c=change[i]
  change2.extend([c]*b)
  count += b
  if count >= N:break

A.extend(change2)
A = sorted(A)
print(sum(A[len(A)-N:]))

Measured memory_bytes: 109760
N, K = map(int, input().split())
S = input().replace('\n', '')


def solve(S, K):
    record = []
    temp = []
    for i in range(len(S) - 1):
        if S[i:i+2] == '01':
            temp.append(i + 1)
        elif S[i:i+2] == '10':
            if not temp: temp = [0, i]
            else: temp.append(i)
            record.append(temp)
            temp = []
    if len(temp) > 0:
        temp.append(len(S) - 1)
        record.append(temp)
    if S[0] == '0':
        record = [[0, 0]] + record
    if S[-1] == '0':
        record = record + [[len(S) - 1, len(S) - 1]]
    if len(record) <= K + 1: return(len(S))
    else:
        cnt = 0
        for i in range(len(record) - K):
            cnt = max(cnt, record[i + K][1] - record[i][0] + 1)
        return(cnt)
print(solve(S, K))

Measured memory_bytes: 12532
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
ll gcd(ll a,ll b){
    
    if(b==0){
        return a;
    }else{
        return gcd(b,a%b);
    }
}
const ll A = 1000010;
int main(){
    ll n;
    cin >> n;
    vector<ll> data(1000010);
    vector<ll> num(n);
    rep(i,0,n){
        ll a;
        cin >> a;
        num[i]=a;
        data[a]++;
    }
    bool pairwise = true;
    rep(i,2,A){
        int cnt = 0;
        for(int j = i;j<A;j+=i){
            cnt += data[j];
        }
        if(cnt>1) pairwise = false;
    }
    if(pairwise){
        cout<<"pairwise coprime"<<endl;
        return 0;
 
    }
    ll g = 0;
    rep(i,0,n){
        g = gcd(g,num[i]);
    }
    //cout<<g<<endl;
    if(g==1){
        cout<<"setwise coprime"<<endl;
    }else{
        cout<<"not coprime"<<endl;
    }
    return 0;
}

Measured memory_bytes: 18780
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B;
  string S;
  cin>>A>>B>>S;
  if(S.at(B-1)=='A'){S.at(B-1)='a';}
  else if(S.at(B-1)=='B'){S.at(B-1)='b';}
  else if(S.at(B-1)=='C'){S.at(B-1)='c';}
  cout<<S<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define MOD 1e9+7
using namespace std;
typedef long long ll;

int main(){
    int n;
    cin>>n;
    vector<int> p(n);

    rep(i,n)cin>>p[i];

    int cnt=0;
    for(int i=1;i<n-1;i++){
        int a = min({p[i-1],p[i],p[i+1]});
        int b = max({p[i-1],p[i],p[i+1]});
        if(a!=p[i]&&b!=p[i])
            cnt++;
    }
    cout<<cnt;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    var (n,k) = readLine()!!.split(" ").map(String::toInt)
    var input = readLine()!!.split(" ").map{it.toInt()}
    input = input.sorted()
    var sum = 0
    var len = input.size-1
    for (i in len downTo len-(k-1)){
        sum += input[i]
    }
    println(sum)
}


Measured memory_bytes: 37996
//#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

//ifstream cin("x.in"); ofstream cout("x.out");

const int nmax = 2e5;
const int inf = 1 << 29;
const int valmax = (1 << 26);

int bst[valmax + 1];
string s;

int main() {
    cin.sync_with_stdio(false);

    cin >> s;

    for (int i = 1; i < valmax; ++ i)
        bst[ i ] = inf;

    int st = 0;
    int lst = inf;

    bst[ 0 ] = 0;
    for (int i = 0; i < (int)s.size(); ++ i) {
        st ^= (1 << (s[ i ] - 'a'));

        int x = bst[ st ] + 1;
        for (int j = 0; j < 26; ++ j) {
            x = min(x, bst[st ^ (1 << j)] + 1);
        }

        lst = x;
        bst[ st ] = min(bst[ st ], x);
    }

    cout << lst;
    return 0;
}


Measured memory_bytes: 262804
from bisect import bisect_left


n = int(input())
l = list(map(int, input().split()))
l.sort()
cnt = 0
for i in range(n-2):
    a = l[i]
    for j in range(i+1, n-1):
        b = l[j]
        cnt += bisect_left(l, a+b) - j - 1
        # bisec_left(l, x)でlの中にxを挿入できる点を探す
print(cnt)


Measured memory_bytes: 3188
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstring>
#include <fstream>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

const int MAX = 100007;
const int MOD = 1000000007;

void solve() {
    int n, h[MAX];
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> h[i + 1];
    }
    int dp[MAX];
    dp[1] = 0;
    dp[2] = abs(h[1] - h[2]);
    for (int i = 3; i <= n; i++) {
        dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
    }
    cout << dp[n];
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    //freopen("in.in", "r", stdin); freopen("out.out", "w", stdout);
    //int tt; cin >> tt; for (int i = 1; i <= tt; i++) {cout << "Case #" << i << ": "; solve();}
    solve();
}

Measured memory_bytes: 4372
import java.util.Scanner;

public class Main {

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

	    long n=gl();
	    long a=gl();
	    long b=gl();
	    
        if((b-a)%2==0) {
		    System.out.println("Alice");
        } else {
        	System.out.println("Borys");
        }
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35620
#include <bits/stdc++.h>
using namespace std; inline void fileio(const char* in, const char* out) { freopen(in, "r", stdin); freopen(out, "w", stdout); } 
#define TD typedef
#define forx(i,n) for(int i = 0; i < (n); ++i)
TD long long ll; TD long double ld; TD pair<int,int> pii; TD pair<ll, ll> pll; TD vector<int> VI; TD vector<bool> VB; TD vector<ll> VL;
const char nl = '\n'; const int INF = 0x3f3f3f3f; const ll LINF = 0x3f3f3f3f3f3f3f3fll; const ld EPS = 1e-9, PI = acos(-1);
#define ff first
#define ss second

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
template <class K, class Hash> struct chash { const size_t RANDOM; const Hash hash; size_t operator()(K key) const { return hash(key) ^ RANDOM; }
  chash() : RANDOM(  (size_t)make_unique<char>().get() ^ (size_t)chrono::high_resolution_clock::now().time_since_epoch().count()  ), hash() { } };
namespace Hashes { struct hash_pii { size_t operator()(pii key) const { return ((size_t)key.ff << 32) | key.ss; } }; }
// HashMap = umap
template <class K, class V, class Hash=hash<K>>
using umap = __gnu_pbds::gp_hash_table<K,V,chash<K,Hash>>;
// HashSet = uset
template <class K, class Hash=hash<K>>
using uset = umap<K, __gnu_pbds::null_type, Hash>;
// oset<K[, Comp]> = Ordered Statistics Set tree
template <class K, class Comp=less<K>>
using oset = __gnu_pbds::tree<K, __gnu_pbds::null_type, Comp, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;

class DSU {
  vector<int> p; int c;
  public:
  DSU (int n) : p(n, -1), c(n) { }
  // Get representative of x
  int find(int x) {
    return (p[x] < 0) ? x : p[x] = find(p[x]);
  }
  // Get size of set containg x
  int size(int x) {
    return -p[find(x)];
  }
  // Get # of disjoint sets
  int count() {
    return c;
  }
  // Joins sets containing x, y
  void join(int x, int y) {
    if ((x = find(x)) == (y = find(y))) return;
    if (p[x] < p[y]) swap(x, y);
    p[y] += p[x];
    p[x] = y;
    c--;
  }
};

int deal(vector<pii>& balls, int p, int q) {
  //cerr << "trying: p=" << p << ", q=" << q<<nl;
  const int n = balls.size();
  DSU lines(n);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i == j) continue;
      if (balls[i].first + p == balls[j].first) {
        if (balls[i].second + q == balls[j].second) {
          lines.join(i,j);
        }
      }
    }
  }
  return lines.count();
}

int main() {
  atexit([](){ cerr << "Time: " << (ld)clock() / CLOCKS_PER_SEC << nl; });
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  // Emily <3
  
  
  
  int n;
  cin >> n;
  
  vector<pair<int,int>> balls(n);
  for(int i = 0; i < n; i++){
    cin >> balls[i].first >> balls[i].second;
  }
  
  int ans = n;

  forx(i, n) {
    forx(j, n) {
      if (i == j) continue;
      int p = balls[i].first - balls[j].first;
      int q = balls[i].second - balls[j].second;
      ans = min(ans, deal(balls, p, q));
    }
  }

  cout << ans << nl;
  
  return 0;
}



Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define MN 10005
using namespace std;
int n,tt;
struct node{int u,v,w;}g[MN];
int main(){
	scanf("%d",&n);
	for(int i=20,j=1;i>=3;i--,j<<=1)g[++tt]=(node){i-1,i,j},g[++tt]=(node){i-1,i,0};
	while(n){
		int tmp=(int)log2(n&(-n));
		if(tmp!=19)g[++tt]=(node){1,20-tmp,n-(n&(-n))};
		else g[++tt]=(node){1,2,1<<18},g[++tt]=(node){1,2,0};
		n-=(n&(-n));
	}printf("%d %d\n",20,tt);
	for(int i=1;i<=tt;i++)printf("%d %d %d\n",g[i].u,g[i].v,g[i].w);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
#define ll long long 
int ctoi(char c) {return c-'0';}/*char to int*/
int gcd(ll a,ll b){return b?gcd(b,a%b):a;}/*MAX*/
int lcm(ll a,ll b){return a*b/gcd(a,b);}/*MIN*/
bool primecheck(ll n){/*sosuu*/if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
int  main(){
	int h;
	cin >> h;
	int w;
	cin >> w;
	vector<string> a(h);
	for (int i = 0; i < h; i++) {
		cin >> a[i];
	}
 
	vector<bool> tate(h, false);
	vector<bool> yoko(w, false);
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (a[i][j] == '#') {
				tate[i] = true;
				yoko[j] = true;
			}
		}
	}
 
	for (int i = 0; i < h; i++) {
		if (tate[i]) {
			for (int j = 0; j < w; j++) {
				if (yoko[j]) {
					cout << a[i][j];
				}
			}
			cout << endl;
		}
	}
}







Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main (String[] args) {
	Scanner scan = new Scanner(System.in);
	int n = Integer.parseInt(scan.nextLine());
	int[] a = new int[10];
	String[] input;
	for (int i = 0; i < n; i++) {
	    input = scan.nextLine().split(" ");
	    for (int j = 0; j < 10; j++) {
		a[j] = Integer.parseInt(input[j]);
	    }
	    if (devideBall(a)) {
		System.out.println("YES");
	    } else {
		System.out.println("NO");
	    }
	}
    }
    static boolean devideBall (int[] a){
	int[] b = new int[11];
	int[] c = new int[11];
	int posB = 1, posC = 1, n, preB, preC;
	for (int i = 0; i < a.length; i++) {
	    n = a[i];
	    preB = b[posB - 1];
	    preC = c[posC - 1];
	    if (n > preB && n > preC) {
		if (preB > preC) {
		    b[posB++] = n;
		} else {
		    c[posC++] = n;
		}
	    } else if (n > preB && n < preC) {
		b[posB++] = n;
	    } else if (n > preC && n < preB) {
		c[posC++] = n;
	    } else {
		return false;
	    }
	}
	return true;
    }
}

Measured memory_bytes: 25916
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
using namespace std;
int w,h,xg,yg,n,ans = 0;
int mas[110][110];
int dx[4] = {0,-1,0,1};
int dy[4] = {1,0,-1,0};
void block(int x, int y, int m);
int main(){
  int c,d,x,y,xs,ys;
  while(1){
    memset(mas,0,sizeof(mas));
    ans = 0;
    scanf("%d %d",&w,&h);
    if(w == 0 && h == 0)break;
    scanf("%d %d",&xs,&ys);
    scanf("%d %d",&xg,&yg);
    scanf("%d",&n);
    for(int u = 0; u < n; u++){
      cin >> c >> d >> x >> y;
      if(d == 0){
	for(int i = y; i < y + 2; i++){
	  for(int j = x; j < x + 4; j++){
	    mas[i][j] = c;
	  }
	}
      }
      else {
	for(int i = y; i < y + 4; i++){
	  for(int j = x; j < x + 2; j++){
	    mas[i][j] = c;
	  }
	}
      }
    }
    if(mas[ys][xs] != 0){
      block(xs,ys,mas[ys][xs]);
    }
    if(ans == 1)cout << "OK" << endl;
    else cout << "NG" << endl;
  }
}

void block(int x, int y, int m){
  if(x == xg && y == yg){
    ans = 1;
    return ;
  }
  mas[y][x] = 0;
  for(int i = 0; i < 4; i++){
    int nx = x + dx[i];
    int ny = y + dy[i];
    if(mas[ny][nx] == m && nx <= w && nx > 0 && ny <= h && ny > 0 && mas[ny][nx] != 0){
      block(nx,ny,mas[ny][nx]);
    }
  }
}

Measured memory_bytes: 1296
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
map< vector<int>, int > mp;
int dx[4] = {0, 0, 1, -1};
int dy[4] = {1, -1, 0, 0};
void init(vector<int> v) {
  queue< vector<int> > que;
  que.push(v);
  while(!que.empty()) {
    vector<int> cur = que.front(); que.pop();
    // 0?????´???
    int idx = 0;
    FOR(i,0,8) {
      if(cur[i] == 0) {
        idx = i;
        break;
      }
    }
    int dist = mp[cur];
    FOR(k,0,4) {
      vector<int> tmp = cur;
      int nx = idx % 4 + dx[k];
      int ny = idx / 4 + dy[k];
      if(nx < 0 || nx >= 4 || ny < 0 || ny >= 2) continue;
      int ns = nx + ny * 4;
      swap(tmp[ns], tmp[idx]);
      if(mp.count(tmp)) continue;
      mp[tmp] = dist + 1;
      que.push(tmp);
    }
  }
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  vector<int> v;
  FOR(i,0,8) v.push_back(i);
  init(v);
  string s;
  while(getline(cin, s)) {
    stringstream ss(s);
    vector<int> vv;
    int num;
    while(ss>>num) vv.push_back(num);
    cout << mp[vv] << endl;
  }
  return 0;
}

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

int main() {
	int N;
	cin >> N;
	for (int i = 0; i <= N/4; ++i) {
		if((N-i*4)%7==0){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<iostream>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> b(n);
   
   for(int i = 0;i < n;i++){
    cin >> a.at(i);
   }
   sort(a.begin(), a.end());
	long tmp;
  	long ans = 99999999;
  
   for(int i = a[0];i < a[n-1]+1;i++){
     tmp = 0;
     for(int j = 0;j < n;j++){
       tmp += pow((a.at(j)-i),2.0);
     }
     ans = min(ans,tmp);
   }
    
    cout << ans;

}
   


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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

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

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; }

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

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

signed main() {
  string s;
  cin >> s;
  int cnt = 0;
  int len = 0;
  for (int i = 0; i < s.size(); i++) {
  	if (s[i] == 'W') {
    	cnt += len;
    } else {
    	len++;
    }
  } 
  
  cout << cnt << endl;
  
   return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int a, b, c;
        int i;
        int count = 0;

        a = sc.nextInt();
        b = sc.nextInt();
        c = sc.nextInt();

        for(i=1; i<=c; i++) {
            if(c%i == 0) {
                if(a<=i && b>=i)  count++;
            }
        }

        System.out.printf("%d\n", count);
    }
}


Measured memory_bytes: 26512
#include <stdio.h>

int main(void){
    int n;
    scanf("%d", &n);
    int rate[9+5]={0};
    
    for(int i=0; i<n; i++){
        int a;
        scanf("%d", &a);
        if(a<3200)rate[a/400]=1;
        else rate[8]+=1;
    }
    
    int min=0;
    for(int i=0; i<8; i++)min+=rate[i];
    
    printf("%d %d\n", min==0?1:min, min+rate[8]);
    
    return 0;
}


Measured memory_bytes: 1704
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    public struct Pair { public int x, y; public Pair(int x, int y) { this.x = x; this.y = y; } }
    public static void Solve()
    {
        string S = NextString();
        long a = 0, ab = 0, abc = 0, hatena = 0;
        for (int i = 0; i < S.Length; i++)
        {
            if (S[i] == 'A') { a += RepPow(3, hatena); }
            else if (S[i] == 'B') { ab += a; }
            else if (S[i] == 'C') { abc += ab; }
            else if (S[i] == '?')
            {
                abc = abc * 3 + ab;
                ab = ab * 3 + a;
                a = a * 3 + RepPow(3, hatena);
                hatena += 1;
            }
            a %= INF;
            ab %= INF;
            abc %= INF;
        }
        Console.WriteLine(abc % INF);
    }
    public static void Main()
    {
        var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        Solve();
        Console.Out.Flush();
    }
    public static long RepPow(long x, long p, long m = 1000000007)
    {
        if (p == 0) return 1;
        if (p == 1) return x % m;
        long b = RepPow(x, p / 2, m) % m;
        if (p % 2 == 0) { return (b * b) % m; }
        else { return (x * ((b * b) % m)) % m; }
    }
}
public class Input
{
    public const long MOD = 1000000007;
    public const int INF = 1000000007;
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


Measured memory_bytes: 13364
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template <class T> int size(const T &x) { return x.size(); }
#define rep(i,a,b) for(int i = (a); i < (b); i++)
#define iter(it,c) for(auto it = (c).begin(); it != (c).end();++it)
#define pb push_back
#define fs first
#define sc second
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

const int INF = ~(1<<31);
const double pi = acos(-1);
const double EPS = 1e-9;

typedef pair<int,ii> iii;

int dist(ii a, ii b) {
	return abs(a.fs-b.fs)+abs(a.sc-b.sc);
}

int main() {
    cin.sync_with_stdio(false);
	int n;
	cin >> n;
	vector<iii> arr;
	arr.pb(iii(0,ii(0,0)));
	rep(i,0,n) {
		int a,b,c;
		cin >> a >> b >> c;
		arr.pb(iii(a,ii(b,c)));
	}
	rep(i,1,n+1) {
		int time = abs(arr[i].fs-arr[i-1].fs);
		int dadist = dist(arr[i].sc, arr[i-1].sc);
		if(dadist > time || (time % 2) != (dadist % 2)) {
			cout << "No" << endl;
			return 0;
		}
	} 
	cout << "Yes" << endl;
    return 0;
}



Measured memory_bytes: 1912
/**
 *    author:  tourist
 *    created: 15.09.2018 15:35:37       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  string foo;
  cin >> foo;
  vector<int> s(n);
  for (int i = 0; i < n; i++) {
    s[i] = (foo[i] == 'B');
  }
  vector<vector<int>> deg(n, vector<int>(2, 0));
  vector<vector<int>> g(n);
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    x--; y--;
    deg[x][s[y]]++;
    deg[y][s[x]]++;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  vector<int> was(n, 0);
  vector<int> que;
  for (int i = 0; i < n; i++) {
    if (deg[i][0] == 0 || deg[i][1] == 0) {
      que.push_back(i);
      was[i] = 1;
    }
  }
  for (int b = 0; b < (int) que.size(); b++) {
    for (int j : g[que[b]]) {
      deg[j][s[que[b]]]--;
      if (deg[j][0] == 0 || deg[j][1] == 0) {
        if (!was[j]) {
          was[j] = 1;
          que.push_back(j);
        }
      }
    }
  }
  cout << ((int) que.size() == n ? "No" : "Yes") << '\n';
  return 0;
}


Measured memory_bytes: 23244
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int x=1;
    string s="";
    if(n==0){
        cout<<0<<endl;
        return 0;
    }
    while(1){
        if(n%2){
            n-=x;
            s="1"+s;
        }
        else s="0"+s;
        x*=-1;
        n/=2;
        if(n==0){
            cout<<s<<endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int num_west[300009];
int num_east[300009];
char str[300009];
int main()
{
	
	int len;
	
	int min,temp;
	int i;
	scanf("%d",&len);
	scanf("%s",str);

	num_west[0]=num_east[0]=0;
	for(i=1;i<=len;i++)
	{
		if(str[i-1]=='W')
		{
			num_west[i]=num_west[i-1]+1;
			num_east[i]=num_east[i-1];
		}else{
			num_west[i]=num_west[i-1];
			num_east[i]=num_east[i-1]+1;
		}
	///	printf("%d  %d<<\n",num_west[i],num_east[i]);
	}
	min=num_east[len]-num_east[1];
	for(i=2;i<=len;i++)
	{
		temp=num_east[len]-num_east[i]+num_west[i-1]-num_west[0];
	//	printf("%d  %d   %d %d %d %d\n",temp,min,num_east[len],num_east[i],num_west[i-1],num_west[0]);
		if(temp<min)
		{
			min=temp;
		}
	}
	printf("%d\n",min);
}

Measured memory_bytes: 2816
#include <cmath>
#include <cstdio>
int main(){
  int N,x[8],y[8];
  double dist=0;
  scanf("%d",&N);
  for(int i=0;i<N;i++){
    scanf("%d %d",&x[i],&y[i]);
    for(int k=0;k<i;k++){
      dist+=2*sqrt((x[i]-x[k])*(x[i]-x[k])+(y[i]-y[k])*(y[i]-y[k]));
    }
  }
  printf("%.7f\n",dist/N);
  return 0;
}

Measured memory_bytes: 128
use text_io::*;
use std::process::exit;
use im_rc::HashMap;
use std::cmp::min;

fn main(){
    let mut a:String = read!();
    if a=="SUN" {
        println!("7");
    }
    if a=="MON" {
        println!("6");
    }
    if a=="TUE" {
        println!("5");
    }
    if a=="WED" {
        println!("4");
    }
    if a=="THU" {
        println!("3");
    }
    if a=="FRI" {
        println!("2");
    }
    if a=="SAT" {
        println!("1");
    }
}

Measured memory_bytes: 2088
N, L = input().split()
N = int(N)
L = int(L)

Nsum=0
sum=0
for i in range(N):
    Nsum+=L+i

sa=1000000000
for i in range(N):
    a = (L+i)
    if(a<0):
      a=-a
    if(sa > a):
        sa=a

if(Nsum<0):
	print(Nsum+sa)
else:  
	print(Nsum-sa)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdint>
#include <algorithm>
#include <cmath>

using namespace std;

int dist(int p1, int p2)
{
    return abs(p1 - p2);
}

int main()
{
    int N, K;
    int x[100'000];

    cin >> N >> K;
    for (int i = 0; i < N; i++)
    {
        cin >> x[i];
    }

    int min_dist = 300'000'000;
    for (int i = 0; i + K - 1 < N; i++)
    {
        const int d1 = dist(0, x[i]) + dist(x[i], x[i + K - 1]);
        const int d2 = dist(0, x[i + K - 1]) + dist(x[i + K - 1], x[i]);
        const int d = min(d1, d2);
        min_dist = min(min_dist, d);
    }

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


Measured memory_bytes: 640
import sys     
import math as mt
import bisect
input=sys.stdin.readline
#t=int(input())
t=1
def ncr_util():
    inv[0]=inv[1]=1
    fact[0]=fact[1]=1
    for i in range(2,300001):
        inv[i]=(inv[i%p]*(p-p//i))%p
    for i in range(1,300001):
        inv[i]=(inv[i-1]*inv[i])%p
        fact[i]=(fact[i-1]*i)%p
def solve():
    s='ACL'
    for i in range(k):
        print(s,end="")
    print()    
for _ in range(t):
    k=int(input())
    #n,k=(map(int,input().split()))
    #n1=n
    #a=int(input())
    #b=int(input())
    #a,b,c,r=map(int,input().split())
    #x2,y2=map(int,input().split())
    
    #n=int(input())
    #s=input()
    #s1=input()
    #p=input()
    #l=list(map(int,input().split()))
    #l2=list(map(int,input().split()))
    #l=str(n)
    #l.sort(reverse=True)
    #l2.sort(reverse=True)
    #l1.sort(reverse=True)
    (solve())

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

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,int> piii;
typedef pair<ll,ll> pll;

#define reps(i,f,n) for(int i = int(f); i <= int(n); i++)
#define rep(i,n) reps(i,0,int(n)-1)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)

#define all(x) (x).begin(),(x).end()
#define X first
#define Y second

#define sz size()
#define eb emplace_back
#define pb push_back

vector<int> a;
vector<ll> x;

int main(void){
  int n;
  cin >> n;
  a.resize(n+1);
  x.resize(n,0);
  rep(i,n) cin >> a[i];
  rep(i,n) a[i] *= 2;
  a[n] = a[0];
  // a[i] = x[i-1]/2 + x[i+1]/2
  // 2a[i] = x[i-1] + x[i+1]
  // 2x[i-1] = 
  
  rep(i, n){
    if (i%2)
      x[0] -= a[i];
      else
      x[0] += a[i];
  }
  x[0]/=2;

  for(int i = 1; i < n; ++i){
    x[i] = a[i-1]/2 - x[i-1]/2;
    x[i] *= 2;
  }


  rep(i,n){
    cout << x[i] << " ";
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 2432
inp = require('fs').readFileSync('/dev/stdin', 'utf8').split('\n')
S = inp.shift()
T = inp.shift()
b = 0
for (i=0; i<S.length; i++) {
    l = S.slice(0, i)
    r = S.slice(i)
    if (r+l == T) {
        b = true
        break;
    }
}
console.log(b ? 'Yes' : 'No')

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


def solve(S: str):
    ret = None
    for i in range(26):
        c = chr(ord('a') + i)
        if not c in S:
            ret = c
            break
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{
    int i,n,a,b,k;
    scanf("%d %d",&n,&k);
    if(n%k==0){
        printf("0");
    }else{
        printf("1");
    }

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <vector>
#include <cmath>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTG(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) (bit>>(i)) & 1
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL((a))), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define ENDL cout << endl;
using namespace std;
using ll = long long;
using ld = long double;
using PII = pair<int, int>;
using VPII = vector<PII>;
using VI = vector<int>;
using VVI = vector<VI>;
using Vll = vector<ll>;
using VVll = vector<Vll>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
const int INF = 1e9;
const ll MOD = 1e9 + 7;

void Group(auto &x, auto &ct, auto &G, auto &group, auto &group2, auto &checked, auto &p)
{
  if (checked[x]) return;
  checked[x] = true;
  group[ct].push_back(x);
  group2[ct].push_back(p[x]);
  REPx(y, G[x]) Group(y, ct, G, group, group2, checked, p);
}

int main()
{
  int N, M;
  cin >> N >> M;
  VI p(N);
  REP(i, N)
  {
    cin >> p[i];
    p[i]--;
  }
  VVI G(N, VI());
  REP(i, M)
  {
    int x, y;
    cin >> x >> y;
    x--; y--;
    G[x].push_back(y); G[y].push_back(x);
  }
  VB checked(N, false);
  VVI group_idx(N), group_p(N);
  int ct = 0;
  REP(i, N)
  {
    if (G[i].empty()) continue;
    if (checked[i] == true) continue;
    Group(i, ct, G, group_idx, group_p, checked, p);
    ct++;
  }

  int ans = 0;
  REP(i, ct)
  {
    int len = group_idx[i].size();
    SORT(group_idx[i]); SORT(group_p[i]);
    int idx = 0;
    REP(j, len)
    {
      while (idx < len)
      {
        if (group_idx[i][j] < group_p[i][idx]) break;
        else if (group_idx[i][j] > group_p[i][idx]) idx++;
        else
        {
          idx++;
          ans++;
          break;
        }
      }
    }
  }
  REP(i, N)
  {
    if (checked[i]) continue;
    if (p[i] == i) ans++;
  }
  cout << ans << endl;

  return 0;
}

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

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int x, a, b;
  	cin >> x >> a >> b;
  	x -= a;
  	cout << x - x / b * b << '\n';
    return 0;
}


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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
vl modinv;
void fillModInv(ll n, ll mod){
  modinv = vl(n+1);
  modinv[1] = 1;
  FOR(i,2,n+1){
    modinv[i] = modinv[mod%i] * (mod - mod/i) % mod;
  }
}
/*}}}*/
int main() {
  string n;
  cin >> n;

  string ans;
  if(n=="ARC") ans = "ABC";
  if(n=="ABC") ans = "ARC";
  
  //cout << fixed << setprecision(10);
  cout << ans << endl;
  return 0;
}


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

using namespace std;

int main(void) {
	vector<int> result(0);
	int m;
	int nMin;
	int nMax;
	cin >> m;
	cin >> nMin;
	cin >> nMax;
	while (m != 0 || nMin != 0 || nMax != 0) {
		vector<int> array(0);
		for (int i = 0; i < m; i++) {
			int p;
			cin >> p;
			array.push_back(p);
		}
		int tmp = -1;
		int diffMax = -10000;
		for (int i = nMin - 1; i < nMax; i++) {
			int diff = array[i] - array[i + 1];
			if (diff >= diffMax) {
				diffMax = diff;
				tmp = i + 1;
			}
		}
		result.push_back(tmp);
		cin >> m;
		cin >> nMin;
		cin >> nMax;
	}
	
	for (int &num:result) {
		cout << num << endl;
	}
	
	return 0;
}



Measured memory_bytes: 3068
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  vector<int> arr(N);
  for(int i=0;i<N;++i) cin>>arr[i];
  sort(arr.begin(), arr.end(), greater<int>());
  int minnum = (arr[0]+1)/2;
  map<int, int> amap;
  vector<int> aru;
  for(int i=0;i<N;++i) {
    if(amap[arr[i]]==0) aru.push_back(arr[i]);
    amap[arr[i]]++;
  }
  sort(aru.begin(), aru.end());
  bool can = true;
  for(int i=minnum;i<=arr[0];++i) {
    if(i==minnum)  {
      if(arr[0]%2==0) {
        if(amap[i]!=1) can = false;
      }
      else {
        if(amap[i]!=2) can = false;
      }
    }
    else {
      if(amap[i]<2) can = false;
    }
  }
  if(can) cout<<"Possible"<<endl;
  else cout<<"Impossible"<<endl;
}



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

typedef long long ll;

int main(){
	int n; 
	cin>>n;
	vector<string>s(n);
	vector<int>t(n);
	map<string,int>u;
	string x;
	for(int i=0;i<n;i++){
		cin>>s[i]>>t[i];
		u[s[i]]=i;
	}
	cin>>x;
	int y=u[x];
	ll ans=0;
	for(int i=y+1;i<n;i++){
		ans+=t[i];
	}
	cout<<ans<<endl;
	return 0;
}

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

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

    int d = 0, c = 0;
    rep(i, n) {
        if (s[i] == '(')
            c++;
        else
            c--;
        d = min(d, c);
    }

    rep(i, -d) cout << '(';
    cout << s;
    rep(i, c - d) cout << ')';

    return 0;
}


Measured memory_bytes: 256
program ccc
implicit none

integer :: n, m, i, res
integer,allocatable,dimension(:) :: p

read*, n
allocate(p(n))
read*, p

res = 0
m   = p(1)
do i = 1, n
if (p(i)<=m) then
res = res + 1
m = p(i)
end if
end do

print*, res

end program

Measured memory_bytes: 1536
import java.util.Scanner;
public class Main {
		 
			public static void main(String[] args) {
		        
				Scanner sc = new Scanner(System.in);
		 
				int n = sc.nextInt();
				String result = "Three";
				for (int i = 0; i < n; i++) {
					if (sc.next().equals("Y")) {
						result = "Four";
						break;
					}
				}
		 
				System.out.println(result);
			}
		 
		}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;

int main(){
    int n;
    cin>>n;
    vector<pair<string,pair<int,int>>> v;
    for(int i=0;i<n;i++){
        string s;
        int p;
        cin>>s>>p;
        v.push_back({s,{-p,i+1}});
    }
    sort(v.begin(),v.end());
    for(auto i:v){
        cout<<i.second.second<<endl;
    }
}


Measured memory_bytes: 256
#include<cmath>
#include<algorithm>
#include<iostream>
#include<vector>
#include<cstdio>

using namespace std;

double EPS = 1e-10;
const double PI = acos(-1);

double add(double a, double b){
  if(abs(a+b) < EPS * (abs(a)+abs(b)))return 0;
  return a+b;
}

struct point{
  double x, y;
  point(){}
  point(double x,double y) : x(x) , y(y){}

  point operator + (point p){
    return point(add(x,p.x), add(y,p.y));
  }

  point operator - (point p){
    return point(add(x,-p.x), add(y,-p.y));
  }

  point operator * (double d){
    return point(x*d,y*d);
  }

  point operator / (double d){
    return point(x/d,y/d);
  }
  
  bool operator == ( const point &p ) const {
    return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS;
  }
};

struct segment{
  point a,b;
};

bool cmp_x(const point& p, const point& q){
  if(p.x != q.x)return p.x<q.x;
  return p.y < q.y;
}

double dot(point a, point b) {
  return (a.x * b.x + a.y * b.y);
}

double cross(point a, point b) {
  return (a.x * b.y - a.y * b.x);
}

double vec_abs(point a){
  return sqrt(a.x*a.x+a.y*a.y);
}

double dist(point a,point b){
  return sqrt(pow(a.x-b.x,2)+pow(a.y-b.y,2));
}

double areaPol(vector<point> t, int n){
  t.push_back(t[0]);
  int tsz=t.size();
  double area=0;
  for(int i=0;i<tsz-1;i++){
    area+=(t[i].x-t[i+1].x)*(t[i].y+t[i+1].y);
  }
  return abs(area)/2.0;
}


int main(void){
  point p;
  vector<point>t;
  int n=0;
  double x,y;
  char k;

  while(cin>>x>>k>>y){
    if(cin.eof())break;
    p.x = x;
    p.y = y;
    t.push_back(p);
    n++;
 }

  printf("%.6f\n",areaPol(t,n));

  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
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; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
    for(auto i=begin(v); i != end(v); ++i){
        if(i !=begin(v)) os << ' ';
        os << *i;
    }
    return os;
}

ll N,M;
string S="";
ll A[13],B[13];

int main(){
    ll N,A,B,C=0;
    cin >> N >> A >> B;
    Rep(i,1,N+1){
        ll M=i,T=0;
        while(M>0){
            T+=M%10;
            M/=10;
        }
        if(T<=B && T>=A){
            C+=i;
        }
    }
    cout << C << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

//std::cout << std::fixed << std::setprecision(10)
constexpr long long MOD = 1000000007;

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

struct Event
{
  int x;
  char c;
  int i;
};

int main()
{
  int N, M;
  std::cin >> N >> M;
  std::vector<Event> events(2 * M);
  for (int i = 0; i < M; ++i)
  {
    int a, b;
    std::cin >> a >> b;
    events[2 * i] = {a, 1, i};
    events[2 * i + 1] = {b, 0, i};
  }
  std::sort(events.begin(), events.end(),
            [](auto&& x, auto&& y) {
              return std::make_tuple(x.x, x.c, x.i) < std::make_tuple(y.x, y.c, y.i); });
  int ans = 0;
  std::unordered_set<int> start;
  for (auto& e: events)
  {
    if (e.c == 1)
    {
      start.insert(e.i);
    }
    else
    {
      auto it = start.find(e.i);
      if (it != start.end())
      {
        start.clear();
        ++ans;
      }
    }
  }
  std::cout << ans << std::endl;
  return 0;
}



Measured memory_bytes: 4224
#include "bits/stdc++.h"

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i,n) for(ll i=1;i<=(ll)(n);i++)
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(ll)(n);i>0;i--)
#define REP(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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 (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = 1e18;
const ll MOD = 1000000007;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//#define mp make_pair

ll gcd(ll a, ll b) {
	if (b > a) {
		swap(a, b);
	}
	ll r = a%b;
	while (r != 0) {
		a = b;
		b = r;
		r = a%b;
	}
	return b;
}


int main() {
  ll n, x;
  cin >> n >> x;
  vl d(n);
  rep (i, n) {
    cin >> d[i];
  }
  rep (i, n) {
    d[i] = abs(d[i] - x);
  }
  ll ans = d[0];
  rep1(i, n - 1) {
    ans = gcd(ans, d[i]);
  }
  cout << ans << endl;
}
  


Measured memory_bytes: 1024