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

using namespace std;
using ll =long long;

#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cout << #x << " = " << (x) << 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; }
bool coY() {cout <<"Yes"<<endl;}
bool coN(){cout <<"No"<<endl;}

const ll INF = 1LL << 60;

ll n,m;
string s;
//Write From this Line

const int mod = 1e9+7;
int main()
{
	cin >> n >> m ; // HP is  m ;
	priority_queue<pair<int,int>> q;
	rep(i,n){
		int a, b;
		cin >> a >> b;
		q.push(make_pair(a,5));
		q.push(make_pair(b,1));
	}
	int ans= 0 ;
	while(1){
		auto p = q.top();
		if(p.second == 1){
			ans += 1;
			m -= p.first ;
			q.pop();
		}else{
			int num =( m + (p.first - 1) ) / p.first ; 
			ans += num ; 
			m -= num * p.first ;
		}
		if( m <= 0 ) break;
	}
	cout << ans << endl;
}


Measured memory_bytes: 2420
S=input()
S=[i for i in S]
if (int(S[0]+S[1])>12 or int(S[0]+S[1])==0) and 0<int(S[2]+S[3])<13:
    print("YYMM")
elif (int(S[2]+S[3])>12 or int(S[2]+S[3])==0) and 0<int(S[0]+S[1])<13:
    print("MMYY")
elif 0<int(S[2]+S[3])<13 and 0<int(S[0]+S[1])<13:
    print("AMBIGUOUS")
else:
    print("NA")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
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;
}
void hr() {
   cerr << "--------------" << endl;
}
const int INF = 1001001001;
const int MOD = 1000000007;

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

   ll x;
   cin >> x;
   ll money = 100;
   int ans = 0;
   while (money < x) {
      money *= 1.01;
      ans++;
   }
   cout << ans << endl;
   return 0;
}

Measured memory_bytes: 3648
using System;
using System.Collections.Generic;
namespace _093b
{
    class Program
    {
        static void Main(string[] args)
        {
            long[] read = Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            long count = 1;
            long start_num = read[0];
            HashSet<long> hsTable = new HashSet<long>();
            while(count<=read[2]){
                // Console.WriteLine(start_num);
                hsTable.Add(start_num);
                start_num++;//2,3,4,5,6,7,8,9
                count++;
                if(start_num>read[1]){
                    break;
                }
            }
            if(read[1]-read[0]<read[2]){
                start_num = read[0];
            }else{
                start_num = read[1] - read[2] + 1;
            }
            count = 1;
            while(count<=read[2]){
                // Console.WriteLine(start_num);
                hsTable.Add(start_num);
                start_num++;
                count++;
                if(start_num>read[1]){
                    break;
                }
            }
            foreach(var num in hsTable){
                Console.WriteLine(num);
            }
        }
    }
}

Measured memory_bytes: 13280
#include<stdio.h>
#define MAX 1000
#define NIL -1

struct Node {int p, l, r;};
struct Node T[MAX];
int n;

void preParse(int u) {
  if(u == NIL) return;
  printf(" %d", u);
  preParse(T[u].l);
  preParse(T[u].r);
}


void inParse(int u) {
  if(u == NIL) return;
  inParse(T[u].l);
  printf(" %d", u);
  inParse(T[u].r);
}

void postParse(int u) {
  if(u == NIL) return;
  postParse(T[u].l);
  postParse(T[u].r);
  printf(" %d", u);
}

int main() {
  int i, v, l, r, root;

  scanf("%d", &n);
  for(i = 0; i < n; i++) {
    T[i].p = NIL;
  }

  for(i = 0; i < n; i++) {
    scanf("%d %d %d", &v, &l, &r);
    T[v].l = l;
    T[v].r = r;
    if(l != NIL) T[l].p = v;
    if(r != NIL) T[r].p = v;
  }

  for(i = 0; i < n; i++) {
    if(T[i].p == NIL) root = i;
  }

  printf("Preorder\n");
  preParse(root);
  printf("\n");
  printf("Inorder\n");
  inParse(root);
  printf("\n");
  printf("Postorder\n");
  postParse(root);
  printf("\n");

  return 0;

}



Measured memory_bytes: 2116
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }





int n, m;
map<string, int> ma;
int main() {
	while (cin >> n) {
		ma.clear();
		for (int i = 0; i < n; ++i) {
			string str;
			cin >> str;
			ma[str]++;
		}
		cin >> m;
		for (int i = 0; i < m; ++i) {
			string str;
			cin >> str;
			ma[str]--;
		}
		int res = 0;
		EACH(it, ma) chmax(res, it->second);
		cout << res << endl;
	}
}















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

using namespace std;


//repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define euc_dis(x, y) sqrt(x*x + y*y)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)

#define pb push_back
#define INF 999999999
#define MOD 1000000007
#define sp ' '


//typedef
typedef long long ll;
typedef pair<int, int> pint;
typedef pair<long, long> pll;
typedef map<int, int> mint;
typedef set<int> sint;
typedef vector<int> vint;
typedef vector<char> vchr;
typedef vector<long long> vll;
typedef vector<string> vstr;


ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll a, ll b, ll c){ll ans=1; rep(i, b){ans=ans*a%c;} return ans;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T>
void dpp(T n){cerr << n << endl;}
template<typename T>
void vpp(T a){rep(i,a.size()){cout << a[i] << endl;}}
template<typename T>
void vdp(T a){rep(i,a.size()){cerr << a[i] << endl;}}

const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int ddx[8] = {1,0,-1,0,1,-1,-1,1};
const int ddy[8] = {0,1,0,-1,1,1,-1,-1};

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    string s;
    cin >> s;
    rep(i, s.size()){
        if(s[i] == '1'){
            cout << '9';
        }
        else{
            cout << '1';
        }

    }

    cout << endl;



    return 0;
}


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

int main() {
	// your code goes here
	int n,i;
	double x[100005],y[100005],dx[100005],dy[100005],xmax=-1000000000,ymax=-1000000000,ymin=1000000000,xmin=1000000000;
	double uu=-1000000000,ud=1000000000,du=-1000000000,dd=1000000000,ll=1000000000,lr=-1000000000,rl=1000000000,rr=-1000000000;
	double um=-1000000000,dm=1000000000,lm=1000000000,rm=-1000000000,s=50000000000000000;
	char ddd;
	cin >> n;
	for(i=0;i<n;i++){
		cin >> x[i] >> y[i] >> ddd;
		if(ddd=='U'){
			lm=min(lm,x[i]);
			rm=max(rm,x[i]);
			uu=max(uu,y[i]);
			ud=min(ud,y[i]);
		}
		if(ddd=='D'){
			lm=min(lm,x[i]);
			rm=max(rm,x[i]);
			du=max(du,y[i]);
			dd=min(dd,y[i]);
		}
		if(ddd=='R'){
			dm=min(dm,y[i]);
			um=max(um,y[i]);
			rr=max(rr,x[i]);
			rl=min(rl,x[i]);
		}
		if(ddd=='L'){
			dm=min(dm,y[i]);
			um=max(um,y[i]);
			lr=max(lr,x[i]);
			ll=min(ll,x[i]);
		}
	}
	for(i=0;i<400000000;i++){
		double cur=0.5*i;
		xmin=min({lm,ll-cur,rl+cur});
		ymin=min({dm,dd-cur,ud+cur});
		xmax=max({rm,rr+cur,lr-cur});
		ymax=max({um,uu+cur,du-cur});
		s=min(s,(xmax-xmin)*(ymax-ymin));
	}
	cout << fixed << setprecision(12) << s << endl;
	return 0;
}


Measured memory_bytes: 1792
s = input()
n = len(s)

odd = 0
even = 0

for i in range(n):
    if i % 2 == 0:
        if s[i] == "1":
            odd += 1
        else:
            even += 1
    else:
        if s[i] == "0":
            odd += 1
        else:
            even += 1

ans = min(odd, even)

print(ans)

Measured memory_bytes: 3188
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    k,a,b = LI()
    s = b-a
    if s <= 2 or k - (a-1) < 2:
        return k+1
    t = a
    k -= a - 1
    if k % 2 == 1:
        k -= 1
        t += 1
    t += s * (k//2)

    return t



print(main())




Measured memory_bytes: 5460
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include <cassert>
#include <numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int,int> P;

int dp[1<<12+5][1005];

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> o(m,0);
    int a[m];
    rep(i,m){
        int b;
        cin >> a[i] >> b;
        rep(j,b){
            int c;
            cin >> c;
            o[i]+=1<<(c-1);
        }
    }
    rep(i,1<<n)rep(j,m+1){
        dp[i][j]=INF;
    }
    dp[0][0]=0;
    rep(i,1<<n){
        rep(j,m){
            chmin(dp[i][j+1],dp[i][j]);
            chmin(dp[i|o[j]][j+1],dp[i][j]+a[j]);
        }
    }
    if(dp[(1<<n)-1][m]==INF)cout << -1 << endl;
    else cout << dp[(1<<n)-1][m] << endl;

    //rep(i,4)rep(j,4)cout << dp[i][j] << endl;
}

Measured memory_bytes: 16768
#include<iostream>
#include<algorithm>
#include<string.h>
#include<cstring>
#include<stdio.h>
using namespace std;
const int maxn=2e5+10;
char c[maxn];
char list[maxn];
int tot,ans;
int main()
{
	char a;
    while(scanf("%c",&a)!=EOF){
    	c[tot++]=a;
	}
	ans=tot-1;
	
    int i=0;
    int head=0;
    while(i<tot-1){
         if(head==0){
         	head++;
         	list[head]=c[i];
         	i++;
		 }
		 else{
		     if(list[head]=='S'&&c[i]=='T'){
		     	ans-=2;
		     	head--;
		     	i++;
			 }
		 	 else{
		 	    head++;
				list[head]=c[i];
				i++; 	
			 }
		 }
	}
	cout<<ans<<endl;
	return 0;
} 

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

using namespace std;

int main(int argc, char const *argv[])
{
    int N;
    cin >> N;
    vector<int> a;
    int in;
    for (int i = 0; i < N; i++)
    {
        cin >> in;
        a.emplace_back(in);
    }

    int now = 0;
    int cnt = 0;
    for (int i = 0; i < N; i++)
    {
        if (now == 1)
        {
            cout << cnt << endl;
            return 0;
        }else
        {
            cnt += 1;
            now = a[now] - 1;
        }

    }
    
    cout << -1 << endl;
    
    return 0;
}

Measured memory_bytes: 892
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int main() {
    int a, b, k;
    cin >> a >> b >> k;
    for (int i = 0; i < k; ++i) {
        if(i%2 == 0){
            b += a/2;
            a /= 2;
        }else {
            a += b/2;
            b /= 2;
        }
    }
    cout << a << " " << b << "\n";
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Main{
	public static void main (String[] args) throws java.lang.Exception{
		Scanner scan = new Scanner(System.in);

		String a = scan.next();
		String b = scan.next();
		int an = Integer.parseInt(a);
		int bn = Integer.parseInt(b);
		int sq = an * bn;
		int arnd = 2 * (an + bn);
		System.out.println(sq + " " + arnd);
	}
}

Measured memory_bytes: 17120
#define _USE_MATH_DEFINES
#define INF 100000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>

using namespace std;

typedef long long ll;
typedef pair <int,int> P;

static const double EPS = 1e-8;


int tx[] = {-1,0,1,0};
int ty[] = {0,1,0,-1};

char buf[1000000];

int main(){
	int m,n;

	while(~scanf("%d",&n)){
		if(n==0) break;
		scanf("%d",&m);
		scanf("%s",buf);

		deque<char> que;
		int tmp = 0;
		int res = 0;
		int state = -1;
		for(int i=0;i<m;i++){
			que.push_back(buf[i]);
			
			if(que.size()==3){
				char f = que[0];
				char m = que[1];
				char r = que[2];
				
				if(f=='I' && m == 'O' && r == 'I'){
					tmp++;
					if(tmp>=n) res++;
					que.pop_front();
					que.pop_front();
				}
				else{
					tmp=0;
					que.pop_front();
				}
			}

		}
		printf("%d\n",res);
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <map>
#include <string>

int main()
{	
	std::map<std::string, long long int> M;
	
	int q; std::string sq;
	getline(std::cin, sq); q = std::stoi(sq);
	for (int i=0; i<q; i++) {
		std::string key;
		int op;
		long long int x;
		
		std::string buf;
		getline(std::cin, buf);
		op = buf[0] - '0';
		int sp_pos = buf.find(' ', 2);
		if (sp_pos != std::string::npos) {
			key = buf.substr(2, sp_pos-2);
			x = std::stoll(buf.substr(sp_pos+1));
		} else {
			key = buf.substr(2);
		}
		if (op==0) {
			M[key] = x;
		} else if (op == 1) {
			if (M.find(key) != M.end()) std::cout << M[key] << std::endl;
			else std::cout << 0 << std::endl;
		} else {
			M.erase(key);
		}
	}
	
	return 0;
}



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

int dp[41][401][401];

int main(){
	int n, ma, mb;
	cin >> n >> ma >> mb;
	int a[n], b[n], c[n];
	for(int i = 0; i < n; i++) cin >> a[i] >> b[i] >> c[i];
	for(int i = 0; i <= n; i++) for(int j = 0; j <= 400; j++) for(int k = 0; k <= 400; k++) dp[i][j][k] = 1e9;
	dp[0][0][0] = 0;
	for(int i = 0; i < n; i++){
		for(int j = 0; j <= 400; j++) for(int k = 0; k <= 400; k++){
			dp[i + 1][j][k] = min(dp[i + 1][j][k], dp[i][j][k]);
			if(j + a[i] > 400 || k + b[i] > 400) continue;
			dp[i + 1][j + a[i]][k + b[i]] = min(dp[i + 1][j + a[i]][k + b[i]], dp[i][j][k] + c[i]);
		}
	}
	int ans = 1e9;
	for(int i = 0; i <= 400; i++) for(int j = 0; j <= 400; j++){
		if(i == 0 && j == 0) continue;
		if(ma * j != mb * i) continue;
		ans = min(ans, dp[n][i][j]);
	}
	cout << (ans == 1e9 ? -1 : ans) << endl;
}

Measured memory_bytes: 25984
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <algorithm>
#include <random>
#include <chrono>
#include <iomanip>
#define lint unsigned long long int
#define FOR(x, to) for(int x=0; x<(int)(to); x++)
#define DUMP(ar) for(auto itd=begin(ar); itd != end(ar); itd++) cout << "["s << itd - begin(ar) << "]:"s << *itd << endl
#define DUMPL(ar) for(auto itd=begin(ar); itd != end(ar); itd++) { cout << *itd; if(end(ar)-itd > 1) cout << ' '; } cout << endl
#define COUT(x) cout << (x) << endl
#define VCIN(ar) for(auto &vcin: (ar)) cin >> vcin
#define ALL(ar) ar.begin(), ar.end()
#define LOOPD(i) cout << "ループ["s << i << "]回目---------------"s << endl
using namespace std;
// lint:64ビット 10^19

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

    int n;
    cin >> n;
    vector<int> a(n);
    VCIN(a);
    map<int, int> m;

    for(int i=0; i<n; i++){
        if(m[a[i]] == 1){
            COUT("NO");
            return 0;
        }else{
            m[a[i]] = 1;
        }
    }

    COUT("YES");

    return 0;
}

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

int main() {
    string str;
    cin >> str;
    string output;
    for (int i = 0; i < str.size(); i++){
        if (str.at(i) == '0'){
            output += "0";
        }
        else if (str.at(i) == '1'){
            output += "1";
        }
        else{
            if (output.size() != 0){
                output.erase(output.size() - 1);
            }
        }
    }

    cout << output << endl;    
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static program.Input;
using static program.MyMath;
using static System.Console;

namespace program {
  class Program {
    static string Alp = "abcdefghijklmnopqrstuvwxyz";
    static void Main()
    {
      int time = 0;
      var times = new List<int>();
      for(int i=0; i<5; i++){
        var x = ScanInt();
        times.Add(x);
      	time += ((x+9)/10)*10;
      }
      var a = times.Select(_=>_%10).Where(_=>_!=0).ToArray();
      if(a.Length != 0) time -= 10 - a.Min();
      WriteLine(time);
    }
  }
  static class Input {
    static public int ScanInt() { return int.Parse(Console.ReadLine()); }
    static public uint ScanUint() { return uint.Parse(Console.ReadLine()); }
    static public double ScanDouble() { return double.Parse(Console.ReadLine()); }
    static public long ScanLong() { return long.Parse(Console.ReadLine()); }
    static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); }
    static public int[] ScanIntArray() { return Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray(); }
    static public uint[] ScanUintArray() { return Console.ReadLine().Split().Select(x => uint.Parse(x)).ToArray(); }
    static public double[] ScanDoubleArray() { return Console.ReadLine().Split().Select(x => double.Parse(x)).ToArray(); }
    static public long[] ScanLongArray() { return Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray(); }
    static public ulong[] ScanUlongArray() { return Console.ReadLine().Split().Select(x => ulong.Parse(x)).ToArray(); }

    static public string ScanStr() { return Console.ReadLine(); }
    static public string[] ScanStrArray() { return ScanStr().Split(); }
  }
  
  static class MyMath {
    public static int GCD(int a, int b) {
        Func<int, int, int> gcd = null;
        gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
        return a > b ? gcd(a, b) : gcd(b, a);
    }
    public static long GCD(long a, long b) {
        Func<long, long, long> gcd = null;
        gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
        return a > b ? gcd(a, b) : gcd(b, a);
    }
    public static ulong extGCD(ulong a, ulong b, ref ulong x, ref ulong y) {
      if(b==0) {
        x=1; 
        y=0;
        return a;
      }
      var d = extGCD(b, a%b, ref y, ref x);
      y -= a/b *x;
      return d;
    }
    public static int LCM(int a, int b) { return a * b / GCD(a, b); }
    public static long LCM(long a, long b) { return a * b / GCD(a, b); }
  }
}


Measured memory_bytes: 13396
#include <algorithm> // sort
 #include <iostream>
using namespace std;
int N, K, p[1010];

int main(){
cin >> N >> K;
for(int i = 0; i < N; ++i) cin >> p[i];
sort(p, p + N);
int ans = 0;
for(int i = 0; i < K; ++i) ans += p[i];
cout << ans << endl;
}

Measured memory_bytes: 3600
import math
from itertools import accumulate

Q=int(input())
lr=[list(map(int,input().split())) for _ in range(Q)]

MAX=10**5
limit=int(math.sqrt(MAX))
primes=[2]
table=[i+1 for i in range(2,MAX,2)]
while limit>table[0]:
  primes.append(table[0])
  table=[j for j in table if j%table[0] != 0]
primes=set(primes+table)

similars=[0]*MAX
for i in range(2,MAX):
  if i in primes and (i+1)//2 in primes:
    similars[i]=1

similars=list(accumulate(similars))

for i in lr:
  l=i[0]
  r=i[1]
  print(similars[r]-similars[l-1])

Measured memory_bytes: 32036
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*
cout<<fixed<<setprecision(20);
cin.tie(0);
ios::sync_with_stdio(false);
*/
const llint mod=1000000007;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	string s;cin>>s;
	int i,n=s.size();
	if(s[n-1]=='1'){cout<<"-1\n";return 0;}
	if(s[0]=='0'){cout<<"-1\n";return 0;}
	for(i=0;i<n/2;i++){
		if(s[i]!=s[n-2-i]){cout<<"-1\n";return 0;}
	}
	int mae=1;
	for(i=0;i<n-1;i++){
		cout<<mae<<" "<<i+2<<endl;
		if(s[i]=='1'){mae=i+2;}
	}
	return 0;
}

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

using namespace std;

int main()
{
    while (1)
    {
        string s;
        int m, t;
        cin>>s;
        if (s=="-") break;
        cin>>m;
        for (int i=0; i<m; i++)
        {
            cin>>t;
            s=s.substr(t, s.size()-t)+s.substr(0, t);
        }
        cout<<s<<'\n';
    }
    return 0;
}



Measured memory_bytes: 3184
import java.util.*;

public class Main {


    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        int[] b = new int[n];
        for(int i=0; i<n; i++) {
            a[i] = sc.nextInt();
            b[i] = a[i];
        }
        int gcd = a[0];
        for(int i=1; i<n; i++) {
            gcd = gcd(gcd, a[i]);
        }
        boolean setwise = gcd == 1;

        if(!setwise) {
            System.out.println("not coprime");
            return;
        }

        boolean[] isnp = new boolean[1001];
        for(int i=2; i<=100; i++) {
            if(isnp[i]) continue;
            for(int j=2; i*j<=1000; j++) {
                isnp[i*j] = true;
            }
        }
        boolean[] used = new boolean[1000001];

        boolean pc = true;
        Set<Integer> p1000 = new HashSet<>();
        for(int i=2; i<=1000; i++) {
            if(!isnp[i]) {
                p1000.add(i);
            }
        }
        for(int i=0; i<n; i++) {
            if(a[i] == 1) continue;
            if(used[a[i]]) {
                pc = false;
                break;
            }
            Set<Integer> rem = new HashSet<>();
            for(int div : p1000) {
                if(a[i] % div == 0) {
                    rem.add(div);
                    while(b[i] % div == 0) {
                        b[i]/=div;
                    }
                }
            }
            for(int div : rem) {
                for(int j = 1; j*div<=1000000; j++) {
                    used[j*div] = true;
                }
                p1000.remove(div);
            }
            if(b[i]>1000 && used[b[i]]) {
                pc = false;
                break;
            }
            used[b[i]] = true;
        }

        if(pc) {
            System.out.println("pairwise coprime");
        } else {
            System.out.println("setwise coprime");

        }


    }
    static int gcd(int m, int n) {
        if(m < n) return gcd(n, m);
        if(n == 0) return m;
        return gcd(n, m % n);
    }

}

Measured memory_bytes: 67184
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

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

		while (true) {
			final int R = sc.nextInt();
			final int C = sc.nextInt();
			
			if(R == 0 && C == 0){
				break;
			}
			
			final int LIM = 1 << R;
			
			boolean[][] map = new boolean[R][C];
			for(int i = 0; i < R; i++){
				for(int j = 0; j < C; j++){
					map[i][j] = sc.nextInt() == 0;
				}
			}
			
			int[] col_sum = new int[C];
			for(int col = 0; col < C; col++){
				for(int row = 0; row < R; row++){
					col_sum[col] += map[row][col] ? 1 : 0;
				}
			}
			
			int max = 0;
			for(int comb = 0; comb < LIM; comb++){
				for(int row = 0; row < R; row++){
					if((comb & (1 << row)) == 0){
						continue;
					}
					
					for(int col = 0; col < C; col++){
						col_sum[col] += map[row][col] ? -1 : 1;
					}
				}
				
				int sum = 0;
				for(int col = 0; col < C; col++){
					sum += Math.max(R - col_sum[col], col_sum[col]);
				}
				
				max = Math.max(max, sum);
				
				for(int row = 0; row < R; row++){
					if((comb & (1 << row)) == 0){
						continue;
					}
					
					for(int col = 0; col < C; col++){
						col_sum[col] += map[row][col] ? 1 : -1;
					}
				}
			}
			
			System.out.println(max);
		}
	}

}

Measured memory_bytes: 75484
a,b,m = map(int,input().split())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
ans = min(a)+min(b)
for _ in range(m):
    x,y,c = map(int,input().split())
    x -= 1
    y -= 1
    ans = min(a[x]+b[y]-c,ans)
print(ans)

Measured memory_bytes: 18488
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;

struct point {
  ld x;
  ld y;
  point(ld x, ld y): x(x), y(y) {}
  point operator+(const point& rhs) const {
    return point(x+rhs.x, y+rhs.y);
  }
  point operator-(const point& rhs) const {
    return point(x-rhs.x, y-rhs.y);
  }
  point operator*(const ld& d) const {
    return point(x*d, y*d);
  }
  point operator/(const ld& d) const {
    assert(d != 0);
    return point(x/d, y/d);
  }
};
ld calc_dist(point p1, point p2) {
  ld dx = p1.x - p2.x;
  ld dy = p1.y - p2.y;
  return sqrt(dx*dx+dy*dy);
}

int N;
vector<point> P;
vector<point> intersection(point p1, point p2, ld r) {
  point mid = (p1+p2)/2.0; // center
  ld dist = calc_dist(p1, p2); // distance
  point diff = point(p1.y-p2.y, -(p1.x-p2.x))/dist; // slope
  vector<point> ret; // intersection
  if(dist > r*2+eps) {
  } else {
    ld h = sqrt(r*r-(dist/2)*(dist/2));
    ret.push_back(mid+diff*h);
    ret.push_back(mid-diff*h);
  }
  return ret;
}

bool testeach(int i, int j, ld k) {
  auto intr = intersection(P[i], P[j], k);
  if(intr.size() != 0) {
    for(auto i: intr) {
      bool ret = true;
      rep(j, N) {
        if(calc_dist(i, P[j]) > k+eps) {
          ret = false;
          break;
        }
      }
      if(!ret) continue;
      return true;
    }
  }
  return false;
}
bool test(ld k) {
  bool ret = false;
  rep(i, N) REP(j, i+1, N) ret |= testeach(i, j, k);
  return ret;
}

ld binary_search() {
  ld ng = 0, ok = 2000;
  rep(i, 50) {
    ld mid = (ok + ng) / 2;
    if(test(mid)) ok = mid;
    else ng = mid;
  }
  return ok;
}

int main() {
  cin >> N;
  P = vector<point>();
  rep(i, N) {
    int x, y;
    cin >> x >> y;
    P.push_back(point(x, y));
  }
  cout << fixed << setprecision(10) << binary_search() << endl;
  return 0;
}


Measured memory_bytes: 3852
#include<bits/stdc++.h>
using namespace std;
#define rep1(i,n) for(int i = 0; i < 3*n; i++)
#define rep2(i,n) for(int i = n; i < 3 * n; i+=2)

int main(void){
  int n;
  cin >> n;
  vector<int> data(3*n);
  rep1(i,n) {
    cin >> data.at(i);
  }

  sort(data.begin(),data.end());
  long long ans = 0;
  rep2(i,n) {
    ans +=data.at(i);
  }
  cout << ans << endl;
  return 0;
}



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

template<typename T1, typename T2>
ostream& operator<< (ostream& os, const pair<T1, T2>& p) {
	return os << "<" << p.first << "," << p.second << ">";
}
#define container_ostream(container)                            \
template<typename... T>                                         \
ostream& operator<< (ostream& os, const container<T...>& c) {   \
	if (c.empty()) return os << "{ }";                          \
	auto ite = c.begin();                                       \
	os << "{ " << *ite;                                         \
	while (++ite != c.end()) os << ", " << *ite;                \
	return os << " }";                                          \
}
container_ostream(vector)
container_ostream(deque)
container_ostream(list)
container_ostream(set)
container_ostream(map)
container_ostream(multiset)
container_ostream(multimap)

void dbg() { cerr << endl; }
template<typename Head, typename... Tail> void dbg(Head h, Tail... t) {
	cerr << " " << h;
	dbg(t...);
}
#ifdef LOCAL
#define debug(...) cerr << "[ "#__VA_ARGS__" ] :", dbg(__VA_ARGS__)
#else
#define debug(...) 0
#endif

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int N;
	cin >> N;
	vector<vector<int>> A(N + 1, vector<int>(N - 1));
	for (int i = 1; i <= N; ++i) {
		for (int& a : A[i]) cin >> a;
		reverse(A[i].begin(), A[i].end());
		debug(i, A[i]);
	}
	vector<int> prev(N), next;
	iota(prev.begin(), prev.end(), 1);
	int res = -1;
	while (!prev.empty()) {
		next.clear();
		for (int i : prev) if (!A[i].empty() && A[A[i].back()].back() == i) {
			debug("pop", i, A[i].back());
			next.push_back(i);
			next.push_back(A[i].back());
		}
		sort(next.begin(), next.end());
		next.resize(unique(next.begin(), next.end()) - next.begin());
		prev = move(next);
		for (int i : prev) A[i].pop_back();
		++res;
	}
	for (int i = 1; i <= N; ++i) if (!A[i].empty()) return cout << -1 << endl, 0;
	cout << res << endl;
}


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

int main(void) {
    int N, sum = 0, tmp;
    vector<int> nums;

    cin >> N;

    for (int i = 0; i < N; i++) {
        cin >> tmp;
        nums.push_back(tmp);
        sum += tmp;
    }

    if (sum % N == 0) {
        int mid = sum / N;
        int result = 0;
        for (int i = 0; i < N; i++) {
            result += (nums[i] - mid) * (nums[i] - mid);
        }
        cout << result << endl;
    } else {
        int mid1 = sum / N;
        int mid2 = sum / N + 1;
        int result1 = 0;
        int result2 = 0;

        for (int i = 0; i < N; i++) {
            result1 += (nums[i] - mid1) * (nums[i] - mid1);
            result2 += (nums[i] - mid2) * (nums[i] - mid2);
        }
        cout << min(result1, result2) << endl;
    }

    return 0;
}


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

int main(){
	ll i,o,t,j,l,s,z;
	cin>>i>>o>>t>>j>>l>>s>>z;
	ll v=(i/2)*4+(j/2)*4+(l/2)*4+o*2;
	if (1&i&j&l){
		v+=6ll;
	}
	else if(i>1&&j%2==1&&l%2==1){
		v+=2ll;
	}
	else if(j>1&&i%2==1&&l%2==1){
		v+=2ll;
	}
	else if(l>1&&i%2==1&&j%2==1){
		v+=2ll;
	}
	cout<<v/2<<endl;
}

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

static const long long INFTY = (1LL << 32);

void WarshallFloyd(long long weight[][100], int verNum) {

	//k????¢??????????????????????????????°????¢??????????????????????????±???????
	//???????????????????¨???????
	for (int k = 0; k < verNum; k++)
		for (int i = 0; i < verNum; i++) {
			//?????????????????£?????????????????§??´??°???????????????????????????
			if (weight[i][k] == INFTY) continue;
			for (int j = 0; j < verNum; j++) {
				if (weight[k][j] == INFTY) continue;
				weight[i][j] = min(weight[i][j], weight[i][k] + weight[k][j]);
			}
		}
}

int main() {

	long long weight[100][100];
	int verNum;
	int edgeNum;
	cin >> verNum >> edgeNum;

	//Initialize
	for (int i = 0; i < verNum; i++)
		for (int j = 0; j < verNum; j++)
			weight[i][j] = (i == j) ? 0 : INFTY;

	for (int i = 0; i < edgeNum; i++) {
		int first_ver, second_ver, wei;
		cin >> first_ver >> second_ver >> wei;
		weight[first_ver][second_ver] = wei;
	}

	WarshallFloyd(weight, verNum);

	//?????¨???
	bool negative = false;
	for (int i = 0; i < verNum; i++)
		if (weight[i][i] < 0) negative = true;

	if (negative)
		cout << "NEGATIVE CYCLE" << endl;
	else {
		for (int i = 0; i < verNum; i++) {
			for (int j = 0; j < verNum; j++) {
				if (j) cout << " ";

				string verVal;
				if (weight[i][j] == INFTY) verVal = "INF";
				else                                  verVal = to_string(weight[i][j]);

				cout << verVal;
			}
			cout << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 3312
import math
a,b,h,m = list(map(int,input().split()))
long = (h*60+m)/(12*60) * 360 * math.pi/180
short = m/60 * 360 * math.pi/180
h_x = math.cos(long) * a
h_y = math.sin(long) * a
m_x = math.cos(short) * b
m_y = math.sin(short) * b

print(math.sqrt((h_x-m_x)*(h_x-m_x)+(h_y-m_y)*(h_y-m_y)))

Measured memory_bytes: 9524
/*
     Author:Raghav Bansal
     IIIT Una
                  */
#include <bits/stdc++.h>
#define int long long int
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define BOLT ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define X first
#define Y second
#define endl "\n"
using namespace std;
vector<int> a;
void dfs(int n, int t) {
	if (n == 10) {
		a.push_back(t);
		return;
	}
	int x = t % 10;
	if (x > 0) dfs(n + 1, t * 10 + x - 1);
	if (x < 9) dfs(n + 1, t * 10 + x + 1);
	dfs(n + 1, t * 10 + x);
	a.push_back(t);
}
void solve() {
	int k;
	cin >> k;
	for (int i = 1; i < 10; ++i) {
		dfs(1, i);
	}
	sort(all(a));
	cout << a[k - 1] << endl;
}
int32_t main() {
	int t;
	t = 1;
	int cnt = 1;
	while (t--)
	{
		solve();
	}
}


Measured memory_bytes: 2420
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		if(n==1) {
			System.out.println("Hello World");
		}else if(n==2) {
			int a = in.nextInt();
			int b = in.nextInt();
			System.out.println(a+b);
		}

	}

}


Measured memory_bytes: 23764
#include<stdio.h>
#define N 10000
#define MAX 100000000
int main(){
  int i,j,n,k,c=0,u,data[500000][3],A[N],flag[N];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    A[i]=MAX;
    scanf("%d%d",&u,&k);
    for(j=0;j<k;j++){
      data[c][0]=u;
      scanf("%d%d",&data[c][1],&data[c][2]);
      c++;
    }
  }
  A[0]=0;
  flag[u]=2;
  while(flag[u]!=0){
    flag[u]=0;
    for(i=0;i<c;i++){
      if(A[data[i][1]]>A[data[i][0]]+data[i][2]){
        A[data[i][1]]=A[data[i][0]]+data[i][2];
        flag[u]=2;
      }
    }
  }
  for(i=0;i<n;i++)printf("%d %d\n",i,A[i]);
  return 0;
}


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


void solve(){
  int n,m,x,count=0;
  scanf("%d",&n);
  char s[50];
  scanf("%s",s);

  for(int i=0;i<n-2;i++){
    //printf("%c",s[i]);
    if(s[i]=='A'){
      if(s[i+1]=='B' && s[i+2]=='C')count++;
    }
  }



 printf("%d\n",count);
}
int main(){
  /*
  int q;
  scanf("%d",&q);
  while(--q)solve();
  */
  solve();

  return 0;
}

Measured memory_bytes: 3796
#整数 Nが与えられます。N以下の正の整数のうち、(先頭に 0をつけずに十進法で表記したときの) 桁数が奇数であるようなものの個数を求めてください。

n=str(input())
m=len(n)
n=int(n)
#m桁の場合
if m%2==1:
  cnt=n-10**(m-1)+1
else:
  cnt=0

#１桁からm-1桁までの場合
for i in range(0, m):
  if i%2==1:
    cnt+=10**i-10**(i-1)
print(cnt)
    

Measured memory_bytes: 38384
tmp = '#.' * 151

def draw(H, W):
    odd = tmp[:W]
    even = tmp[1:W + 1]
    print((odd + '\n' + even + '\n') * (H // 2) + (odd  + '\n' if H % 2 else ''))
    
while True:
    H, W = map(int, input().split())
    if H == W == 0:
        break
    draw(H, W)

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int x,t; cin>>x>>t;
	if (x>t) cout<<(x-t);
	else cout<<"0"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
const int maxn =2e5+10;
const int mod=1e9+7;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n;
	cin>>n;
	int cnt=0;
	map<ll,int>mp;
	for(ll i=2;i*i<=n;i++)
    {
        if(n%i==0)
        {
            ll x=1;
            while(n%i==0)
            {
                x*=i;
                if(mp[x]==0)
                {
                    cnt++;
                    mp[x]=1;
                    x=1;
                }
                n/=i;
            }
        }
    }
    if(n>1)
        cnt++;
    cout<<cnt<<'\n';


}



Measured memory_bytes: 3656
#include<bits/stdc++.h>
#include<vector>
#define REP(i,n) for(int i=0;i<n;i++)
#define V vector
#define VI vector<int>
#define VVI vector<vector<int>>
#define M 1000000007

using namespace std;

int main(void){
   int N,Q,cnt=0;
   cin>>N;
   VI a(N),b(N);
   REP(i,N){
       cin>>a[i];
       b[i]=a[i];
   }
   sort(b.begin(),b.end());
   REP(i,N)if(a[i]==b[i])cnt++;
   if(cnt==N){
       cout<<'0'<<endl;
       return 0;
   }
   cin>>Q;

   REP(i,Q){
       int x,y;
       cin>>x>>y;
       x--;
       y--;

       if(a[x]==b[x])cnt--;
       if(a[y]==b[y])cnt--;

       swap(a[x],a[y]);
       if(a[x]==b[x])cnt++;
       if(a[y]==b[y])cnt++;

       if(cnt==N){
       cout<<i+1<<endl;
       return 0;
   }
   }
   
   cout<<"-1"<<endl;
   return 0;

}



Measured memory_bytes: 5204
//AUTHOR : TIRTH JARSANIA
//COLLEGE : DAIICT

#include<bits/stdc++.h>
using namespace std;

#define INF LONG_LONG_MAX
#define MINF LONG_LONG_MIN
#define bp __builtin_popcountll
#define ll long long int
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define pii pair<ll,ll>
#define precision(x,d) cout<<fixed<<setprecision(d)<<x
#define minQueue priority_queue<pii,vector<pii>,greater<pii> > 
#define maxQueue priority_queue<pii> 
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL))

int main()
{
    FAST;
    string s,t;
    cin >> s >> t;
    ll ans = 0;
    if( s[0] == t[0] ) ans++;
    if( s[1] == t[1] ) ans++;
    if( s[2] == t[2] ) ans++;
    cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define st first
#define nd second

using namespace std;

void debug_out() { cerr << endl; }
template<class T> ostream& prnt(ostream& out, T v) { out << v.size() << '\n'; for(auto e : v) out << e << ' '; return out;}
template<class T> ostream& operator<<(ostream& out, vector <T> v) { return prnt(out, v); }
template<class T> ostream& operator<<(ostream& out, set <T> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, map <T1, T2> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, pair<T1, T2> p) { return out << '(' << p.st << ' ' << p.nd << ')'; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}

#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(int _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"

// const int N = ;
long long n;

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

	cin >> n;
	cout << (n - 1) * n / 2;	
}	


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
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; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define req(i,n) for(long long i=n-1; i>=0; i--)
#define range(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define onBoard(y,x) (y>=0 && y<h && x>=0 && x<w)
#define vint vector<int>
#define pri_que priority_queue
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vvchar vector<vector<char>>
#define vchar vector<char>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define show(x) cout<<#x<<"="<<x<<endl;
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a/gcd(a,b)*b;}
const long long dx[8]={1,0,-1,0,1,-1,-1,1};
const long long dy[8]={0,1,0,-1,1,1,-1,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int n,d; cin >> n >> d;
    vp pos(n);
    rep(i,n)cin >> pos[i].F>>pos[i].S;
    int res=0;
    rep(i,n){
        ld dist=0.0;
        dist=sqrt(pos[i].F*pos[i].F+pos[i].S*pos[i].S);
        if(dist<=d)res++;
    }
    cout<<res<<endl;
}

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

int main() {
double n,m,sum;
int ans = 0;
cin>>n>>m;
vector<double> a(n);
rep(i,n)
{int ai;
  cin >> ai;
  sum += ai;
  a[i]=ai;
}
sum=sum/(4*m);
rep(i,n)if(a[i]>=sum)ans++;
if(ans>=m)cout<<"Yes"<<endl;
else cout<<"No"<<endl;

return 0;
}
/*vector <ll> a(3);
for (ll i = 0; i < n; i++) {
    cin >> a.at(i);
  }*/

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

ll Euclid(ll A, ll B){
    if(A<B) swap(A, B);
    ll C = B;
    while(C != 0){
        C = A%B;
        A = B;
        B = C;
    }
    return A;
}

int main(){
	ll N;
	cin >> N;
	vector<ll> A(N);
	REP(i, N) cin >> A[i];

	ll tmp = A[0];
	REP(i, N-1){
		tmp = Euclid(tmp, A[i+1]);
	}
	cout << tmp << endl;
    return 0;
}

Measured memory_bytes: 1024
def main():
    n = int(input())
    a_list = list(map(int, input().split()))
    cnt = 0

    for i in range(n - 1):
        if a_list[i] == a_list[i + 1]:
            a_list[i + 1] = -1
            cnt += 1

    print(cnt)


if __name__ == "__main__":
    main()


Measured memory_bytes: 61928
time = 1

class Vertex:
	def __init__(self, u, k):
		self.u = u
		self.vertices = [0] * k
		self.d = self.f = 0
	def __str__(self):
		return str(self.u) + ' ' + str(self.d) + ' ' + str(self.f)

def DFS(n, vertices):
	for i in range(n):
		if vertices[i].d == 0:
			DFS_(vertices, vertices[i].u)
			
def DFS_(vertitces, u):
	vertex = vertices[u-1]
	if vertex.d == 0:
		global time
		vertex.d = time
		time += 1
		for i in range(len(vertex.vertices)):
			DFS_(vertices, vertex.vertices[i])
		vertex.f = time
		time += 1
	
n = int(input())
vertices = []
for i in range(n):
	v = list(map(int, input().split()))
	u = v[0]
	k = v[1]
	vertex = Vertex(u, k)
	for j in range(k):
		vertex.vertices[j] = v[j+2]
	vertices.append(vertex)

DFS(n, vertices)
for i in range(n):
	print(str(vertices[i]))



Measured memory_bytes: 5632
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include<iomanip>
#include<sstream>
#define debug(x) cerr << #x << ‘:’ << x << endl
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
using namespace std;
typedef long long ll;

struct info{
   int ci;
   int pref;
   int year;
   string id;
   info(int i, int p, int y){
       ci = i;
       pref = p;
       year = y;
   }
};

bool comp1(const info &a, const info &b){
   if(a.pref==b.pref){
       return a.year < b.year;
   } else
       return a.pref < b.pref;
}

bool comp2(const info &a, const info &b){
   return a.ci < b.ci;
}

int main(){
   int n,m;
   cin >> n >> m;
   vector<info> A;
   REP(i,m){
       int p, y;
       cin >> p >> y;
       string s;
       A.push_back(info(i, p, y));
   }
   sort(ALL(A), comp1);
   int order=0;
   int past=-1;
   for(int i=0; i<m; i++){
       stringstream ss;
       if(A[i].pref==past)
           order+=1;
       else
           order = 1;

       ss << setfill('0') << setw(6);
       ss << A[i].pref << setfill('0') << setw(6) << order;
       ss >> A[i].id;
       past = A[i].pref;
   }
   sort(ALL(A), comp2);

   for(auto x : A)
       cout << x.id<< endl;
   return 0;
}

Measured memory_bytes: 7408
#include<iostream>
#include<stdio.h>
#include<vector>
#include<cmath>
#include<queue>
#include<string.h>
#include<map>
#include<algorithm>
#define ll long long
#define rep(i,a,b) for(int i = a;i < b;i++)
#define N 100004
#define INF 1e9+7

using namespace std;

ll a[3],ans = INF;

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

    cin >> a[0] >> a[1] >> a[2];

    rep(i,0,3)
    {
        ans =  min(ans,abs(a[(i+1)%3] - a[i]) + abs(a[(i+2)%3] - a[i]));
    }

    cout << ans;

    return 0;
}



Measured memory_bytes: 256