akhauriyash/Code-Regression huggingface dataset:
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
#define dcml(n) fixed<<setprecision(n)
//CONST
//------------------------------------------
const ll INF=1010000000000000017LL;
const ll MOD=1000000007LL;
const ld EPS=1e-12;
const ld PI=3.14159265358979323846;
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define  FORS(i,m,n) for(ll (i)=(m);   (i)<=(n); (i)++)
#define  RFOR(i,m,n) for(ll (i)=(n)-1; (i)>=(n); (i)--)
#define RFORS(i,m,n) for(ll (i)=(n);   (i)>(n);  (i)--)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
#define WREPS(i,in,j,jn) REPS(i,in)REPS(j,jn)
//-----------------------------------------
//namespace
using namespace std;
//ライブラリはここに
//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

//-----------------------------------------
int main(void){
    ll N,M;cin>>N>>M;
    vi S[M];
    REP(i,M){
        ll k;cin>>k;
        REP(j,k){
            ll s;cin>>s;s--;
            S[i].push_back(s);
        }
    }
    ll p[M];REP(i,M)cin>>p[i];
    ll ans=0;
    for(int bit=0;bit<(1<<N);bit++){
        bool ok=true;
        REP(i,M){
            ll on=0;
            REP(j,S[i].size()){
                if(bit & (1<<S[i][j])){
                    on++;
                }
            }
            if(on%2==p[i]) continue;
            ok=false;break;
        }
        if(ok)ans++;
    }
    cout<<ans<<"\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N = 510;
struct E{
	int from,to,w,nxt;
}e[N*N],r[N*N];
int ct=0,cnt=0,head[N],n,a[N][N],pre[N],ans=0,m;
void add(int u,int v,int w) {
	r[++ct]=(E) {u,v,w,head[u]};
	head[u]=ct;
}
int find(int u) {
	return u==pre[u]?u:pre[u]=find(pre[u]);
}
int dis[N];
void dfs(int u,int fa) {
	for(int v,i=head[u];i;i=r[i].nxt) {
		if((v=r[i].to)!=fa) {
			dis[v]=dis[u]+r[i].w;
			dfs(v,u);
		}
	}
}

bool cmp(E a,E b) {
	return a.w<b.w;
}
int b[N][N];
main() {
	cin>>n;
	for(int i=1;i<=n;i++) {
		for(int j=1;j<=n;j++){
			scanf("%lld",&a[i][j]);
			e[++cnt]=(E) {i,j,a[i][j],0};
		}
		pre[i]=i;
	}
	
	
	int ok=0;
	for(int i=1;i<=n;i++) {
		for(int j=1;j<=n;j++) {
			if(i==j) b[i][j]=0;
			else b[i][j]=(int) 1e9;
		}
	}
	for(int k=1;k<=n;k++) {
		for(int i=1;i<=n;i++) {
			for(int j=1;j<=n;j++) {
				b[i][j]=min(b[i][j],a[i][k]+a[k][j]);
			}
		}
	}
//	for(int i=1;i<=n;i++) {
//		for(int j=1;j<=n;j++) {
////			if(i==j) b[i][j]=0;
////			else b[i][j]=(int) 1e9;
////		
//	cout<<b[i][j]<<" ";
//		}
//		puts("");
//	}
	for(int i=1;i<=n;i++) {
		for(int j=1;j<=n;j++) {
			if(a[i][j]!=b[i][j]) ok=1;
		}
	}
	if(ok) return puts("-1"),0;
	int ans=0;
	for(int i=1;i<=n;i++) {
		for(int j=i+1;j<=n;j++) {
			int now=0;
			for(int k=1;k<=n;k++) {
				if(k!=i&&k!=j&&b[i][j]==b[i][k]+b[k][j]) {
					now=1;
				}
			}
			if(!now) ans+=b[i][j];
		}
	}
	printf("%lld\n",ans);
	
}

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

int main() {
  int h, w, n;
  cin >> h >> w >> n;
  vector<pair<int, int>> v(n);
  for (auto &e : v) {
    cin >> e.second >> e.first;
    e.first--;
    e.second--;
  }
  sort(begin(v), end(v));
  int r = h, d = 0;
  for (auto e : v) {
    if (e.second - e.first == d) {
      d++;
    } else if (e.second - e.first > d) {
      r = min(r, e.second);
    }
  }
  cout << r << endl;
}


Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<vector>

void print_vec(std::vector<int> v){
	for(auto it=v.begin();it!=v.end();++it){
		std::cout << *it;
		if(it!=v.end()-1) std::cout << ' ';
		else std::cout << std::endl;
	}
}

int main() {
	int n;
	std::vector<int> ele;

	std::cin >> n;

	int temp;
	for(int i=0;i<n;i++){
		std::cin >> temp;
		ele.push_back(temp);
	}

	print_vec(ele);

	for(auto it1=ele.begin()+1;it1!=ele.end();++it1){
		auto it2=it1;
		int key=*it1;
		while(key < *(it2-1) && it2!=ele.begin()){
			*it2 = *(it2-1);
			*(it2-1) = key;
			--it2;
		}
		print_vec(ele);
	}

	return 0;
}



Measured memory_bytes: 3148
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,j,n) for(int i = j; i < n; i++)
#define rrep(i,j,n) for(int i = j-1; i >= n; i--)
#define prec(n) fixed << setprecision(n)
#define print_array(v) rep(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define fi first
#define se second
#define endl "\n"
using namespace std;

//constexpr int inf = 2147483647;
//constexpr int64_t inf64 = 9223372036854775807;
//constexpr int mod = 1e9+7;

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

  vector<int> cnt(4, 0);
  rep(i,6) {
    int a;
    cin >> a;
    cnt[a-1]++;
  }

  rep(i,4) {
    if (cnt[i] > 2) { cout << "NO" << endl; return 0; }
  }
  cout << "YES" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int a,b;
    scanf("%d %d",&a,&b);
    if(1<=a&&a<=1000000000&&1<=b&&b<=1000000000){
    printf("%d %d %lf\n",a/b,a%b,(double)a/b);
    }
    return 0;
}


Measured memory_bytes: 2092
import sys

# 1????????¢10??????3????????????4?£????????????????????????????????????????
def make_room_data():
    room_data = []
    for i in range(4):
        one_house = []
        for j in range(3):
            one_floor = []
            for k in range(10):
                one_floor.append(0)

            one_house.append(one_floor)

        room_data.append(one_house)

    return room_data
    
def main():
    room_data = make_room_data()
    n = int(sys.stdin.readline().strip())

    for _ in range(n):
        data = sys.stdin.readline().strip().split(' ')
        b, f, r, v = [int(i) for i in data]
        room_data[b-1][f-1][r-1] += v

    # ????????¨???
    for i in range(4):
        for j in range(3):
            for k in range(10):
                print(' %d' % (room_data[i][j][k]), end='')

            print('')

        if i != 3:
            print('#' * 20)

if __name__ == '__main__':
    main()

Measured memory_bytes: 7748
import java.util.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main{
    static final long mod=1000000007;
//    static int dx[]={-1,0,1,0};
//    static int dy[]={0,-1,0,1};

    public  static void main(String[] args)   throws Exception, IOException{        
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);
        // int n=sc.nextInt();
        // char c[][] = new char[h][w];
        // char c[]=sc.nextString().toCharArray();
        // int d[]=new int[n];
        // for(int i=0; i<n; i++) {d[i]=sc.nextInt();}

        int n=sc.nextInt();
        int k=sc.nextInt();
        int a[]=sc.nextIntArray(n);
        long dp[][]=new long[2][k+1];
        int f=0;
        dp[1][0]=1;
        for (int i = 0; i < n; i++,f^=1) {        	
			for (int t = 1; t <= k; t++) {
				dp[f^1][t]+=dp[f^1][t-1];
				if(dp[f^1][t]>=mod) dp[f^1][t]-=mod;
			}
			for (int t = 0; t <= k; t++) {
				if(t-a[i]>0)dp[f][t]=dp[f^1][t]-dp[f^1][t-a[i]-1];
				else dp[f][t]=dp[f^1][t];
				if(dp[f][t]<0)dp[f][t]+=mod;
			}
		}
	     
        out.println(dp[f^1][k]);
        out.flush();
    }
    
    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }

    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }  
}

//class P {
//    int id, d;
//    P(int  id, int d) {
//        this.id=id;
//        this.d=d;
//    }
//}

//class P implements Comparable<P>{
//    int id, d;
//    P(int  id, int d) {
//        this.id=id;
//        this.d=d;
//    }
//    public int compareTo(P p){
//        return d-p.d; //des
//    }
//}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public int[] nextIntArray(int size) throws IOException{
    	int r[] = new int[size];
    	for (int i = 0; i < size; i++) {
			r[i] = this.nextInt(); 
		}
    	return r;
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


Measured memory_bytes: 24404
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String s = br.readLine();
        String p = br.readLine();
        boolean check = false;
        label:for(int i=0;i<s.length();i++){
            if(s.charAt(i)==p.charAt(0)){
                for(int j=1;j<p.length();j++){
                    if(s.charAt((i+j)%s.length())!=p.charAt(j)) continue label;
                }
                check = true;
            }
        }
        if(check){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 24312
#include<iostream>

using namespace std;

struct Card{
    char ch,val;
};

void Bubble_sort(Card dat[],int size){
    bool judge = 1;
    for (int i = 0; judge; ++i) {
        judge = 0;
        for (int j = size - 1; j >= i + 1; --j) {
            if (dat[j].val < dat[j - 1].val) {
                swap(dat[j], dat[j - 1]);
                judge = 1;
            }
        }
    }
    return;
}
void Selection_sort(Card dat[],int size){
    int min;
    for(int i=0;i<size;++i){
        min=i;
        for(int j=i;j<size;++j){
            if(dat[j].val<dat[min].val) min=j;
        }
        swap(dat[i],dat[min]);
    }
    return;
}

int is_Stable(Card dat1[],Card dat2[],int size){
        for(int i=0;i<size;++i){
        if(dat1[i].ch != dat2[i].ch) return 0;
    }
    return 1;
}

void print(Card dat1[],Card dat2[],int size){
    for(int i=0;i<size;++i){
        if(i) cout<<" ";
        cout<<dat1[i].ch<<dat1[i].val;
    }
    cout << endl;
    cout<<"Stable"<<endl;
    for(int i=0;i<size;++i){
        if(i) cout<<  " ";
        cout<<dat2[i].ch<<dat2[i].val;
    }
    cout<<endl;
    if(is_Stable(dat1,dat2,size))cout<<"Stable"<<endl;
    else cout<<"Not stable"<<endl;
    return;
}
int main(){
    const int max=36;
    int size;
    Card C1[max],C2[max];
    cin >> size;
    for(int i=0;i<size;++i){
        cin >> C1[i].ch >> C1[i].val;
        C2[i].ch=C1[i].ch;
        C2[i].val=C1[i].val;
    }
    Bubble_sort(C1,size);
    Selection_sort(C2,size);
    print(C1,C2,size);
    return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define fr(i,s,e) for(i=s;i<e;i++)
#define rf(i,s,e) for(i=s-1;i>=e;i--)
#define pb push_back
#define mp make_pair

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<pair<long long,long long> > vpll;
typedef vector<vector<ll> > vvll;

template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
template<typename T> T pow(T a,T b, ll m){T ans=1; while(b>0){ if(b%2==1) ans=(ans*a)%m; b/=2; a=(a*a)%m; } return ans%m; }

bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
} 

bool sortinrev(const pair<int,int> &a,  
               const pair<int,int> &b) 
{ 
       return (a.first > b.first); 
} 
int main() {
	ll i,n,max=0;
	cin>>n;
	ll a[n],b[n];
	fr(i,0,n)
	{
		cin>>a[i];
		b[i]=a[i];
	}
	fr(i,0,n-1)
	{
		
		if(a[i]>a[i+1])
		{
			max=a[i];a[i+1]=max;
		}
		
	}ll s=0;
	fr(i,0,n)
	{
		s+=(a[i]-b[i]);
	}
	cout<<s;
	return 0;
	
}


Measured memory_bytes: 6756
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<utility>
#include<memory>
#include<cmath>
#include<stack>
#include<tuple>
#include<numeric>
#include<cassert>

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define pb push_back
#define DEBUG false

using namespace std;

using ll = long long;
using P = pair<int,int>;
using Pl = pair<int,ll>;
using Pd = pair<double,double>;
using T = tuple<double,double,int>;

const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll LINF=1LL<<60;
const int MAX_N = 100005;
const ll lmod = 1e9+7;

template <typename T>
class FenwickTree {
  const int n;
  vector<T> data;
public:
  FenwickTree(int n) : n(n), data(n, 0) {}
  void add(int i, T value) {
    for (; i < n; i |= i + 1) data[i] += value;
  }
  T sum(int i) const {
    // sum of [0,i]
    T res = 0;
    for (; i >= 0; i = (i & (i + 1)) - 1) res += data[i];
    return res;
  }
  T sum(int l, int r) const { return sum(r - 1) - sum(l - 1); }
};

FenwickTree<int> tree(MAX_N);
bool isPrime[MAX_N];

void prepare(){
  fill(isPrime,isPrime+MAX_N,true);
  isPrime[1] = false;
  REP(i,2,int(sqrt(double(MAX_N))+1)){
    int a = i;
    while(true){
      a += i;
      if(a>MAX_N) break;
      isPrime[a] = false;
    }
  }
  rep(i,MAX_N/2){
    int j = 2*i + 1;
    if(isPrime[j]&&isPrime[(j+1)/2]) tree.add(j,1);
  }
}

void solve(){
  int l,r;
  scanf("%d%d",&l,&r);
  printf("%d\n",tree.sum(l,r+1));
}

int main(){
  int Q; cin >> Q ;
  prepare();
  rep(i,Q) solve();
  return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define int long long
//#define ll long long
const int maxm=3e5+5;
int a[maxm];
int n,m;
signed main(){
    cin>>n>>m;
    for(int i=1;i<=n;i++)cin>>a[i];
    priority_queue<int,vector<int>,less<int> >q;
    for(int i=1;i<=n;i++){
        q.push(a[i]);
    }
    while(m&&!q.empty()){
        int x=q.top();q.pop();
        x/=2;
        m--;
        if(x)q.push(x);
    }
    int ans=0;
    while(!q.empty()){
        ans+=q.top();q.pop();
    }
    cout<<ans<<endl;
    return 0;
}
/*


*/


Measured memory_bytes: 5100
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <set>
#include <queue>
#include <iomanip>
#include <tuple>
#include <unordered_set>
#include <unordered_map>

using namespace std;


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

	long long res = 0;

	unordered_map<string, long long> anagrams;

	for (int i = 0; i < n; i++) {
		string temp;
		cin >> temp;
		sort(temp.begin(), temp.end());
		if (anagrams.find(temp) == anagrams.end()) anagrams[temp] = 0;
		else anagrams[temp]++;
		res += anagrams[temp];
	}

	cout << res;
}


Measured memory_bytes: 10660
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {

		try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))){

			final String inputLine = br.readLine();
			final String[] inputNumber = inputLine.split(" ");

			final Integer height = Integer.valueOf(inputNumber[0]);
			final Integer width = Integer.valueOf(inputNumber[1]);

			final Integer area = height * width;
			final Integer around = (height + width) * 2;

			System.out.println(area + " " + around);
		}

	}

}


Measured memory_bytes: 24252
import { count } from 'console';

process.stdin.resume();
process.stdin.setEncoding('utf8');

// 標準入力取込
let gInput = '';
process.stdin.on('data', (chunk) => (gInput += chunk));
process.stdin.on('end', () => main(gInput.split(/\r?\n/)));

// 解答
function main(inputs: string[]): void {
  const n = Number(inputs[0]);
  let hitList = new Set;

  for (let i = 1; i <= n; i++) {
    hitList.add(inputs[i]);
  }

  console.log(hitList.size);
}


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

int main(){
    int N;
    cin >> N;
    string S;
    cin >> S;

    int num=0;

    for (int i = 0; i < N-2; i++){
        if(S[i]=='A'&&S[i+1]=='B'&&S[i+2]=='C'){
            num++;
        }
        
    }

    cout << num;
    

    return 0;
}

Measured memory_bytes: 256
// Problem : B - Echo
// Contest : AtCoder Beginner Contest 145
// URL : https://atcoder.jp/contests/abc145/tasks/abc145_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
ordered_set;	

#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define FORD(i,a,b) for(int i = (a); i >= (b); --i)
#define RI(i,n) FOR(i,1,(n))
#define REP(i,n) FOR(i,0,(n)-1)
#define mini(a,b) a=min(a,b)
#define maxi(a,b) a=max(a,b)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define sz(w) (int) w.size()
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<pii, int> para;
const ll inf = 1e18 + 7;
const ll maxN = 1e6 + 5;
const ll MOD = 1e9 + 7;

int main() {
	ios_base::sync_with_stdio(0);
	string s;
	int n;
	cin >> n >> s;
	if (n % 2 == 1) {
		cout << "No";
		return 0;
	}
	if (s.substr(0, n / 2) == s.substr(n / 2, n / 2)) cout << "Yes";
	else cout << "No";
	return 0;
}



Measured memory_bytes: 256
using static System.Math;
using static System.Console;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(ReadLine());
            var permutation = ReadLine().Split(' ').Select(value => int.Parse(value) - 1).ToArray();

            var exists = new bool[n, n];
            var seats = new int[n, n];
            for (var i = 0; i < n; i++)
            {
                for (var j = 0; j < n; j++)
                {
                    exists[i, j] = true;
                    seats[i, j] = Min(Min(i, j), Min(n - (i + 1), n - (j + 1)));
                }
            }

            var count = 0;
            foreach (var number in permutation)
            {
                var row = number / n;
                var col = number % n;
                count += seats[row, col];
                exists[row, col] = false;

                var queue = new Queue<int[]>();
                queue.Enqueue(new int[2] { row, col });

                while (queue.Count > 0)
                {
                    var seat = queue.Dequeue();

                    var tmpRow = seat[0] + 1;
                    var tmpCol = seat[1];
                    var cost = seats[seat[0], seat[1]] + (exists[seat[0], seat[1]] ? 1 : 0);
                    if (tmpRow < n && seats[tmpRow, tmpCol] > cost)
                    {
                        queue.Enqueue(new int[2] { tmpRow, tmpCol });
                        seats[tmpRow, tmpCol] = cost;
                    }
                    tmpRow = seat[0] - 1;
                    tmpCol = seat[1];
                    if (tmpRow >= 0 && seats[tmpRow, tmpCol] > cost)
                    {
                        queue.Enqueue(new int[2] { tmpRow, tmpCol });
                        seats[tmpRow, tmpCol] = cost;
                    }
                    tmpRow = seat[0];
                    tmpCol = seat[1] + 1;
                    if (tmpCol < n && seats[tmpRow, tmpCol] > cost)
                    {
                        queue.Enqueue(new int[2] { tmpRow, tmpCol });
                        seats[tmpRow, tmpCol] = cost;
                    }
                    tmpRow = seat[0];
                    tmpCol = seat[1] - 1;
                    if (tmpCol >= 0 && seats[tmpRow, tmpCol] > cost)
                    {
                        queue.Enqueue(new int[2] { tmpRow, tmpCol });
                        seats[tmpRow, tmpCol] = cost;
                    }
                }
            }

            WriteLine(count);
        }
    }
}


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

int main() {
    string s;
    cin >> s;
    string res = "";
    for (int i=0; i<int(s.size()); i++) {
        switch(s.at(i)) {
            case '0':
                res+='0';
                break;
            case '1':
                res+='1';
                break;
            default:
                if (!res.empty()) res.erase(res.size()-1);
        }
    }
    cout << res << "\n";
}

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

int main() {
  int n; cin >> n;
  vector<ll> a(n), b(n);
  ll ans = 0;
  rep(i,n) cin >> a[i] >> b[i];
  for (int i = n-1; i>=0; i--) {
    a[i] += ans;
    ll x = a[i] % b[i];
    if (x) ans += b[i] - x;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4824
#include <iostream>
#include <map>
#include <cmath>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstdio>
using namespace std;

vector<double> xv,yv,rv;
const double eps = 1e-9;

int main() {
    int n,tc = 1;
    double x,y,r;
    while(cin>>n, n) {
        xv.clear(); yv.clear(); rv.clear();
        priority_queue<double, vector<double>, greater<double> > q;
        for(int i=0; i<n; ++i) {
            cin>>x>>y>>r;
            xv.push_back(x); yv.push_back(y); rv.push_back(r);
            q.push(x-r-eps); q.push(x+r-eps);
        }

        x = q.top(); q.pop();
        double ans = 0;
        while(!q.empty()) {
            double nx = q.top(); q.pop();
            double ll = -(1<<29);

            vector<pair<double,double> > rrv;
            for(int i=0; i<n; ++i)
                if(fabs(nx - xv[i]) < rv[i])
                    rrv.push_back(make_pair(yv[i]-rv[i],yv[i]+rv[i]));

            sort(rrv.begin(), rrv.end());
            double len = 0;
            for(int i=0; i<rrv.size(); ++i) {
                //cout<<i<<" : "<<rrv[i].first<<","<<rrv[i].second<<endl;
                len += max(0.0, rrv[i].second-max(ll,rrv[i].first));
                ll = max(ll, rrv[i].second);
            }

            ans += (nx-x) * len;
            //cout<<"add "<<len<<"*("<<nx<<"-"<<x<<")"<<endl;
            x = nx;
        }

        printf("%d %.2f\n", tc++, ans);
    }
}

Measured memory_bytes: 0
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        int[] nums=new int[n];
        for(int i=0;i<n;i++){
            nums[i]=sc.nextInt();
        }
        Arrays.sort(nums);
        System.out.println(nums[n/2]-nums[n/2-1]);
    }

}

Measured memory_bytes: 50528
using System;
public class Hello{
    public static void Main(){
        string[] input = Console.ReadLine().Split(' ');
        int X = int.Parse(input[0]);
        int A = int.Parse(input[1]);
        int B = int.Parse(input[2]);
        
        if(-A + B <= 0){
            Console.WriteLine("delicious");
        }else if(-A + B <= X){
            Console.WriteLine("safe");
        }else{
            Console.WriteLine("dangerous");
        }
    }
}


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

int main(){
  int n;
  cin>>n;
  int sum=0;
  REP(i,n){
    REP(j,n){
      REP(k,n){
        sum=sum+__gcd(k,__gcd(i,j));
      }
    }
  }
  cout <<sum<<endl;
}


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

typedef long long ll;

static const ll INF = 1ll<<60;
static const int MOD = 1e9+7;

int main(){
    int H,W,K;
    cin>>H>>W>>K;
    char board[10][10];

    ll ans = 0;
    
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            cin>>board[i][j];
        }
    }

    for(int hbit = 0; hbit < (1<<H); hbit++){
        for(int wbit = 0; wbit < (1 << W); wbit++){
            int cnt = 0;

            //列をみる
            for(int i=0; i<H; i++){
                for(int j=0; j<W; j++){
                    if(!(hbit & (1<<i)) && !(wbit & (1<<j))){
                        if(board[i][j] == '#') cnt++;
                    }
                }
            }

            if(cnt == K) ans++;
        }
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin >> S;
  int Q;
  cin >> Q;
  int dir = 0; //0: 普通 1: 反転
  deque<char> s;
  for (int i = 0; i < S.size(); i++){
    s.push_back(S[i]);
  }
  for (int i = 0; i < Q; i++){
    int q;
    cin >> q;
    if (q == 1){
      //反転
      dir = 1 - dir;
    } else {
      int F;
      cin >> F;
      char c;
      cin >> c;
      if (dir == 0 && F == 2 || dir == 1 && F == 1){
        s.push_back(c);
      } else {
        s.push_front(c);
      }
    }
  }
  if (dir == 0){
    for (int i = 0; i < s.size(); i++){
      cout << s[i];
    }
  } else {
    for (int i = s.size() - 1; i >= 0; i--){
      cout << s[i];
    }
  }
}

Measured memory_bytes: 896
poland = input().split()
num = []
for p in poland:
    if p.isdigit():
        num.append(int(p))
    else:
        b = num.pop()
        a = num.pop()
        if p == '*':
            num.append(a * b)
        elif p == '/':
            num.append(a / b)
        elif p == '+':
            num.append(a + b)
        elif p == '-':
            num.append(a - b)
print(num.pop())

Measured memory_bytes: 6728
n = int(input())

c = []

for i in range(n):
    now = 0
    for j in range(i + 1):
        now = 0
        k = j + 1
        while k % 2 == 0:
            now += 1
            k -= k // 2
            
    c.append(now)


#print(c)


print(max(range(len(c)), key = lambda i: c[i]) + 1)


Measured memory_bytes: 3060
X,Y,A,B,C=(int(x) for x in input().split())
P=list(map(int, input().split()))
Q=list(map(int, input().split()))
R=list(map(int, input().split()))

D=sorted(P, reverse=True)[:X]
E=sorted(Q, reverse=True)[:Y]
Z=X+Y
if C>=Z:
    F=sorted(R, reverse=True)[:Z]
else:
    F=R

D.extend(E)
D.extend(F)
I=sorted(D, reverse=True)[:Z]

print(sum(I))

Measured memory_bytes: 24052
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
int x[2000], y[2000], xy[2]={0,0}, n;
vector<int> v;
char g;
int main(){
	scanf("%d",&n);
	for(int i=0; i<n; i++) {
		scanf("%d%d",&x[i],&y[i]);
		xy[(x[i]+y[i])%2]=1;
	}
	if (xy[0] && xy[1]) {
		printf("-1\n");
		return 0;
	}
	if (xy[0]) v.pb(1);
	for(int i=1<<30; i>0; i>>=1) {
		v.pb(i);
	}
	printf("%d\n",v.size());
	for(int i=0; i<v.size(); i++) {
		printf(i==v.size()-1?"%d\n":"%d ",v[i]);
	} 
	for(int i=0; i<n; i++) {
		int xx=0, yy=0;
		for(int j=0; j<v.size(); j++){
			if (abs(x[i]) > abs(y[i])) {
				if (x[i] > 0) {x[i]-=v[j]; g = 'R';}
				else {x[i]+=v[j]; g = 'L';}
			} else {
				if (y[i] > 0) {y[i]-=v[j]; g = 'U';}
				else {y[i]+=v[j]; g = 'D';}
			}
			printf("%c",g);
		}
		printf("\n");
	}
	return 0;
}

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

int main()
{
    int n;
    cin >> n;
    map<string, long long> s;
    string t;
    for( int i = 0; i < n; i++ )
    {
        cin >> t;
        s[t] = s[t] + 1;
    }
    
    int flag = 0;
    for(map<string, long long>::iterator itr = s.begin(); itr != s.end(); ++itr)
    {
        if( itr->second > 1)
        {
            flag = 1;
        }
    }

    if( flag == 1 )
    {
        cout << "NO" << endl;
    }
    else if( flag == 0 )
    {
        cout << "YES" << endl;
    }
    
    return 0;
}



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

using namespace std;
using i64 = long long;

int main(){
    string s;
    i64 n;
    cin>>n;
    while(n>26){
        i64 a=(n-1)%26;
        s+='a'+a;
        n=(n-1)/26;
    }
    i64 a=(n-1)%26;
        s+='a'+a;
        n/=26;
    reverse(s.begin(),s.end());
    cout<<s<<endl;

    return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX
#define INFL LLONG_MAX
typedef long long ll;
using namespace std;
int main(){
  int n; cin >> n;
  string s,t; cin >> s >> t;

  rep(i,s.size()){
    cout << s.at(i) << t.at(i);
  }

}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e6 + 50;
int n;
ll a[maxn];
map<ll, ll> mp;
int main()
{
    std::ios::sync_with_stdio(false);
    cin >> n;
    for(int i = 0;i < n;i++){
        cin >> a[i];
    }
    sort(a, a + n);
    ll gcd = a[0];
    for(int i = 1;i < n;i++){
        gcd = __gcd(gcd, a[i]);
    }
    bool ok = true;
    for(int i = 0;i < n;i++){
        ll now = a[i];
        for(ll j = 2;j * j <= now;j++){
            if(now % j == 0LL){
                if(mp[j] || mp[now / j]){
                    ok = false;
                    break;
                }
                mp[j] = 1;
                mp[now / j] = 1;
            }
        }
        mp[now] = 1;
        if(!ok) break;
    }
    if(ok) cout << "pairwise coprime\n";
    else if(gcd == 1LL) cout << "setwise coprime\n";
    else cout << "not coprime\n";
    return 0;
}


Measured memory_bytes: 11396
////////////////いろいろあるよ//////////////////////////////////
//include,namespace
 #include<bits/stdc++.h>
 #include<iostream>
 #include<bitset>
 using namespace std;
//REPmacro
 #define all(x) (x).begin(),(x).end()             //ソート
 #define FOR(i,x,n)for(int i=(x);i<(n);i++)
 #define FOR_R(i,x,n) for(int i=(n-1);i>=(x);i--)
 #define REP(i, n) FOR(i, 0, n)
 #define REP_R(i, n) FOR_R(i, 0, n)
//long long(define)
 using ll = long long;
 typedef long long ll;
 typedef long long int64;
 typedef long long lint;
 typedef long long lli;

//bit
 /*
 const unsigned int BIT_FLAG_0 = (1 << 0); // 0000 0000 0000 0001
 const unsigned int BIT_FLAG_1 = (1 << 1); // 0000 0000 0000 0010
 const unsigned int BIT_FLAG_2 = (1 << 2); // 0000 0000 0000 0100
 const unsigned int BIT_FLAG_3 = (1 << 3); // 0000 0000 0000 1000
 const unsigned int BIT_FLAG_4 = (1 << 4); // 0000 0000 0001 0000
 const unsigned int BIT_FLAG_5 = (1 << 5); // 0000 0000 0010 0000
 const unsigned int BIT_FLAG_6 = (1 << 6); // 0000 0000 0100 0000
 const unsigned int BIT_FLAG_7 = (1 << 7); // 0000 0000 1000 0000 
 */

//variable
 //const int INF = 1000000;
 //int dp[INF][INF];
 //int ans=0;

 //int dx[4]={1,0,-1,0};
 //int dy[4]={0,1,0,-1};

int N=0;
int M=0;
////////////////いろいろあるよ//////////////////////////////////

int main(){
 	cin >> N;
	 pair<string,int> data[N];
	 REP(i,N)cin >> data[i].first >> data[i].second;
	 string sleep;
	 cin >> sleep;
	 int start=0;
	 REP(i,N){
		 if(data[i].first == sleep){
			 start = i;
		 	 //cout << "success" << start << data[i].first << sleep<< endl;
		 	 break;
		 }
	 }
	 int count=0;
	 for(int i=start+1;i<N;i++){
		 count+= data[i].second;
	 }
	 cout << count << endl;
	
 	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(a: int):
    print(int(a + a ** 2 + a ** 3))
    return


# 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)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    a = int(next(tokens))  # type: int
    solve(a)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9164
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(), a.end());
    //int max = sqrt(a[1]);
    int gcd = 1;
    for (int i = a[1]; i > 1; i--){
        bool flag = true;
        int cnt = 0;
        for (int j = 0; j < n; j++){
            if (a[j] % i != 0){
                cnt++;
                if ( cnt > 1) {
                    flag = false;
                    break;
                }
            }
        }
        if (flag){
            gcd = i;
            break;
        }
    }
    cout << gcd << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(c) (c).begin(),(c).end()
int main(){
	while(true){
		int n,r,a[50]={},b[50]={};
		cin >> n >> r;
		if(n==0) break;
		rep(i,n) a[i]=n-i;
		rep(i,r){
			int p,c;
			cin >> p >> c;
			rotate(a,a+p-1,a+p+c-1);
		}
		cout << a[0] << endl;
	}
	return 0;
}

Measured memory_bytes: 1184
#include<stdio.h>
#define N 100

int main()
{
  int i,j,n=0,num[N],min=0,kari=0,count=0;

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

  for( i = 0 ; i < n ; i++ )
  {
    min = i;

    for( j = i ; j < n ; j++)
    {
      if( num[j] < num[min] )
      {
        min = j;
      }
    }
    if( num[min] != num[i] )count++;
    
    kari = num[min];
    num[min] = num[i];
    num[i] = kari;
  }

  for( i = 0 ; i < n-1 ; i++ )
  {
    printf("%d ",num[i]);
  }
  printf("%d\n%d\n",num[n-1],count);

  return 0;
}



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

template<typename T> void chmin(T &a,T b){if(a>b) a=b;}
template<typename T> void chmax(T &a,T b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n,k;
  cin>>n>>k;
  vector<Int> c(n),r(n);
  for(Int i=0;i<n;i++) cin>>c[i]>>r[i];

  vector<vector<Int> > G(n);
  for(Int i=0;i<k;i++){
    Int x,y;
    cin>>x>>y;
    x--;y--;
    G[x].emplace_back(y);
    G[y].emplace_back(x);
  }
  
  auto bfs=[&](Int s,auto &d){
    d.assign(n,-1);
    queue<Int> q;
    d[s]=0;
    q.emplace(s);
    while(!q.empty()){
      Int v=q.front();q.pop();
      for(Int u:G[v]){
	if(~d[u]) continue;
	d[u]=d[v]+1;
	q.emplace(u);
      }
    }
  };
  
  vector<vector<Int> > di(n);
  for(Int i=0;i<n;i++) bfs(i,di[i]);

  const Int INF = 1e15;
  vector<Int> dp(n,INF);
  vector<Int> used(n,0);
  dp[0]=0;
  
  for(Int i=0;i<n;i++){
    Int u=-1;
    for(Int j=0;j<n;j++){
      if(used[j]||dp[j]==INF) continue;
      if(u<0||dp[u]>dp[j]) u=j;
    }
    if(u<0) break;
    used[u]=1;
    for(Int j=0;j<n;j++){
      if(di[u][j]>r[u]) continue;
      chmin(dp[j],dp[u]+c[u]);
    }
  }
  
  cout<<dp[n-1]<<endl;
  return 0;
}



Measured memory_bytes: 198960
#include<iostream>
#include<climits>
#include<cstring>
#define ll long long
using namespace std;
ll n, w;
ll weight[100005], value[100005];
ll dp[105][100005];
ll solve(ll i, ll j){
	if(i==n+1)
		return 0;
	if(j==0)
		return 0;
	if(dp[i][j] != -1)
		return dp[i][j];
	if(j-weight[i] < 0)
		return dp[i][j] = solve(i+1, j);
	else
		return dp[i][j] = max(value[i] + solve(i+1, j-weight[i]), solve(i+1, j));
}
int main(){
	cin>>n>>w;
	for(ll i=1;i<=n;i++){
		cin>>weight[i]>>value[i];
	}
	memset(dp, -1, sizeof(dp));
	cout<<max(solve(1, w-weight[1]), solve(1, w));
	return 0;
}


Measured memory_bytes: 82304
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(v) v.begin(), v.end()

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  
  int s1 = max(max(a, b), c);
  int s2 = min(min(a, b), c);
  int s3 = a+b+c -s1-s2;
  
  cout << s1*pow(2, k) +s2 + s3 << "\n";

}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#ifdef ONLINE_JUDGE
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif
#define fu(a,b,c) for(int a=b;a<=(int)c;++a)
#define fd(a,b,c) for(int a=b;a>=(int)c;--a)
#define cu(a,b,c) for(int a=b;a<(int)c;++a)
#define cd(a,b,c) for(int a=(b)-1;a>=(int)c;--a)
#define gcd(a,b) __gcd(a,b) 
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define pf push_front
#define uint unsigned int
#define MOD 1000000007
#define MAXN 5000
#define MAXH 4
#define MAXM 4
#define INF 1LL << 62
#define ll long long
#define ull unsigned long long
#define RNG rng mt19937(time(NULL))
#define udist(a,b) uniform_int_distribution<uint32_t> distribution(a,b)
#define max3(a,b,c) max(a, max(b, c))
#define min3(a,b,c) min(a, min(b, c))
#define gmax(a,b) a = max(a, b)
#define gmin(a,b) a = min(a, b)
#define whatis(x) cerr << #x << " is " << x << endl;
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI 3.1415926535897932384626433
using namespace std;

int main(){
	fast_io();
	int n;
	cin >> n;
	vector<int> v(3*n);
	cu(i,0,3*n)cin >> v[i];
	priority_queue<int, vector<int>, greater<int>> pq;
	multiset<int> lea,oth;
	ll rsum=0,leasum=0;
	cu(i,0,n){
		pq.push(v[i]);	
		rsum += v[i];
	}
	cu(i,n,3*n){
		oth.insert(v[i]);	
	}
	cu(i,0,n){
		leasum += *oth.begin();
		//lea.insert(*oth.begin());
		oth.erase(oth.begin());
	}
	ll ans = rsum - leasum;
	cu(i,n,2*n){
		if(v[i] > pq.top()){
			rsum += v[i] - pq.top();
			pq.pop();
			pq.push(v[i]);
		}
		if(v[i] >= *oth.begin()){
			oth.erase(oth.find(v[i]));
		}
		else{
			leasum -= v[i];	
			//lea.erase(lea.find(v[i]));
			leasum += *oth.begin();
			oth.erase(oth.begin());
			//lea.insert(lea.find(v[i]));
		}
		gmax(ans, rsum - leasum);
	}
	cout << ans << '\n';
}


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

using namespace std;

int n,num;
vector<string> s;

int solve(int c, int a, int b)
{
    if(c == 0){
        return a+b;
    }else{
        return a*b;
    }
}

int dfs(int d,int id)
{
    int res = id;
    while(num < n){
        if(isdigit(s[num].back())){
            if((int)s[num].size()-1 < d){
                return res;
            }
            res = solve(id,res,(s[num].back()-'0'));
            num++;
        }else{
            if((int)s[num].size()-1 < d){
                return res;
            }
            int flag = (s[num].back()=='*');
            num++;
            int ans = dfs(d+1,flag);
            res = solve(id,res,ans);
        }
    }
    return res;
}

int main()
{
    while(1){
        cin >> n;
        if(n == 0){
            break;
        }
        s.resize(n);
        rep(i,n){
            cin >> s[i];
        }
        num = 0;
        cout << dfs(0,0) << "\n";
    }
}



Measured memory_bytes: 3192
#include "bits/stdc++.h"
using namespace std; 

#define IOS {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}
#define ll long long 

int main(){
        IOS;
        string s;
        cin>>s;
        ll sum=0;
        ll n=(int)s.size();
        for(ll i=0;i<n;i++) sum+=(s[i]-'0');
        if(sum%9==0 ) cout<<"Yes\n";
        else cout<<"No\n";
}


Measured memory_bytes: 3764
#include <iostream>

int main(void)
{
    int a,b;
    std::cin >> a;
    std::cin >> b;
    if (a<b) {
        std::cout<<"a < b\n";
    }else if (a>b){
        std::cout<<"a > b\n";
    }else{
        std::cout<<"a == b\n";
    }
    return 0;
}

Measured memory_bytes: 1124
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <iomanip>
#include <ctype.h>

using namespace std;
using ll = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

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

ll GCD(ll x, ll y) {
    if (y == 0) return x;
    else return GCD(y, x % y);
}

bool my_compare(pair<string, int> a, pair<string, int> b) {
    if (a.first != b.first) {
        return a.first < b.first;
    }

    if (a.second != b.second) {
        return a.second > b.second;
    }
    else {
        return true;
    }
}

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

    vector<int> L(N);
    rep(i, N) cin >> L[i];

    int S = 0;

    rep(i, N) S += L[i];

    int M = 0;

    rep(i, N) M = max(M, L[i]);

    if (M < S - M) { cout << "Yes" << endl; }
    else { cout << "No" << endl; }
}

Measured memory_bytes: 384
#include<iostream>
#include <algorithm>
#include <functional>
#include<vector>
#include<math.h>
#include<bitset>
#include<string>
#include <deque>
#include<queue>
#include <iomanip>
#include<map>
#include <random>
#include<type_traits>
#include<stack>
#include <sstream> 
#include <limits>
#include <numeric>
#include<string.h>
using namespace std;
#define ll long long int
#define all(v) begin(v), end(v)
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
//typedef vector<int> V;
//typedef vector<V> VV;
//typedef vector<VV> VVV;
using namespace std;
int tru[103];

int main() {
	int n, a[103];
	string s[103];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> s[i] >> a[i];
	}
	for (int i = 0; i <n; i++) {
		int index = -1,m=0;
		string sss = "zzzzzzzzzzzzzzzzzzzzz";
		for (int j = 0; j < n; j++) {
			if (sss > s[j] && tru[j]==0) {
				index = j;
				sss = s[j];
				m=a[j];
			}
			else if (sss==s[j]&& a[j] > m && tru[j] == 0) {
				index = j;
				sss = s[j];
				m = a[j];
			}
		}
		cout <<index+1<< endl;
		tru[index] = 1;
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
#define all(obj) (obj).begin(), (obj).end()
static const int dx[4] = {0, 1, 0, -1};
static const int dy[4] = {1, 0, -1, 0};
static const char dir[4] = {'u', 'r', 'd', 'l'};
static const ll INF = 1ll << 60;
static const ll MOD = 1e9 + 7;

signed main() {
  string S;
  cin >> S;
  vector<int> cnt(3);
  for (auto& c : S) {
    cnt[c - 'a']++;
  }
  sort(all(cnt));
  if (cnt[2] - cnt[0] > 1)
    puts("NO");
  else
    puts("YES");
  return 0;
}

Measured memory_bytes: 512
G = [[] for _ in range(4)]
for _ in range(3):
    a, b = map(int, input().split())
    a, b = a - 1, b - 1
    G[a].append(b)
    G[b].append(a)

num = []
for i in range(4):
    num.append(len(G[i]))

cnt = num.count(1)
if cnt < 3:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 61920
#include <iostream>
#include <vector>
#include <numeric>
#include <random>
using namespace std;

int solve(int N, vector<int>& Nums) {
	vector<int> Primes(1000001, 1);
	int now = 2;
	bool setwise = false;
	while (now <= 1000000) {
		int a = now;
		int num = Nums[a];
		while (a + now <= 1000000) {
			a += now;
			Primes[a] = 0;
			num += Nums[a];
		}
		if (num == N) {
			cout << "not coprime" << endl;
			return 0;
		}
		if (num > 1) setwise = true;
		now++;
		while (now <= 1000000 && !Primes[now]) now++;
	}
	cout << (setwise ? "setwise coprime" :"pairwise coprime") << endl;
	return 0;
}

int main() {
	vector<int> Nums(1000001, 0);
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) {
		int A;
		cin >> A;
		Nums[A]++;
	}
	solve(N, Nums);
}


Measured memory_bytes: 11164
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;
string X;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>X;
    int n=X.length();
    int res=0;
    int ans=0;
    rer(i,n,0){
        if(X[i]=='T') res++;
        else {
            if(res){
                res--;
                ans++;
            }
        }
    }
    cout <<n-2*ans<<"\n";
}

Measured memory_bytes: 720
#include <stdio.h>
#include <stdlib.h>

int c(const void *v1,const void *v2){
    return *(int *)v1-*(int *)v2;
}
int main(void){
    int sign=0,i,o,t,r,s,sum=0,n,line[1000],line1[1000];
    char cline[10001];
    scanf("%d",&n);
    for(i=0;i<n;i++)
        scanf("%d",&line[i]);
    for(t=1,r=0;t<=n;r=0,t++){
        for(i=0;i+t<=n;sum=0,i++){
            for(o=0;o<t;o++){
                cline[o]=line[i+o]+48;
            }
            cline[o]=0;
            sum=atoi(cline);
            if(sum >= sign)
                line1[r++]=sum;
        }
        qsort(line1,r,sizeof(int),c);
        if(line1[0] != 0 && t==1){
            puts("0");
            break;
        }
        for(s=0;s<r;s++){
            if(sign == line1[s])
                continue;
            else if(sign+1 == line1[s])
                sign++;
            else
                break;
        }
        if(s != r){
            printf("%d\n",sign+1);
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 664