akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
int main(){
int x,y,i;
for(i=0;i<=3000;i++){
	cin>>x>>y;
	if(x==0&&y==0)break;
	else if(x<y)cout<<x<<" "<<y<<endl;
	else if(x>y)cout<<y<<" "<<x<<endl;
	else cout<<x<<" "<<y<<endl;
}
return 0;
}


Measured memory_bytes: 2972
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef long long ll;

class team {
public:
    int accept_count;
    int total_time;
    int wrong_answer_count[11];
    int team_id;
    void set_team_id(int id) {
        team_id = id;

    }
    void query(int tId, int pId, int time_, string message) {
        if(message == "WRONG") {
            wrong_answer_count[pId]++;
        }
        else {
            accept_count++;
            total_time += time_;
            total_time += 1200 * wrong_answer_count[pId];
        }

    }
    bool operator< (const team& t) const {
        if(this->accept_count != t.accept_count) {
            return this->accept_count > t.accept_count;
        }
        if(this->total_time != t.total_time) {
            return this->total_time < t.total_time;
        }


        return this->team_id < t.team_id;
    }
};

int T,P,R;

void solve() {
    vector<team> teams(T);
    rep(i,teams.size()) {
        teams[i].set_team_id(i+1);
    }
    rep(i,R) {
        int a,b,c;
        string d;
        cin>>a>>b>>c>>d;
        teams[a-1].query(a,b,c,d);
    }
    sort(all(teams));

    rep(i,teams.size()) {
        cout<<teams[i].team_id<<" "<<teams[i].accept_count<<" "<<teams[i].total_time<<endl;
    }
}
int main() {
    while(cin>>T>>P>>R) {
        if(T+P+R==0) break;
        solve();

    }
    return 0;
}

Measured memory_bytes: 1248
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define sz(x) int(x.size())
using namespace std;
using ll = long long;
using P = pair<int ,int>;
const int INF = 1001001001;
const int MOD = 1000000007;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

#ifdef _DEBUG
#include "debug.h"
#else
#define debug(...)
#define print(...)
#endif

int main() {
    int n; cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    ll ans = 0;
    rep(i, n) {
        // 2つ以上あるなら、a[i]で作れるだけペアを作る
        if (a[i]>=2) {
            ans += a[i]/2;
            a[i] %= 2;
        }
        // 1余ったら、a[i+1]を見る、ペアが作れるなら貪欲に作る
        if (a[i]==1) {
            if (i<n-1 && a[i+1]>0) {
                ans++;
                a[i+1]--;
            }
        }
        debug(i, ans);
    }
    cout << ans << endl;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;
#define ll long long
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, n+1)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define rwhole(x) (x).rbegin(), (x).rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define P pair<ll, ll>
#define debug(var) cerr << "[" << #var << "] " << var << endl
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define pr(s) cout << (s) << '\n'
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};
const int INF = 1001001001;
const ll INFll = 1E+18;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n, x, m;
    cin >> n >> x >> m;
    ll ans = 0;
    vector<P> memo(m, P(-1, -1));
    for (ll i=0; i<n; i++) {
        if (memo[x].second>0) {
            ll loop = i - memo[x].first;
            //debug(loop);
            ll sum_loop = ans - memo[x].second + x;
            ll num = (n-i-1)/loop;
            ans += sum_loop * num;
            i += loop*num;
        }
        else {
            memo[x] = {i, ans+x};
        }
        ans += x;
        x = (x*x)%m;
        if (x==0) break;
    }
    
    pr(ans);
    return 0;
}


Measured memory_bytes: 4764
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);
		int l = sc.nextInt();
		int r = sc.nextInt();
		int d = sc.nextInt();
		sc.close();

		int ans =0;
		for(int i=l;i<=r;i++) {
			if(i%d==0) {
				ans++;
			}
		}
		System.out.println(ans);


	}
}

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

int main() {
	int a,b;
  string op;
  cin >> a >> op >> b;
  
  if(op == "+")
  {
  	cout << a + b << endl;
  }
  else if(op == "-")
  {
  	cout << a - b << endl;
  }
}


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

int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}

main()
{
 /*   int a,b,c;
    scanf("%d%d%d",&a,&b,&c);

    if(a==b){
        if(a!=c){
            printf("Yes");
        }
        else{
            printf("No");
        }
    }
    else{
        if(b==c){
            printf("Yes");
        }
        else{
            printf("No");
        }
    }

*/

   // int data[] = {4, 2, 3, 6, 3, 2, 1, 3, 5, 7};
   // int i;

    //when you use sort
    /*qsort(data, 10, sizeof(int), compare_int);
    for (i = 0; i < 10; i++) {
        printf("%3d", data[i]);
    }
    printf("\n");
    */


    int N,i;
    scanf("%d",&N);
    int A[N];
    for(i=0;i<N;i++){
        scanf("%d",&A[i]);
    }
    for(i=0;i<N;i++){
        if(A[i]%2 == 0){
            if(A[i]%3 == 0){
                continue;
            }
            else if(A[i]%5 == 0){
                continue;
            }
            else{
                printf("DENIED");
                return 0;
            }
        }
    }
    printf("APPROVED");
}


Measured memory_bytes: 128
#include<stdio.h>

int abs(int x)
{
    return x>0?x:-x;
}
int main()
{
    int a,b,c,d;
    while(~scanf("%d%d%d%d",&a,&b,&c,&d))
    {
        if(abs(a-c)<=d)
            puts("Yes");
        else if(abs(a-b)<=d && abs(b-c)<=d)
            puts("Yes");
        else
            puts("No");
    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
#define uint unsigned int
#define inf 0x3f3f3f3f
#define db double
using namespace std;
const int maxn=1e7+10;
int d[2][6], cnt1=0,cnt2=0;
ll a[maxn];
int main() {
	a[0]=0;
	int n;
	cin>>n;
	for(int i=1;i<=n;i++) a[i]=a[i-1]+i;
	ll ans=0;
	for(int i=1;i<=n;i++){
		int t=n/i;
		ans+=(ll)i*a[t];
	}	
	cout<<ans<<endl;
}

Measured memory_bytes: 81752
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ll N,ans=1,a,MOD=1e9+7,i;
	cin >> N;
	priority_queue<pair<ll,ll>> Q;
	for(i=0;i<N;i++)cin>>a,Q.push({-a,-1});
	for(i=0;i<N;i++)cin>>a,Q.push({-a,1});
	a = 0;
	while(!Q.empty()){
		i=Q.top().second;
		if(a!=i*llabs(a))
			(ans*=llabs(a))%=MOD;
		a+=i;Q.pop();
	}
	cout << ans << endl;
}

Measured memory_bytes: 6256
import java.util.*;
/*
Main class for AOJ where there is no input.
*/
public class Main{
   public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      int n = Integer.parseInt(sc.nextLine());
      
      String str = sc.nextLine();
      String[] arr = str.split(" ");
      String s = "";
      
      for(int i = n - 1; i >= 0 ; i--){
         s += arr[i];
         if(i != 0){
            s += " ";
         }
      } 
      System.out.println(s);   
   }//main method 
}//class

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

int main(){
  ll k;
  cin>>k;
  ll cul=0,i;
  for(i=1;i<k+1;i++){
  	cul*=10;
    cul+=7;
    cul%=k;
    if(cul==0){
      	cout<<i<<endl;
      return 0;
    }
  }
  cout<<-1<<endl;
  return 0;
}



Measured memory_bytes: 3676
n = int(input())
a = [int(x) for x in input().split()]
res = "APPROVED"
for x in a:
    if x % 2 == 0:
        if x % 3 == 0 or x % 5 == 0:
            pass
        else:
            res = "DENIED"
            break
print(res)

Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

int main()
{
	int p, q, r;
	std::cin >> p >> q >> r;
	int max = std::max(p, std::max(q, r));
	std::cout << p + q + r - max << '\n';
	return (0);
}

Measured memory_bytes: 3596
/**********************
 * Author: Cloud_     *
 * Date:   06.07.2020 * 
 * Time:   15.45.10   *
 *                    *
***********************/
#include <bits/stdc++.h>
using namespace std;

#define gap " "
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ok cout<<"ok"<<endl
#define dbg(x) cout<<(#x)<<" is "<<x<<endl
#define fastio {ios_base::sync_with_stdio(false);cin.tie(NULL);}

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

const int N=100009;
vector<string> vec;
int row,col,k;
int checkbit(int n,int k) 
{
  return ((n>>k)&1);
}
int fn(int x,int y)
{
	int i,j,cnt=0;
    int visr[12],visc[12];
    for(i=0; i<10; i++) {visr[i]=0; visc[i]=0;}

    for(i=0; i<row; i++)
    {
      visr[i]=checkbit(x,i);
      
    }
    for(i=0; i<col; i++)
    {
    	visc[i]=checkbit(y,i);
    	
    } 	

    for(i=0; i<row; i++)
    {
    	if(visr[i]==1) continue;
    	for(j=0; j<col; j++)
    	{
    		 if(visc[j]==0 && vec[i][j]=='#')
    		 {
               cnt++;
    		 }
    	}
    }
    if(cnt==k) return 1;
    else return 0;
}
int main()
{
  //fastio; 
  string s;
  int i,j,cnt=0,limr,limc;
  cin>>row>>col>>k;
  for(i=0; i<row; i++)
  {
     cin>>s;
     vec.pb(s); 
  }
  limr= 1 << row; limc= 1 << col;
  for(i=0; i<limr; i++)
  {
  	 for(j=0; j<limc; j++)
  	 {
  	   // cout<<fn(i,j)<<endl;
       cnt+=fn(i,j);
  	 }
  }

  cout<<cnt<<'\n';
  return 0;
  
}

Measured memory_bytes: 3580
N = int(input())
A = [int(s) for s in input().split()]

def com(x):
    return int(x * (x - 1) / 2)

data_dict = {}
for x in A:
    if x not in data_dict:
        data_dict[x] = 1
    else:
        data_dict[x] += 1
# print(data_dict)

com_dict = {}
com_sum = 0
for x in data_dict.keys():
    com_dict[x] = com(data_dict[x])
    com_sum += com_dict[x]
# print(com_dict)
# print(com_sum)

result_dict = {}
for x in A:
    if x not in result_dict:
        result_dict[x] = com_sum - com_dict[x] + com(data_dict[x] - 1)
    print(result_dict[x])


Measured memory_bytes: 41108
#include <iostream>
#include <string>
#include <vector>
#include <algorithm> // sort
#include <map> // pair
#include <queue>
#include<iomanip>
#include <cmath>
#include <set>
#include <unordered_set>

#define ABS(x) ((x)>0?(x):-(x))
#define MIN(x,y) ((x)>(y)?(y):(x))
#define MAX(x,y) ((x)<(y)?(y):(x))

#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

#define INF 1000000000

using namespace std;
typedef long long ll;

ll newton(long long int a, long long int  b)
{
	if(a==b)
		return a;
	while(a != 0 && b != 0)
	{
		if(a > b)
		{
			b += a;
			a = b-a;
			b -= a;
		}
		b %= a;
	}
	return a;
}

struct UnionFind {
	vector<int> p;
	UnionFind(int N):p(N)
	{
		for(int i=0; i< N; i++)
		{
			p[i] = i;
		}
	}
	int root(int x)
	{
		if(p[x] == x)
			return x;
		return p[x] = root(p[x]);
	}
	void unite(int x, int y)
	{
		int rx = root(x);
		int ry = root(y);
		if(rx == ry) return;
		p[rx] = ry;
	}
	bool issame(int x, int y)
	{
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};

//大きな数に対する割り算をするとき、MODを指定することで掛け算の値に変換できる

ll div2mul_calc(ll a, ll b, ll m)
{
	if (b == 0) {
        return 1;
    } else if (b % 2 == 0) {
        ll d = div2mul_calc(a, b / 2, m);
        return (d * d) % m;
    } else {
        return (a * div2mul_calc(a, b - 1, m)) % m;
    }
}
ll div2mul(ll n, ll mod)
{
	return div2mul_calc(n, mod-2, mod);
}

ll twoRow(ll a, ll b, ll mod)
{
	ll ret = 1;
	for(ll i = 1 ;i <= a+b;++i)
	{
		ret *= i;
		ret %= mod;
	}
	for(ll i = 1 ;i <= a;++i)
	{
		ret *= div2mul(i,mod);
		ret %= mod;
	}
	for(ll i = 1 ;i <= b;++i)
	{
		ret *= div2mul(i,mod);
		ret %= mod;
	}
	return ret;
}

struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};

vector< ll > divisor(ll n) {
  vector< ll > ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(ret.begin(), ret.end());
  return (ret);
}
/*
*/

int main()
{
	ll i,j,k;
	ll N;
	vector<ll> v;
	ll mp[2560] = {0};

	cin>>N;
	for(i=0;i<N;++i)
	{
		cin >> j;
		v.push_back(j);
	}
	for(i=0;i<N;++i)
	{
	for(j=0;j<=v[i];++j)
	{
		mp[j] ++;
	}
	}
	ll mx,mn,ans=0;
	for(i=0;i<N;++i)
	{
		for(j=i+1;j<N;++j)
		{
			mn = MAX(v[i],v[j])-MIN(v[i],v[j])+1;
			mx = v[i]+v[j];
			ans += mp[mn]-mp[mx];
			if(mn<=v[i]&&v[i]<mx)
				ans --;
			if(mn<=v[j]&&v[j]<mx)
				ans --;
		}
	}
	cout << ans/3 << endl;
	return 0;
}




















Measured memory_bytes: 256
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXLEN=200000;

char s[MAXLEN+1]; int n;

int dp[MAXLEN+1]; // dp[i] = x -> we can make all string of length x starting at i
int mask[MAXLEN+1]; // if bit j in mask[i] is set we cannot make at least one string of length dp[i]+1 starting with j


char ret[MAXLEN+1]; int nret;

void run() {
	scanf("%s",s); n=strlen(s);

	dp[n]=0; mask[n]=(1<<26)-1;
	for(int i=n-1;i>=0;--i) {
		int nmask=mask[i+1]&~(1<<(s[i]-'a'));
		if(nmask==0) dp[i]=dp[i+1]+1,mask[i]=(1<<26)-1; else dp[i]=dp[i+1],mask[i]=nmask;
	}
	//REPE(i,n) { printf("%2d: %c %d ",i,s[i],dp[i]); REP(j,26) printf("%c",((mask[i]>>j)&1)?'X':'.'); puts(""); }

	nret=0;
	for(int at=0;at<n;) {
		int j=0; while(((mask[at]>>j)&1)==0) ++j;
		ret[nret++]='a'+j;
		while(at<n&&s[at]!='a'+j) ++at;
		++at;
	}
	ret[nret]='\0';
	printf("%s\n",ret);
}

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


Measured memory_bytes: 2048
#include<iostream>

using namespace std;

int main(){
  int A, B, C;
  int ans = 0;
  cin >> A >> B >> C;

  if(B >= C){
    ans = B + C;
  }else{
    if(A+B >= C){
      ans = B + C;
    }else{
      ans = A + 2*B + 1;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
const ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a[ohara], b, c, d, tmp, m, h, w, x, y, sum[ohara], k, q;
ll fr[ohara], ba[ohara];

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

  cin >> n >> k;
  rep(i, n) {
    cin >> a[i];
    sum[i] = a[i];
    if (a[i] > 0) fr[i] = a[i], ba[i] = a[i];
  }
  rrep(i, 1, n) {
    sum[i] += sum[i - 1];
    fr[i] += fr[i - 1];
  }
  rrrep(i, n - 2, 0) { ba[i] += ba[i + 1]; }
  rep(i, n - k + 1) {
    cnt = sum[i + k - 1];
    if (i - 1 >= 0) cnt -= sum[i - 1];
    cnt = max(cnt, 0LL);
    cnt += ba[i + k];
    if (i - 1 >= 0) cnt += fr[i - 1];
    ans = max(ans, cnt);
  }
  Cout(ans);

  return 0;
}

Measured memory_bytes: 11264
#include <bits/stdc++.h>
#define ld long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define rep(i,l,r) for(int i = (int)l;i<(int)r;i++)
#define td(v) v.begin(),v.end()
#define sz(v) (int)v.size()
//#define M   1000000007 // 1e9 + 7
#define int long long
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
inline ll mod(ll n, ll m){ ll ret = n%m; if(ret < 0) ret += m; return ret; }
ll gcd(ll a, ll b){return (b == 0LL ? a : gcd(b, a%b));}
ll exp(ll a,ll b,ll m){
    
    if(b==0LL) return 1LL;
    if(b==1LL) return mod(a,m);
    ll k = mod(exp(a,b/2,m),m);
    if(b&1LL){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);
}


int32_t main(){
  fastio;
  int a,b;
  string s,t;
  cin>>s>>t;
  cin>>a>>b;
  string u;
  cin>>u;
  if(u==s)a--;
  else b--;
  cout <<a <<" "<<b <<endl;
  // Math -> gcd it all
  // Did u check N=1? Did you switch N,M?
}

Measured memory_bytes: 256
#include <stdio.h>

using namespace std;

int main(){
	char str[20001];
	int m,tmp,length;
	while(true){
		scanf("%s",str);
		if(str[0] == '-') break;
		length = 0;
		for(int k = 0; str[k] != '\0';k++) length++;
		scanf("%d",&m);
		int index = 0;
		for(int i = 0; i < m; i++){
			scanf("%d",&tmp);
			for(int j = 0; j < tmp; j++){
				str[index+length] = str[index];
				index++;
			}
		}
		for(int p = 0; p < length; p++){
			printf("%c",str[index+p]);
		}
		printf("\n");
	}
}


Measured memory_bytes: 2588
import math

N = int(input())
A = list(map(int, input().split()))
C = [0] * (10 ** 6 + 1)

for i in range(N):
    C[A[i]] += 1

is_pairwise = True
max_a = max(A) + 1
X = [0] * max_a
for i in range(2, max_a):
    count = 0
    for j in range(i, max_a, i):
        count += C[j]
    if count > 1:
        is_pairwise = False

if is_pairwise:
    print('pairwise coprime')
    exit()

tmp = A[0]
for i in range(1, N):
    tmp = math.gcd(tmp, A[i])

if tmp == 1:
    print('setwise coprime')
else:
    print('not coprime')


Measured memory_bytes: 197012
N, C, K = map(int, input().split())
T = [int(input()) for _ in range(N)]
T.sort()

first = T[0]
count = 0
res = 0
for i in range(N):
    if count < C and T[i] <= first + K:
        count += 1
    else:
        res += 1
        first = T[i]
        count = 1
print(res + 1)


Measured memory_bytes: 50264
#include<iostream>
using namespace std;
int main(){
  int x[10000][2];
  int num=0;
  int c=1;
  while(1){
    cin>>x[num][0]>>x[num][1];
    if(x[num][0]==0&&x[num][1]==0){
      break;
    }
    num++;
  }
  for(int a=0;a<num;a++){
    if(x[a][0]>x[a][1])
    cout<<x[a][1]<<" "<<x[a][0]<<'\n';
    else
    cout<<x[a][0]<<" "<<x[a][1]<<'\n';
  }
  return 0;
}

Measured memory_bytes: 2992
#include <bits/stdc++.h>
 
using namespace std;
inline void prep ()
{
  cin.tie (0);
  cin.sync_with_stdio (0);
};
const double pi = acos(-1.);
//printf(%.12lf\n,mid);
// __builtin_popcount(int) count 1's in binary
// get decimal part of number
/*
double intpart;
double thiss = modf((double)(n*m)/(double)k, &intpart);
*/
// round = (int)(num+.5)
long long mod = 1000000007;
 
// 32 mil = ~1 sec 
long long mymod(long long num){
  if (num< 0 && !(num%mod == 0)){
    if (mod == 1){
      return 0;
    }
    return mod-abs(num)%mod;
  }else{
    return num%mod;
  }
}
 
/*string sentence = And I feel fine...;
    istringstream iss(sentence);
*/  
 
double eps = .000000001;

double distt(pair<double, double> a, pair<double, double> b){
    return sqrt(pow(a.first-b.first, 2)+pow(a.second-b.second, 2));
}
int n;
pair<double, double> arr[1000];

int main ()
{
  prep();
  
  cin >> n;
  
  for (int i=0; i<n; i++){
      double a, b;
      cin >> a >> b;
      arr[i] = {a, b};
  }
  // from https://www.youtube.com/watch?v=WGOSX6d17TU
  double dist = 1;
  double cx = 0;
  double cy = 0;
  for (int i=0; dist > eps; i++){
      for (int j=0; j<100; j++){
          double maxest = 0;
          int ind = 0;
          for (int j=0; j<n; j++){
              double cur = distt(arr[j], {cx, cy});
              if (cur > maxest){
                  maxest = cur;
                  ind = j;
              }
          }
          double diffx = arr[ind].first-cx;
          double diffy = arr[ind].second-cy;
          cx = cx+diffx*dist;
          cy = cy+diffy*dist;
          
          //cout << cx << " " << cy << endl;
      }
      dist *= .5;
  }

  //cout << cx << " " << cy;
  double rad = 0;
  for (int i=0; i<n; i++){
      rad = max(rad, distt({cx, cy}, arr[i]));
  }
  printf("%.7lf", rad);
  return 0; 
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a;
    cin >> a;
    vector<int> b(a);
    for(int i = 0; i < a; i++){
        cin >> b[i];
    }
    for(int i = a - 1; 0 < i; i--){
        if(b[i] >= b[i - 1])
        {

        }
        else if(b[i] + 1 == b[i - 1]) {
            b[i - 1]--;
        }
    else
    {
        cout << "No" << endl;
        return 0;
    }
    
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 640
// includes, macros {{{
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <climits>
#include <cassert>
#include <functional>
#include <numeric>
#include <limits>
using namespace std;

#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)

#define rep(i, s, e)    for (int i = (s); i < (int)(e); i++)
//#define PB(e) push_back(e)
//#define MP(a, b) make_pair(a, b)

// for debug
#define kita            cout << "kita\n"
#define print2(i, n)    cout << (i) << ": " << (n) << endl
#define print3(i, j, n)     cout << "(" << (i) << ", " << (j) << ") : " << (n) << endl
#define print4(i, j, n, m)  cout << "(" << (i) << ", " << (j) << ") : " << (n) << ", " << (m) << endl
#define print_mat(mat, h, w) for(int i=0;i<(h);i++){for(int j=0;j<(w);j++){cout << mat[i][j] << " ";}cout << endl;}
 
typedef long long ll;
typedef unsigned long long ull; // }}}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os, const map<T,U>& mp){ os << "{"; for(auto& p : mp){ os << p << ","; } os << "}"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int,int>;
using vi = std::vector<int>;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int main(){
    int a,b,c; cin >> a >> b >> c;

    cout << max(0,c-(a-b)) << endl;
}


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

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

  for (size_t i = 0; i <= K; i++) {
    int _C = C; 
    for (size_t j = 0; j <= K; j++) {
      if (A < B and B < _C and i + j <= K) {
        cout << "Yes";
        return 0;
      }
      _C = _C * 2;
    }
    B = 2*B;
  }

  cout << "No";

  return 0;
}


Measured memory_bytes: 3648
#include <iostream>

int main() {
    int A, B;
    std::string S;
    std::cin >> A >> B >> S;
    if (S.size() == A + B + 1 && S[A] == '-') {
        try {
            std::stoi(S.substr(0, A));
        } catch (...) {
            std::cout << "No" << std::endl;
            return 0;
        }

        try {
            std::stoi(S.substr(A + 1));
        } catch (...) {
            std::cout << "No" << std::endl;
            return 0;
        }

        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No" << std::endl;
    }
    return 0;
}


Measured memory_bytes: 384
n = gets.to_i
a = gets.split.map(&:to_i)

SENTINEL = 2000000000
$cnt = 0

def merge(a, left, mid, right)
  n1 = mid - left
  n2 = right - mid
  l = []
  r = []

  (0...n1).each do |i|
    l[i] = a[left + i]
  end
  (0...n2).each do |i|
    r[i] = a[mid + i]
  end

  l[n1] = r[n2] = SENTINEL
  i = j = 0

  (left...right).each do |k|
    $cnt += 1

    if l[i] <= r[j]
      a[k] = l[i]
      i += 1
    else
      a[k] = r[j]
      j += 1
    end
  end
end

def merge_sort(a, left, right)
  if left+1 < right
    mid = (left + right) / 2
    merge_sort(a, left, mid)
    merge_sort(a, mid, right)
    merge(a, left, mid, right)
  end
end

merge_sort(a, 0, n)
puts a.join(' ')
puts $cnt


Measured memory_bytes: 60700
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <climits>
#include <numeric>
#include <cmath>
#include <queue>
#include <sstream>
#include <string.h>
#include <bitset>
#include <stack>

using namespace std;
typedef long long ll;

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec[i];
  }
  
  int ans = 0;
  int minc = min(K, N);
  for (int l = 0; l <= minc; l++) {
    for (int r = 0; r <= minc - l; r++) {
      int tmp  = 0;
      vector<int> minus;
      for (int i = 0; i < l; i++) {
        tmp += vec[i];
        if (vec[i] < 0) {
          minus.push_back(vec[i]);
        }
      }
      for (int i = 0; i < r; i++) {
        tmp += vec[N - 1 - i];
        if (vec[N - 1 - i] < 0) {
          minus.push_back(vec[N - 1 - i]);
        }
      }
      sort(minus.begin(), minus.end());
      int m = min(K - l - r, (int)minus.size());
      for (int i = 0; i < m; i++) {
        tmp -= minus[i];
      }
      ans = max(ans, tmp);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
N=int(input())
a=[]
for i in range(N):
    a.append(list(map(int,input().split())))
a.sort(key=lambda x:x[1])
check=0
sum=0
for i in range(N):
    sum+=a[i][0]
    if sum>a[i][1]:
        check+=1
if check>0:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 53720
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<sstream>
#include<string>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main(){
    int n, k;
    cin >> n >> k;
    vector<ll> x(n);
    rep(i, n) {
        cin >> x[i];
    }

    ll ans = 1e18;
    rep(i, n - k + 1) {
        ll l = x[i];
        ll r = x[i+k-1];
        ans = min(ans, abs(r)+abs(r-l));
        ans = min(ans, abs(l)+abs(r-l));
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define ll long long
using namespace std;

const ll mod = 1e9 + 7;

ll C[2005][2005];
ll dp[100005][13];


int main(){
    int K,X;
    cin >> K>>X;
    if(500*K >= X) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int K,N;
  cin >> N >> K;
  
  vector<int>A(N);
  vector<int>B(N,0);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
    B.at(A.at(i)-1)++;
  }
  sort(B.begin(), B.end());
  reverse(B.begin(), B.end());
  
  int count0 = 0;
  for (int i = 0; i < N; i++) {
    if (B.at(i) == 0){
      count0++;
    }
  }
  int M = N - count0 - K;
  
  int count1 = 0;
  reverse(B.begin(), B.end());
  for (int i = count0; i < count0+M; i++) {
    count1 += B.at(i);
  }
  cout << count1 << endl;
}
  
      

Measured memory_bytes: 4840
n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
s = 0
for i in range(n):
  if a[i] + a[i+1] <= b[i]:
    s += a[i] + a[i+1]
    a[i+1] = 0
  elif a[i] + a[i+1] > b[i] and a[i] <= b[i]:
    s += b[i]
    a[i+1] -= b[i] - a[i]
  elif a[i] > b[i]:
    s += b[i]
print(s)
    
    

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

#define fi first
#define se second
#define pb push_back
#define sz(a) (int)(a).size()
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;

const ll MOD = 1e9 + 7;
const ll INF = 1e18;
const ll IINF = INT_MAX;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, d;
    ll a;
    cin >> n >> d >> a;
    vector<pll> xh(n);
    for (int i = 0; i < n; i++) {
        cin >> xh[i].fi >> xh[i].se;
    }
    sort(xh.begin(), xh.end());
    ll ans = 0;
    vll psum(n + 5, 0);
    for (int i = 0; i < n; i++) {
        if (i) psum[i] += psum[i - 1];
        if (xh[i].se - (psum[i] * a) > 0) {
            int l = i, r = n  - 1, m, id = -1;
            while (l <= r) {
                m = (l + r) / 2;
                if (xh[m].fi <= xh[i].fi + 2 * d) {
                    id = m;
                    l = m + 1;
                } else {
                    r = m - 1;
                }
            }
            if (id == -1) id = i;

            ll rem = (xh[i].se - psum[i] * a);
            psum[i] += (rem + a - 1) / a;
            psum[id + 1] -= (rem + a - 1) / a;
            ans += (rem + a - 1) / a;
        }
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
    using namespace std;
    #define ll long long int
    #define MOD 1000000007ll
    #define pb push_back
    #define vl vector<ll>
    #define pll pair<ll,ll>
    #define mp make_pair
    using namespace std; 
    ll gcdExtended(ll a, ll b, ll *x, ll *y); 
      
    // Function to find modulo inverse of a 
    ll modInverse(ll a, ll m) 
    { 
        ll x, y; 
        ll g = gcdExtended(a, m, &x, &y); 
        if (g != 1) 
            cout << "Inverse doesn't exist"; 
        else
        { 
            // m is added to handle negative x 
            ll res = (x%m + m) % m; 
            return  res; 
        } 
    } 
      
    // C function for extended Euclidean Algorithm 
    ll gcdExtended(ll a, ll b, ll *x, ll *y) 
    { 
        // Base Case 
        if (a == 0) 
        { 
            *x = 0, *y = 1; 
            return b; 
        } 
      
        ll x1, y1; // To store results of recursive call 
        ll gcd = gcdExtended(b%a, a, &x1, &y1); 
      
        // Update x and y using results of recursive 
        // call 
        *x = y1 - (b/a) * x1; 
        *y = x1; 
      
        return gcd; 
    } 
    ll power(ll x, ll y, ll p) 
    { 
        ll res = 1;      // Initialize result 
        x = x % p;  // Update x if it is more than or 
                    // equal to p 
        while (y > 0) 
        { 
            // If y is odd, multiply x with result 
            if (y & 1) 
                res = (res*x) % p; 
      
            // y must be even now 
            y = y>>1; // y = y/2 
            x = (x*x) % p; 
        } 
        return res; 
    } 
    ll nCr(ll n,ll r,ll m)
    {
        ll res = 1;
        for (ll i = 1; i <= r; ++i)
        {
            res = (res*(n-i+1)%MOD)*modInverse(i,MOD);
            res%=MOD;
        }
        return res;
    }
    int main()
    {
        ll n,a,b;
        cin>>n>>a>>b;
        cout<<(power(2,n,MOD)-nCr(n,a,MOD)-nCr(n,b,MOD)-1+MOD+MOD+MOD)%MOD<<endl;
    }

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        char c = sc.next().toCharArray()[0];
        int B = sc.nextInt();

        
        if(c=='+'){
        System.out.println(A+B);  
        }else{
        System.out.println(A-B);     
        }
    }
}

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



int main(){
	
	int n;
	cin >> n;
	int ans= 0;
	int a[2][n];
	vector<int> row(2,0);
	for(int i = 0; i < 2; i++)
	{
		for(int j = 0; j < n; j++)
		{
			cin >> a[i][j];
			if(i == 1) row[1] += a[1][j];
		}		
	}
	
	for(int i = 0; i < n; i++)
	{
		row[0] += a[0][i];
		ans = max(ans, row[0] + row[1]);
		row[1] -= a[1][i];
	}
	

	
	cout << ans << endl;

	return 0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define BIT(X, i) ((X>>i)&1)
#define REP(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
#define r_all(a) (a).rbegin(), (a).rend()
#define in(x) cin>>x
#define ina(x, n) rep(x_i,n) cin>>x[x_i]
#define outa(x, n) rep(x_i,n) cout<<x[x_i]<<" \n"[x_i==n-1]

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> pll;
typedef vector<pll> vll;
typedef priority_queue<ll> pq;

const int MOD = 1e9+7;
const int INF = (1<<30);
const ll INFL = (1L<<62);

ll f(ll x) {
  ll res = 0;
  for (ll i = x/4*4; i <= x; i++) {
    // cout << i << endl;
    res ^= i;
  }
  return res;
}

int main() {
  ll a, b; cin >> a >> b;
  if (!a) a++;
  // f(b);
  cout << (f(b)^f(a-1)) << endl;
  return 0;
}


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


void solve(long long N, std::vector<long long> A){
  long long count = 0;
  vector<long long> tab(N);
  map<long long, long long> counts;
  tab[0] = A[0];
  counts[A[0]]++;
  for(long long i = 1; i < N; i++){
    tab[i] = tab[i-1] + A[i];
    counts[tab[i]]++;
  }

  long long acc = 0;
  for(auto x: counts){
    acc += ((x.second <= 1) ? 0 : ((x.second*(x.second-1))/2));
  }
  acc += counts[0];

  cout << acc << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
  scanf("%lld",&N);
  std::vector<long long> A(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&A[i]);
  }
    solve(N, std::move(A));
    return 0;
}


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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

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


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;
  cin >> n;
  string s;
  cin >> s;
  ll ans = 0;
  rep(i, n - 2) {
    if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
using System;

public class AtCoder
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());

        int[] nums = new int[n];
        var line = Console.ReadLine();
        var lineWords = line.Split(' ');
        for (int i = 0; i < n; i++)
        {
            nums[i] = int.Parse(lineWords[i]);
        }

        int answer = 0;

        int min = int.MaxValue;
        for (int i = 0; i < n; i++)
        {
            int now = nums[i];
            if (now < min)
            {
                min = now;
                answer++;
            }
        }

        Console.WriteLine(answer);
    }
}

Measured memory_bytes: 29404
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <algorithm>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

bool comp(tuple<int, int, int>& x, tuple<int, int, int>& y){
    int x_i = get<0>(x);
    int y_i = get<0>(y);
    int x_a = get<1>(x);
    int y_a = get<1>(y);
    int x_t = get<2>(x);
    int y_t = get<2>(y);

    if(x_a != y_a){
        return x_a > y_a;
    }

    if(x_t != y_t){
        return x_t < y_t;
    }

    return x_i > y_i;
}

signed main(){
    while(true){
        int M, T, P, R;
        cin >> M >> T >> P >> R;

        if(M == 0 && T == 0 && P == 0 && R == 0){
            break;
        }

        vector<vector<int>> res(T+1, vector<int>(P+1));
        vector<vector<bool>> ac(T+1, vector<bool>(P+1, false));
        vector<int> time(T+1);

        rep(i, R){
            int m, t, p, j;
            cin >> m >> t >> p >> j;

            if(j == 0){
                ac[t][p] = true;
                time[t] += m;
                continue;
            }
            res[t][p]++;
        }

        vector<tuple<int, int, int>> rank;
        for(int i = 1; i <= T; i++){
            int pena = 0;
            int AC = 0;
            for(int j = 1; j <= P; j++){
                if(ac[i][j]){
                    pena += res[i][j];
                    AC++;
                }
            }
            pena *= 20;

            rank.emplace_back(i, AC, time[i] + pena);
        }
        sort(rank.begin(), rank.end(), comp);

        rep(i, T-1){
            int r = get<0>(rank[i]);
            int x_a = get<1>(rank[i]);
            int y_a = get<1>(rank[i+1]);
            int x_t = get<2>(rank[i]);
            int y_t = get<2>(rank[i+1]);

            if(x_a != y_a || x_t != y_t){
                cout << r << ",";
            }else{
                cout << r << "=";
            }
        }
        cout << get<0>(rank[T-1]) << endl;

    }

    return 0;
}



Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    ll n, d[1000006] = {}, c = 0;
    cin >> n;
    d[0] = 1; d[1] = n; d[2] = n * n % mod; c = n - 1;
    for (int i = 3; i <= n; i++) {
        c = (c + d[i - 3] - 1) % mod;
        d[i] = (d[i - 1] + (n - 1) * (n - 1) + c) % mod;
    }
    cout << d[n] << '\n';
}


Measured memory_bytes: 8064
#include <cstdio>
#include <cmath>

using namespace std;

int main()
{
	int a, l, x;
	
	while (scanf("%d %d %d", &a, &l, &x) == 3){
		double s1 = (a + 2 * l) / 2.0;
		double s2 = (x + 2 * l) / 2.0;
		double m = (l + x) / 2.0;
		
		s1 = sqrt(s1 * (s1 - a) * (s1 - l) * (s1 - l));
		s2 = 2 * sqrt(s2 * (s2 - m) * (s2 - m) * (s2 - l));
		
		printf("%lf\n", s1 + s2);
	}
	
	return (0);
}

Measured memory_bytes: 1064
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <queue>
#include <string>
using namespace std;

typedef long long ll;
typedef unsigned long long u_ll;

int N;
ll ans = 1;
string S;

int main() {
	cin >> N >> S;
	int i = 0;
	while (i < N-1) {
		ans += 1;
		if (S[i] == S[i + 1]) {
			ans -= 1;
		}
		i++;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 512
using System;

class Program
{
    static void Main(string[] args)
    {
        string[] st = Console.ReadLine().Split(' ');
        int a = int.Parse(st[0]);
        int b = int.Parse(st[1]);

        if (a >= 13) Console.WriteLine(b);
        else if (a <= 5) Console.WriteLine(0);
        else Console.WriteLine(b / 2);
    }
}

Measured memory_bytes: 13140
#include<stdio.h>
int main()
{
    char s[4];
    int i,count=0;
    scanf("%s",&s);
    for(i=0; i<3; i++)
    {
        if(s[i]=='7')
            count++;
    }
    if(count==0)
    {
        printf("No\n");
    }
    else
    {
        printf("Yes\n");
    }
    return 0;
}


Measured memory_bytes: 1644
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for (int i = (a); i <= (b); ++ i)
#define rrp(i,a,b) for (int i = (a); i >= (b); -- i)
#define gc() getchar()
#define fir first
#define sec second
typedef pair<int,int> pii;
typedef double db;
typedef long long ll;
template <typename tp>
inline void read(tp& x) {
  x = 0; char tmp; bool key = 0;
  for (tmp = gc(); !isdigit(tmp); tmp = gc())
    key = (tmp == '-');
  for (; isdigit(tmp); tmp = gc())
    x = (x << 3) + (x << 1) + (tmp ^ '0');
  if (key) x = -x;
}
template <typename tp>
inline void ckmn(tp& x,tp y) {
  x = x < y ? x : y;
}
template <typename tp>
inline void ckmx(tp& x,tp y) {
  x = x < y ? y : x;
}

const int N = 100010;
int n, s, x[N], m;
ll p[N];
pair<int,ll> solve(int l,int r) {
  if (l > m) return make_pair(x[r], x[r] - s);
  if (r <= m) return make_pair(x[l], s - x[l]);
  if (p[r] <= p[l]) {
    p[l] += p[r];
    pair<int,ll> tmp = solve(l, r-1);
    return make_pair(x[r], tmp.sec + x[r] - tmp.fir);
  } else {
    p[r] += p[l];
    pair<int,ll> tmp = solve(l+1, r);
    return make_pair(x[l], tmp.sec + tmp.fir - x[l]);
  }
}
int main() {
  read(n), read(s);
  rep (i, 1, n)
    read(x[i]), read(p[i]);
  m = 0;
  while (x[m+1] < s && m < n) ++ m;
  cout << solve(1, n).sec << endl;
  return 0;
}


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

int main(){
  int N, K;
  cin>>N>>K;
  string S;
  cin>>S;
  
  if(S.at(K-1)=='A'){
    S.at(K-1) = 'a';
  }
  else if(S.at(K-1)=='B'){
    S.at(K-1) = 'b';
  }
  else if(S.at(K-1)=='C'){
    S.at(K-1) = 'c';
  }
  cout<<S<<endl;
}

Measured memory_bytes: 3564
#include<iostream>
using namespace std; // 575

int main() {
	string S;
	cin >> S;
	int ans[2] = {0, 0};
	for (int i = 0;i < S.size();++ i) ++ ans[(S[i] + i) & 1];
	cout << min(ans[0], ans[1]);
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

最終系は010101…か101010…なので、どっちがより変える数が少ないか数えておけばいい

*/

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

int x, k;
int main(){
  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
 // freopen("in.txt", "r", stdin);
#endif // ONLINE_JUDGE
  cin >> k >> x;
  --k;
  for(int i = max(-1000000, x - k); i <= min(1000000, x + k); ++i)
    cout << i << ' ';
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define lson o<<1
#define rson o<<1|1
#define CLR(A, X) memset(A, X, sizeof(A))
using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
const double eps = 1e-10;
int dcmp(double x){if(fabs(x)<eps) return 0; return x<0?-1:1;}
const int N = 1e5+5;
const int INF = 0x3f3f3f3f;

bool prime[N];
int a[N];

int main() {
    int n, k, x;
    scanf("%d%d", &n, &k);
    bool flag = 0;
    for(int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
        if(a[i] == k) flag = 1;
    }
    sort(a, a+n);
//    if(flag) puts("POSSIBLE");
    if(k > a[n-1]) puts("IMPOSSIBLE");
    else {
        CLR(prime, 0);
        for(int i = 2; i < N; i++) if(!prime[i]) {
            for(int j = i+i; j < N; j += i) prime[j] = 1;
        }
        bool prm = 1;
        for(int i = 2; i < N; i++) if(!prime[i]) {
            if(a[0]%i == 0) {
                prm = 0;
                bool ok = 1;
                for(int j = 0; j < n; j++) {
                    if(a[j]%i != 0) {
                        ok = 0;
                        break;
                    }
                }
                if(ok && k%i!=0) { puts("IMPOSSIBLE"); return 0; }
            }
//            else if(k%i == 0) { puts("IMPOSSIBLE"); return 0; }
        }
        if(prm) {
            bool ok = 1;
            for(int j = 0; j < n; j++) {
                if(a[j]%a[0] != 0) {
                    ok = 0;
                    break;
                }
            }
            if(ok && k%a[0]!=0) { puts("IMPOSSIBLE"); return 0; }
        }
        puts("POSSIBLE");
    }
    return 0;
}


Measured memory_bytes: 768