akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>       // for next_permutation
#include <vector>
#include <cstdlib>
#define INF 998244353

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

const ll MOD = 1e9+7;

static long gcd(long a, long b) {
    if (b == 0) {
        return a;
    }
    return gcd(b, a % b);
}
/*
long long int facctorialMethod(int k){//階乗
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}*/

long long int tousasum(long long int n){//等差数列
    return n*(n+1)/2;
}

unsigned GetDigit(unsigned num){//桁数
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}

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 > prime_factor(ll n) {//素因数分解
    map< ll, ll > ret;
    for(ll i = 2; i * i <= n; i++) {
        while(n % i == 0) {
            ret[i]++;
            n /= i;
        }
    }
    if(n != 1) ret[n] = 1;
    return ret;
}

ll calcNumOfCombination(ll n, ll r){
    ll num = 1;
    for(ll i = 1; i <= r; i++){
        num = num * (n - i + 1) / i;
    }
    return num;
}

int bubblesort(vector<int> array,int size){//バブルソート　転倒数
    int kaisu = 0;
    for(int i = 0; i < size; i++){
        for(int j = i + 1; j < size; j++){
            if(array[i] > array[j]){
                int number = array[i];
                array[i] = array[j];
                array[j] = number;
                kaisu++;
            }
        }
    }
    return kaisu;
}

ll facctorialMethod(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum = (sum * i)%MOD;
    }
    return sum;
}

// nPnの順列に対して処理を実行する
void foreach_permutation(int n, std::function<void(int *)> f) {
    int indexes[n];
    for (int i = 0; i < n; i++) indexes[i] = i;
    do {
        f(indexes);
    } while (std::next_permutation(indexes, indexes + n));
}



int main() {
    int result = 0;
    int x[2];
    cin >> x[0] >> x[1];
    for(int i = 0;i<2;i++){
        if(x[i]==1){
            result += 300000;
        }else if(x[i]==2){
            result += 200000;
        }else if(x[i]==3){
            result += 100000;
        }
    }
    if(x[0]==1&&x[1]==1){
        result += 400000;
    }
    cout << result << endl;
}








Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int times[101]={0};
	int num;
	while(cin >> num){
		times[num]++;
	}
	int maxtimes = 0;
	for(int i = 0;i < 101;i++){
		if(times[i] > maxtimes) maxtimes = times[i];
	}
	int maxnum[101]={0};
	int ptr=0;
	for(int i = 0; i < 101; i++){
		if(times[i]==maxtimes){
			maxnum[ptr++] = i;
		}
	}
	for(int i=0; i< ptr; i++){
		cout << maxnum[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 0
x, n = [int(e) for e in input().split()]
nums = [int(e) for e in input().split()]

ans = x
for i in range(2*n):
    if x-i not in nums:
        ans = x-i
        break
    elif x+i not in nums:
        ans = x+i
        break
    else:
        continue
print(ans)

Measured memory_bytes: 9180
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    int k=sc.nextInt();
    int n=sc.nextInt();
    int a[]=new int[n+1];
    for (int i=0;i<n;i++) {
      a[i]=sc.nextInt();
    }
    a[n]=k+a[0]-a[n-1];

    for (int i=n-1;i>0;i--) {
      a[i]=a[i]-a[i-1];
      // System.out.println(a[i]);
    }

    Arrays.sort(a);


    System.out.println(k-a[n]);
  }
}


Measured memory_bytes: 82640
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
static const ll MAX = 1000000000000000;
static const int NIL = -1;
using namespace std;


int main() {

    int n,m; cin >> n >> m;
    cout << (((n-m)*100 + m*1900)*pow(2,m));
    return 0;
}


Measured memory_bytes: 4244
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

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

#define MP make_pair
#define EACH(i,c) for(auto i: c)
#define SORT(c) sort((c).begin(),(c).end())

#define ALL(a)  (a).begin(),(a).end()

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int N, K;
	cin >> N >> K;

	vector<int> done(N, 0);
	REP(i, K){
		int d;
		cin >> d;
		REP(j, d){
			int a;
			cin >> a;
			done[a - 1] = 1;
		}
	}

	int ret = 0;

	REP(i, N) if(done[i] == 0) ret++;

	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 3192
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  vector<ll> A(N);
  for(int i=0;i<N;++i) cin>>A[i];
  sort(A.begin(), A.end());
  cout<<A[N-1]-A[0]<<endl;
}



Measured memory_bytes: 3604
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan=new Scanner(System.in);
        String words, sentence;
        words = scan.next().toUpperCase();
        sentence = scan.next();
        int result=0;
        
        while(!sentence.equals("END_OF_TEXT")){
            if(sentence.toUpperCase().equals(words))
                result++;
            sentence=scan.next();
        }
        
            System.out.println(result);
    }
}


Measured memory_bytes: 26232
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    int a,b,n;
    cin>>n;
    cin>>a>>b;
    int cnt=0;
    for(int i=a;i<=b;i++)
    {
        if(i%n==0)
        {
            cnt++;
            break;
        }
    }
    if(cnt==0)
    {
        cout<<"NG"<<endl;
    }
    else
    {
        cout<<"OK"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3620
#include"iostream"
#include"string"
using namespace std;

int main()
{
	string a, b;
	cin >> a >> b;
	int n = stoi(a + b);
	bool ans = false;
	for (int i = 0; i < 320; i++)
	{
		if (i*i == n)ans = true;
	}
	cout << (ans ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
lines = readlines.map{|line| line.split(' ')}
a=lines[0][0].to_i
b=[]
for i in 1..a
  b.push(lines[i][0])
end
count = Hash.new(0)
b.each do |elem|
  count[elem] += 1
end
c=count.sort_by { |key, value| value }.reverse.to_h
d=c.group_by{|k,v| v}.max
d[1]=d[1].sort
for j in d[1]
  puts j[0]
end

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

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

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

using namespace std;

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if (b < c || d < a) {
    cout << 0 << endl;
    return 0;
  }
  cout << min(b, d) - max(a, c) << endl;
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/pb_ds/assoc_container.hpp> 
using namespace std; 
using namespace __gnu_pbds;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
template <class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
#define FOR(i,a,b) for(int i = a; i < b; i++)
#define F0R(i,a) for(int i = 0; i < a; i++)
#define pb push_back
#define all(x) x.begin(), x.end()
#define sz(x) int((x).size())
#define newl '\n'
 
#define FAST ios::sync_with_stdio(0); cin.tie(0);
#define finish(x) return cout << x << "\n", 0;
#define bug(x) cerr << ">>> " << #x << " = " << x << "\n";
#define _ << " " << 
 
const ll MOD = 998244353;
const ll INF = 1e9 + 7;

int n, a;
deque<int> b;

//check int vs ll and precision
//check logic
int main(){ FAST

	cin >> n;
	F0R(i,n) {
		cin >> a;
		if (i % 2 == 0) {
			b.push_back(a);
		}
		else {
			b.push_front(a);
		}
	}
	if (n % 2 == 0) {
		while (!b.empty()) {
			cout << b.front() << " ";
			b.pop_front();
		}
	}
	else {
		while (!b.empty()) {
			cout << b.back() << " ";
			b.pop_back();
		}
	}

	






    return 0;
}
	


Measured memory_bytes: 4484
import scala.annotation.tailrec
import scala.io.StdIn

object Main extends App {
  
  @tailrec def loop(x: Int, y: Int): Unit = {
    if(x != 0 || y != 0){
      if(x <= y) println(x + " " + y)
      else println(y + " " + x)

      val a = StdIn.readLine().trim.split(' ').map(_.toInt)
      loop(a(0), a(1))
    } 
  }

  val Array(fx, fy) = StdIn.readLine().trim.split(' ').map(_.toInt)

  loop(fx, fy)

}



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


if (($input[0] === $input[1] && $input[0] !== $input[2]) || ($input[1] === $input[2] && $input[1] !== $input[0]) || ($input[2] === $input[0] && $input[0] !== $input[1])) {
    echo 'Yes';
} else {
    echo 'No';
}

Measured memory_bytes: 4604
a,b,c,d=map(int,input().split())
if a<=b<=c or c<=b<=a:
  if abs(b-a)<=d and abs(c-b)<=d:
    print('Yes')
  else:
    print('No')
elif (b<a<=c or a<=c<b) or (b<c<=a or c<=a<b):
  if c-a<=d:
    print('Yes')
  else:
    print('No')

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

int main() {
    char a;
    cin >> a;
    if (a >= 65 && a <= 90) cout << 'A' << endl;
    else cout << 'a' << endl;
}

Measured memory_bytes: 3632
while 1:
    n,a,b=map(int,input().split())
    if n==a==b==0:break
    c=0;d=[1]+[0]*2000000
    for i in range(0,n+1):
        if d[i]:d[i+a]=d[i+b]=1
        else:c+=1
    print(c)

Measured memory_bytes: 54344
#include <iostream>
#include <string>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long LL;

int write_move(char c, int dist) {
  REP(i, dist) {
    cout << c;
  }
}

int sign(int x) {
  return (x>0)-(x<0);
}

int main(){
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;
  int dx = tx - sx, dy = ty - sy;
  write_move('R', dx);
  write_move('U', dy);
  write_move('L', dx);
  write_move('D', dy);
  write_move('D', 1);
  write_move('R', dx+1);
  write_move('U', dy+1);
  write_move('L', 1);
  write_move('U', 1);
  write_move('L', dx+1);
  write_move('D', dy+1);
  write_move('R', 1);
  cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define pb push_back
#define mp make_pair
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
typedef long long ll;
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; }
using namespace std;

std::vector<ll> divisor(ll n)//nの約数を列挙
{
  std::vector<ll> ret;
  for(ll i=1 ; i*i<=n ; ++i)
  {
    if(n%i == 0)
    {
      ret.push_back(i);
      if(i!=1 && i*i!=n)
      {
        ret.push_back(n/i);
      }
    }
  }
  return ret;
}

int main(){
  int A,B,K;
  cin >> A >> B >> K;
  int gcd = __gcd(A,B);

  auto v = divisor(gcd);
  v.push_back(gcd);
  sort(all(v),greater<ll>());
  
  cout << v[K-1] << endl;




  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll int64_t
#define f first
#define sec second
#define pb push_back
#define pf push_front
#define pbb pop_back
#define vi vector<ll>
#define vii vector< pair<ll,ll> >
#define pi pair<ll,ll>
#define map map<ll,ll>
#define set set<ll>
const int m=1e9+7;
int main(){
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,k;
    cin>>n>>k;
    ll count=0;
    while(n>0){
        n=n-k;
        count++;
    }
    cout<<count<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define N 12000000
char a[2][N];
int main(void)
{
    while (1) {
        int i, n, f, k;
        n = atoi(fgets(a[0], N, stdin));
        if (n == 0) break;
        *strchr(fgets(a[0], N, stdin), '\n') = 0;
        k = f = 0;
        while (n--) {
            int c = 1;
            k = 0;
            for (i=0; i<strlen(a[f]); ++i) {
                if (a[f][i] != a[f][i+1]) {
                    if (c >= 100) {
                        a[1-f][k++] = c/100+'0'; c %= 100;
                        a[1-f][k++] = c/10+'0'; c %= 10;
                    }
                    else if (c >= 10) {
                        a[1-f][k++] = c/10+'0'; c %= 10;
                    }
                    a[1-f][k++] = c+'0';
                    a[1-f][k++] = a[f][i];
                    c = 1;
                }
                else c++;
            }
            a[1-f][k] = 0;
            f = 1 - f;
        }
        for (i=0; i<k; ++i) putchar(a[f][i]); puts("");
    }
    return 0;
}

Measured memory_bytes: 424
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

#ifndef U_L_LONG
typedef unsigned long long U_L_LONG;
#endif
#ifndef L_LONG
typedef long long L_LONG;
#endif

typedef std::pair<int, int> IntPair;

#ifndef LL_ABS
#define LL_ABS(x) (((((L_LONG)(x) < 0) ? ((L_LONG)(x) * (-1)) : ((L_LONG)(x)))))
#endif

//static void ABC120D_DecayedBridges();
static void ABC119C_MonstersBattleRoyale();

#if 1
int main()
{
	//ABC120D_DecayedBridges();
	ABC119C_MonstersBattleRoyale();

	fflush(stdout);
	return 0;
}
#endif

L_LONG llong_gcd(L_LONG first, L_LONG second)
{
	L_LONG num1 = first, num2 = second;
	L_LONG remainder = 0, common = 0;

	while (!common) {
		remainder = num1 % num2;

		if (remainder == 0) {
			common = num2;
		}
		else {
			num1 = num2;
			num2 = remainder;
		}
	}
	return(common);
}


static void ABC119C_MonstersBattleRoyale()
{
	int N = 0;
	static L_LONG A[100000] = { 0 };

	scanf(" %d", &N);

	for (int i = 0; i < N; i++) {
		scanf("%llu", &A[i]);
	}

	L_LONG hp = A[0];
	for (int i = 0; i < N - 1; i++) {
		hp = llong_gcd(hp, A[i + 1]);
	}
	printf("%lld\n", hp);
}


Measured memory_bytes: 1024
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdlib>
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0' && ch<='9')x=x*10+ch-'0',ch=getchar();
    return x*f;
}
int stack[20];
inline void write(int x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
inline void pr1(int x){write(x),putchar(' ');}
inline void pr2(int x){write(x),puts("");}
const int mod=1000000007;
inline int ad(int x){return x>=mod?x-mod:x;}
inline int dec(int x){return x<0?x+mod:x;}
inline int gcd(int a,int b)
{
	if(a==0)return b;
	else return gcd(b%a,a);
}
inline int power(int a,long long b)
{
	int ans=1;b%=(mod-1);
	while(b)
	{
		if(b&1)ans=1LL*ans*a%mod;
		a=1LL*a*a%mod;
		b>>=1;
	}return ans;
}
int main()
{
    //freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	int n=read(),m=read(),T=read(),h=n/gcd(n,T),l=m/gcd(m,T);
	pr2(power(dec(ad(ad(power(2,h)+power(2,l))+power(2,gcd(h,l)))-3),1LL*n*m/h/l));
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

int main (void){

  int N,K,R,i,j,k,l,count,sum=0;
  int m[100][100]={0};
  int dame[100]={0},pq[3000][2]={0};
  scanf("%d %d",&N,&K);
  for(i=1;i<=K;i++){
    scanf("%d",&m[i][0]);
    for(j=1;j<=m[i][0];j++){
      scanf("%d",&m[i][j]);
    }
  }
  
  scanf("%d",&R);
  for(k=1;k<=R;k++){
    for(l=0;l<2;l++){
      scanf("%d",&pq[k][l]);
    }
  }
  
  //count
  for(k=1;k<=R;k++){
    for(i=1;i<=K;i++){
      count=0;
      for(l=0;l<2;l++){
        for(j=1;j<=m[i][0];j++){
          
          // printf("m=%d pq=%d\n",m[i][j],pq[k][l]);
          if(m[i][j]==pq[k][l]){
            count++;  
          }
        }
        if(count==2){
          dame[pq[k][0]]=1;
          dame[pq[k][1]]=1;
        }
        // printf("count=%d\n",count);
      }
    }
  }
  
  for(i=1;i<=N;i++){
    sum += dame[i];
  }
  printf("%d\n",sum);
  return 0;
}

Measured memory_bytes: 672
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 3e5 + 10;
LL ans[N];
int a[N];
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n;
	cin >> n;
	priority_queue<int, vector<int>, greater<int>> pq1, pq2;
	LL sum = 0;
	for (int i = 1; i <= n * 3; i++)
	{
		cin >> a[i];
		pq1.push(a[i]);
		sum += a[i];
		if (pq1.size() > n)
		{
			sum -= pq1.top();
			pq1.pop();
		}
		ans[i] = sum;
	}
	sum = 0;
	LL res = -INF * INF;
	for (int i = n * 3; i > n; i--)
	{
		sum += a[i];
		pq2.push(-a[i]);
		if (pq2.size() > n)
		{
			sum += pq2.top();
			pq2.pop();
		}
		if (pq2.size() == n)
		{
			res = max(res, ans[i - 1] - sum);
		}
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 4856
fun main(args: Array<String>?): Unit {
    val pairs = Array(20000){ArrayList<Pair<Int, Int>>()}
    for (i in 1 .. Math.sqrt(19999.0).toInt()) for (j in 0 .. Math.min(i, Math.sqrt(19999.0 - i * i).toInt())) {
        pairs[i * i + j * j].run{
            add(Pair(j, i))
            add(Pair(-j, i))
            add(Pair(j, -i))
            add(Pair(-j, -i))
        }
    }
    repeat(readLine()!!.trim().toInt()){
        val (m, n) = readLine()!!.trim().split(' ').map(String::toInt)
        var isPrime = true
        loop@for (i in 2 .. Math.sqrt(m * m + n * n.toDouble()).toInt()) if ((m * m + n * n) % i == 0){
            for ((x, y) in pairs[i]) {
                val s = x * x + y * y
                if ((m * x + + n * y) % s == 0 && (m * y - n * x) % s == 0) {
                    isPrime = false
                    break@loop
                }
            }
        }
        println(if (isPrime) "P" else "C")
    }
}
fun <T> T.run(func: T.() -> Unit): Unit {
    func(this)
}



Measured memory_bytes: 41692
#include <stdio.h>
#include <ctype.h>

int main(void)
{
	char ch;
	while(1){
		scanf("%c", &ch);
		if(isupper(ch)) {
			ch = tolower(ch);
		} else if(islower(ch)) {
			ch = toupper(ch);
		}
		printf("%c",ch);
    		if ( ch == '\n' ) break;
	}	
	return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
using namespace std;
#define int long long   // aaaaaaaaaaaaaaaaaa
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define allr(x) (x).rbegin(),(x).rend()
#define in(s,x) s.find(x) != s.end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define SIZE(buff) (sizeof(buff)/sizeof(buff[0]))
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<pair<int,int>> VPII;
const ll mod=1000000007;
const ll INF= 1LL<<60-1;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;} ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
template<class T> void chmin(T& a,const T& b) { if(a>b) a=b; }
template<class T> void chmax(T& a,const T& b) { if(a<b) a=b; }
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
template<typename T, typename U>ostream& operator << (ostream& os, pair<T, U>& pair_var)
{os << pair_var.first << " " << pair_var.second ;return os;}
template<class tContainer>
long long sum(tContainer const& iContainer) {return  std::accumulate(std::begin(iContainer), std::end(iContainer), 0LL);}
 
// head
 
 
int m,n,k,res,tmp,tmp2,tmp3,h,w,x,y;
VI a;
deque<PII> que;
string s;
//VI b;
vector<PII> g[2100600];
int b[2100000];
int c[210] = {};
int rui[210000];
set<int> ch;
 
signed main() {
	cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>n;
  res = 0;
  rep(i,0,n){cin>>m;
            res^=m;}
  if(res==0){cout<<"Yes"<<endl;}
  else cout<<"No"<<endl;
  
    
}

Measured memory_bytes: 51200
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int x=sc.nextInt();
		int a=sc.nextInt();
		int b=sc.nextInt();
		int i=0;
		while(x-a-(b*i)>=0) {
			++i;
		}
		System.out.println(x-a-(b*(i-1)));
	}

}


Measured memory_bytes: 35564
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long A,B,C;
  cin>>A>>B>>C;
  bool flag=true;
  long long count=0;
  while(flag){
    if(A%2!=0||B%2!=0||C%2!=0){
      flag=false;
      break;
    }
    if(A==B&&B==C){
      count=-1;
      flag=false;
      break;
    }
    long long AA=A;
    long long BB=B;
    long long CC=C;
    A=BB/2+CC/2;
    B=AA/2+CC/2;
    C=BB/2+AA/2;
    count++;
  }
  cout<<count<<endl;
}

Measured memory_bytes: 3564
import collections

N = int(input())
v = list(map(int,input().split()))

even = v[0::2]
odd = v[1::2]

count_even = collections.Counter(even).most_common()
count_sort_even = sorted(count_even, key = lambda x: x[1])[::-1]

count_odd = collections.Counter(odd).most_common()
count_sort_odd = sorted(count_odd, key = lambda x: x[1])[::-1]

if count_sort_even[0][0] != count_sort_odd[0][0]:  ans = N - count_sort_even[0][1] - count_sort_odd[0][1]
    
else:
    if len(count_sort_even) == 1:
        if len(count_sort_odd) == 1:  ans = N // 2
        else:  ans = N - count_sort_even[0][1] - count_sort_odd[1][1]
    elif len(count_sort_odd) == 1:  ans = N - count_sort_even[1][1] - count_sort_odd[0][1]
    else:
        ans1 = N - count_sort_even[1][1] - count_sort_odd[0][1]
        ans2 = N - count_sort_even[0][1] - count_sort_odd[1][1] 
        ans = min(ans1, ans2)    
    
print(ans)

Measured memory_bytes: 98944
import java.util.Scanner;
public class Main{
    public static void main(String args[]){
      Scanner sc=new Scanner(System.in);
      int amr,flag;
      flag=0;
      amr=0;
      int N=sc.nextInt();
      int A=sc.nextInt();
      if(N%500==0){
        flag=1;  
        System.out.println("Yes");
      }
      else for(int i=0;i<A;i++){
               amr=N%500;
               if(amr==i) {  
                flag=1;   
                System.out.println("Yes");
                              break;
                }
                 
            }
     if(flag==0) System.out.println("No");
     sc.close();

      
         
    }
}

Measured memory_bytes: 22868
#include <stdio.h>
int main()
{
	int n;
	scanf("%d",&n);
	long long int count=0;
	for(int i=1;i<=n;i++)
	{
		if(i%3!=0&&i%5!=0)
		{
			count+=i;
		}
	}
	printf("%lld\n",count);
}

Measured memory_bytes: 1732
# coding: utf-8
import math
n=int(input())
flg=False
for i in range(1, 3501):
    for j in range(1, 3501):
        a=i
        b=j
        if 4*a*b-n*(a+b)!=0:
            c=n*a*b/(4*a*b-n*(a+b))
            if c==int(c) and c>0:
                c=int(c)
                flg=True
                break
    if flg:
        break
print(a,b,c)

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

int main(){
  int n;
  cin >> n;
  for(int i = 1; i <= 9; i++){
    if(n <= i * 100 + i * 10 + i){
      cout << i * 100 + i * 10 + i << endl;
      break;
    }
    else if(n > i * 100 + i * 10 + i && n <= (i + 1) * 100 + (i + 1) * 10 + (i + 1)){
      cout << (i + 1) * 100 + (i + 1) * 10 + (i + 1) << endl;
      break;
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b;
    cin>>a>>b;

    if(a>=13){
       cout<<b<<endl;
    }
    else if(a<=5){
        cout<<0<<endl;
    }
    else{
        cout<<b/2<<endl;
    }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#define MAXVAL 2147483647

#define min(a, b) ((a)<(b)?(a):(b))

int *a, *b, v, n;
unsigned int s, t;

int find_min(unsigned int k, unsigned int l, unsigned int r)
{
  if (r<=s || t<=l) return MAXVAL;
  if (s<=l && r<=t) return a[k] + b[k];
  int m1 = find_min((k<<1)+1, l, (l+r)>>1);
  int m2 = find_min((k<<1)+2, (l+r)>>1, r);
  return min(m1, m2) + a[k]; 
}

void update(unsigned int k, unsigned int l, unsigned int r)
{
  if (r<=s || t<=l) return;
  if (s<=l && r<=t) {
    a[k] += v;
  } else {
    unsigned int k1 = (k<<1)+1, k2 = k1 + 1;
    update(k1, l, (l+r)>>1);
    update(k2, (l+r)>>1, r);
    b[k] = min(a[k1]+b[k1], a[k2]+b[k2]);
  }
}

int main()
{
  int i, w, sign;
  char *p, buf[64] = {0};
  buf[62] = '\n';
  fgets(buf, 64, stdin);
  for (n=0,p=buf; *p>' '; n=n*10+*(p++)-'0');
  w = n>1 ? pow(2, (int)ceil(log2(n)))-1 : 0;
  b = (a = (int*)malloc(sizeof(int)*(w+n)*2)) + w + n;
  w++;
  while (fgets(buf, 64, stdin)) {
    for (s=0,p=buf+2; *p>' '; s=s*10+*(p++)-'0');
    for (t=0,p++; *p>' '; t=t*10+*(p++)-'0');
    t++;
    if (*buf=='0') { // update(s, t, x)
      if (*(++p)=='0') continue;
      sign=0;
      if (*p=='-') {sign=1;p++;}
      for (v=0; *p>' '; v=v*10+*(p++)-'0');
      if (sign) v=-v;
      update(0, 0, w);
    } else { // find(s, t)
      v = find_min(0, 0, w);
      if (v<0) {
	putchar('-');
	v = -v;
      }
      if (v<10) {
	putc_unlocked('0'+v, stdout);
	putc_unlocked('\n', stdout);
      } else {
	for (i=62; v>0; buf[--i]='0'+v%10,v/=10);
	fputs(buf+i, stdout);
      }
    }
  }
  return 0;
}



Measured memory_bytes: 3008
def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    a.sort()
    mod = 10 ** 9 + 7
    fac = [1 for _ in range(n + 1)]
    inv = [1 for _ in range(n + 1)]
    for i in range(1, n + 1):
        fac[i] = fac[i - 1] * i
        fac[i] %= mod
        inv[i] = inv[i - 1] * pow(i, -1, mod)
        inv[i] %= mod

    def comb(a, b, mod):
        return (fac[a] * inv[b] * inv[a - b]) % mod

    ans = 0
    for i in range(k - 1, n):
        nck = comb(i, k - 1, mod)
        ans += nck * a[i]
        ans -= nck * a[n - i - 1]
        ans %= mod

    print(ans)


if __name__ == '__main__':
    main()


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

using namespace std;

int main() {
    int H, N;
    cin >> H >> N;

    vector<int> a(N), b(N);
    for (int i = 0; i < N; i++) {
        cin >> a[i] >> b[i];
    }

    vector<int> dp(H + 1, 1e9);
    dp[0] = 0;
    for (int i = 0; i <= H; i++) {
        for (int j = 0; j < N; j++)
            dp[i] = min(dp[max(0, i - a[j])] + b[j], dp[i]);
    }
    cout << dp[H] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>          // printf(), scanf()
#include <stdbool.h>

int
main(int argc, char** argv)
{
	int count;
	int n, x;
	int i, j, k;

	while (true)
	{
		scanf("%d %d\n", &n, &x);
		if (n == 0 && x == 0)
			break;

		count = 0;
		for (i = 1; i <= n - 2; ++i)
		{
			for (j = i + 1; j <= n - 1; ++j)
			{
				for (k = j + 1; k <= n; ++k)
				{
					if (i + j + k == x)
					{
						count++;
						break;
					}
				}
			}
		}

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

	return 0;
}

Measured memory_bytes: 604
import sys
sys.setrecursionlimit(1000000000)
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
mlmis = lambda: [-int(x) for x in input().split()]
INF = float('inf')
#

def main():
    N = ii()
    D = lmis()
    if (D[0] > 1) or (0 in D[1:]):
        print(0)
        return
    L = [0] * (max(D)+1)
    for d in D:
        L[d] += 1
    ans = 1
    for i in range(1, len(L)):
        ans *= (L[i-1]%998244353) ** L[i]
        ans %= 998244353
    print(ans)





main()


Measured memory_bytes: 14324
def solve():
    N, *A = map(int, open(0).read().split())
    
    dp = [[0 for _ in range(2)] for _ in range(N+1)]
    dp[0][1] = -10**15
    for i in range(N):
        dp[i+1][0] = max(dp[i][0]+A[i], dp[i][1]-A[i])
        dp[i+1][1] = max(dp[i][0]-A[i], dp[i][1]+A[i])
    print(dp[N][0])


if __name__ == '__main__':
    solve()

Measured memory_bytes: 27412
#include<stdio.h>

int main()
{
	int num, i, remind, save;
	scanf("%d", &num);
	
	i = 1; 
	while(num!=0)
	{
		remind = num % 10;
		num = num / 10;
		if(remind == 7)
		 {
		 	save = 1;
		 	break;
		 }
		 else {
		 	save = 2;
		 }
	}
	if(save == 1)
		printf("Yes\n");
	else 
		printf("No\n");
}

Measured memory_bytes: 1660
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    string S, T;

    void solve() {
        cin >> S >> T;
        vector<vector<int>> vs(26);

        for (int i = 0; i < S.size(); ++i) {
            char c = S[i];
            vs[c - 'a'].push_back(i);
        }


        Int base = 0ll;
        Int add = 0ll;
        int idx = -1;

        for (int i = 0; i < T.size(); ++i) {
            int c = T[i] - 'a';
            if (vs[c].size() == 0) {
                cout << -1 << endl;
                return;
            }

            auto pt = upper_bound(all(vs[c]), idx);
            if (pt == vs[c].end()) {
                base += S.size();
                idx = -1;
            }

            pt = upper_bound(all(vs[c]), idx);
            idx = *pt;
            add = idx + 1;
        }

        Int ans = base + add;
        cout << ans << endl;


    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();


    return 0;
}


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

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

  ll A; cin >> A;
  ll B; cin >> B;
  ll C; cin >> C;
  string ans = "No";
  if (A == B && B != C) ans = "Yes";
  if (B == C && C != A) ans = "Yes";
  if (C == A && A != B) ans = "Yes";
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,ans=0;
    cin>>n;
    int a[n];
    for(int i=0; i<n; i++)
        cin>>a[i];
    for(int i=1; i<n-1; i++)
    {
        if((a[i-1]<a[i] && a[i]<a[i+1]) || (a[i-1]>a[i] && a[i]>a[i+1]))
            ans++;
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 3576
n=int(input())
s=[input() for x in range(n)]
m=int(input())
t=[input() for x in range(m)]

from collections import Counter
sd=dict(Counter(s))
td=dict(Counter(t))
ans=0
for x in sd:
    y=sd.get(x,0)-td.get(x,0)
    ans=max(y,ans)
print(ans)

Measured memory_bytes: 3316
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define c(P)        cout<<P<<"\n"
#define dbg(P)      cout<<P<<" "
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define F           first
#define S           second
#define mem(a,val)  memset(a,val,sizeof(a))
#define fr(i,x,n)   for(ll i=x;i<n;i++)
#define frr(i,x,n)  for(ll i=n-1;i>=x;i--)


const ll N   =  305;
const ll mod = 1e9 + 7;

using namespace std;

  ll n,x;
long double dp[N][N][N]; bool vis[N][N][N];
ll a[4];
long double f(ll a,ll b,ll c)
{
    if(a<0 or b<0 or c<0)
    return 0;
  if(a==0 && b==0 && c==0)
    return 0;
  long double &ans=dp[a][b][c];
    if(vis[a][b][c])
      return ans;
    vis[a][b][c]= 1;
    ans = n + a*f(a-1,b,c) + b*f(a+1,b-1,c) + c*f(a,b+1,c-1);
    ans /=(a+b+c);
    return ans;
}
void solve()
{
// string s;
  cin>>n;
  for (ll i = 0; i < n; ++i)
  {
  cin>>x;
    a[x]++;
  }
  cout<<fixed<<setprecision(12)<<(f(a[1],a[2],a[3]));

}

signed main(){
   
      ios_base::sync_with_stdio(false);   
      cin.tie(NULL);
      ll T=1;
      //cin>>T;
      while(T--)
      {
      solve();
      }
      return 0;
    }


Measured memory_bytes: 465152
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,Q;string S;cin>>N>>Q>>S;
  vector<int>V(N);
  int U=0;
  for(int X=0;X<N;X++){
    if(X!=0&&S[X]=='C'&&S[X-1]=='A'){
      U++;
    }
    V[X]=U;
  }
  for(int X=0;X<Q;X++){
    int A,B;cin>>A>>B;
    if(A!=1&&V[A-2]!=V[A-1]){
      cout<<V[B-1]-V[A-1]<<endl;
    }
    else{
      cout<<V[B-1]-V[A-1]<<endl;
    }
  }
}


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

int main()
{
    long long x;
    cin >> x;
    long long ans = x / 11;
    if(x % 11 == 0){
        cout << ans * 2 << endl;
    }
    else if(x % 11 <= 6){
        cout << ans * 2 + 1 << endl;
    }
    else{
        cout << ans * 2 + 2 << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mid (tl+tr)/2
#define mod 1000000007
#define fain(arr) for(int i=0;i<n;i++)cin>>arr[i];
#define faio(arr) for(int i=0;i<n;i++)cout<<arr[i]<<" ";
#define all(x) x.begin(),x.end()
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define bugv(n1) if(DEBUG)cout<<#n1<<" is "<<n1<<'\n';
#define FILE freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define endl '\n'
#define ll long long 
#define pii pair<int,int>
#define pll pair<long long ,long long >
#define pi acos(-1)
#define sz(x) ((int)x.size())
#define clr(x) memset(x, 0, sizeof(x))
#define init(x, a) memset(x, a, sizeof(x))
#define DEBUG true
using namespace std;

int main() {
  // FILE;
  SPEED;
  int n,k;
  cin>>n>>k;
  string s;
  cin>>s;

  s[k-1]-='A';
  s[k-1]+='a';

  cout<<s<<endl; 

}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int i;
	int j;
	
	for(i = 1; i < 10; i++){
		for(j = 1; j < 10; j++){
			printf("%dx%d=%d\n", i, j, i*j);
		}
	}
	return 0;
}

Measured memory_bytes: 924
# ABC087-C
N = int(input())
A = []
for i in range(2):
    A.append(list(map(int, input().split())))
ans_list = []
for i in range(N):
    count = A[0][0]
    place_0 = 0
    place_1 = 0
    for k in range(N):
        if k == i:
            place_1 += 1
        else:
            place_0 += 1
        count += A[place_1][place_0]
    ans_list.append(count)
print(max(ans_list))    

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main()
{
    int N,M,D;
    vector<vector<int> > r,c;
    vector<int> temp;

    string instr;

    cin >> N >> M >> D;

    for(int i=0; i<N; ++i) {
        cin >> instr;
        for(int j=0; j<M; ++j) {
            temp.push_back((instr[j]=='.'?0:1));
        }
        r.push_back(temp);
        temp.clear();
    }

    for(int i=0; i<M; ++i) {
        for(int j=0; j<N; ++j) {
            temp.push_back(r[j][i]);
        }
        c.push_back(temp);
        temp.clear();
    }

    int ans=0;
    for(int i=0; i<N; ++i) {
        int t=0;
        for(int j=0; j<M; ++j) {
            if(r[i][j]==0) {
                ++t;
                if(t>=D) ++ans;
            } else {
                t=0;
            }
        }
    }

    for(int i=0; i<M; ++i) {
        int t=0;
        for(int j=0; j<N; ++j) {
            if(c[i][j]==0) {
                ++t;
                if(t>=D) ++ans;
            } else {
                t=0;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define MAX_V 100001
const int INF = 1001001001;
int dp[101][MAX_V];

int main(){
  int N,W,w[101],v[101],ans=0;cin>>N>>W;
  REP(i,N) cin>>w[i]>>v[i];
  REP(i,MAX_V) dp[0][i]=(i?INF:0);

  REP(i,N) REP(j,MAX_V){
    if(j-v[i]>=0) dp[i+1][j]=min(dp[i][j-v[i]]+w[i],dp[i][j]);
    else dp[i+1][j]=dp[i][j];
  }

  REP(i,N+1) REP(j,MAX_V) if(dp[i][j]<=W) ans=max(ans,j);  
  cout<<ans<<endl;
}

Measured memory_bytes: 43052
#include <bits/stdc++.h>
#define double long double
#define int long long
#define mi map<int,int>
#define pii pair<int,int>
#define low lower_bound
#define upp upper_bound
#define mod 1000000007 //10^9+7
#define inf (int)50000000000000000 //5･10^16
#define rep(i,n) for(int i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define vsort(vec) sort(all(vec))
#define vrever(vec) reverse(all(vec));
#define vunsort(vec) vsort(vec); vrever(vec);
#define bisea binary_search
#define cend cout<<endl;
#define F first
#define S second
using namespace std;
signed main() {
  int sx,sy,tx,ty;
  cin>>sx>>sy>>tx>>ty;
  rep(i,ty-sy) cout<<"U";
  rep(i,tx-sx) cout<<"R";
  rep(i,ty-sy) cout<<"D";
  rep(i,tx-sx) cout<<"L";
  cout<<"L";
  rep(i,ty-sy+1) cout<<"U";
  rep(i,tx-sx+1) cout<<"R";
  cout<<"D"<<"R";
  rep(i,ty-sy+1) cout<<"D";
  rep(i,tx-sx+1) cout<<"L";
  cout<<"U"<<endl;
}

Measured memory_bytes: 384
from sys import stdin, setrecursionlimit
input = stdin.buffer.readline
setrecursionlimit(10 ** 7)

from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
from collections import deque, defaultdict
from itertools import combinations, permutations, combinations_with_replacement
from itertools import accumulate
from math import ceil, sqrt, pi

MOD = 10 ** 9 + 7
INF = 10 ** 18

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

ST = []
for s, t, x in STX:
    ST.append([s - x, t - x])

start = [[] for _ in range(Q + 1)]
end   = [[] for _ in range(Q + 1)]

for i, (s, t) in enumerate(ST):
    si = bisect_left(D, s)
    ti = bisect_left(D, t)
    start[si].append(STX[i][2])
    end[ti].append(STX[i][2])
#print(start)
#print(end)

end_flag = defaultdict(int)
hp = []

for i in range(Q):
    for ed in end[i]:
        end_flag[ed] += 1
    for st in start[i]:
        heappush(hp, st)
    #print(i, hp)
    while 1:
        if hp:
            tmp = heappop(hp)
            if end_flag[tmp]:
                end_flag[tmp] -= 1
            else:
                print(tmp)
                heappush(hp, tmp)
                break
        else:
            print(-1)
            break

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

int main() {
    long double a, b, x;
    cin >> a >> b >> x;

    long double V = a * a * b;

    if(V / 2 > x) {
        cout << setprecision(9) << 90 - atan((2 * x) / (a * b * b)) * 180 / M_PI
             << endl;
    } else {
        cout << setprecision(9)
             << atan(2 * (a * a * b - x) / (a * a * a)) * 180 / M_PI << endl;
    }

    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); i++)
#define intt int64_t
#define all(vec) vec.begin(), vec.end()
#define MOD 1000000007

int main() {
    int x, a, b;
    scanf("%d %d %d", &x, &a, &b);
    if (b-a > x) printf("dangerous\n");
    else if(a-b >= 0) printf("delicious\n");
    else printf("safe\n");
}


Measured memory_bytes: 256
using	System;

class Program
{
	public static void Main()
	{
		int a,b,c;
		int i;
		int[] m;
		m = new int[10];

		a = 0;
		b = 0;
		c = 0;

		for(i=0;i<10;i++)
		{
			m[i] = int.Parse(Console.ReadLine());

				if(a<m[i])
				{
					c = b;
					b = a;
					a = m[i];
				}
				else if(b<m[i])
				{
					c= b;
					b = m[i];
				}
				else if(c<m[i])
				{
					c = m[i];
				}
		}

		Console.WriteLine("{0}\r\n{1}\r\n{2}",a,b,c);
	}
}

Measured memory_bytes: 9204
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
//桁数指定　cout << fixed << setprecision(2)
int main() {
  int n;
  cin>>n;
  vector<int> v(n);
  vector<int> ans(n);
  rep(i,n){cin>>v[i+1];v[i+1]--;}
  rep(j,n){
    ans[v[j]]++;
  }
  ans[0]--;
  rep(k,n){
  cout<<ans[k]<<endl;
  }
}

Measured memory_bytes: 4844
#include <stdio.h>
int main(void){
 long long int a,b,c,m;
 scanf("%lld%lld%lld",&a,&b,&c);
 m=a;
 if(m<b) m=b;
 if(m<c) m=c;
 if(m%2==0) puts("0");
 else printf("%lld",m==a?b*c:m==b?a*c:a*b);
 return 0;
}

Measured memory_bytes: 128
### 動的計画法
#ABC129C - Typical Stairs
#https://atcoder.jp/contests/abc129/tasks/abc129_c

mod = 10**9+7
n, m = list(map(int,input().split()))
a = [int(input()) for _ in range(m)]
dp = [float("Inf")]*(n+1)
for i in range(m):
    dp[a[i]] = 0
dp[0] = 1
if dp[1] == float("Inf"):
    dp[1] = 1
for i in range(2,n+1):
    if dp[i] == float("Inf"):
        dp[i] = dp[i-1] + dp[i-2]
print(dp[n]%mod)

Measured memory_bytes: 460020
// k - stones...
#include<bits/stdc++.h>
using namespace std;

int main(){
	int n, k;
	scanf("%d%d",&n,&k);
	
	vector < int > num(n);
	for(int &x : num)
		scanf("%d",&x);
	
	/*here k is the number of stones
	 * k will be our dimension of dp */
	vector < bool > dp(k+1,false);
	for(int stones=0; stones<= k ; ++stones){
		for(int x : num){
			if( x <= stones && !dp[stones-x]){
				assert(!dp[stones-x]);
				dp[stones]=true;
				break ;
			}
		}
	}
	// if dp[k] is true , then first is winner ... 
	puts(dp[k]?"First" : "Second");
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
int main(){
  int n,r;
  while(cin>>n>>r,n!=0||r!=0){
  int A[n];
  rep(i,n){
    A[i]=n-i;
  }
  rep(i,r){
    int p,c;
    cin>>p>>c;
    vector<long long> v(c);
    for(int j=p-1;j<p+c-1;j++){
      v[j-(p-1)]=A[j];
    }
    for(int j=p-2;j>=0;j--){
      A[j+c]=A[j];
    }
    for(int j=0;j<c;j++){
      A[j]=v[j];
    }
  }
  cout<<A[0]<<endl;
  }
 return 0;
}

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	int b1=b;
	int q=0;
	int b2=1;
	while(b1!=0)
	{
		q++;
		b1/=10;
		b2*=10;
	}
	a=a*b2+b;
	//cout<<a<<endl;
	for(int i=1;i<=500;i++)
	{
		if(a==i*i)
		{
			//cout<<i<<' '<<a<<endl;
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
}

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

int main() {
    int a, b; cin >> a >> b;
    int c=(a+b)/2;
    if((a+b)%2==0) {
        cout << c << endl;
    }
    else {
        cout << "IMPOSSIBLE" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define limit(x, l, r) max(l, min(x, r))
#define lims(x, l, r) (x = max(l, min(x, r)))
#define isin(x, l, r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)), x.end())
#define show(x) cout << #x << " = " << x << endl;
#define print(x) cout << x << endl;
#define PQ(T) priority_queue<T, v(T), greater<T> >
#define bn(x) ((1 << x) - 1)
#define dup(x, y) (((x) + (y)-1) / (y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int n;
  cin >> n;
  string s, t;
  cin >> s >> t;
  rep(i,n+1){
    string ans = s.substr(0,i)+t;
    if(ans.substr(0,n) == s){
      cout<<sz(ans)<<endl;
      return 0;
    }
  }
  return 0;
}

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

typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const int mod = 1e9+7;

#define pi pair<int,int>
#define pl pair<lld,lld>

#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#define mem0(x) memset(x,0,sizeof(x))
#define fillnum(x,n) fill(begin(x),end(x),n)
#define asort(x) sort(x.begin(),x.end())
#define dsort(x,t) sort(x.begin(),x.end(),greater<t>())
#define vuniq(x) x.erase(unique(x.begin(), x.end()), x.end())

#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)

int main() {
    ll N;
    cin >> N;
    ll cnt = 0;
    for (int i = 1; i <= N; i++) {
        if((i >= 1 && i <= 9) || (i >= 100 && i <= 999) || (i >= 10000 && i <= 99999)){
            cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3552
# 2019/05/31
# AtCoder Beginner Contest 073 - C

# For the answer:
# 累積和してTで飛ばしていく
# - 累積和しないで足し込めばいける気もする // 採用

# Input
n, t = map(int, input().split())
tl = list(map(int, input().split()))

et = t      ### Because  tl[0] == 0
tsum = t

for i in range(1, n):
    if tl[i] >= et:
        tsum += t
    else:
        tsum += tl[i] - tl[i - 1]
    et = tl[i] + t

# Output
print(tsum)


Measured memory_bytes: 26708
using DataStructures
const double = Float64
const int = Int64

parseint(x) = parse(int, x)
readint() = map(parseint, split(readline()))

function main()
  N = readint()[1]

  if N < 600
    println(8)
  elseif N < 800 
    println(7)
    elseif N < 1000
      println(6)
    elseif N < 1200 
      println(5)
    elseif N < 1400
      println(4)
    elseif N < 1600
      println(3)
    elseif N < 1800
      println(2)
    elseif N < 2000
      println(1)
    end
  

end

main()

Measured memory_bytes: 185528
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int D[100];

int main() {
  int N, result;
  int i, j;
  scanf ("%d", &N);
  
  for (i=0;i<N;i++) {
      scanf("%d", &D[i]);
  }
  
  result = 0;
  for (i=0;i<N;i++) {
      for (j=i+1;j<N;j++) {
              result += D[i]*D[j];
      }
  }
  
  
  printf("%d", result);
  return 0;
}




Measured memory_bytes: 128
from sys import stdin
N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]
d_A = sum(A)

d1 = 0
d2 = d_A
delta = 1000000000000
for i in range(0,N):
    d1 += A[i]
    d2 -= A[i]
    if abs(d1 - d2) <= delta:
        delta = abs(d1-d2)
print(delta)

Measured memory_bytes: 26396