akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef double dl;
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define MOD 1e9+7
#define lb lower_bound
#define ub upper_bound
#define SZ(x) (int)x.size()
#define INF 1000000000
int K;
deque<int> dq;
int res[100100];

int main(){
  // freopen("input.txt","r",stdin);
  cin>>K;
  dq.push_back(1);
  memset(res,-1,sizeof(res));
  res[1] = 0;
  while (dq.size()){
    int cur = dq[0];
    // cout << cur << '\n';
    dq.pop_front();
    // cout << (cur*10)%K << ' ' << res[(cur*10)%K] << ' ' << res[cur] << '\n';
    if (res[(cur * 10) % K] == -1 || res[(cur*10)%K] > res[cur]){
      res[(cur*10)%K] = res[cur];
      // cout << "GG " << res[(cur*10)%K] << '\n';
      dq.push_front((cur*10)%K);
    }
    if (res[(cur+1)%K] == -1){
      res[(cur+1)%K] = res[cur] + 1;
      dq.push_back((cur+1)%K);
    }
  }
  // cout << res[1] << ' ' << res[10%7] << ' ' << res[100%7] << ' ' << res[1000%7] << '\n';
  cout << res[0]+1;
}

Measured memory_bytes: 896
/*****Enigma27*****/
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pll         pair<ll int,ll int>
#define vll          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
#define ios	    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
ll n,i,j,k,l,sum=0,flag=0,t,a[100005],ans=0;
map<ll,ll> f;
int main()
{
	ios
	cin>>n;
	for(i=0;i<n;i++){
		cin>>k;
		sum+=k;
		if(sum==0) ans++;
		ans+=f[sum];
		f[sum]++;
	}
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 12800
yn = lambda b: print('Yes') if b else print('No')
#-------------------------------------------------------------------
import sys
def p(*_a):
  _s=" ".join(map(str,_a))
  #print(_s)
  sys.stderr.write(_s+"\n")
#-------------------------------------------------------------------

N = int(input())						# 5

if N==1:
	yn(True)
	exit(0)

A =        list( map(int, input().split()) )	# 1 2 3 4 5 ...

b=False
B=[0]*(N)
for i in range(N-1):
	a = A[i+1]-A[i]
	B[i+1]=a
	
	if a<=-2:
		yn(False)
		exit(0)
	
	
	if a==-1:
		if b:
			yn(False)
			exit(0)
		else:
			b=True
	
	if a>=1:
		b=False

p("A ",A)
p("B ",B)

yn(True)


Measured memory_bytes: 14480
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		PriorityQueue<Integer> q = new PriorityQueue<>(new Comparator<Integer>() {
			public int compare(Integer i1, Integer i2) {
				return - Integer.compare(i1, i2);
			}
		});
		
		for(int i=0; i<N; i++)
			q.add(sc.nextInt());
		
		for(int i=0; i<M; i++) {
			int max = q.poll();
			q.add(max/2);
		}
		long ans = 0;
		while(!q.isEmpty())
			ans += q.poll();
		
		System.out.println(ans);
		sc.close();
	}
}


Measured memory_bytes: 58992
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int A, B, T =0;
    int ans=0;
    cin >> A >> B >> T;
    for(int i=A; i <=T; i+=A){ //Aずつ
        ans +=B;
        //cout << i << endl;
    }
    cout << ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
int main(){
int n, t,a;
cin >> n >> t >> a;
int i = 0;
double ness = 1e9;
for(int k=1;k<=n;k++){
int h;cin >> h;
if(ness > abs((double)h*0.006+a-t)){
i = k;ness = abs((double)h*0.006+a-t);
}}
cout << i;
return 0;
}

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

int n,m;
unordered_set<int> s[200005];

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

    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        int x,y;
        cin>>x>>y;
        s[x].insert(y);
        s[y].insert(x);
    }
    for(int i=2;i<=n-1;i++)
    {
        if(s[i].count(1)*s[i].count(n))
        {
            cout<<"POSSIBLE"<<endl;
            return 0;
        }
    }

    cout<<"IMPOSSIBLE"<<endl;

    return 0;
}


Measured memory_bytes: 34784
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 7;

int n, m, l[maxn], r[maxn], BIT[4 * maxn];
int ans[maxn], root;
int dist[maxn], par[maxn], deg[maxn];

vector<int> vt[maxn], inv[maxn];

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    if(fopen("test.inp", "r")) freopen("test.inp", "r", stdin);
    cin >> n >> m;
    for(int i = 1; i <= n + m - 1; i++)
    {
        int u, v;
        cin >> u >> v;
        inv[u].push_back(v);
        vt[v].push_back(u);
        deg[v]++;
    }
    for(int i = 1; i <= n; i++)
    {
        if(deg[i] == 0)
        {
            root = i;
        }
    }
    queue<int> q;
    vector<int> order(0);
    q.push(root);
    while(!q.empty())
    {
        int u = q.front();
        q.pop();
        order.push_back(u);
        for(auto v: inv[u])
        {
            deg[v]--;
            if(deg[v] == 0) q.push(v);
        }
    }
    for(auto i: order)
    {
        if(i == root) continue;
        for(auto j: vt[i])
        {
            if(dist[i] < dist[j] + 1)
            {
                dist[i] = dist[j] + 1;
                par[i] = j;
            }
        }
    }
    for(int i = 1; i <= n; i++) cout << par[i] << '\n';
}

Measured memory_bytes: 62844
#include<bits/stdc++.h>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef long long ll;
typedef pair<ll,ll> P;
const int INF=INT_MAX / 3;
const ll LINF=LLONG_MAX / 3LL;
#define CONST 1000000007
#define EPS (1e-8)
#define PB push_back
#define MP make_pair
#define sz(a) ((int)(a).size())
#define reps(i,n,m) for(int i=(n);i<int(m);i++)
#define rep(i,n) reps(i,0,n)
#define SORT(a) sort((a).begin(),(a).end())
ll mod(ll a,ll m){return (a%m+m)%m;}
int dx[9]={0,1,0,-1,1,1,-1,-1,0},dy[9]={1,0,-1,0,1,-1,1,-1,0};
typedef vector<int> VI;
typedef vector<VI> VVI;

struct unionFind {
  VI par, rank;
  int n;
  void init(int x) {
    n = x;
    par.resize(n);
    rank.resize(n);
    rep(i,n) {
      par[i] = i;
      rank[i] = 0;
    }
  }
  int root (int x) {
    if (par[x] == x) {
      return x;
    }
    return par[x] = root(par[x]);
  }
  bool same (int x, int y) {
    return root(x) == root(y);
  }
  void unite (int x, int y) {
    x = root(x);
    y = root(y);
    if (x==y) return;
    if(rank[x]<rank[y]) {
      par[x] = y;
    } else {
      par[y] = x;
      if(rank[x]==rank[y]) rank[x]++;
    }
  }
  int treeNum () {
    set<int> s;
    rep(i,n) {
      s.insert(root(i));
    }
    return s.size();
  }
};

ll n,m;
int main(){
  cin>>n>>m;
  unionFind uf;
  uf.init(n + m);
  rep(i,n){
    int k;
    cin>>k;
    rep(j,k){
      int l;
      cin>>l;
      uf.unite(i, n+l-1);
    }
  }
  bool flg=true;
  rep(i,n){
    if(!uf.same(0,i))flg=false;
  }
  cout<<(flg?"YES":"NO")<<endl;
  return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>

using namespace std;

int main(void){
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	int T[100];
	for(int i=0; i<100; i++){
		T[i]=0;
	}
	for(int i=A; i<B; i++){
		T[i]++;
	}
	for(int i=C; i<D; i++){
		T[i]++;
	}
	int t=0;
	for(int i=0; i<100; i++){
		if(T[i]==2){
			t++;
		}	
	}

	cout << t << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdlib>
#define fs first
#define se second

using namespace std;
typedef long long llong;
typedef pair<int, int> pii;

int par[10];
int deg[10];
int find(int x) {
    if (par[x]) return par[x] = find(par[x]);
    return x;
}

void fail() {
    printf("NO\n");
    exit(0);
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    for (int i = 0; i < 3; ++i) {
        int a, b;
        cin >> a >> b;
        if (find(a) == find(b)) fail();
        par[find(a)] = find(b);
        deg[a] ^= 1;
        deg[b] ^= 1;
    }
    int cnt = 0;
    for (int i = 1; i <= 4; ++i) if (deg[i]) ++cnt;
    if (cnt > 2) fail();
    printf("YES\n");
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Text;
					
public class Program
{
	static int H = 0;
	
	public static void Main()
	{
		int[] S = new int[2000001];
		string order;
		StringBuilder sb = new StringBuilder();
		
		order = Console.ReadLine();
		
		while(order != "end") {
			switch(order[0]) {
				case 'e':
					sb.AppendLine(Extract(S).ToString());
					break;
				case 'i':
					Insert( S, 
						int.Parse(order.Split(" ".ToCharArray())[1]) );
					break;
			}
			
			order = Console.ReadLine();
		}
		
		Console.Write(sb);
	}
	
	public static int Extract(int[] A)
	{
		int ret;
		
		if (H < 1) return int.MinValue;
		
		ret = A[1];
		A[1] = A[H--];
		
		MaxHeapify(A, 1);	
		
		return ret;
	}
	
	public static void Insert(int[] A, int key)
	{
		H++;
		A[H] = int.MinValue;
		
		IncreaseKey(A, H, key);
	}
	
	public static void IncreaseKey(int[] A, int i, int key)
	{
		if(key < A[i]) return;
		A[i] = key;
		
		while(i > 1 && A[i] > A[i/2]) {
			Swap(A, i, i/2);
			i /= 2;
		}
	}
	
	public static void MaxHeapify(int[] A, int i)
	{
		int l = Left(A, i);
		int r = Right(A, i);
		int largest = i;
		
		if(l >= 0) {
			if(A[l] > A[largest]) largest = l;	
		}
		if(r >= 0) {
			if(A[r] > A[largest]) largest = r;
		}
		
		if(i != largest) {
			Swap(A, i, largest);
			MaxHeapify(A, largest);
		}
	}
	
	public static int Left(int[] A, int i)
	{	
		return ( 2*i <= H )? 2*i : -1;
	}
	
	public static int Right(int[] A, int i)
	{	
		return ( (2 * i + 1) <= H)? (2*i + 1) : -1;
	}
	
	public static void Swap(int[] A, int i, int j)
	{
		int tmp = A[i];
		A[i] = A[j];
		A[j] = tmp;
	}
}

Measured memory_bytes: 46124
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	int n;
	cin >> n;
	vector<pair<int, int>> c(n);
	rep(i, n){
		int a, b;
		cin >> a >> b;
		c.at(i) = make_pair(b, a);
	}
	sort(c.begin(), c.end());
	int t = 0;
	rep(i, n){
		int a, b;
		tie(b, a) = c.at(i);
		// cerr << t << " " << a << " " << b << endl;
		if(t + a > b){
			cout << "No" << endl;
			return 0;
		}else{
			t += a;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 1792
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll INF=1e9+7;

int main(){
    ll n;
    cin >> n;
    string ans="";
    while(n){
        ll m=n%26;
        if(m==0){
            m=26;
        }
        m--;
        char c='a'+m;
        ans+=c;
        if(m==25){
            n-=26;
        }
        n/=26;
        //cout << m << endl;
    }
    reverse(ans.begin(),ans.end());
    cout << ans << endl;
} 

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

using namespace std;

int main(){
	string c; int m=0; bool b = true; int q=0;
	cin>>c;
	
	for(int i = 0 ; i<c.size() ; i++){
		if (c[i]!='k'&&c[i]!='e'&&c[i]!='y'&&c[i]!='n'&&c[i]!='c'){
			c[i]='0';
		}
	}
	for(int i = 0 ; i< c.size()-7 ; i++){
			if(c[i]==c[i+1]){
				q++;
			}
			else{
				break;
			}
		}

	if(c[0]!='k'||q!=0){
		for(int i = 1 ; i< c.size()-7 ; i++){
			if(c[i]=='k'&&c[i+1]=='e'&&c[i+2]=='y'&&c[i+3]=='e'&&c[i+4]=='n'&&c[i+5]=='c'&&c[i+6]=='e'){
				cout<<"YES";
				b=false;
			}
		}
	}


	else{
		

		if(c[1]!='e'){
			m=1;
		}
		else if(c[2]!='y'){
			m=2;
		}
		else if(c[3]!='e'){
			m=3;
		}
		else if(c[4]!='n'){
			m=4;
		}
		else if(c[5]!='c'){
			m=5;
		}
		else if(c[6]!='e'){
			m=6;
		}
	}
	

	for(int i = c.size()-7 ; i<c.size() ; i++ ){
		if(m==1){
			if(c[i+1]=='e'&&c[i+2]=='y'&&c[i+3]=='e'&&c[i+4]=='n'&&c[i+5]=='c'&&c[i+6]=='e'){
				cout<<"YES";
				b=false;
		}
	}
		if(m==2){
			if(c[i+2]=='y'&&c[i+3]=='e'&&c[i+4]=='n'&&c[i+5]=='c'&&c[i+6]=='e'){
				cout<<"YES";
				b=false;
		}
	}
	if(m==3){
			if(c[i+3]=='e'&&c[i+4]=='n'&&c[i+5]=='c'&&c[i+6]=='e'){
				cout<<"YES";
				b=false;
		}
	}

	if(m==4){
			if(c[i+4]=='n'&&c[i+5]=='c'&&c[i+6]=='e'){
				cout<<"YES";
				b=false;
		}
	}
	if(m==5){
			if(c[i+5]=='c'&&c[i+6]=='e'){
				cout<<"YES";
				b=false;
		}
	}

	if(m==6){
			if(c[i+6]=='e'){
				cout<<"YES";
				b=false;
		}
	}

}

if(c[0]=='k'&&c[1]=='e'&&c[2]=='y'&&c[3]=='e'&&c[4]=='n'&&c[5]=='c'&&c[6]=='e'){
	cout<<"YES";
	b=false;
}

if(b){
	cout<<"NO";
}

}

Measured memory_bytes: 256
# region header
import sys
import math
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, deque, Counter
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import accumulate, groupby, product, permutations, combinations, combinations_with_replacement
from math import ceil, floor, factorial, log, sqrt, sin, cos
from operator import itemgetter
sys.setrecursionlimit(10**6)
rs = lambda: sys.stdin.readline().rstrip()
ri = lambda: int(rs())
rf = lambda: float(rs())
rs_ = lambda: [_ for _ in rs().split()]
ri_ = lambda: [int(_) for _ in rs().split()]
rf_ = lambda: [float(_) for _ in rs().split()]
INF = float('inf')
MOD = 10 ** 9 + 7
PI = math.pi
# endregion

X, A = ri_()
print(0 if X < A else 10)

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

#define rep(i, first, to) for(ll i = first; i < to; ++i)

using namespace std;
typedef long long ll;
const int MAXN = 1000;

int a[MAXN];

void solve() {
	int n;
	cin >> n;
	rep(i, 0, n) {
		cin >> a[i];
	}
	sort(a, a + n);
	cout << a[n - 1] - a[0] << endl;
}

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	ll n;
	cin >> n;
	ll c,s,f;
	vector<vector<ll>> a(n,vector<ll>(3));
	vector<ll> ans(n);
	for(ll i = 0; i < n - 1; i++) {
		cin >> c >> s >>f;
		a[i][0]= c;
		a[i][1]= s;
		a[i][2]= f;
	}
	for(ll j = 0; j < n; j++) {
		ll t = 0;
		for(ll i = j; i < n - 1; i++) {
			if (a[i][1] >= t){//始発前
				t = a[i][1];
			}
			else{//始発が行ったあと
				for(ll d = 0; d < a[i][2]; d++) {
					if ((t + d) % a[i][2] == 0){
						t += d;
						break;
					}
				}
			}
			t += a[i][0];
		}
		ans[j] = t;
			cout << ans[j] << 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() {
    string s;
    cin >> s;

    vector<int> v(4);
    rep(i, 4) v[i] = s[i] - '0';

    int n = 3;
    char c[3];
    rep(i, 1 << n) {
        int sum = v[0];
        rep(j, n) {
            if ((i >> j) & 1) {
                sum += v[j + 1];
                c[j] = '+';
            } else {
                sum -= v[j + 1];
                c[j] = '-';
            }
        }

        if (sum == 7) {
            cout << v[0];
            rep(j, n) {
                cout << c[j] << v[j + 1];
            }
            cout << "=7" << endl;
            return 0;
        }
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
#define PI 3.14159265358979323846264338327950L
using namespace std;
using P = pair<int,int>;
using ll = long long;
int main(void){
    int n; cin >> n;
    int x[n]; rep(i, n){cin >> x[i];}
    int sum = 0;
    int mini = 100000000;
    for(int i = 1; i <= 100; ++i){
        rep(j, n){
            sum += (i - x[j]) * (i - x[j]);
        }
        mini = min(mini, sum);
        sum = 0;
    }
    
    cout << mini << endl;
    return 0;
}


Measured memory_bytes: 3572
#include <cstdio>
#include <vector>
#include <string>
#include <sstream>

using A = std::vector<uint32_t>;
using B = std::string;
bool printed = false;
void Solve(const A& v, const B& b, int index, uint32_t acc) {
  if (v.size() == index) {
    if (acc == 7 && !printed) {
      printed = true;
      printf("%s=7\n", b.c_str());
    }
    return;
  }
  auto c = v[index];
  auto n = index + 1;

  std::stringstream ss_1;
  std::stringstream ss_2;

  if (index == 0) {
    ss_1 << c;
    ss_2 << c;
  } else {
    ss_1 << b << '+' << c;
    ss_2 << b << '-' << c;
  }
  
  Solve(v, ss_1.str(), n, acc + c);
  Solve(v, ss_2.str(), n, acc - c);
}

int main() {
  char s[4];
  scanf("%s", s);
  std::vector<uint32_t> v;
  for (int i = 0; i < 4; i++) {
    v.push_back(s[i] - 48);
  }

  Solve(v, "", 0, 0);
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		for(int i = 0; i < 2; i++) {
			if(!S.substring(i + 1, i + 2).equals(S.substring(i, i + 1))) {
				System.out.println("Yes");
				return;
			}
		}
		System.out.println("No");
	}
}


Measured memory_bytes: 23508
<?php
$abk = explode(" ",trim(fgets(STDIN)));


for($i=0;$i<$abk[2];$i++){
$ans[] = $i+$abk[0];
if(count($ans)==$abk[1]-$abk[0]+1){
break;
}
}
for($i=0;$i<$abk[2];$i++){
if(count($ans)==$abk[1]-$abk[0]+1){
  break;
  }
$ans[] = $abk[1]-$i;
}
sort($ans);
foreach($ans as $value){
echo $value."\n";
}


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

int main() {
  int a, b;
  cin >> a >> b;
  vector<string> S(2);
  rep(i, b) S.at(0)+=to_string(a);
  rep(i, a) S.at(1)+=to_string(b);
  sort(S.begin(), S.end());
  cout << S.at(0) << endl;
}
  
  

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
    int n,d,ans=0,tmp=1;
    cin >> n >> d;
    vector<vector<int> > vec(n,vector<int>(d));
    map<int,int> mp;
    while(tmp*tmp<=16000){
        mp[tmp*tmp]=1;
      	tmp++;
    }
    rep(i,n){
        rep(j,d){
            cin >> vec.at(i).at(j);
        }
    }
    rep(i,n){
        rep(j,i+1){
            tmp=0;
            rep(k,d){
                tmp+=pow((vec.at(i).at(k)-vec.at(j).at(k)),2);
            }
            ans+=mp.count(tmp);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define all(v) v.begin(),v.end()
#define repf(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define MOD 998244353 

using namespace std;
using namespace __gnu_pbds;

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

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

ll power(ll a, ll n, ll m)
{
    ll ans=1;
    while(n)
    {
        if(n&1) ans=(ans*a)%m;
        n>>=1;
        a=(a*a)%m;
    }
    return ans;
}

ll invmod(ll a, ll m)
{
    return power(a,m-2,m);
}

int main()
{
    IOS;
    ll x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;
    ll p[a],q[b],r[c];
    repf(i,0,a) cin>>p[i];
    repf(i,0,b) cin>>q[i];
    repf(i,0,c) cin>>r[i];
    sort(p,p+a);
    sort(q,q+b);
    sort(r,r+c);
    reverse(p,p+a);
    reverse(q,q+b);
    reverse(r,r+c);
    ll ans=0;
    repf(i,0,x) ans+=p[i];
    repf(i,0,y) ans+=q[i];
    ll i=x-1,j=y-1,k=0;
    while(i>=0 && j>=0 && k<c && r[k]>min(p[i],q[j]))
    {
        if(p[i]<q[j])
        {
            ans-=p[i];
            ans+=r[k];
            k++,i--;
        }
        else
        {
            ans-=q[j];
            ans+=r[k];
            k++,j--;
        }
    }
    while(i>=0 && k<c && r[k]>p[i])
    {
        ans-=p[i];
        ans+=r[k];
        i--;
        k++;
    }
    while(j>=0 && k<c && r[k]>q[j])
    {
        ans-=q[j];
        ans+=r[k];
        j--;
        k++;
    }
    cout<<ans<<endl;
}     

Measured memory_bytes: 2560
#include <bits/stdc++.h>
            using namespace std;
             
            int main() {
              int N, l, r, i, sum;
              
              cin >> N;
              for(i = 0; i < N; i++){
                cin >> l >> r;
                sum += r - l + 1;
              }
              cout << sum << endl;
            }

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;

static const int INTINF = (2147483647);
static const ll LLINF = (9223372036854775807);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;

namespace Printer{
    template<class T>
    void print(T x){
        cout << x << endl;
    }

    template<class T>
    void print(T x, T y){
        cout << x << "," << y << endl;
    }

    template<class T>
    void print(vector<T> v){
        rep(i, v.size()){
            if(i) cout << " ";
            cout<< v[i];
        }
        cout << endl;
    }

    template<class T>
    void print(vector<vector<T> > vv){
        rep(i, vv.size()){
            rep(j, vv[i].size()){
                if(j) cout << " ";
                cout << vv[i][j];
            }
            cout << endl;
        }
    }

    void print(pair<int, int> p){
        cout << "(" << p.first << ", " << p.second << ")" << endl;
    }
};
using namespace Printer;

//--global--//



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

int main(int argc, const char * argv[]) {
    //提出時、消す----//
    //--------------//

    ll n;
    cin >> n;
    vector<pair<ll, ll> > xl(n);
    vector<ll> x(n);
    vector<pair<ll, ll> > a(n);
    rep(i, n){
        ll x, l;
        cin >> x >> l;
        xl[i] = make_pair(x, l);
    }
    sort(ALL(xl));

    rep(i, n){
        a[i] = make_pair(xl[i].first+xl[i].second, xl[i].first-xl[i].second);
        //print(a[i].first, a[i].second);
    }
    sort(ALL(a));

    int ans = 0; int t= -INTINF;
    for(int i=0; i<n; i++){
        if(t <= a[i].second){
            ans++;
            t = a[i].first;
        }
    }
    print(ans);
    
    return 0;
}


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

int main()
{
  long long int deposit = 100;
  long long int x;
  cin >> x;
  int ans = 0;
  
  while(deposit < x) {
    deposit += deposit / 100;
    ans++;
  }
  cout << ans << "\n";
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
typedef complex<double> P;
typedef vector<P> vec;

double eps=1e-5;
bool eq(double a,double b){return (b-a<eps&&a-b<eps);}
double dot(P a,P b){return real(b*conj(a));}
double cross(P a,P b){return imag(b*conj(a));}
P project(P a,P b,P c){b-=a;c-=a;return a+b*real(c/b);}
P reflect(P a,P b,P c){b-=a;c-=a;return a+conj(c/b)*b;}
int ccw(P a,P b,P c){
  b-=a,c-=a,a=c*conj(b);
  if(a.imag()>eps)return 1;//ccw
  if(a.imag()<-eps)return -1;//cw
  if(a.real()<-eps)return 2;//ob
  if(abs(b)+eps<abs(c))return -2;//of
  return 0;//os
}

//segment ab , point c
double dist(P a,P b,P c){
  if(dot(b-a,c-a)<0)return abs(c-a);
  if(dot(a-b,c-b)<0)return abs(c-b);
  return abs(cross(b-a,c-a))/abs(b-a);
}

bool isintersect(P a,P b,P c,P d){
  return ((ccw(a,b,c)*ccw(a,b,d)<=0)&&(ccw(c,d,a)*ccw(c,d,b)<=0));
}

//segment ab , segment cd
P intersect(P a,P b,P c,P d){
  a-=d;b-=d;c-=d;
  return d+a+(b-a)*imag(a/c)/imag(a/c-b/c);
}

double dist(P a,P b,P c,P d){
  if(isintersect(a,b,c,d))return 0;
  double ab=min(dist(a,b,c),dist(a,b,d));
  double cd=min(dist(c,d,a),dist(c,d,b));
  return min(ab,cd);
}

double calcArea(vec &t){
  double res=0;
  int n=t.size();
  for(int i=0;i<n;i++)res+=cross(t[i],t[(i+1==n?0:i+1)]);
  return abs(res/2.0);
}


double Arg(P a,P b,P c){
  b-=a,c-=a;
  double res=acos( max(-1.0,min(1.0,dot(b,c)/abs(b)/abs(c))) );
  if(cross(b,c)<0)res*=-1.0;
  return res;
}

int inPolygon(vec &t,P p){
  int n=t.size();
  double sum=0;
  for(int i=0;i<n;i++){
    P a=t[i],b=t[(i+1==n?0:i+1)];
    if( ccw(a,b,p) == 0 )return 1;
    sum+= Arg(p,a,b);
  }
  if( abs(sum) < 0.5 )return 0;
  else  return 2;
}

int main(){
  int n;
  cin>>n;
  vec t;
  double x,y;
  for(int i=0;i<n;i++){
    cin>>x>>y;
    t.push_back(P(x,y));
  }
  int q;
  cin>>q;
  while(q--){
    cin>>x>>y;
    cout<<inPolygon(t,P(x,y))<<endl;
  }

  return 0;
}

Measured memory_bytes: 1320
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int ans;

    if(a >= 10) {
      ans = b;
    } else {
      ans = b + 100 * (10 - a);
    }
      System.out.println(ans);
  }
}

Measured memory_bytes: 21332
N = int(input())
d = {}
x = 0
for i in [0]*N:
    s = ''.join(sorted(input()))
    if s in d:
        d[s] += 1
    else:
        d[s] = 0
for p in d.values():
    x += (p+1) * p // 2
print(x)

Measured memory_bytes: 18616
using System;
using System.Linq;

class Program
{
    static void Main (string[] args)
    {
        var s = Console.ReadLine ();
        var count = 0;
        if (s[0] == 'A')
        {
            for (var i = 2; i <= s.Length - 2; i++)
            {
                if (s[i] == 'C')
                {
                    count++;
                }
            }
            var quary = s.Where (x => x != 'A' && x != 'C')
                .ToArray ();
            for (var i = 0; i < quary.Length; i++)
            {
                if (Char.IsUpper (quary[i]) || count == 0 || count > 1)
                {
                    Console.WriteLine ("WA");
                    return;
                }
            }
        }
        else
        {
            Console.WriteLine ("WA");
            return;
        }
        if (count == 1)
        {
            Console.WriteLine ("AC");
        }
    }
}

Measured memory_bytes: 13268
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b)for(int i=(a);i<=(b);i++)
#define repR(i,n) for(int i=n;i>=0;i--)
#define P pair<int, int>
#define sz(x) x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<int>
#define COUT(x) cout<<(x)<<endl
#define MA map<int,int>
#define SE set<int>
#define PQ priority_queue
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

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

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

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

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


signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	vector<int>h(n); rep(i, n)cin >> h[i];
	vector<int>dp(n); rep(i, n)dp[i] = INF;
	dp[0] = 0;
	FOR(i,1,n) {
		chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
		if (i >= 2)chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
	}
	cout << dp[n - 1] << endl;
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#pragma GCC optimize("unroll-loops")
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/detail/standard_policies.hpp>
// using namespace __gnu_pbds;
// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>ordered_set;
/////////////////// TYPES & MACROS ///////////////////////////////
#define mp make_pair
#define eb emplace_back
#define pb push_back
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define vv vector
#define exist(s,e) (s.find(e)!=s.end())
using ll=long long int; using dd=double;
using pii=pair<int,int>; using pll=pair<ll,ll>;
typedef vector<int> vi;
ll INFLL=(ll)2e18, MOD=1'000'000'007;
const int INF=0x3f3fffff ;
/////////////////// DEBUG /////////////////////////////////////////
#define D(x) cerr<<#x<<" is: "<<x<<'\n';
#define DD(x,y) cerr<<"("<<#x<<","<<#y<<") are: "<<x<<" "<<y<<'\n';
/////////////////// VARIABLES & FUNCTIONS//////////////////////////
vector<vector<int>> adj; vector<int> vis;
int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1},dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};
inline ll mexp(ll x,ll n,ll m){ll res=1;while(n){if(n&1)res=(res*x)%m;n>>=1;x=((x%m)*(x%m))%m;}return res;}
inline bool ispow2(ll x){ return x && (!(x&(x-1)));}
inline ll gcd(ll x, ll y){ pll p{x,y}; while(p.ss) p={p.ss,p.ff%p.ss}; return p.ff;}


/////////////////// MAIN STARTS //////////////////////////////////
int main(){
ios_base::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
cout<<fixed;cerr<<fixed; cout<<setprecision(10); cerr<<setprecision(3);
// random_device rd; mt19937 genr(rd());

#ifdef DEBUG
  auto tStart = chrono::system_clock::now(); //freopen("op.txt","w",stdout);
#endif

int n,k; cin>>n>>k;
cout<<(n%k==0?0:1)<<'\n';

#ifdef DEBUG
  auto diff=chrono::system_clock::now()-tStart;
  cerr<<"\nExecution time: "<<chrono::duration<dd,milli>(diff).count()<<" ms.\n";
#endif
return 0;
}


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

static const int N_MAX=1000;
static const int W_MAX=10000;

int n; //??°???
int A[N_MAX],B[N_MAX]; //A?????±?????°??????B?????????????\?????????°???
int s;//s?????¨?????°??????????°????
int T[W_MAX+1]; //??\??°????????????????\?????????°???????????????

int solve()
{
    int ans=0; //?????¬???
    bool V[N_MAX]; //???????¢??????????
    for(int i=0;i<n;i++)
    {
        B[i]=A[i]; //?????°????????¶??????
        V[i]=false; //????§????
    }
    sort(B,B+n); //??????
    for(int i=0;i<n;i++) T[B[i]]=i; //????§???????????????????????\?????????°????????????
    for(int i=0;i<n;i++)
    {
        if(V[i]) continue; //???????¢??????????????????????
        int cur=i; //????????????
        int S=0; //S??°???????????????????????????????????????
        int m=W_MAX; //m?????¨?????°?????\??????????????????????°????
        int an=0; //an?????????????´???°???
        while(1) //????§???????
        {
            V[cur]=true; //????§??????°
            an++; //??°?????????
            int v=A[cur]; //v?????????????????????
            m=min(m,v); //??°????????????????°????
            S+=v; //??\???????????????????????????????????????????????????
            cur=T[v]; //??????????????????????????????????????°???????????????
            if(V[cur]) break; //????????????????????????????¢??????????????????\?????????????????????????????¨??¨?¢???????
        }
        ans+=min(S+(an-2)*m,m+S+(an+1)*s);
    }
    return ans;
}
int main()
{
    cin>>n;
    s=W_MAX;
    for(int i=0;i<n;i++)
    {
        cin>>A[i];
        s=min(s,A[i]);
    }
    cout<<solve()<<endl;
}

Measured memory_bytes: 3168
#include <cstdio>
#include <algorithm>
using namespace std;

int
main(void)
{
    int N, X;
    int temp;
    int hcf;

    scanf("%d%d", &N, &X);

    scanf("%d", &temp);
    --N;
    
    hcf = temp - X > 0 ? temp - X : X - temp;

    while(N--)
    {
	scanf("%d", &temp);

	temp = temp - X > 0 ? temp - X : X - temp;

	hcf = __gcd(hcf, temp);
    }

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

    return 0;
}

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

using ll = long long;
const ll amari = 1e9+7;
#define ben(a) a.begin(),a.end()
#define pb(a,b) a.push_back(b)

int main(){
	int a,b,c;
	cin >> a >> b >> c;
	int maxi = max(max(a,b),c);
	if((maxi = a && b + c == a) || (maxi = b && a + c == b) || (maxi = c && b + a == c))cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0; 
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>

#include <map>
#include <vector>
#include <algorithm>
#include <functional>

#include <sstream>
#include <iostream>

using namespace std;
typedef long long llint;
const llint inf = 1000000000000000000LL;

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

#define TRACE(x) cerr << #x << " = " << x << endl
#define _ << " _ " <<

const int MAXN = 1e5 + 5;
vector<int> G[MAXN];

int color[MAXN];
int cnt[2];

bool mark(int i, int c) {
  if (color[i] != -1)
    return color[i] == c;

  ++cnt[c];
  color[i] = c;

  for (int j : G[i])
    if (!mark(j, !c))
      return false;

  return true;
}

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

  vector<pair<int,int>> edges;

  REP(i, M) {
    int a, b;
    cin >> a >> b;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  memset(color, -1, sizeof color);

  if (!mark(1, 0))
    cout << (llint)N * (N - 1) / 2 - M << endl;
  else
    cout << (llint)cnt[0] * cnt[1] - M << endl;

  return 0;
}




Measured memory_bytes: 6400
//Radhe Radhe
#include<bits/stdc++.h>
#define ll long long
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
using namespace std;

bool prime (int i) {
    for (int j = 2; j * j <= i; j++) {
        if (i % j == 0) return false;
    }
    return true;
}
int main()
{
    fast_io
    ll i,n,p,j,k;
    cin>>n;
    for(j=2; j<55555; j++)
    {
        if(n==0)
            break;
        if(prime(j)==true&&j%5==1)
        {
                cout<<j<<" ";
                n--;
        }
    }
    return 0;
}





Measured memory_bytes: 3624
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  int h, n;
  readf("%s %s\n", &h, &n);
  auto a = readln.chomp.split.to!(int[]).sum;
  if (h <= a) {
    writeln("Yes");
  } else {
    writeln("No");
  }
}


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

int a, b;

int main() {
	cin >> a >> b;
	if((long long) a * b <= 0) puts("Zero");
	else if(a > 0) puts("Positive");
	else puts((b - a + 1) % 2 == 0 ? "Positive" : "Negative");
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);    //標準入力システム
        int x = sc.nextInt();  //入力呼び出し
        int h,m,s;
        h = x / 3600;
        m = (x-h*3600) / 60;
        s = x-h*3600-m*60;
        
        System.out.println(h +":"+ m +":"+ s);  
    }
}


Measured memory_bytes: 26228
n,p = gets.split.map(&:to_i)
ans = []
while n !=0 && p !=0
	i = 0
	tmp = p
	a = Array.new(n,0)
	while p != 0 
		if tmp != 0
			a [i] += 1
			tmp -= 1
		elsif tmp == 0 && a[i] == p
			break
		else
			tmp = a[i]
			a[i] = 0
		end
		i = i + 1
		i = 0 if i == n
	end
	ans.push(i)
	n,p = gets.split.map(&:to_i)
end
puts ans

Measured memory_bytes: 8616
N = int(input())
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))

p, q = 0, 0
B1 = []
B2 = []
for i in range(N):
    p += A1[i]
    B1.append(p)
    j = (N - 1) - i
    q += A2[j]
    B2.append(q)
B2.reverse()

ans = 0

for i in range(N):
    ans = max(ans, B1[i] + B2[i])
print(ans)


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

A.sort()
prev = A[0]
tmp = 0
ans = 0
if len(A) == 1:
    print(1)
    exit()
for a in A:
    if a != prev:
        if tmp % 2 == 1:
            ans += 1
        tmp = 1
    else:
        tmp += 1
    prev = a
if tmp % 2 == 1:
    ans += 1
print(ans)

Measured memory_bytes: 7488
var a:array[1..3,1..3]of longint;
    i,j:longint;
begin
  for i:=1 to 3 do
    for j:=1 to 3 do
      read(a[i,j]);
  if a[1,2]+a[2,3]+a[3,1]+a[1,3]+a[2,1]+a[3,2]=(a[1,1]+a[2,2]+a[3,3])*2 then
    writeln('Yes')
  else
    writeln('No');
end.

Measured memory_bytes: 128
#include <stdio.h>

int main(){
   int d,c[26],s[365][26],last[26],i,j,t;
   long sum;

   scanf("%d",&d);
   for (i=0;i<26;i++) {
      scanf("%d",&c[i]);
      last[i]=-1;
   }
   for (j=0;j<d;j++)
      for (i=0;i<26;i++) scanf("%d",&s[j][i]);
   sum=0;
   for (i=0;i<d;i++) {
      scanf("%d",&t);
      sum+=s[i][t-1];
      last[t-1]=i;
      for (j=0;j<26;j++)
         sum-=c[j]*(i-last[j]);
      printf("%ld\n",sum);
   }
   return 0;
}


Measured memory_bytes: 1764
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <string>
#include <utility>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstring>
#include <complex>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
  vector<complex<double>> v(1001);
  v[0].real(1.0);
  v[0].imag(0.0);
  REP(i,1,1000){
    v[i].real(v[i-1].real()-v[i-1].imag()/abs(v[i-1]));
    v[i].imag(v[i-1].imag()+v[i-1].real()/abs(v[i-1]));
  }
  int n;
  while(cin>>n,n!=-1){
    n--;
    cout<<v[n].real()<<endl<<v[n].imag()<<endl;
  }
}



Measured memory_bytes: 3304
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long
#define inf 999999999999
#define mx 200005
#define gcd __gcd
#define pb push_back
#define mk make_pair
#define bs binary_search
#define ub upper_bound
#define lb lower_bound
#define endl "\n"
#define vl vector<ll>
#define vs vector<string>
using namespace std;

bool isp[mx];

void sv(){

	ll i,j;
	memset(isp, true, sizeof(isp));
	
	isp[1]= false;
	for(i=2;i*i<mx;i++){
		if(isp[i]){
			for(j=i*i;j<mx;j+=i)
			isp[j]= false;
		}
	}
}

ll powr(ll a,ll b)
{
	ll res=1;
	while(b)
	{
		if(b&1)res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	//sv();
    
    ll n,m,i,j,x,y,ans=1;
    cin>>n>>m>>x>>y;
    m--;
    while(m--){
        cin>>i>>j;
        x= max(x,i);
        y= min(y,j);
        if(y<x)
        {
            ans=0;
            break;
        }
    }
    if(ans)
    ans=y-x+1;
    cout<<ans;
    return 0;
}























Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <math.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using pint = pair<int,int>;
using vec = vector<int>;
using ll=long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main() {
  int n;
  cin>>n;
  vector<int> a(n+1);
  rep1(i,n) cin>>a[i];
  vector<int> l(n+1), r(n+1);
  rep1(i,n-1) l[i+1] = __gcd(l[i], a[i]);
  for (int i = n; i >= 2; --i) r[i-1] = __gcd(r[i], a[i]);
  int ans = 1;
  rep1(i,n) ans = max(ans, __gcd(l[i],r[i]));
  cout<<ans<<endl;
  return 0;
}

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

#define ll long long
#define ld long double

#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
#define repA(i,A)   for(auto i:A)

#define err() cout<<"=================================="<<endl;
#define errA(A) for(auto i:A)   cout<<i<<" ";cout<<endl;
#define err1(a) cout<<#a<<" "<<a<<endl
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl
#define err4(a,b,c,d) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<" "<<#d<<" "<<d<<endl

#define mp make_pair
#define pb push_back
#define all(A)  A.begin(),A.end()
#define allr(A)	A.rbegin(),A.rend()
#define ft first
#define sd second

#define pll pair<ll,ll>
#define V vector<ll>
#define S set<ll>
#define VV vector<V> 
#define Vpll vector<pll>

#define endl "\n"

const ll logN = 20;
const ll M = 1000000007;
const ll INF = 1e12;
#define PI 3.14159265

const ll N = 100005;

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
 	ll n,k;
 	string s;
 	cin>>n>>k>>s;
 	ll ans=0;
 	rep(i,0,n){
 		if(s[i]=='L'){
 			if(i>0 and s[i-1]=='L')	ans++;
 		}	
 		else{
 			if(i<n and s[i+1]=='R')	ans++;
 		}
 	}
 	rep(i,0,k){
 		ans = min(n-1, ans+2);
 	}
 	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
int main()
{
int a,b,c;
scanf("%d %d %d",&a,&b,&c);
if(a!=b&&a!=c)
printf("%d\n",a);
else if(b!=a&&b!=c)
printf("%d\n",b);

else
    printf("%d\n",c);

}



Measured memory_bytes: 128
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N; cin>>N;
    int ans=0;
    int sum=0;
    map<int,int> cnt;
    cnt[sum]++;
    REP(i,N){
        int a; cin>>a;
        sum+=a;
        ans+=cnt[sum];
        cnt[sum]++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 12800
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ff first
#define ss second
#define quick                    \
    ios::sync_with_stdio(false); \
    cin.tie(0);
#define time cerr << (0.1 * clock()) / CLOCKS_PER_SEC << endl;
#define mod 1000000007
typedef long long ll;
typedef pair<ll, ll> pl;
#define forn(n) for (ll i = 0; i < ll(n); i++)

void solve() {
    ll n, k;
    cin >> n >> k;
    vector<ll> v(n);
    forn(n) {
        cin >> v[i];
    }
    sort(v.begin(), v.end());
    ll sum = 0;
    forn(k) {
        sum += v[i];
    }
    cout << sum << '\n';
}

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

Measured memory_bytes: 3640
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(a){return a?cin[cid++]:+cin[cid++];}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var myOut = main();
if(myOut !== undefined)console.log(myOut);

function main(){
  var h = next(), w = next(), k = next();
  var s = nexts(h,1);
  var ans = 1e9;
  for(var i = 0; i < 1 << h-1; i++){
    var c = 0, j = i, x = 1, ary = [0];
    while(j){
      if(j & 1)c++, ary.push(x);
      j >>= 1;
      x++;
    }
    var map = xArray(0, ary.length);
    for(var x = 0; x < w && c < ans; x++){
      var id = ary.length-1;
      for(var y = h; y--;){
        if(y < ary[id])id--;
        if(s[y][x] === "1")map[id]++;
      }
      if(Math.max(...map) > k){
        c++;
        map = xArray(0,ary.length);
        id = ary.length-1;
        for(var y = h; y--;){
          if(y < ary[id])id--;
          if(s[y][x] === "1")map[id]++;
        }
      }
      if(Math.max(...map) > k)c = ans;
    }
    if(c < ans)ans = c;
  }
  return ans;
}

Measured memory_bytes: 10436
n,k=[int(input()) for _ in range(2)]
x=list(map(int,input().split()))
ans=0
for i in range(n):
    x_i=x[i]
    if x_i*2<=k:
        ans+=x_i*2
    else:
        ans+=(k-x_i)*2
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k,sum=0,a,b;
  cin>>n>>k;
  int x;
  for(int i=0;i<n;i++){
    cin>>x;
    a=k-x;
    if(a<0)a*=-1;
    if(x>a)sum+=a*2;
    else sum+=x*2;
  }
  cout<<sum<<endl;
  return(0);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i,n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<"\n"
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define mp make_pair
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using vc = vector<char>;
using vvc = vector<vc>;
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; 
}
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll n,x;
  cin>>n>>x;
  if(x==1||x==2*n-1){
    COUT("No");
  }
  else if(n==2){
    COUT("Yes");
    COUT(1);
    COUT(2);
    COUT(3);
  }
  else{
    vll a(4);
    set<ll> s;
    rep(i,2*n-1){
        s.insert(i+1);
    }
    a[1]=x;
    if(x==2){
      a[0]=3;
      a[2]=1;
      a[3]=4;
      
    }
    else if(x==2*n-2){
      a[2]=2*n-1;
      a[0]=2*n-3;
      a[3]=2*n-4;
    }
    else{
      a[0]=x-1;
      a[2]=x+1;
      a[3]=x-2;
    }
    rep(i,sz(a)){
      s.erase(a[i]);
    }
    
    COUT("Yes");
    rep(i,(2*n-1)/2-1){
      COUT(*begin(s));
      ll h=*begin(s);
      s.erase(h);
    }
    rep(i,4){
      COUT(a[i]);
    }
    for(auto p:s){
      COUT(p);
    }
  }
}

Measured memory_bytes: 12964