akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define N 100000

int head=0,tail=0;
int Qi[N];
char Qc[N][10];

void enq(char *s,int x){
  int i=0;
  if(isFull()){
    fprintf(stderr,"over flow\n");
    exit(1);
  }
  Qi[tail] = x;
  /*
  while(i<10&&s[i]!=NULL){
    printf("%s\n",s);
    Qc[tail][i]=s[i];
    i++;
  }*/
  strcpy(Qc[tail],s);
  
  if(tail+1 == N){
    tail = 0;
  }else{
    
    tail++;
  }
}

int deq(){
  int x;
  if(isEmpty()){
    fprintf(stderr,"empty\n");
    exit(2);
  }
  x = head;
  if(head + 1 == N){
    head = 0;
  }else{
    head++;
  }
  return x;
}

int isEmpty(){
  return head == tail;
}

int isFull(){
  return head == (tail + 1) % N;
}

void roundschedule(int n,int q){
  int i,num,sum=0,over;
  char name[10];
  for(i=0;i<n;i++){
    scanf("%s ",name);
    scanf("%d",&num);
    enq(name,num);
  }
 
  while(!isEmpty()){
     num=deq();
    if(q>=Qi[num]){
      sum+=Qi[num];
      printf("%s %d\n",Qc[num],sum);
    }else{
      over=Qi[num]-q;
      sum+=q;
      enq(Qc[num],over);
    }

  }
}

int main(){
  int n,q;
  scanf("%d%d",&n,&q);
  roundschedule(n,q);
  return 0;
}



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

int64_t MOD = 1000000007;
int64_t MAX = 9223372036854775807;
double PI = 3.141592653589793;

bool bekijo(int64_t N)
{
    if (N == 1)
        return true;
    bool x = false;
    for (int i = 2; i <= sqrt(N); i++)
    {
        int tmp = i;
        while (tmp < N)
            tmp *= i;
        if (tmp == N)
            x = true;
    }
    if (x)
        return true;
    else
        return false;
}

int main()
{
    int N;
    cin >> N;
    for (int i = N; i > 0; i--)
        if (bekijo(i))
        {
            cout << i;
            break;
        }
}

Measured memory_bytes: 3680
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
 
 
int main() {
    int A, B;
    cin >> A >> B;
    if (A <= 8 && B <= 8) {
        cout << "Yay!" << endl;
    } else {
        cout << ":(" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
N, M, X = map(int, input().split())
prices = []
effects = []
for _ in range(N):
	values = list(map(int, input().split()))
	prices.append(values[0])
	effects.append(values[1:])

sum_price = sum(prices)
min_price = sum_price + 1

for n in range(2 ** N):
	price = 0
	understood = [0] * M
	i = 0
	while n > 0:
		if n % 2 == 1:
			price += prices[i]
			for j in range(M):
				understood[j] += effects[i][j]
		i += 1
		n //= 2
	if all(understood[j] >= X for j in range(M)):
		if price < min_price:
			min_price = price

if min_price > sum_price:
	print(-1)
else:
	print(min_price)


Measured memory_bytes: 9232
import std.algorithm, std.conv, std.range, std.stdio, std.string;
import std.math;

void main()
{
  auto rd = readln.split.map!(to!real);
  auto p1 = point(rd[0], rd[1]), p2 = point(rd[2], rd[3]);
  auto p = p1 - p2;
  writefln("%.5f", hypot(p.x, p.y));
}

struct Point(T) {
  T x, y;

  point opBinary(string op)(point rhs) {
    static if (op == "+") return point(x + rhs.x, y + rhs.y);
    else static if (op == "-") return point(x - rhs.x, y - rhs.y);
  }
}

alias Point!real point;

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

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

	for (int i = 0; i < n; i++) {
		string num1, num2;
		cin >> num1 >> num2;
		if (num1.size() < num2.size()) swap(num1, num2);
		if (num1.size() > 80) {
			cout << "overflow\n";
			continue;
		}

		reverse(num1.begin(), num1.end());
		reverse(num2.begin(), num2.end());

		for (int j = 0; j < num2.size(); j++) {
			int p = (num1[j] - '0') + (num2[j] - '0');
			if (p >= 10) {
				num1[j] = ((num1[j] - '0') + (num2[j] - '0')) % 10 + '0';

				int k = j + 1;
				while (num1[k] == '9' && k < num1.size()) {
					num1[k++] = '0';
				}
				
				if (k == num1.size()) num1 = num1 + "1";
				else num1[k]  = num1[k] + 1;
			}
			else {
				num1[j] = num1[j] + (num2[j] - '0');
			}
		}
		if (num1.size() > 80) {
			cout << "overflow\n";
			continue;
		}
		reverse(num1.begin(), num1.end());
		cout << num1 << endl;
	}
}


Measured memory_bytes: 3152
/* Author : samarth
   Handle : ssg_13 */

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

using namespace std;
using namespace __gnu_pbds;
using namespace std::chrono;

#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define eb emplace_back //faster than pb
#define pb push_back 
#define Db(x) cout << '>' << #x << ':' << x << endl;
#define forn(i,n) for(ll i=0;i<n;i++)
#define rforn(i,n) for(ll i=n-1;i>=0;i--)
#define forne(i,n) for(ll i=1;i<=n;i++)
#define forse(i,s,e) for(ll i=s;i<e;i++)
#define rforse(i,s,e) for(ll i=e;i>=s;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size()
#define fill(a,x) memset(a,x,sizeof a);
#define trav(a,x) for(auto &a:x)
#define PT palindromeTest	//Input - string, int, ll, l
#define GS generateSubsets	//Input - n		//Return - vector<vector<int>>
#define GP generatePermutations //Input - int n 	//Return - vector<vector<int>>
#define PF primeFactorization	//Input - ll	//Return - vector<ll>
#define nCr nCrModPFermat   //Input - n, r, p	//Return - nCr mod p
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// find_by_order(i) return pointer to ith index in ordered set


const ll MOD = 1000000007;
ll modpow(ll a,ll b,ll m=MOD) {a%=m;ll res=1;while(b){if(b&1)res=res*a%m;a=a*a%m;b>>=1;}return res;}
ll bpow(ll a, ll b) {ll res = 1;while(b){if(b&1)res=res*a;a=a*a;b>>=1;}return res;}
ll modinv(ll a){return modpow(a,MOD-2,MOD);}
void graph(vector<ll> adj[], ll m){ll x, y; forn(i, m){cin>>x>>y;adj[x-1].pb(y-1);adj[y-1].pb(x-1);}}
ll sum() { return 0; }
template<typename T, typename... Args>
auto sum(T a, Args... args) { return a + sum(args...); }

const ll INF=(ll)1e18;
const int MAXN = 200001;
//----------------------template ends--------------------------------//

int main()
{
fast;
cout << fixed << setprecision(11);
cerr << fixed << setprecision(6);
auto start = high_resolution_clock::now();
ll T;
// cin>>T;
T=1;
while(T--)
{
    ll n;
    cin>>n;
    ll d=n%1000;
    if(d==0) cout<<0<<'\n';
    else cout<<1000-d<<'\n';
}
auto stop = high_resolution_clock::now(); 
auto duration = duration_cast<microseconds>(stop - start);
// cout << "Time taken by function: "
//          << duration.count() << " microseconds" << endl; 
}

Measured memory_bytes: 3632
import sys


def main():
    S = sys.stdin.readline().rstrip()

    if len(S) % 2 == 0:
        S = S[:-2]
    else:
        S = S[:-1]

    while S:
        if S[: len(S) // 2] == S[len(S) // 2 :]:
            break
        else:
            S = S[:-2]

    print(len(S))


if __name__ == "__main__":
    main()

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

using namespace std;
int ans=0; 
int main()
{
	int n,k;
	cin>>n>>k;
	int j=k;
	while(k)
    {
       k/=10;
       ans++;
    }
    int cnt=pow(10,ans);
    int sum=cnt*n+j;
    //cout<<sum<<" ";
    for(int i=1;i*i<=sum;i++)
    if(i*i==sum)
	{
		cout<<"Yes";
    	return 0;
	}
    cout<<"No";
	return 0;
}

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

double a, b, c, d, e, f;
double x, y;

double RoundNumber(double f) {
  int tf = (int)(10000 * f);
  if (tf % 10 >= 5) {
    tf += 10;
  }
  tf /= 10;
  return (double)tf / 1000.0f;
}

void solve(){
  /*
  double tmp1 = f-(c*d/a);
  double tmp2 = e-(b*d/a);
  y = tmp1/tmp2;
  x = (c - b * y) / a;
  */
  x = (c*e-b*f) / (a*e-b*d);
  y = (c*d-a*f) / (b*d-a*e);
  printf("%.3f %.3f ", RoundNumber(x), RoundNumber(y));        
}

int main(int argc, char const* argv[]) {
  int n;
  cin>>n;
  for (int i = 0; i < n; i += 1) {
    double x1, y1, x2, y2, x3, y3;
    cin>>x1>>y1>>x2>>y2>>x3>>y3;
    a = -2*x1 + 2*x2;
    b = -2*y1 + 2*y2;
    c = x2*x2 + y2*y2 - x1*x1 - y1*y1;
    d = -2*x1 + 2*x3;
    e = -2*y1 + 2*y3;
    f = x3*x3 + y3*y3 - x1*x1 - y1*y1;

    solve();
    
    double r = (x - x1)*(x - x1) + (y - y1)*(y - y1);
    r = sqrt(r);
    printf("%.3f\n", RoundNumber(r));
  }  
  return 0;
}

Measured memory_bytes: 0
// C++ 14
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <math.h>

#define ll long long
#define Int ll
#define loop(x, start, end) for(Int x = start; x < end; x++)
#define loopdown(x, start, end) for(int x = start; x > end; x--)
#define span(a,x,y) a.begin()+x,a.begin()+y
#define span_all(a) a.begin(),a.end()
#define len(x) (x.size())
#define last(x) (*(x.end()-1))

using namespace std;

#define EPS 0.000000001
#define fequals(a,b) (fabs((a) - (b)) < EPS)

class Vector2 {
public:
  double x, y;
  
  Vector2(double x = 0, double y = 0): x(x), y(y) {}
  
  Vector2 operator + (const Vector2 v) const { return Vector2(x + v.x, y + v.y); }
  Vector2 operator - (const Vector2 v) const { return Vector2(x - v.x, y - v.y); }
  Vector2 operator * (const double k) const { return Vector2(x * k, y * k); }
  Vector2 operator / (const double k) const { return Vector2(x / k, y / k); }
  
  double length() { return sqrt(norm()); }
  double norm() { return x * x + y * y; }
  double dot (Vector2 const v) { return x * v.x + y * v.y; }
  double cross (Vector2 const v) { return x * v.y - y * v.x; }
  
  bool parallel(Vector2 &other) {
    return fequals(fabs(dot(other)), length() * other.length());
  }
  
  bool orthogonal(Vector2 &other) {
    return fequals(0, dot(other));
  }
  
  bool operator < (const Vector2 &v) {
    return x != v.x ? x < v.x : y < v.y;
  }
  
  bool operator == (const Vector2 &v) {
    return fabs(x - v.x) < EPS && fabs(y - v.y) < EPS;
  }
};

ostream & operator << (ostream & out, Vector2 const & v) { 
  out<< "Vector2(" << v.x << ", " << v.y << ')';
  return out;
}

istream & operator >> (istream & in, Vector2 & v) { 
  double x, y;
  in >> x;
  in >> y;
  v.x = x;
  v.y = y;
  return in;
}


#define MAX_N 1001
Int N;
Vector2 a, b, c, d;

void input() {
  cin >> N;
  loop(n,0,N) {
    cin >> a >> b >> c >> d;
    a = b - a;
    c = d - c;
    if (a.parallel(c)) cout << 2 << endl;
    else if (a.orthogonal(c)) cout << 1 << endl;
    else cout << 0 << endl;
  }
}

int main() {
  input();
}


Measured memory_bytes: 3216
//Author- Vaibhav Singh


#include<bits/stdc++.h>
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_multiset tree<long long , null_type,less_equal<long long >, rb_tree_tag,tree_order_statistics_node_update>
#define ordered_set tree<long long , null_type,less<long long >, rb_tree_tag,tree_order_statistics_node_update>
*/
using namespace std;
#define ll long long int
#define YES cout<<"YES"<<"\n";
#define NO cout<<"NO"<<"\n";
#define ld     long double 
#define yes cout<<"yes"<<"\n";
#define no cout<<"no"<<"\n";
#define No cout<<"No"<<"\n";
#define Yes cout<<"Yes"<<"\n";
#define f(i,a) for(i=0;i<a;i++)
#define fo(i,a) for(i=1;i<=a;i++)
#define fa(i,a) for(auto i:a)
#define r(i,a) for(auto i=a.rbegin();i!=a.rend();i++)
#define en cout<<"\n";
#define ull unsigned long long int
#define o(x) cout<<x<<"\n";
#define o1(x) cout<<x<<" ";
#define pb push_back
#define F first
#define in insert
#define mp make_pair
#define S second
#define pre(n) cout<<fixed<<setprecision(n);
#define      gcd(a,b)    __gcd(a,b)
#define bs            binary_search
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define test ll t;cin>>t;while(t-->0)
const ll Mod = 998244353;
#define mod 1000000007
#define pi 3.14159265358979323846
#define all(x) x.begin(),x.end()
#define re return 0;
// *#######################################################################################*

/*
bool isp(ll n)
{
    ll i;
    for(i=2;i*i<=n;i++)
    {
        if(n%i==0)
        {
            return false;
        }
        
    }
}
  */
  
  ll powerm(ll x, unsigned ll y, ll p)  
{  
    ll res = 1;    
  
    x = x % p; 
   
    if (x == 0) return 0;
  
    while (y > 0)  
    {  
        if (y & 1)  
            res = (res*x) % p;  
   
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}
  long long lcm(long long a, long long b){//最小公倍数を求める
   return a * b / gcd(a, b);
}

/*
ll po(ll z,ll z1)
{
    ll rer=0;
    rer=     ((z*(z-1))/2+(z1*(z1-1))/2);
    return rer;

}
*/
/*
bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
}
*/
/*
bool is_prime(ll n){
    for(ll i = 2;i*i<=n;i++){
        if(n%i == 0) return false;
    }
    return true;
}
*/

       int main()
       {
    fast
      ll n;
      cin>>n;
      ll a[n],b[n],i;
      f(i,n)
      {
          cin>>a[i];
      }
       f(i,n)
      {
          cin>>b[i];
      }
  vector<ll>v;
  f(i,n)
  {
      v.pb(i+1);
  }
  ll now=0,c1,c2;
  do
  {
      ll s=0,p=0;
      f(i,n)
      {
          if(a[i]==v[i])
          {
              s++;
          }
      }
        f(i,n)
      {
          if(b[i]==v[i])
          {
              p++;
          }
      }
      if(s==n)
      {
          c1=now;
      }
      if(p==n)
      {
          c2=now;
      }
      
      now++;
  }
  while(next_permutation(all(v)));
  o(abs(c1-c2))
  
  
  
  
  
  
  
  
  
  
  

re}

Measured memory_bytes: 3656
#include<cstdio>
#define ri register int
int k,s,t;
main(){
	scanf("%d%d",&k,&s);
	for(ri x=0;x<=k;++x)
		for(ri y=0;y<=k;++y)
			if(s>=x+y&&s<=k+x+y)
				++t;
	printf("%d\n",t);
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(){
int x ,y;
cin >> x >> y;
while (x!=0||y!=0){
if (x>y){
cout << y <<" " << x << endl;
}else{
cout << x << " " <<y << endl;
}
cin >> x >> y;
}
return 0;
}


Measured memory_bytes: 2988
#include <bits/stdc++.h>
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
#define D()
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 10000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

int main(){
	std::string s;
	std::cin >> s;
	int i, cnt;
	REP(i,s.size()) if(s[i] == '1') cnt++;
	std::cout << cnt << std::endl;
	return 0;
}


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

int main(){
	int n;char x[15];
	scanf("%s%d",x,&n);
	char d[15];
	int res=0;
	for(int i=0;i<n;i++){
		scanf("%s",d);
		for(int j=0;j<10;j++){
			int ok=0;
			for(int k=0;k<=10;k++){
				if(x[k]==0){ok=1;break;}
				if(x[k]!=d[(j+k)%10])break;
			}
			if(ok){res++;break;}
		}
	}
	printf("%d\n",res);
}

Measured memory_bytes: 1188
from collections import Counter

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

counter = Counter(A)
tmp_sum = sum(A)
for i in range(Q):
    B, C = map(int, input().split())
    B_cnt = counter[B]
    counter[B] = 0
    counter[C] += B_cnt
    tmp_sum = tmp_sum + (C - B) * B_cnt
    print(tmp_sum)


    


Measured memory_bytes: 23792
#include <iostream>

using namespace std;

int main(){
  int n;
  
  cin >> n;
  
  if(n % 10 == 7){
    cout << "Yes" << endl;
    return 0;
  }
  n /= 10;
  if(n % 10 == 7){
    cout << "Yes" << endl;
    return 0;
  }
  n /= 10;
  if(n % 10 == 7){
    cout << "Yes" << endl;
    return 0;
  }
  
  
  cout << "No" << endl;
  
  
  return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000010;
constexpr ll INF= 1000000000000000000;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

template<typename T>
T Pow(T a,T b) {
    T ret = 1;
    for(int i = 0;i < b;i++) {
        ret *= a;
    }
    return ret;
}

ll mod(ll val) {
    ll res = val % MOD;
    if(res < 0) {
        res += MOD;
    }
    return res;
}

ll RS(ll N, ll P, ll M){
    if(P==0) return 1;
    if(P < 0) {
        return 0;
    }
    if(P%2==0){
        ll t = RS(N, P/2, M);
        return t*t % M;
    }
    return N * RS(N, P-1, M) % M;
}

int main() {
    int L,R;
    cin >> L >> R;
    int d;
    cin >> d;
    cout << R / d - (L - 1) / d << endl;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;
 
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }
 
const int mod=1e9+7;
 
struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
};
 
mint c[4005][4005];
void init() {
  c[0][0] = 1;
  for (int i = 0; i <= 4000; i++) {
    for (int j = 0; j <= i; j++) {
      c[i+1][j] += c[i][j];
      c[i+1][j+1] += c[i][j];
    }
  }
}
mint comb(int n, int k) {
  return c[n][k];
}
 
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
 
    return true;
}
 
map<ll, ll> primeFact(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      res[i]++;
      n /= i;
    }
  }
  if (n != 1) res[n]++;
  return res;
}
 
void printv(vi& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
void printv(vll& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
int vtotal(vi& v){
  int total=0;
  rep(i,v.size()) total+=v[i];
  return total;
}
 
int main()
{
  //init(); // mint初期化
  cin.tie( 0 );
  ios::sync_with_stdio( false );
  
  int a,b;cin>>a>>b;
  string ans="Impossible";
  if(a%3==0||b%3==0||(a+b)%3==0)ans="Possible";
  cout(ans);
  
  return 0;
}

Measured memory_bytes: 125568
#include<bits/stdc++.h>
#include<queue>
#include<vector>
#include<map>
#include<string>
using namespace std;
#define loop(i,N) for(int i = 0;i < N;i++)
#define INF 10000000
#define MAX_N 1000001

int N,Q;
int sum = 0;
char S[MAX_N];
int C[MAX_N - 1];
int main(){
    cin >> N >> Q;
    cin >> S[0];
  	
    for(int i = 0;i < N-1 ;i++){
        cin >> S[i+1];
        if(S[i+1] == 'C' && S[i] == 'A'){
            sum++;
            C[i] = sum;
        }else{
            C[i] = sum;
        }
    }
    for(int i = 0;i < Q;i++){
        int l,r;
        int count = 0;
        cin >> l >> r;
        if(l == 1){
            cout << C[r - 2] << endl;
        }else{
            cout << C[r - 2] - C[l - 2] << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3328
#include <cstdio>

using namespace std;

const int MOD = 1000000007;
int n, m;
int main()
{
    scanf("%d%d", &n, &m);
    if(n > m + 1 || m > n + 1) printf("0");
    else{
        if(n < m) ++n, --m;
        if(n == m){
            int f1 = 1;
            for(int i = 2; i <= n ; ++i)
                f1 = (1LL * f1 * i) % MOD;
            f1 = (1LL * f1 * f1 * 2) % MOD;
            printf("%d", f1);
        }
        else if(n > m){
            int f1 = 1;
            for(int i = 2; i <= m ; ++i)
                f1 = (1LL * f1 * i) % MOD;
            f1= (1LL *f1 * f1) % MOD;
            f1 = (1LL * f1 * n) % MOD;
            printf("%d", f1);
        }

    }
    return 0;
}


Measured memory_bytes: 128
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define vint(a,n) vint a(n); rep(i, n) cin >> a[i];
#define vll(a,n) vll a(n); rep(i, n) cin >> a[i];
#define ALL(n) begin(n),end(n)
#define RALL(n) rbegin(n),rend(n)
#define MOD (1000000007)
#define INF (2e9)
#define INFL (2e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
using vint=vector<int>;
using vll=vector<ll>;
using vbool=vector<bool>;
template<class T>using arr=vector<vector<T>>;
template<class T>int popcount(T &a){int c=0; rep(i, 8*(int)sizeof(a)){if((a>>i)&1) c++;} return c;}
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} pr(a[a.size()-1]);}
template<class T>void prarr(arr<T>& a){rep(i, a.size()) if(a[i].empty()) pr(""); else prvec(a[i]);}
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; }
struct edge{
    int to, c;
};

arr<edge> g;
// int col[1005][1005];
set<int> st[100005];

void dfs(int n, int p){
    int ci = 0;
    for(edge& e: g[n]){
        if(e.to==p) continue;
        while(st[n].find(ci)!=st[n].end()) ci++;
        // col[n][e] = col[e][n] = ci;
        e.c = ci;
        st[e.to].insert(ci);
        st[n].insert(ci);
    }

    for(edge e: g[n]){
        if(e.to == p) continue;
        dfs(e.to, n);
    }
}

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

    vint x(n), y(n);
    g.resize(n);
    rep(i, n-1){
        int a, b; cin >> a >> b;
        a--; b--;
        g[a].push_back({b, 1000000});
        g[b].push_back({a, 1000000});
        x[i] = a;
        y[i] = b;
    }

    // rep(i, n) rep(j, n) col[i][j] = INF;
    
    dfs(0, -1);

    int m = 0;
    rep(i, n) chmax(m, (int)g[i].size());
    pr(m);

    // rep(i, 3){
    //     rep(j, 3) cout << col[i][j] << " ";
    //     pr("");
    // }

    rep(i, n-1){
        bool flg = false;
        for(edge e: g[x[i]]){
            if(e.to == y[i] && e.c!=INF){
                pr(e.c+1);
                flg = true;
                break;
            }
        }
        if(flg) continue;
        for(edge e: g[y[i]]){
            if(e.to == x[i] && e.c!=INF){
                pr(e.c+1);
                flg = true;
                break;
            }
        }
    }

    return 0;}

Measured memory_bytes: 23872
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define llint long long
#define mod 1000000007

using namespace std;

llint n;
llint a[200005], b[200005];
llint da[200005], db[200005];
vector<llint> vec;
llint z[600005];

void z_algorithm(vector<llint> &s, llint z[])
{
	z[0] = s.size();
	
	int x = 0, y = 0;
	for(int i = 1; i < s.size(); i++){
		if(i > y){
			z[i] = 0;
			for(int j = 0; j < s.size(); j++){
				if(i+j > s.size() || s[i+j] != s[j]) break;
				z[i]++;
			}
			x = i, y = i + z[i] - 1;
		}
		else if(i + z[i-x] <= y) z[i] = z[i-x];
		else{
			z[i] = y-i+1;
			for(int j = y-i+1; j < s.size(); j++){
				if(i+j > s.size() || s[i+j] != s[j]) break;
				z[i]++;
			}
			x = i, y = i + z[i] - 1;
		}
	}
}

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	for(int i = 0; i < n; i++) cin >> a[i];
	for(int i = 0; i < n; i++) cin >> b[i];
	
	for(int i = 0; i < n; i++){
		da[i] = a[i] ^ a[(i+1)%n];
		db[i] = b[i] ^ b[(i+1)%n];
	}
	for(int i = 0; i < n; i++) vec.push_back(db[i]);
	vec.push_back(-1);
	for(int i = 0; i < n; i++) vec.push_back(da[i]);
	for(int i = 0; i < n; i++) vec.push_back(da[i]);
	
	z_algorithm(vec, z);
	
	for(int i = n+1; i <= 2*n; i++){
		if(z[i] >= n){
			cout << i-(n+1) << " " << (a[i-(n+1)]^b[0]) << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 20328
from sys import stdin

N, M = [int(x) for x in stdin.readline().rstrip().split()]

head = 1
tail = N

while head <= M:
    if (N % 2 == 0 and tail - head == N // 2) or (N % 4 == 0 and tail - head == N // 2 - 1):
        tail -= 1
    print(head, tail)
    head += 1
    tail -= 1


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

using namespace std;

typedef unsigned long long ull;
typedef pair<int, int> P;

int main(){
    int N, K; cin >> N >> K;
    int ans = 0;
    rep(i, N) {
        int H; cin >> H;
        if (K <= H) ans++;
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
using namespace std;
 
int main() {
  int N, M;
  cin >> N >> M;
  map<long long, long long, greater<long long>> numbers;
  for(int i=0; i<N; i++){
    long long num;
    cin >> num;
    numbers[num]++;
  }
  for(int i=0; i<M; i++){
    long long selectableCard, point;
    cin >> selectableCard >> point;
    numbers[point] += selectableCard;
  }
  long long sum = 0;
  int cnt = 0;
  for(auto v : numbers){
    if(cnt == N) break;
    long long remainCnt = N - cnt;
    sum += v.first * min(v.second, remainCnt);
    cnt += min(v.second, remainCnt);
  }
  cout << sum;
  return 0;
}

Measured memory_bytes: 12800
program main
 implicit none
 integer*8 n,i,ans
 integer*8, allocatable::p(:)
 read(*,*) n
 allocate (p(1:n))
 ans = 0
 read(*,*) p
 do i=1,n-2
  if(p(i)<=p(i+1) .and. p(i+1)<=p(i+2))then
   ans = ans + 1
  else if(p(i)>=p(i+1) .and. p(i+1)>=p(i+2))then
   ans = ans + 1
  end if
 end do
 write(*,*) ans
end program main

Measured memory_bytes: 256
//Author : pakhandi
//
using namespace std;

#include <bits/stdc++.h>

#define wl(n) while(n--)
#define fl(i,a,b) for(i=a; i<b; i++)
#define rev(i,a,b) for(i=a; i>=b; i--)

#define si(n) scanf("%d", &n)
#define sll(l) scanf("%lld",&l)
#define ss(s) scanf("%s", s)
#define sc(c) scanf("%c", &c)
#define sd(f) scanf("%lf", &f)

#define pi(n) printf("%d\n", n)
#define pll(l) printf("%lld\n", l)
#define ps(s) printf("%s\n", s)
#define pc(c) printf("%c\n", c)
#define pd(f) printf("%lf\n", f)

#define debug(x) cout<<"\n#("<<x<<")#\n"
#define nline printf("\n")

#define mem(a,i) memset(a,i,sizeof(a))

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

#define PB push_back
#define SZ size
#define MP make_pair

#define IGNORE cin.ignore (std::numeric_limits<std::streamsize>::max(), '\n');

std::vector<pair<ll, ll> > v;
stack<ll> st;
ll N, A[200005];

int main()
{
	int i, j;

	cin >> N;

	fl(i,0,N)
		cin >> A[i];

	v.resize(N);

	i = 0;
	v[0].first = 0;
	st.push(i);



	fl(i,1,N)
	{
		int ele = A[i];
		int tp = st.top();

		// cerr << ele << " " << tp << "\n";

		if(A[tp] < ele)
		{
			v[i].first = (i - tp - 1);
			st.push(i);
		}
		else
		{
			while(A[tp] > ele)
			{
				v[tp].second = (i - tp - 1);
				st.pop();
				if(st.SZ() == 0)
				{
					v[tp].first = tp;
				}
				else
					v[tp].first = (tp - st.top() - 1);
				if(st.SZ() == 0)
					break;
				tp = st.top();
			}
			st.push(i);
		}
	}

	// return 0;

	int last = N;
	while(st.SZ())
	{
		int tp = st.top();
		v[tp].second = (last - tp - 1);
		// last = tp;
		st.pop();
		if(st.SZ() == 0)
		{
			v[tp].first = tp;
		}
		else
			v[tp].first = (tp - st.top() - 1);
	}

	// nline;

	ll ans = 0;

	fl(i,0,N)
	{
		// cout << v[i].first << " " << v[i].second; nline;
		ans += ( A[i] * (v[i].first + 1) * (v[i].second + 1) );
	}

	cout << ans;


	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 6528
import math;

def swap(a,b):
    return (b,a)

def gcd(a,b):
    if (a<b):
        a,b = swap(a,b)
    if (b==0):
        return a
    else:
        return gcd(b,a%b)

xm = [1,0,-1,0]
ym = [0,1,0,-1]

def bfs(y,x):
    if (y==gy and x==gx):
        return
    for i in range(4):
        for j in range(4):
            if (c[y+ym[i]][x+xm[j]]=='#'):
                continue
            if (aom[y+ym[i]][x+xm[j]]!=-1):
                continue
            aom[y+ym[i]][x+xm[j]] = aom[y][x] + 1

def main():
    a = int(input())
    s = input()
    if a>=3200:
        print(s)
    else:
        print('red')
    return

if __name__ == '__main__':
    main()

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define REP3(i,x,n) for(int i=x; i>(n); i--)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main(){
    ll R;

    scanf("%lld",&R);
    printf("%.12f",(double)2*R*M_PI);
    return 0;
}

Measured memory_bytes: 3852
s = input()

f = True
if s[0] != 'A':
    f = False
else:
    cnt=0
    for _s in s[2:-1]:
        if _s == 'C':
            cnt+=1
    if cnt!=1:
        f = False
    else:
        cnt = 0
        for _s in s:
            if _s.isupper():
                cnt+=1
        if cnt>2:
            f = False
if f:
    print('AC')
else:
    print('WA')




Measured memory_bytes: 9072
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <string>
#include <cstdio>
#include <cmath>

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

using ll = long long;
using namespace std;

constexpr int INF = 2147483647; // 2 * 1e9
constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin >>s;
	if(s[0] == 'Y' && s[1] == 'A' && s[2] == 'K' && s[3] == 'I')cout << "Yes\n";
	else cout << "No\n";
	return 0;
}


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

#define MAX_N 100


// int N = 5;
// int A = 2;
// int B = 4;

int N, A, B;
int main() {
    cin >> N >> A >> B;
    int dist = abs(A - B);

    if (dist % 2 == 0) {
        printf("Alice\n");
    } else {
        printf("Borys\n");
    }
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int N;
char S[100+5];
bool X[26+5],Y[26+5];
int main() {
	#ifdef LOACL
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
	#endif
	int ans=0;
	scanf("%d %s",&N,S);
	memset(X,false,sizeof false);
	for(int i=0;i<N;i++) {
		X[S[i]-'a']=true;
		memset(Y,false,sizeof Y);
		for(int j=i+1;j<N;j++)
			Y[S[j]-'a']=true;
		int now=0;
		for(int j=0;j<26;j++)
			if(X[j]==true&&Y[j]==true)
				now++;
		ans=max(ans,now);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
typedef const void cv;
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define per(i,n) for((i)=(n)-1;(i)>=0;(i)--)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max((a),(b))-min((a),(b)))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll nPr(int n,int r){ll i,result=1;rep(i,r){result*=(ll)(n-i);}return result;}
ll nCr(int n,int r){ll i,result=1;if(n<r) return 0;rep(i,min(r,n-r)){result*=(ll)(n-i);result/=(ll)(i+1);}return result;}
#define nHr(n,r) nCr((int)((n)+(r)+1),(int)(r))
#define sankaku(x) (((x)*((x)+1))/2)
int dx[8]={1,0,-1,0,1,-1,-1,1},dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(cv *a, cv *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(cv *a, cv *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(cv *left, cv *right) {return strcmp((char *)left,(char *)right);}
int downchar(cv *left, cv *right) {return strcmp((char *)right,(char *)left);}
void tmpInit(int *c,ll m) {ll i;rep(i,m) c[i]=i;}
ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1){
      res *= a; if(mod>=1) res %= mod;
    }
    a *= a; if(mod>=1) a %= mod;
    n >>= 1;
  }
  return res;
}
void initialize(){
  
}
int main(void){
  initialize();
  ll n,m,i,j,k,result=0;
  int a[LIMIT2]={0};
  char s[LIMIT1];
  
  cin >> n >> k;
  rep(i,n) cin >> a[i];
  
  sort(a,a+n);
  
  rep(i,k) result += (ll)a[i];
  cout << result << endl;
  return 0;
}

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

using namespace std;

int main() {
    int n,k;
    cin>>n>>k;
    long long int a[n+5],f[n+5],s=0;
    f[0]=0;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        f[i]=INT_MAX;
        //cout<<a[i]<<"\n";
    }
    f[1]=0;
    // f[1]=abs(a[1]-a[0]);
    // s+=f[1];
    for(int i=1;i<=n;i++){
        for(int j=1;j<=k;j++){
            if(i+j<=n){
                f[i+j] = min(f[i+j],f[i]+abs(a[i+j]-a[i]));
            }
        }
        // f[i] = min(f[i-1]+abs(a[i]-a[i-1]),f[i-2]+abs(a[i]-a[i-2]));
    }
    // for(int i=0;i<n;i++){
    //     cout<<f[i]<<"\n";
    // }
    cout<<f[n]<<"\n";
    return 0;
    
}

Measured memory_bytes: 1792
n = int(input())
s = set()

ok = True
t = input()
p = t[-1]
s.add(t)
for i in range(n-1):
    t = input()
    if t in s:
        ok = False
    s.add(t)
    if t[0] != p:
        ok = False
    p = t[-1]

print('Yes' if ok else 'No')


Measured memory_bytes: 9128
#include <stdio.h>

struct process{//プロセス
    char name[10];
    int time;
};



int main(){
    int n,q;//プロセス数n、クオンタムq
    struct process process[1000000];//プロセス
    struct process process_fin[1000000];//完了済みプロセス
    int now_time=0;

    //入力
    scanf("%d %d",&n,&q);
    for(int i=0;i<n;i++){
        scanf("%s %d",&process[i].name,&process[i].time);
    }
    
    int head=0,tail=n;
    int fin_num=0;

    while(head!=tail){
        if(process[head].time>q){//クオンタムより大きい
            now_time += q;
            process[head].time -= q;
            process[tail]=process[head];
            head++;
            tail++;

        }else{//クアンタム以下
            now_time += process[head].time;
            process_fin[fin_num]=process[head];
            process_fin[fin_num].time=now_time;
            head++;
            fin_num++;
        }

        if(head==1000000){
            head=0;
        }
        if(tail==1000000){
            tail=0;
        }
    }

    for(int i=0;i<fin_num;i++){
        printf("%s %d\n",process_fin[i].name,process_fin[i].time);
    }
}


Measured memory_bytes: 5428
#include <iostream>

using namespace std;

int main() {
    int n, t;
    cin >> n >> t;
    int mini = -1;
    int minc = 1001;
    int c, tt;
    for (int i = 0; i < n; i++) {
        cin >> c >> tt;
        if (tt <= t && c < minc) {
            minc = c;
        }
    }
    if (minc == 1001) {
        cout << "TLE\n";
    } else {
        cout << minc << "\n";
    }
}

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

using namespace std;

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

#define pb push_back
#define mp make_pair

int n;
int a[100010];
int ans = 1;

int main()
{
    ios_base::sync_with_stdio(0);
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    int st = -1;
    int h = 0;
    for(int i = 0; i < n; i++){
        if(st == -1){
            st = a[i];
        }
        else{
            if(a[i] == st) continue;
            if(a[i] > st){
                if(h == 0) h = 1;
                else if(h == 2) {
                    h = 0;
                    ans++;
                }
                st = a[i];
            }
            else{
                if(h == 0) h = 2;
                else if(h == 1){
                    h = 0;
                    ans++;
                }
                st = a[i];
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9 + 7;

int main() {
  int n;
  cin >> n;
  vector<tuple<string, int, int>> dic;
  for (int i = 1; i <= n; i++) {
    string s;
    int p;
    cin >> s >> p;
    p *= -1;
    dic.push_back(tie(s, p, i));
  }
  sort(all(dic));
  for (int i = 0; i < n; i++) {
    cout << get<2>(dic[i]) << endl;
  }
}

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

template <class T>
T abs(T a) { return (a < 0 ? -a : a); }

int main() {
    int n;
    std::cin >> n;
    std::vector<long long> a(n);
    for (int i = 0; i < n; i++) std::cin >> a[i];
    int m = 0;
    for (int i = 1; i < n; i++) if (abs(a[i]) > abs(a[m])) m = i;
    if (a[m] == 0) {
        std::cout << 0 << std::endl;
        return 0;
    }

    std::deque<std::pair<int, int>> q;
    if (a[m] > 0) {
        for (int i = 0; i < n; i++) {
            if (a[i] < 0) {
                q.emplace_back(m, i);
                a[i] += a[m];
            }
        }
        for (int i = 1; i < n; i++) {
            if (a[i - 1] > a[i]) {
                q.emplace_back(i - 1, i);
                a[i] += a[i - 1];
            }
        }
    } else {
        for (int i = 0; i < n; i++) {
            if (a[i] > 0) {
                q.emplace_back(m, i);
                a[i] += a[m];
            }
        }
        for (int i = n - 2; i >= 0; i--) {
            if (a[i + 1] < a[i]) {
                q.emplace_back(i + 1, i);
                a[i] += a[i + 1];
            }
        }
    }

    std::cout << q.size() << "\n";
    for (auto& el : q) std::cout << el.first + 1 << " " << el.second + 1 << std::endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
	  Scanner sc = new Scanner(System.in);
	  int N = Integer.parseInt(sc.next());
	  
	  int[] C = new int[N];
	  int[] S = new int[N];
	  int[] F = new int[N];
	  
	  for(int i = 0; i < N-1; i++) {
		  C[i] = Integer.parseInt(sc.next());
		  S[i] = Integer.parseInt(sc.next());
		  F[i] = Integer.parseInt(sc.next());
	  }
	  
	  int[] temp = new int[N];
	  C[N-1] = S[N-1] = F[N-1] = 0;
	  for(int i = 0; i < N; i++) {
		  temp[i] = S[i] + C[i];
		  for(int j = i+1; j < N-1; j++) {
			  temp[i] = Math.max(S[j], ((temp[i] + F[j] - 1) / F[j]) * F[j]);
			  temp[i] += C[j];
		  }
		  
		  System.out.println(temp[i]);
	  }
	  sc.close();
	  
  }
}

Measured memory_bytes: 26852
// ITP1_10_B Triangle
import java.io.*;

class Main {

   public static void main(String[] args) {
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

      try {
         String[] input = br.readLine().split(" ");
         int a = Integer.parseInt(input[0]);
         int b = Integer.parseInt(input[1]);
         int C = Integer.parseInt(input[2]);
         double RadC = Math.toRadians(C);
         double S, L, h;
         double c;

         S = a * b * Math.sin(RadC) / 2;
         c = Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * Math.cos(RadC));
         L = a + b + c;
         h = b * Math.sin(RadC);

         System.out.print(S + "\n" + L + "\n" + h);
      }

      catch (Exception e) {
         e.printStackTrace();
      }
   }
}

Measured memory_bytes: 16940
//
//  main.cpp
//  CoderTest
//
//  Created by yuya on 2019/05/20.
//  Copyright © 2019 yuya. All rights reserved.
//

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


int main(){
    int i;
    
    int N; cin >> N;
    int Mp = 0;
    vector<int> p(N);
    for(i=0;i<N;i++){
        cin >> p[i];
        Mp = max(p[i], Mp);
    }
    
    cout << accumulate(p.begin(), p.end(), 0) - Mp/2 << endl;
    
    return 0;
}


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

using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;
    vector<vector<int>> g(n);
    for (int i = 0; i < m; ++i) {
        int x, y;
        cin >> x >> y;
        --x, --y;
        g[x].push_back(y);
    }
    vector<bool> vst(n, false);
    vector<int> cache(n, 0);
    function<int(int)> f = [&](int u) {
        if (!vst[u]) vst[u] = true;
        else return cache[u];
        int& res = cache[u];
        for (int v : g[u])
            res = max(res, f(v) + 1);
        return res;
    };
    int res = 0;
    for (int i = 0; i < n; ++i)
        res = max(res, f(i));
    cout << res;
    return 0;
}


Measured memory_bytes: 8832
#include <bits/stdc++.h>
using namespace std;
using ll = long long; // ll は long long　と同じとする。
int main () {
    int a , b , c , d;
    cin >> a >> b >> c >> d;
    int x = c - a;
    int y = d - b;
    cout << c - y << ' ' << d + x << ' ' << a - y  << ' ' << b + x << endl;
}


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

int main() {
  int x, original;
  cin >> x;
  
  original = x;
  int total = 0;
  while (x != 0) {
    total += x % 10;
    x /= 10;
  }

  if (original % total == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <vector>
#include <algorithm>


typedef long long ll;

using namespace std;

/* Driver program to test above function */
int main() 
{ 
    vector< pair <ll,ll> > factors;

    ll n;
    cin >> n;

    for (ll i=1; i<=sqrt(n); i++) 
	{ 
		if (n%i == 0) 
		{ 
			if (n/i == i) 
				factors.push_back(make_pair(i, i)); 

			else 
                factors.push_back(make_pair(i, n/i));
		} 
	} 

    ll res = 1e12;

    for (ll i = 0; i < factors.size(); i++){
        ll temp = (factors[i].first + factors[i].second) - 2; 
        res = min(temp, res);
    }

    cout << res << endl;

	return 0; 
} 


Measured memory_bytes: 384
#include<iostream>
#include<queue>
#include<vector>
using namespace std;
vector<vector<int>> G(100);
vector<int> d(100);
const int INF = 1<<28;
void bfs(){
    queue<int> Q;
    Q.push(0);
    fill(d.begin(),d.end(),INF);
    d[0]=0;
    while(!Q.empty()){
        int u=Q.front();
        Q.pop();
        for(auto a:G[u]){
            if(d[a]!=INF) continue;
            d[a]=d[u]+1;
            Q.push(a);
        }
    }
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    for(int i=0;i<n;++i){
        int u,k;
        cin>>u>>k;
        for(int j=0;j<k;++j){
            int v;
            cin>>v;
            G[u-1].push_back(v-1);
        }
    }
    bfs();
    for(int i=0;i<n;++i)
        cout<<i+1<<' '<<(d[i]==INF?-1:d[i])<<endl;
}

Measured memory_bytes: 3176
/*input
2000000000 0 0 2000000000
*/
/**
    Author: Kristopher Paul
    Date Created: 04-05-2020
    Contest Name:
                _/    _/   _/_/_/_/   _/   _/_/_/_/
               _/  _/     _/    _/   _/   _/
              _/_/       _/_/_/_/   _/   _/_/_/_/
             _/  _/     _/  _/     _/         _/
            _/    _/   _/    _/   _/   _/_/_/_/
**/
#include<bits/stdc++.h>
#include<stdio.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define int ll
#define pb push_back
#define INF 1e18
#define MOD 1000000007
//#define MOD 998244353
#define mp make_pair
const double PI=3.141592653589793238462643383279502884197169399375105820974944;
#define REP(i,n) for (int i = 0; i < n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)
#define remax(a,b) a = max(a,b)
#define remin(a,b) a = min(a,b)
#define umap unordered_map
#define pii pair<int,int>
#define F first
#define S second
#define mii map<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define itr :: iterator it
#define all(v) v.begin(),v.end()
#define WL(t) while(t--)
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define out(x) cout << #x << " is " << x << endl
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
 
//Uncomment for File I/O
//ifstream fin("input.in")
 
//using namespace __gnu_pbds;
 
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds; // set
//typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> pbds; // multiset
 
int ModExp(int x,int y,int m){
    int res = 1;
    x = x % m;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % m;
 
        y = y>>1;
        x = (x*x) % m;
    }
    return res;
}

void solve(){
    int a,b,c,k;
    cin >> a >> b >> c >> k;
    int ans = 0;
    if(k <= a){
        ans += k;
        cout << ans << endl;
        return;
    }else{
        ans += a;
        k -= a;
    }
    if(k <= b){
        cout << ans << endl;
        return;
    }else{
        k -= b;
    }
    ans += -k;
    cout << ans << endl;
}
 
signed main(){
    FastIO;
    int t = 1;
//    cin >> t;
    WL(t){
        solve();
    }
}

Measured memory_bytes: 3648
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>


#define P push
#define PB push_back
#define F(i,a,b) for (ll i=a; i<=b; i++)
#define FF(i,a,b) for (ll i=b; i>=a; i--)
using namespace std;
typedef long long int ll;
const int maxN=1e5+100;

vector <int> g[maxN],topol;
int n,m,x,y;
bool mark[maxN];
void dfs(int v)
{
  mark[v]=true;
  if(g[v].size())
    F(i,0,g[v].size()-1)
      {
	if(!mark[g[v][i]])
	  dfs(g[v][i]);
      }
  topol.PB(v);
}
void input()
{
  cin>>n>>m;
  F(i,1,m)
    {
      cin>>x>>y;
      g[x+1].PB(y+1);
    }
}
int main()
{
  //ios::sync_with_stdio(false);
  input();
  F(i,1,n)
    {
      if(!mark[i])
	dfs(i);
    }
  reverse(topol.begin(),topol.end());
  F(i,0,topol.size()-1)
    cout<<topol[i]-1<<endl;
  return 0;
}

Measured memory_bytes: 4072
n = gets.to_i
a = gets.split(' ').map {|i| i.to_i}

def c(a)
  a.map {|i| (i % 2 == 0) ? i/2 : 0 }
end

def o?(a)
  a.include?(0)
end

t = nil
c = 0
while true
  if t == nil
    t = a
  end
  h = c(t)
  if o?(h)
    break
  else
    t = h
    c += 1
  end
end

puts c

Measured memory_bytes: 1788