akhauriyash/Code-Regression huggingface dataset:
#![allow(non_snake_case)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use itertools::*;
use proconio::marker::Usize1;
use proconio::{fastout, input};
use std::vec::*;

macro_rules! echo {
  {$x:expr} => {println!("{}", $x)}
}

macro_rules! chmax {
  {$x:expr, $y:expr} => {
    $x = std::cmp::max($x, $y)
  }
}

macro_rules! chmin {
  {$x:expr, $y:expr} => {
    $x = std::cmp::min($x, $y)
  }
}

#[allow(unused_variables)]
#[fastout]
fn main() {
  let n: usize;
  let m: usize;
  let ps: Vec<usize>;
  input! {
    n: usize,
    m: usize,
    ps: [Usize1; m*2]
  }
  let mut nanachi = vec![0; n];
  for p in ps {
    nanachi[p] += 1;
  }
  echo!(if nanachi.iter().all(|&x| x % 2 == 0) {
    "YES"
  } else {
    "NO"
  });
}


Measured memory_bytes: 5180
#include "bits/stdc++.h"
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long int
#define int ll
//#define slld(t) scanf("%lld",&t)
//#define sd(t) scanf("%d",&t)
//#define pd(t) printf("%d\n",t)
//#define plld(t) printf("%lld\n",t)
#define vec vector < int >
#define vecp vector < pair < int , int > >
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define pii pair < int , int >
#define pll pair < ll , ll > 
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define mod  1000000007
#define N   200005
#define MAX 300005
#define mod1 1000000007
#define mod2 998244353
#define bitcnt __builtin_popcountll
#define PI acos(-1)
//#define endl "\n"
#define inf 1e+15
multiset <int > s;
signed main(){
  fast;
  int n; cin >> n;
  int x;
  for(int i = 1 ; i<= n ; i++){
  	   cin >> x;
  	   auto it = s.upper_bound(x-1);
  	   if(it == s.begin()){
  	      s.insert(x);
  	      continue;
  	   }
       else 
  	     it--;

  	  s.erase(it);
  	  s.insert(x);

  }

  cout << s.size() << endl;


}
  


Measured memory_bytes: 4992
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#define nmax_def 110000
#define Cmax_def 2200
#define mod 1000000007
using namespace std;
typedef long long ll;

int main() {
	ll i, j;
	ll N;
	ll a[nmax_def];
	cin >> N;
	bool ans = true;
	bool ans1 = true;
	for (i = 0; i < N; i++)
	{
		cin >> a[i];
		if (a[i] != 0)
			ans1 = false;
	}
	sort(a, a + N, less <ll>());
	if (ans1)
		ans = true;
	else
	{
		if (N % 3 != 0)
			ans = false;
		else
		{
			int M = N / 3;
			for (i = 1; i < M; i++)
			{
				if (a[0] != a[i])
					ans = false;
				else if (a[M] != a[i + M])
					ans = false;
				else if (a[2 * M] != a[i + 2 * M])
					ans = false;
			}
			if (ans)
			{
				ll b[3];
				for (i = 0; i < 40; i++)
				{
					ll sum = 0;
					for (j = 0; j < 3; j++)
					{
						b[j] = (a[j * M] >> i) % 2;
						if (b[j] == 1)
							sum++;
					}
					if (sum == 1 || sum == 3)
						ans = false;
				}
			}
		}
	}
	if (ans)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(30);
#define ll long long
#define ld long double
#define pi 3.14159265359
using namespace std;

int main()
{
    IOS;
    ld n,a,s=1;
    cin>>n;
    while(n--){
        cin>>a;
        if(a==0) return cout<<0,0;
        s*=a;
    }
    if(s>(pow(10,18))) return cout<<-1,0;
    cout<<s;
    return 0;
}


Measured memory_bytes: 3812
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[n+5],q;
	memset(a,0,sizeof(a));
	while(cin>>q)
	{
		if(getchar()=='\n')
		{
			a[q]++;
			break;
		}
		
		a[q]++;
	}
	for(int i=1;i<=n;i++)
	{
		cout<<a[i]<<endl;
	}
}

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

int main()
{
  string S, T;
  cin >> S >> T;
  
  int count = 0;
  for(int i = 0; i < S.size(); i++)
  {
    if(S.at(i) == T.at(i))
      count++;
  }
  cout << count << endl;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a.at(i);
  reverse(ALL(a));
  multiset<int> ans;
  rep(i, n){
    auto itr = ans.upper_bound(a.at(i));
    if(itr != ans.end()) ans.erase(itr);
    ans.insert(a.at(i));
  }
  cout << ans.size() << endl;
  return 0;
}

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

    #define FOR(i,a,b) for (int i = (a); i < (b); i++)
    #define rep(i,n) FOR(i,0,n)
    #define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
    #define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
    #define FILL(a,value) memset(a, value, sizeof(a))

    #define SZ(a) (int)a.size()
    #define ALL(a) a.begin(), a.end()
    #define PB push_back
    #define MP make_pair
    #define SC second
    #define FS first

    typedef long long LL;
    typedef vector<int> VI;
    typedef vector<LL>VL;
    typedef vector <bool >VB;
    typedef vector<vector<int>>WI;
    typedef vector<vector<LL>>WL;
    typedef pair<int, int> PII;
    typedef pair<double, double> PDD;

    const double PI = acos(-1.0);
    const int INF = 1000 * 1000 * 1000 + 7;
    const LL LINF = LL(1e12);
    const int MAS = int(1e5 * 3 + 1);
    const double EPS = 1e-7;
    const LL MAX = 4294967296;
    const LL MOD =LL(1e9+7);



    LL dp[MAS] ;
    int main()
    {
      int n ; cin >> n;
      cout << n*n*n;
    }


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<cstring>
#include<sstream>
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define lb(v,n) lower_bound(v.begin(),v.end(),n)
#define ub(v,n) upper_bound(v.begin(),v.end(),n)
#define mae(v) max_element(v.begin(),v.end())
#define mie(v) min_element(v.begin(),v.end())
#define INF 0x7FFFFFFF
#define mod 1000000007
typedef long long ll;
////////////////////////////////////////////////////////////
const int MAX_V = 100;
vector<vector<ll>> d(MAX_V,vector<ll>(MAX_V,INF));
//d[[i][j]:i,j間の最短経路
int E,V; //辺の数，頂点数
int nxt[MAX_V][MAX_V];
void wf(){
	rep(k,0,V){
		rep(i,0,V){
			rep(j,0,V){
				if( d[i][j] > d[i][k] + d[k][j] ){
					d[i][j] = d[i][k] + d[k][j];
					nxt[i][j] = nxt[i][k];
				}
			}
		}
	}
}

bool r[MAX_V][MAX_V];
//入力
void make(){
	rep(i,0,E){
		int u,v,c;
		cin>>u>>v>>c;
		u--; v--;
		d[u][v] = c;
		d[v][u] = c;
		r[u][v] = 1;
		r[v][u] = 1;
	}
}

//初期化
void init(){
	rep(i,0,V){
		rep(j,0,V){
			if( i == j ) d[i][j] = 0;
			else d[i][j] = INF;
			nxt[i][j] = j;
		}
	}
}

//経路復元
void printPath( int start , int goal ){
	int bef = start;
	for(int cur = start ; cur != goal ; cur = nxt[cur][goal] ){
		//cout << cur << " ";
		r[bef][cur] = 0;
		r[cur][bef] = 0;
		bef = cur;
	}
	//cout << goal << endl;
	r[bef][goal] = 0;
	r[goal][bef] = 0;
}

int main(){
	cin >> V >> E;
	init();
	make();
	wf();
	
	rep(i,0,V) rep(j,0,V) printPath(i,j);
	
	ll sum = 0;
	rep(i,0,V) rep(j,0,V) if(r[i][j]) sum++;
	P(sum/2);

	ret 0;
}

Measured memory_bytes: 384
n, m = [int(i) for i in input().split()]
a = [-1] + [int(input()) for _ in range(m)] + [n+1]

fib_l = [-1] * (n+3)

def make_fib(n):
    fib_l[0] = fib_l[1] = 1
    for i in range(2, n):
        fib_l[i] = fib_l[i-1] + fib_l[i-2]

make_fib(n+3)
ret = 1
for i in range(m+1):
    t = a[i+1] - a[i] - 2
    if t < 0:
        ret = 0
        break
    ret *= fib_l[t]
print(ret % 1000000007)

Measured memory_bytes: 463984
/*
 _     _                             
| |__ | |__   __ _  __ _ _   _  __ _ 
| '_ \| '_ \ / _` |/ _` | | | |/ _` |
| |_) | | | | (_| | (_| | |_| | (_| |
|_.__/|_| |_|\__,_|\__, |\__, |\__,_|
                   |___/ |___/       
*/
#include<bits/stdc++.h>

#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define	endl		'\n'
#define mii         map<ll int,ll int>
#define msi         map<string,ll int>
#define mis         map<ll int, string>
#define mpi         map<pair<ll int,ll int>,ll int>
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define what_is(x)  cerr << #x << " is " << x << endl;
using namespace std;

#define N  100005

ll int degree[N];
ll int dp[N][2];
ll int last=-1;
ll int vis[N];
vi a[N];

void dfs(ll int node,ll int par)
{
	last=node;
	vis[node]=1;
	if(par==-1) dp[node][0]=dp[node][1]=1;
	else
	{
		dp[node][0]=1;
		dp[node][1]=1;
		for(auto i:a[node])
		{
			if(vis[i]==1)
			{
				dp[node][0]=(dp[node][0]*(dp[i][0]+dp[i][1]))%hell;
				dp[node][1]=(dp[node][1]*dp[i][0])%hell;
			}
		}
	}
	for(auto i:a[node])
	{
		if(vis[i]==0)
		{
			degree[i]--;
			if(degree[i]<=1)
			{
				dfs(i,node);
			}
		}
	}
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		ll int n,m;
		cin>>n;
		m=n-1;
		memset(degree,0,sizeof(degree));
		while(m--)
		{
			ll int u,v;
			cin>>u>>v;
			a[u].pb(v);
			a[v].pb(u);
			degree[u]++;
			degree[v]++;
		}
		memset(vis,0,sizeof(vis));
		for(ll int i=1;i<=n;i++)
		{
			if(!vis[i]&&degree[i]<=1)
			{
				dfs(i,-1);
			}
		}
		cout<<(dp[last][0]+dp[last][1])%hell;
	}
	return 0;
}

Measured memory_bytes: 12032
#include<iostream>
#include<string>
using namespace std;
int main(){
string s;
cin>>s;
bool f1=0,f2=0,f3=0;


for(int i=0;i<3;i++){
    if(s[i]=='a') {f1=1;}
    if(s[i]=='b') {f2=1;}
    if(s[i]=='c') {f3=1;}
}
if(f1&&f2&&f3) cout<<"Yes";
else cout<<"No";


}


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

using namespace std;


#define ss second
#define ff first
#define int long long
//#define double long double
#define pb push_back

const int N = 1e6 + 1, MOD = 1e9 + 7, mod = 998244353, INF = 3e18;

mt19937 Flash_new_51(51515);

using vi = vector <int>;
using vp = vector <pair <int, int>>;



signed main() {
   cin.tie(0);
   ios_base::sync_with_stdio(0);
   int a, b;
   cin >> a >> b;
   if (a <= 0 && b >= 0) {
      cout << "Zero";
      return 0;
   }
   if (b < 0) {
      int k = abs(b - a) + 1;
      if (k % 2) {
         cout << "Negative";
      }
      else cout << "Positive";
   }
   else {
      cout <<"Positive";
   }
}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.List;
import java.util.ArrayList;
import java.util.Scanner;

// ALDS1_7_A
public class Main {
	void searchDepth(Node[] tree, int i, int n) {
		tree[i].depth = n;
		for (Integer k : tree[i].childs) {
			searchDepth(tree, k, n+1);
		}
	}
	
	void run() throws IOException {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Node[] tree = new Node[n];
		for (int i = 0; i < n; i++) {
			tree[i] = new Node(i);
		}
		for (int i = 0; i < n; i++) {
			int number = sc.nextInt();
			int k = sc.nextInt();
			List<Integer> lis = new ArrayList<Integer>();
			for (int j = 0; j < k; j++) {
				int child = sc.nextInt();
				tree[child].parent = number;
				lis.add(child);
			}
			tree[number].childs = lis;
			if (lis.isEmpty()) tree[number].type = "leaf";
			else tree[number].type = "internal node";
		}
		// search root
		int root = 0;
		for (int i = 0; i < tree.length; i++) {
			if (tree[i].parent == -1) {
				tree[i].type = "root";
				root = i;
			}
		}
		searchDepth(tree, root, 0);
		for (int i = 0; i < n; i++) {
			tree[i].print();
		}
	}
	
	public static void main(String[] args) throws IOException {
		new Main().run();
	}
}

class Node {
	int number;
	int parent = -1;
	int depth;
	String type;
	List<Integer> childs;
	Node(int number) {
		this.number = number;
	}
	
	void print() {
		System.out.println("node " + number + ": parent = " + parent + ", depth = " + depth + ", " + type + ", " + childs);
	}
}


Measured memory_bytes: 172132
#include <iostream>
#include <cstdio>
using namespace std;
static const int MAX = 1e+5 + 1;

int a[MAX];

int main() {
    int N; cin >> N;
    for (int i = 0; i < N; i++) {
        scanf("%d", &a[i]);
    }

    int cnt = 0;
    for (int i = 0; i < N; i++) {
        if (a[i] % 2 == 0) cnt++;
    }

    if (cnt == N) cout << "second\n";
    else cout << "first\n";

}


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

int main()
{
    int a,b;
    int rep1,rep2;
    cin >> a >> b;
    int k = a;
    int kk = b;
    for(int i = 0; i < kk-1; i++)
    {
        rep1 = a*10;
        a = rep1 + k;
    }
    for(int i = 0; i < k-1; i++)
    {
        rep2 = b*10;
        b = rep2 + kk;
    }
    stringstream ss;
    ss<<a;
    string f1;
    ss>>f1;
    stringstream hh;
    hh<<b;
    string f2;
    hh>>f2;
    if(f1>=f2)
    {
        cout<<f2<<endl;
    }else
    {
        cout<<f1<<endl;
    }
    return 0;
}


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

void dfs(vector<int> &discover, vector<int> &finished, vector<vector<bool>> &g, int n, vector<int> &color, int &time, int u){
    color[u]++;
    discover[u] = ++time;
    for (int i = 0; i < n; i++){
        if (g[u][i]){
            if (color[i] == 0){
                dfs(discover, finished, g, n, color, time, i);
            }
        }
    }
    color[u]++;
    finished[u] = ++time;
}

int main(){
    int n, u, k;
    int time = 0;
    cin >> n;
    vector<int> discover(n);
    vector<int> finished(n);
    vector<int> color(n, 0);
    vector<vector<bool>> g(n, vector<bool>(n, false));
    for (int i = 0; i < n; i++){
        cin >> u >> k;
        u--;
        int v;
        for (int j = 0; j < k; j++){
            cin >> v;
            v--;
            g[u][v] = true;
        }
    }

    for (int j = 0; j < n; j++){
        if (!color[j]){
            dfs(discover, finished, g, n, color, time, j);
        }
    }

    for (int i = 0; i < n; i++)
        cout << i + 1 << ' ' << discover[i] << ' ' << finished[i] << endl;
    return 0;
}


Measured memory_bytes: 3100
n = gets.to_i
as = gets.split.map(&:to_i)
sum = [tmp = 0].concat(as.map{|a| tmp += a})
diff = Float::INFINITY
n.times do |i|
  next if i == 0
  l = sum[i]
  r = sum[n] - sum[i]
  t = (l - r).abs
  diff = t if diff > t
end
p diff

Measured memory_bytes: 21252
n = int(input())
a = []
for i in range(n):
    x,l = map(int,input().split())
    s = x-l
    g = x+l
    a.append((s,g))

a = sorted(a, reverse=False, key=lambda x: x[1]) 
tmp = a[0][1]
ans = 1
for i in range(1,len(a)):
    if tmp <= a[i][0]:
        tmp = a[i][1]
        ans += 1 

print(ans)

Measured memory_bytes: 24668
# coding: utf-8
def main():
	N=int(input())
	shougen = [[] for n in range(N)]
	for n in range(N):
		A=int(input())
		for a in range(A):
			x,y = map(int, input().split())
			shougen[n].append([x,y])
	
	OKlis = []
	for n in range(2**N):
		isOK = True
		bit = '{n:0{width}b}'.format(n=n,width=N)
		for i,v in enumerate(bit):
			if v == '0':
				continue
			for x,y in shougen[i]:
				if bit[x-1] != str(y):
					isOK = False
					break
			if isOK == False:
				break
		if isOK:
			OKlis.append(bit)
	OKlis = [ i.count('1') for i in OKlis]
	print(max(OKlis))

if __name__ == '__main__':
	main()



Measured memory_bytes: 5648
#include <bits/stdc++.h>
using namespace std;
int n,m,q;
vector<int> a,b,c,d;
int A[10];
int ans = 0;

void dfs(int depth){
    if(depth == n){
        int tmp = 0;
        for(int i=0; i<q; i++){
            if(A[b[i]]-A[a[i]] == c[i]) tmp += d[i];
        }
        ans = max(tmp,ans);
    }
    else{
        if(depth == 0){
            for(int i=1; i<=m; i++){
                A[0] = i;
                dfs(1);
            }
        }
        else{
            for(int i=A[depth-1]; i<=m; i++){
                A[depth] = i;
                dfs(depth+1);
            }
        }
    }
    return;
}

int main(){
    cin >> n >> m >> q;
    for(int i=0; i<q; i++){
        int e,f,g,h;
        cin >> e >> f >> g >> h;
        e--;f--;
        a.push_back(e);
        b.push_back(f);
        c.push_back(g);
        d.push_back(h);
    }
    dfs(0);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
    vector<int> size;
    UnionFind(int N): par(N),size(N) {

         //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++){
            par[i] = i;
            size[i] = -1;
        }
            
    }
    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
        size[ry] += size[rx];
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
    int getsize(int x){
        return -size[root(x)];
    }
    int getNunion(){
        map<int,int> m;
        rep(i,par.size()){
            m[this->root(i)]++;
        }
        return int(m.size());
    }
};


int main(){
    ll N, M;
    cin >> N >> M;
    vector<ll> A(M),B(M);
    rep(i,M){
        cin >> A[i] >> B[i];
        A[i]--;B[i]--;
    }
    UnionFind tree(N);
    ll ans = N*(N-1)/2;
    ll Nuni = N;
    vector<ll> v;
    //tree.unite(0,3);
    //tree.unite(1,2);    
    /*rep(i,N){
        cout << tree.getsize(i) <<endl;
    }*/
    
    rep(i,M){
        v.push_back(ans);
        ll a = tree.getsize(A[M-1-i]);
        ll b = tree.getsize(B[M-1-i]);
        if(!tree.same(A[M-1-i], B[M-1-i])){
            ans -= a*b;
        }
        tree.unite(A[M-1-i], B[M-1-i]);
        /*if(Nuni > tree.getNunion()){
            Nuni = tree.getNunion();
            ans -= a*b;
            //cout << ans << " " << a << " "<< b << endl;
        }*/
    }
    rep(i,M){
        cout << v[M-1-i] << endl;
    }
}

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

int main(void) {
	string s;
	cin >> s;
	bool ans = true;
	for (int i = 0; i < s.size(); i++) {
		if (i % 2 == 0 && s[i] == 'L') {
			ans = false;
			break;
		} else if (i % 2 == 1 && s[i] == 'R') {
			ans = false;
			break;
		}
	}
	if (ans) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}

	return 0;
}


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

void solve(){
	int x;
	cin >> x;
	int fifty, three;
	fifty = x / 500;
	x %= 500;
	three = x / 5;
	cout << (long long) fifty * 1000 + (5 * three) << "\n"; 
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	solve();
}

Measured memory_bytes: 3552
#include<iostream>
#include<cmath>
#include<string>
#include<fstream>
#include<vector>
#include<algorithm>
using namespace std;

int main()
{
    int n;
    cin>>n;
    int ans=0;
    int a;
    for(int i=0; i<n; i++)
    {
        cin>>a;
        while(a%2==0)
        {
            ans++;
            a=a/2;
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

#define rep(i,a,b) for(long long i = a; i < b; i++)
#define dump(a) for(auto x : a) cout << x << " "; cout << "\n"
#define print(a) cout << a << "\n"
#define debug(x) std::cerr<<#x<<": "<<x<<"\n"
#define debug2(x,y) std::cerr << #x << ": " << x << ", " << #y << ": " << y << "\n"
#define debug3(x,y,z) std::cerr << #x << ": " << x << ", " << #y << ": " << y << ", " << #z << ": " << z << "\n"

typedef long long ll;
using vi   = vector<int>;
using vll  = vector<long long>;
using vs   = vector<string>;
using vvi  = vector<vector<int>>;
using vvll = vector<vector<long long>>;
using vvs  = vector<vector<string>>;


int main() {
  ll n;cin>>n;
  string c;cin >> c;

  ll left = 0;
  ll right = n;
  ll ttl = 0;
  char tmp = c[0];
  rep(i,0,n) {
    if(tmp != c[i]) {
      break;
    }
    if(i == n - 1) {
      print(0);
      return 0;
    }
  }
  
  while(true){
    while (c[left] != 'W') left++;
    while (c[right] != 'R') right--;
    if(left > right) break;
    char tmp = c[left];
    c[left] = c[right];
    c[right] = tmp;
    ttl++;
    //print(c);
    //print(left);
    //print(right);
  }
  print(ttl);
       
  return 0;
}

Measured memory_bytes: 3768
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int mod=998244353;
int f[205][8005],fac[8005],ifac[8005],a[16384],b[16384];
inline int power(int a,int b){
	int c=1;
	while(b){
		if(b&1)c=1ll*c*a%mod;
		a=1ll*a*a%mod;
		b>>=1;
	}
	return c;
}
int r[16384];
void fft(int *a,int n,int opt){
	for(int i=0;i<n;i++)if(i<r[i])swap(a[i],a[r[i]]);
	for(int i=1;i<n;i<<=1){
		int wn=power(3,(mod-1)/i/2);
		if(opt==-1)wn=power(wn,mod-2);
		for(int j=0;j<n;j+=(i<<1)){
			int w=1;
			for(int k=0;k<i;k++,w=1ll*w*wn%mod){
				int x=a[j+k],y=1ll*a[j+k+i]*w%mod;
				a[j+k]=(x+y)%mod;
				a[j+k+i]=(x-y+mod)%mod;
			}
		}
	}
	if(opt==-1){
		int rev=power(n,mod-2);
		for(int i=0;i<n;i++)a[i]=1ll*a[i]*rev%mod;
	}
}
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	fac[0]=1;
	for(int i=1;i<=n+2;i++)fac[i]=1ll*fac[i-1]*i%mod;
	ifac[n+2]=power(fac[n+2],mod-2);
	for(int i=n+2;i>=1;i--)ifac[i-1]=1ll*ifac[i]*i%mod;
	for(int i=1;i<16384;i++)r[i]=(r[i>>1]>>1)|((i&1)*8192);
	for(int i=1;i<=n;i++)a[i]=ifac[i+2];
	// for(int i=1;i<=n;i++)printf("%d ",a[i]); puts("");
	fft(a,16384,1);
	f[0][0]=1;
	for(int i=0;i<m;i++){
		memset(b,0,sizeof(b));
		for(int j=0;j<=n;j++)b[j]=1ll*f[i][j]*ifac[j]%mod;
		// for(int j=0;j<=n;j++)printf("%d ",b[j]); puts("");
		fft(b,16384,1);
		for(int j=0;j<16384;j++)b[j]=1ll*b[j]*a[j]%mod;
		fft(b,16384,-1);
		// for(int j=0;j<=n;j++)printf("%d ",b[j]); puts("");
		for(int j=0;j<=n;j++)f[i+1][j]=(1ll*b[j]*fac[j+2]+1ll*f[i][j]*((j+1)*j/2+1))%mod;
	}
	// for(int i=0;i<=m;i++){
		// for(int j=0;j<=n;j++)printf("%d ",f[i][j]); puts("");
	// }
	int ans=0;
	for(int i=0;i<=n;i++)ans=(ans+1ll*f[m][i]*fac[n]%mod*ifac[i]%mod*ifac[n-i])%mod;
	printf("%d\n",ans);
	return 0;
}

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

int main(){
  int n,l[300],u[300];
  while(cin >> n,n){
    for(int i=0;i<n;i++)cin >> l[i];
    
    double m = 1e10;
    int x,y,z;
    for(int s=0;s<16;s++){
      for(int a=0;a<16;a++){
	for(int c=0;c<16;c++){
	  for(int i=0;i<256;i++)u[i] = 0;
	  
	  int r = s;
	  for(int i=0;i<n;i++){
	    r = (a*r + c) % 256;
	    u[(r + l[i]) % 256]++;
	  }
	  
	  double tmp = 0;
	  for(int i=0;i<256;i++)if(u[i])tmp -= (double)u[i]*log((double)u[i]/n);
	  if(m > tmp + 1e-8){
	    m = tmp; x = s; y = a; z = c;
	  }
	}
      }
    }
    cout << x << " " << y << " " << z << endl;
  }
}

Measured memory_bytes: 1204
#pragma GCC optimize "-O3"
#pragma GCC target ("avx")
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v),greater<int>())
#define SPEED ios::sync_with_stdio(false);cin.tie(0);cout<<fixed<<setprecision(12)
signed gcd(int a, int b){return b?gcd(b,a%b):a;}
signed lcm(int a, int b){return a*b/gcd(a,b);}
//priority_queue<int, vi, greater<int> > que;//昇順

using namespace std;

const int mod=1e9+7;

signed main(){
    SPEED;
    string s1,s2;
    cin >> s1 >> s2;
    if(s1[0]==s2[2]&&s1[1]==s2[1]&&s1[2]==s2[0])
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
s =list(input())
gene = list(["A","T","G","C"])
count = 0
numl = list()
numl.append(0)
for i in range(0,len(s)):
    if s[i] in gene:
        count += 1
    else:
        numl.append(count)
        count = 0
numl.append(count)
print(max(numl))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const auto INF = (ll)1e9;
using v = vector<int>;
using m = map<int,int>;
int main(){
	int n;
    cin >>n;
    auto a = v(n,0);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    
    int c=0;
    int ans =0;
    int b =0;
    for (int i=0;i<n;i++)
    {
        if(b!=a[i]&&b!=0){
            if(b<c){
                ans+=c-b;
            }else if(b==c){
                ans+=0;
            }else{
                ans+=c;
            }
            c=0;
        } 
        b=a[i];
        c++;
    }

    if(b<c){
        ans+=c-b;
    }else if(b==c){
        ans+=0;
    }else{
        ans+=c;
    }

    cout << ans;
    
}


Measured memory_bytes: 640
let readString() = stdin.ReadLine()
let readStringArray() = stdin.ReadLine().Split(' ');
let readInt() = readString() |> int
let readIntArray() = readStringArray() |> Array.map(fun x -> int x)
let char2String(value) = List.ofSeq value |> List.toArray |> System.String

let b = readString()

match b with 
| "A" -> "T"
| "T" -> "A"
| "C" -> "G"
| "G" -> "C"
| _ -> ""
|> printfn "%s"

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

typedef long long ll;
#define fio() cin.tie(0); ios::sync_with_stdio(false);
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define all(c) c.begin(),c.end()
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
#define pu push
#define pb push_back
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
const ll MOD = 1000000007;


int main(){
    fio();
    string str;
    cin>>str;
    cout<<str.substr(0,5)<<" ";
    cout<<str.substr(6,7)<<" ";
    cout<<str.substr(14,5);




}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;
#define ip(arr, n) for(int i=1; i<=n; i++) cin>>arr[i];
#define op(arr, n) for(int i=0; i<n; i++) cout<<arr[i]<<" ";
#define fstIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define MAX 100005
#define mod 1000000007

ll dp[105][MAX] = {0};
int *arr;
int main(){
    int n, k;
    cin>>n>>k;
    arr = new int[n+1];
    ip(arr, n);
    
    for(int i=0; i<=n; i++){
        for(int j=0; j<=k; j++){
            if(i==0){
                if(j==0) dp[i][j]=1;
                else dp[i][j]=0;
            }
            else if(j==0){
                dp[i][j]=dp[i-1][j];
            }
            else{
                dp[i][j] = (mod+dp[i-1][j]+dp[i][j-1] -((j-arr[i]-1)>=0?dp[i-1][j-arr[i]-1]:0))%mod;
            }
        }
    }
    
    cout<<dp[n][k]<<endl;
    return 0;
}

Measured memory_bytes: 80128
fun square(n: Int): Double = Math.pow(n.toDouble(), 2.0)

fun main(args: Array<String>) {
    val (a, b, C) = readLine()!!.split(" ").map(String::toInt)
    val radC = Math.toRadians(C.toDouble())
    val sinC = Math.sin(radC)
    val cosC = Math.cos(radC)

    val S = a * b * sinC / 2
    val L = a + b + Math.sqrt(square(a) + square(b) - 2 * a * b * cosC)
    val h = b * sinC
    println(S)
    println(L)
    println(h)
}


Measured memory_bytes: 26664
W, a, b = map(int, input().split())

if a <= b:
    if b - (a + W) < 0:
        print(0)
    else:
        print(b - (a + W))
else:
    if a - (b + W) < 0:
        print(0)
    else:
        print(a - (b + W))

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

#define ll long long
ll mod=1e9+7;
int main(){
    ll n,k;
    cin>>n>>k;
    ll a[n+1];
    f(i,n)cin>>a[i+1];
    ll dp[n+1][k+1];
    // memset
    // cout<<"sak";
    f(i,k+1)dp[0][i]=0;
    // f(i,n+1)dp[i][0]=1;
    dp[0][0]=1;

    for(ll i=1;i<=n;i++){
         ll sum[k+1];
            sum[0]=dp[i-1][0]%mod;
            // cout<<sum[0]<<endl;
            for(ll s=1;s<=k;s++){
                sum[s]=(sum[s-1]+dp[i-1][s]%mod)%mod;
                // cout<<sum[s]<<"aSDcsac"<<endl;
            }
        for(ll j=0;j<=k;j++){
            if((j-a[i]-1)>=0){
            dp[i][j]=(sum[j]-sum[(j-a[i]-1)]+mod)%mod;
            }
            else dp[i][j]=sum[j]%mod;
        }
    }
    // cout<<"As";
    // f(i,n+1){
    //     f(j,k+1)cout<<dp[i][j]<<" ";

    //     cout<<endl;
    // }
    cout<<dp[n][k]%mod<<endl;
    return 0;
}


Measured memory_bytes: 83124
#include <bits/stdc++.h>
#define rep(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
using namespace std;
using ll = int64_t;
const int MOD = 1000000007; // 10^9+7

int main() {
    ll n, m;
    cin >> n >> m;

    cout << n * (n - 1) / 2 + m * (m - 1) / 2 << endl;    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define ll long long int
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define rep(i,a,b)	for(ll  i=a;i<b;i++)
#define hello777 ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#include <string>
#define pie 3.14159265358979323846
constexpr int MOD = 1e9+7;
const int MAX= 1e5+5;
using namespace std;


//ll gcd(int a, int b)
//{ 
//    if (a == 0) 
//        return b;  
//    return gcd(b % a, a);  
// } 
// 
//ll lcm(int a, int b)  
// {  
//    return a/gcd(a, b) *b;  
// }
//  
//int prime(int n)
//{
//	rep(i,2,n+1)
//	{
//		if(n%i==0)return i;
//	}
//	
//vector<unordered_set<int> > prime_factors(MAX,unordered_set<int>());
//int primes[MAX];
//int prefix[MAX][6];
//void sieve(){
//    //primes i stores the largest prime factor of a number....
//    for(int i=2;i<MAX;++i){
//        if(primes[i]!=0){
//            continue;
//        }
//        primes[i] = i;
//        for(int j=2*i;j<MAX;j+=i){
//            primes[j] = i;
//        }
//    }
//    
//    for(int i=2;i<MAX;++i){
//        int current = i;
//        
//        while(current!=1){
//            prime_factors[i].insert(primes[current]);
//            current = current/primes[current];
//        }
//    }
//    
//    for(int i=1;i<MAX;++i){
//        for(int k=1;k<=5;++k){
//            prefix[i][k] = prefix[i-1][k] + (prime_factors[i].size()==k);
//        }
//    }
//    
//}
void solve() 
{
	int d,t,s;
	cin>>d>>t>>s;
	if(d<=s*t)cout<<"Yes"<<endl;
	else cout<<"No";
}



int main()
{
	hello777;

	int q=1;
	
//    cin>>q;
    while(q--)
    {   
      solve();
    }
}

 

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<endl;
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;
const ll inf=1e15;

class UnionFind{
public:
	vector<int> par;
	vector<int> rank;
	vector<int> size;
 
	UnionFind(int n){
		rep(i,n){
			par.push_back(i);
			rank.push_back(0);
			size.push_back(1);
		}
	}
 
	int find(int x) {
		if(par[x]==x){
			return x;
		}else{
			return par[x]=find(par[x]);
		}
	}
 
	void unite(int x,int y){
		x=find(x);
		y=find(y);
		if(x==y) return;
		if(rank[x]<rank[y]){
			par[x]=y;
			size[y]+=size[x];
		}else{
			par[y]=x;
			size[x]+=size[y];
			if(rank[x]==rank[y]) rank[x]++;
		}
	}

	bool same(int x,int y){
		return find(x)==find(y);
	}
};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,m;cin>>n>>m;
  vector<P> a(m);
  UnionFind uf(n);
  rep(i,m){
    cin>>a[i].fi>>a[i].se;
    a[i].fi--;
    a[i].se--;
  }
  reverse(begin(a),end(a));
  vector<ll> ans;
  ll now=n*(n-1)/2;
  rep(i,m){
    ans.push_back(now);
    if(!uf.same(a[i].fi,a[i].se)){
      ll cnt1=uf.size[uf.find(a[i].fi)];
      ll cnt2=uf.size[uf.find(a[i].se)];
      uf.unite(a[i].fi,a[i].se);
      now-=cnt1*cnt2;
    }
  }
  reverse(begin(ans),end(ans));
  cout_vec(ans);
}

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

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> II;
typedef vector<II> VII;

#define REP(x, n) for (int x = 0; x < (n); ++x)
#define INF (1e9 + 1)
#define EPS 1e-9
#define PB push_back
#define MP make_pair
#define F first
#define S second

int solve(VI& s) {
    int max_moves = 0;
    int cur_moves = 0;
    REP (i, s.size() - 1) {
        if (s[i] >= s[i + 1]) {
            ++cur_moves;
        }
        else {
            cur_moves = 0;
        }
        max_moves = max(max_moves, cur_moves);
    }
    return max_moves;
}

int main() {
    
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int n;
    cin >> n;
    VI sq(n);
    REP (i, n) {
        cin >> sq[i];
    }
    cout << solve(sq) << '\n';
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
  int K;
  cin>>K;
  string S;
  cin>>S;
  if(S.size()>K){
    for(int i=0; i<K; i++)cout<<S[i];
    cout<<"..."<<endl;
  }else{
    cout<<S<<endl;
  }
}

Measured memory_bytes: 3596
# include <bits/stdc++.h>
using namespace std;
int main() {
  int N, A, B;
  cin >> N >> A >> B;
  if (N * A == B) {
    cout << B << endl;
  }
  else if (N * A <= B) {
    cout << N * A << endl;
  }
  else if (N * A >= B) {
    cout << B << endl;
  }
    return 0;
  }

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author cherrypi59
 */

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class BStringPalindrome {
public:
    bool check(string& s){
        int n = LEN(s);
        REP(i, n/2){
            if(s[i]!=s[n-i-1]) return false;
        }
        return true;
    }

    void solve(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in.tie(nullptr), out.tie(nullptr);
        string s, t, u;
        in>>s;
        int n = LEN(s);
        t = s.substr(0, n/2);
        u = s.substr(n/2+1);
        if(check(s) and check(t) and check(u)) out<<"Yes\n";
        else out<<"No\n";
    }
};


int main() {
	BStringPalindrome solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
using System;

namespace teeeeeeeeeeeeeeest
{
    class Program
    {
        static void Main(string[] args)
        {
            string n;
            string[] N;
            int a;
            n = Console.ReadLine();
            N = n.Split();
            a = int.Parse(N[0]) * int.Parse(N[1]);
            Console.WriteLine(a);
        }
    }
}



Measured memory_bytes: 17972
c = input()

arr = [['A', 'T'], ['G', 'C']]

if c in arr[0]:
    index = arr[0].index(c)
    print(arr[0][(index+1)%2])
elif c in arr[1]:
    index = arr[1].index(c)
    print(arr[1][(index+1)%2])


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define fi first
#define se second
#define debugv(v) for (auto& x: v) cerr << x << " "; cerr << '\n';
#define debug2v(v) for (auto& x: v) cerr << x.fi << " - " << x.se << '\n';
using namespace std;
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
 
using ll = long long;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }  
 
int main(void) {
  FAST
  int n; cin >> n;
  vector<int> arr(n);
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  vector<int> pre(n);
  pre[0] = arr[0];
  for (int i = 1; i < n; i++) {
    pre[i] = min(pre[i - 1], arr[i]);
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (arr[i] == pre[i]) {
      ans++;
    }  
  }
  cout << ans << '\n';  return 0;
}

Measured memory_bytes: 1920
use std::cmp::Ordering;
use std::collections::BinaryHeap;

fn main(){
  let nq: Vec<usize> = read_vec();
  let n = nq[0];
  let q = nq[1];
  
  let mut cnt: Vec<i32> = vec![0;n];
  let mut bh = BinaryHeap::new();
  
  for _ in 0 .. q {
    let av: Vec<i32> = read_vec();
    let a = av[0] as usize - 1;
    let v = av[1];
    
    cnt[a] = cnt[a] + v;
    bh.push(Angler{a:a, v:cnt[a]});
    
    loop {
      let &ang = bh.peek().unwrap();

      if cnt[ang.a] == ang.v {
        println!("{} {}", ang.a + 1, ang.v);
        break;
      }
      
      bh.pop();
    }
  }
}

#[derive(Eq, PartialEq, Debug, Copy, Clone)]
struct Angler {
  a: usize,
  v: i32,
}

impl Ord for Angler {
  fn cmp(&self, other: &Angler) -> Ordering {
    if self.v == other.v {other.a.cmp(&self.a)} else {self.v.cmp(&other.v)}
  }
}

impl PartialOrd for Angler {
  fn partial_cmp(&self, other: &Angler) -> Option<Ordering> {
    Some(self.cmp(other))
  }
}

fn read_vec<T>() -> Vec<T>
  where T: std::str::FromStr,
        T::Err: std::fmt::Debug
{
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).expect("failed to read");
  buf.split_whitespace().map(|e| e.parse().unwrap()).collect()
}



Measured memory_bytes: 11172
#include "bits/stdc++.h"
 
using namespace std;
typedef int64_t ll;
typedef vector<int64_t> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
typedef vector<double> vd;
typedef vector<vd> vvd;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SIZE(a) int((a).size())
const int MAX = 1000000000;
const int MOD = 1000000007;
int main(){
  string s;int ans=INT_MAX;
  cin>>s;
  REP(i,SIZE(s)-2){
    int a,b,c;
    a=s[i]-'0';b=s[i+1]-'0';c=s[i+2]-'0';
    ans=min(abs(a*100+b*10+c-753),ans);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
import sys

input = sys.stdin.readline

ri = lambda: int(input())
rs = lambda: input().rstrip()
ril = lambda: list(map(int, input().split()))
rsl = lambda: input().rstrip().split()
ris = lambda n: [ri() for _ in range(n)]
rss = lambda n: [rs() for _ in range(n)]
rils = lambda n: [ril() for _ in range(n)]
rsls = lambda n: [rsl() for _ in range(n)]

s = rs()
res = [0] * len(s)
for i, c in enumerate(s):
    if c in 'ACGT':
        if i > 0:
            res[i] = res[i - 1] + 1
        else:
            res[i] = 1
print(max(res))

Measured memory_bytes: 3064
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <iomanip>
using namespace std;
typedef long long LL;
typedef pair<int,int> P;

template<int NN> class BipartiteMatch
{
	public:
	BipartiteMatch()
	{
		memset(matchedTo, -1, sizeof(matchedTo));
	}
	vector<int> edge[NN];
	void add(int a, int b)
	{
		edge[a].push_back(b);
		edge[b].push_back(a);
		//cout << a << ", " << b << endl;
	}
	int matchedTo[NN];
	bool augment(int s)
	{
		memset(visited, 0, sizeof(visited));
		return aug(s);
	}
	bool visited[NN];
	private:
	bool aug(int s)
	{
		if(s<0){
			return true;
		}
		for(int i=0;i<edge[s].size();i++){
			int t=edge[s][i];
			if(!visited[t]){
				visited[t]=true;
				if (aug(matchedTo[t])){
					matchedTo[t]=s;
					return true;
				}
			}
		}
		return false;
	}
};

int gcd(int a,int b){
	while(b){
		int r=a%b;
		a=b;
		b=r;
	}
	return a;
}
int m,n;
int b[500];
int r[500];
int main() {
	while(1){
	cin >> m >> n;
	if(m==0&&n==0)return 0;
	BipartiteMatch<1000> bm;
	for(int i=0;i<m;i++){
		cin >> b[i];
	}
	for(int i=0;i<n;i++){
		cin >> r[i];
		for(int j=0;j<m;j++){
			if(gcd(r[i],b[j])>1){
				bm.add(i+m,j);
			}
		}
	}
	int ret=0;
	for(int i=0;i<m;i++){
		if(bm.augment(i)){
			ret++;
		}
	}
	cout << ret << endl;
	}
}

Measured memory_bytes: 2732
#include <bits/stdc++.h>
typedef unsigned long long ull;
typedef long long ll;
#define MAX 12
using namespace std;

int main() {
    ll D, G;
    cin >> D >> G;
    vector<ll> p(D), c(D);
    for (ll i = 0; i < D; i++) {
        cin >> p[i] >> c[i];
    }

    ll ans = INT_MAX;
    for (ll i=0;i<(2<<D);i++) {
        ll num = 0;
        ll score = 0;
        //max_indexというのはコンプリートしていない最大の値
        ll max_index = 0;
        for (ll j=0;j<D;j++) {
            if (i & (1<<j)) {
                num += p[j];
                score += p[j] * (j + 1) * 100 + c[j];
            } else {
                max_index = max(max_index, j);
            }
        }
        for (ll n = 0; n < p[max_index]; n++) {
            if (score >= G) {
                ans = min(ans, num);
                break;
            }
            score += 100 * (max_index+1);
            num++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
N_A, N_B, N_M = map(int,input().split(" "))
A = list(map(int,input().split(" ")))
B = list(map(int,input().split(" ")))
M = [list(map(int,input().split(" "))) for i in range(N_M)]

candidates = [min(A)+min(B),]

for m in M:
    #print(A[m[0]-1] + B[m[1]-1] - m[2])
    candidates.append(A[m[0]-1] + B[m[1]-1] - m[2])

print(min(candidates))

Measured memory_bytes: 42336
import sys
def input():
    return sys.stdin.readline()[:-1]

N = int(input())

for i in range(100):
    cnt = 0
    cnt += i*4
    for j in range(100):
        cnt += j*7
        if cnt>N:
            break
        if cnt==N:
            print('Yes')
            exit()
print('No')

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

int main(){
  int N;
  cin>>N;
  vector<int> p(N);
  for(int i=0;i<N;i++){
    cin>>p.at(i);
  }
  sort(p.begin(),p.end());
  int ans=0;
  for(int i=0;i<N-1;i++){
    ans+=p.at(i);
  }
  ans+=p.at(N-1)/2;
  cout<<ans<<endl;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/abc164/tasks/abc164_d

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

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DEBUG 0
#if DEBUG
  #define DUMP(a) REP(_i, a.size()) cout << a[_i] << (_i + 1 == a.size() ? "\n" : " ")
  #define DUMP2D(b) REP(_j, b.size()) DUMP(b[_j]); cout << endl
#else
  #define DUMP(a)
  #define DUMP2D(b)
#endif

const int S_MAX = 200000;
const int MOD = 2019;

string S;

int N;
vector<int> v;
map<int, int> mp;

int main() {
  cin >> S;
  N = S.size();

  v = vector<int>(N);
  reverse(S.begin(), S.end());

  int w = 0;
  int mag = 1;
  REP(i, N) {
    int d = S[i] - '0';
    v[i] = w = (d * mag % MOD + w) % MOD;
    mp[v[i]]++;
    mag = mag * 10 % MOD;
  }

  ll ans = mp[0];
  REP(i, N - 1) {
    mp[v[i]]--;
    ans += mp[v[i]];
#if DEBUG
    cout << i << "," << v[i] << "," << mp[v[i]] << endl;
#endif
  }

  cout << ans << endl;
}


Measured memory_bytes: 4408
#include <iostream>
#include <bitset>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <sstream>

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

using namespace std;

const double INF = 1e+10;

int main() {
  string str;
  while (getline(cin, str)) {
    stringstream ss;
    ss << str;
    int l;
    ss >> l;
    vector<int> r;
    while(ss){
      int ri;
      ss >> ri;
      r.push_back(ri);
    }
    r.pop_back();
    int n=r.size();
    vector<vector<double>> d(n+1,vector<double>(n+1,INF));
    REP(i,n)REP(j,n){
      double h = abs(r[i] - r[j]);
      double c = r[i] + r[j];
      double w = sqrt(c*c - h*h);
      d[i][j] = w;
    }
    REP(i,n){
      d[i][n] = d[n][i] = r[i];
    }
    vector<vector<double>> dp(1<<(n+1), vector<double>(n+1,INF));
    dp[1<<n][n] = 0.0;
    REP(i,1<<(n+1)){
      bitset<13> bs(i);
      REP(j,n+1){
        if(!bs[j]){
          auto cp = bs;
          cp[j] = true;
          REP(k,n+1)
            dp[cp.to_ulong()][j] = min(dp[cp.to_ulong()][j], dp[i][k] + d[k][j]);
        }
      }
    }
    double mind = INF;
    REP(i,n){
      mind = min(mind, dp[(1<<(n+1))-1][i] + r[i]);
    }
    if (mind <= l)
      cout << "OK" << endl;
    else
      cout << "NA" << endl;
  }
  return 0;
}

Measured memory_bytes: 2152
def gs() gets.chomp end
def gi() gets.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end
 
def desc(ar) ar.sort!{|x,y|y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+) end

N,K = gsmi
S = gs

tmp = []

cnt = 0
now = 1
S.each_char do |s|
	if s.to_i==now
		cnt += 1
	else
		tmp << cnt
		now = 1 - now
		cnt = 1
	end
end
tmp << cnt if cnt!=0

tmp << 0 if S[-1] == '0'

ans = 0
left = 0
right = 2*K
if right > tmp.size
	ans = sum tmp 
else
	now = sum tmp[left..right]
	ans = now
end
until (right+2) > tmp.size do
	now -= (tmp[left] + tmp[left+1])
	now += tmp[right+1] + tmp[right+2]
	left += 2
	right += 2
	ans = max(ans,now)
end
puts ans

Measured memory_bytes: 3068
n = int(input())
i = 0
s = ''
for _ in range(100):
    # print(n)
    d = n % 2**(i+1)
    # print(d)
    if d:
        n -= (-2)**i
        s = '1' + s
    else:
        s = '0' + s
    if n == 0:
        break
    i += 1
    
print(s)

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

using namespace std;

#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(0)
#define FOR(i, a, b) for(int i = (a); i <= (b); i++)
#define REP(n) FOR(O, 1, (n))
#define pb push_back
#define f first
#define s second
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<ll> vl;
typedef vector<piii> viii;

const int MAXN = 500100, MAXK = 30;
const ll MOD = 1e9+7;
const ll INF = 1e18;
const ld PI = asin(1) * 2;



int main()
{
    FAST_IO;

    char c; cin >> c;
    cout << ((char)(c+1)) << endl;

    return 0;
}


Measured memory_bytes: 256