akhauriyash/Code-Regression huggingface dataset:
#include	<bits/stdc++.h>
using	namespace	std;
typedef	long long ll;

// int/long:		-2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)
// while (getline(cin, S)) {}

// #include <cstdio>
// int a;
// scanf("%d", &a);
// printf("%d\n", a);
//
// for (int i=0; i<n; ++i)
// 	scanf("%d", &a[i]);
//
// char c;
// scanf(" %c", &c);
//
// cout << "\n";

// cout <<fixed <<setprecision(10)

// priority_queue<int> q;
// priority_queue<int, vector<int>, less<int>> q; // Default: vector, less
// priority_queue<vector<int>, vector<vector<int>>, greater<vector<int>>> q;

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

//
// Notes
//
// When specified less than N, try full scan.
// RE: empty vector
// Check Qs
// long/int
// xor -> count each bit
// Check values
// 	1,000,000 -> Loop
// 	100,000	-> vector(int:400KB, long:800KB) 

#define	INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define	MOD 1000000007

/*
ll	myPow(ll x, ll n) {
	if (0==n)
		return 1;
	if (0==n%2)
		return myPow(x*x%MOD, n/2);
	else
		return x*myPow(x, n-1)%MOD;
}
*/
ll	myPow(ll x, ll n) {
	ll r=1;
	while(n>0)
		if (0==n%2) {
			x *=x;
			x %=MOD;
			n /=2;
		} else {
			r *=x;
			r %=MOD;
			n--;
		}
	return r;
}

#define	Rep0(i, n)	for (ll i=0; i<n; i++)
#define	Rep1(i, n)	for (ll i=1; i<=n; i++)
#define Sort(P)	sort(P.begin(), P.end())
#define Rev(P)	reverse(P.begin(), P.end())

int	main() {
	ll N;
	cin >>N;
	vector<ll> A(N, 0);
	vector<ll> S(N+1, 0);
	Rep0(i, N) {
		cin >>A.at(i);
		S.at(A.at(i))++;
	}
	ll SS=0;
	Rep1(i, N)
		SS+=(S.at(i)*(S.at(i)-1))/2;
	Rep0(i, N) {
		ll I=A.at(i);
		ll NN=S.at(I);
		ll SSS=SS-(NN*(NN-1))/2;
		if (NN>2) {
			NN--;
			SSS+=(NN*(NN-1))/2;
		}
		cout <<SSS <<endl;
	}
	return 0;
}



Measured memory_bytes: 5760
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int f=0;
    int t=0;
    int o=0;
    for(int i=0;i<n;i++){
      int in=sc.nextInt();
      if(in%4==0){
        f++;
      }else if(in%2==0){
        t++;
      }else{
        o++;
      }
    }
    if(t>0){
      if(f>=o){
        System.out.println("Yes");
      }else{
        System.out.println("No");
      }
    }else{
      if(f>=o-1){
        System.out.println("Yes");
      }else{
        System.out.println("No");
      }
    }
  }
}

Measured memory_bytes: 46216
#include<cstdio>
#include<queue>
#include<utility>
#include<cstring>
#include<stack>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<map>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
bool cmp_P(const P &a,const P &b){
  return a.second < b.second;
}
int main()
{
  string s;
  int arr[10];
  REP(i,10)arr[i] = 0;
  cin >> s;
  if((s[0] == s[1] && s[1] == s[2]) || (s[1] == s[2] && s[2] == s[3])){
    cout << "Yes" << endl;
  }else
    cout << "No" << endl;
  
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

//木の根を求める
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(ranks[x] < ranks[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

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



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

int main(){
 int N,X,T,t;
  cin>>N>>X>>T;
  if(N%X==0){
 t=(N/X)*T;
  }
  else{
  t=(N/X+1)*T;
  }
  cout<<t<<endl;
  
}

Measured memory_bytes: 3588
//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;
////////////////いろいろあるよ//////////////////////////////////
 
int main(){
  int N,K;
  cin >> N >>K;
  int data[N];
  REP(i,N){
    int a;
    cin >> a;
    data[i] = a + 1;
  }
 
  int S[N+1];
  S[0]=0;
  S[1]=data[0];
  for(int i=1;i<N;i++)S[i+1]=S[i]+data[i];
 
  double ans=0;
  REP(i,N-K+1){
  	int piyo=0;
    piyo=S[i+K]-S[i];
    if(piyo>ans) ans=piyo;
  }
  
  cout << fixed << setprecision(12);
  cout << ans/2 <<endl;
  
  
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int,ll> pil;
ll dist[100001];
ll inf=1LL<<60;
vector<pil> v[100001];
void dfs(int k){
  for(int i=0;i<v[k].size();i++){
    if(dist[v[k][i].first]==inf){
      dist[v[k][i].first]=dist[k]+v[k][i].second;
      dfs(v[k][i].first);
      }
    }
  }
int main(){
  int n;
  cin>>n;
  int a[n],b[n];
  ll c[n];
  for(int i=1;i<n;i++){
    cin>>a[i]>>b[i]>>c[i];
    v[a[i]].push_back(pil(b[i],c[i]));
    v[b[i]].push_back(pil(a[i],c[i]));
    }
  for(int i=1;i<=n;i++){
    dist[i]=inf;
    }
  int q,k;
  cin>>q>>k;
  dist[k]=0;
  dfs(k);
  for(int i=0;i<q;i++){
    int l,r;
    cin>>l>>r;
    cout<<dist[l]+dist[r]<<endl;
    }
  return 0;
  }


Measured memory_bytes: 15872
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

int main() {
	ll n; cin >> n;
	ll a[100000] = {};
	ll maxV = 0;
	rep(i, 0, n) {
		cin >> a[i];
		maxV = max(maxV, a[i]);
	}

	sort(a, a + n);

	ll minV = (ll)(1 << 30);
	ll ans = 0;
	rep(i, 0, n) {
		if (a[i] != maxV && minV >= abs(maxV - 2 * a[i])) {
			minV = maxV - 2 * a[i];
			ans = a[i];
		}
	}

	cout << maxV << " " << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
N = int(input())
AC = 0
WA = 0
TLE = 0
RE = 0
for i in range(N):
    a = input()
    if a == "AC":
        AC += 1
    elif a == "WA":
        WA += 1
    elif a == "TLE":
        TLE += 1
    elif a == "RE":
        RE += 1
print(f"AC x {AC}")
print(f"WA x {WA}")
print(f"TLE x {TLE}")
print(f"RE x {RE}")

Measured memory_bytes: 9168
#include <stdio.h>

#define INF 10000000
#define NIL -1
#define BLACK 1
#define WHITE 0

void dijkstra(void);

int n,a[101][101],w=0,d[101],pi[101],color[101];

int main()
{
  int i,j,u,k,v;


  scanf("%d",&n);

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      a[i][j]=-1;
    }
  }

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

    scanf("%d",&u); //頂点の番号
    scanf("%d",&k); //出次数

    for(j=0;j<k;j++){
      scanf("%d",&v);
      scanf("%d",&a[u][v]);
    }
  }

  dijkstra();

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

  return 0;
}

void dijkstra(void){
  int mincost,u,v,i;

  for(u=0;u<n;u++){ // each u in G
    d[u] = INF;
    pi[u] = NIL;
    color[u] = WHITE;
  }

  d[0] = 0;

  while(1){
    mincost = INF;
    for(i=0;i<n;i++){ //each i in G
      if (color[i] != BLACK && d[i] < mincost){
	mincost = d[i];
	u = i;
      }
    }
    color[u] = BLACK;

    if(mincost == INF) break;

    for(v=0;v<n;v++){// each v in Adj[u]
      if(a[u][v]!=-1){
	if (color[v] != BLACK && a[u][v]+d[u] < d[v]){
	  pi[v] = u;
	  d[v] = d[u]+a[u][v];
	}
      }
    }
  }
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
#include<random>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
#define rep(i, n) for(int i=0; i<n; i++)
const int MOD=1e9+7;

int main(){

  int n, m, a[10010];
  cin >> n >> m;
  rep(i, m){
    cin >> a[i];
    n -= a[i];
  }
  if(n < 0){
    cout << -1 << endl;
  } else {
    cout << n << endl;
  }

  return 0;
}

Measured memory_bytes: 3680
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N=sc.nextInt();
        int A=sc.nextInt();
        int B=sc.nextInt();
        int[] P=new int[N];
        for(int i=0;i<N;i++){
            P[i]=sc.nextInt();
        }
//        Arrays.sort(P);
        int n1=0;
        int n2=0;
        int n3=0;
        for(int i=0;i<N;i++){
            if(P[i]<=A){
                n1++;
                continue;
            }
            if(P[i]<=B){
                n2++;
                continue;
            }
            n3++;
        }
        int result=n1;
        if(result>n2){
            result=n2;
        }
        if(result>n3){
            result=n3;
        }

        System.out.println(result);
    }


}

Measured memory_bytes: 22740
#include <bits/stdc++.h>
#define rep(i,s,n) for(int i=s;i<n;i++)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define int long long
using namespace std;
using P=pair<int,int>;
using Graph=vector<vector<int>>;
using ll=long long;



signed main(){
    int n,a,b;
    cin>>n>>a>>b;
    int ans=0;
    ans += (n/(a+b))*a;
    ans += min(a,n%(a+b));

    cout<<ans<<endl;
}   

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef pair<int, int>P;
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
typedef vector<vector<ll>> mat;
typedef vector<int> vec;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
const ll mod = 1000000007;
const ll INF = mod * mod;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
ll qp(ll a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };

void solve() {
    ll h, a;
    cin >> h >> a;
    ll co;
    co = h / a;
    if(h%a != 0) co++;

    cout << co << endl;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    //cout << fixed << setprecision(10);
    solve();
    // stop
        return 0;
}

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

using namespace std;
const int MAXN = 1e5+10;
int t[MAXN];
int main(){
	int n, c, k;
	cin >> n >> c >> k;

	for (int i = 0; i < n; ++i) {
		cin >> t[i];
	}

	sort(t, t + n);

	int curt = 0;
	int cant = 0;
	int res = 0;
	for (int i = 0; i < n; ++i) {
		if(cant == c || (cant > 0 && t[i] > curt + k)){
			res++;
			cant = 0;
		}
		if(cant == 0){
			curt = t[i];
		}
		cant++;
	}
	if(cant > 0) res++;
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y);
#define chmin(x,y) x = min(x,y);
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};
const int INF = 1001001001;



int main() {
    int n, x;
    cin >> n >> x;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    rep(i,n) {
        a[i] -= x;
        a[i] = abs(a[i]);
    }
    int ans = 0;
    rep(i,n) {
        ans = __gcd(ans, a[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3692
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Collections;

static class Extensions
{
    public static int ToInt(this string s) => int.Parse(s);
    public static long ToLong(this string s) => long.Parse(s);
    public static char ToChar(this string s) => char.Parse(s);
    public static double ToDouble(this string s) => double.Parse(s);
    public static int[] ToIntArray(this string s) => s.Replace(',', ' ').Split(' ').Select(x => x.ToInt()).ToArray();
    public static long[] ToLongArray(this string s) => s.Replace(',', ' ').Split(' ').Select(x => x.ToLong()).ToArray();
    public static double[] ToDoubleArray(this string s) => s.Replace(',', ' ').Split(' ').Select(x => x.ToDouble()).ToArray();
    public static Queue<T> ToQueue<T>(this IEnumerable<T> seq) => new Queue<T>(seq);
    public static Stack<T> ToStack<T>(this IEnumerable<T> seq) => new Stack<T>(seq);
    public static HashSet<T> ToHashSet<T>(this IEnumerable<T> seq) => new HashSet<T>(seq);
}
static class MyMath
{
    static public long GCD(long a, long b) => (a < b) ? GCD(b, a) : ((b == 0) ? a : GCD(b, a % b));
    static public long LCM(long a, long b) => (a > b) ? (a / GCD(a, b) * b) : (b / GCD(a, b) * a);
    static private readonly long _m = 1000000000 + 7;
    static public long Mod(long val) => (val % _m + _m) % _m;
    static private long extGCD(long a, long b, ref long x, ref long y) => (b == 0) ? (a + (x = 1) * 0 + (y = 0) * 0) : (extGCD(b, a % b, ref y, ref x) + (y -= a / b * x) * 0);
    static public long ModInverse(long a, long dummy1 = 0, long dummy2 = 0) => extGCD(a, _m, ref dummy1, ref dummy2) * 0 + Mod(dummy1);    
}

class Program
{
    static string[] ReadLines(int n) => Enumerable.Range(0, n).Select(s => Console.ReadLine()).ToArray();

    static void Main()
    {
        int N = Console.ReadLine().ToInt();
        var pList = Console.ReadLine().ToIntArray().ToList();

        var sortedList = pList.OrderBy(n => n).ToList();

        var zz = pList.Zip(sortedList, (n1, n2) => n1 == n2).Count(b => b == false);

        if (zz <= 2)
        {
            Console.WriteLine("YES");
        }
        else
        {
            Console.WriteLine("NO");
        }

    }
    
}

Measured memory_bytes: 13524
#include <iostream>
#include <set>
#include <algorithm>
using i64 = long long;

int main() {
    int n;
    std::cin >> n;
    i64 ret = 0;
    std::multiset<i64> pp, pm, mp, mm;
    for (int i = 0; i < n; i++) {
        i64 x, y;
        std::cin >> x >> y;
        if (i) {
            const i64 max = std::max({
                x + y + *mm.rbegin(),
                x - y + *mp.rbegin(),
                -x + y + *pm.rbegin(),
                -x - y + *pp.rbegin(),
            });
            if (max > ret) ret = max;
        }
        pp.insert(x + y);
        pm.insert(x - y);
        mp.insert(-x + y);
        mm.insert(-x - y);
    }

    std::cout << ret << std::endl;

    return 0;
}


Measured memory_bytes: 41144
#include <iostream>

int main(void){
    int N, K, ans=0;
    std::cin >> N >> K;

    for (int i=0; i<N; ++i){
        int x;
        std::cin >> x;
        if (x > abs(x - K)){
            ans += 2 * abs(x - K);
        } else {
            ans += 2 * x;
        }
    }

    std::cout << ans << std::endl;

    return 0;
}

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

int main(){
  string str,p,que,tmp;
  int q,a,b;
  char temp;
  cin >> str;
  cin >> q;
  for(int i=0;i<q;i++){
    cin >> que >> a >> b;
    if(que == "replace"){
      cin >> p;
      str = str.replace(a,b - a + 1,p);
    }
    else if(que == "reverse"){
      reverse(str.begin() + a,str.begin() + b + 1);
    }
    else if(que == "print"){
      cout << str.substr(a,b - a + 1) << endl;
    }
  }
}

      
  
  

Measured memory_bytes: 1220
#include <bits/stdc++.h>
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define inf 1000000000000000001
#define mod 1000000007
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define pb push_back
#define f first
#define s second
#define fast_cin ios_base::sync_with_stdio(false);cin.tie(NULL);
#define precise fixed(cout);cout<<setprecision(16);
#define Set(N,p) N=((N)|((1LL)<<(p)))
#define Reset(N,p) N=((N)&(~((1LL)<<(p))))
#define Check(N,p) (!(((N)&((1LL)<<(p)))==(0)))
#define POPCOUNT __builtin_popcountll
#define RIGHTMOST __builtin_ctzll
#define LEFTMOST(x) (63-__builtin_clzll((x)))
#define NUMDIGIT(x,y) (((vlong)(log10((x))/log10((y))))+1)
#define OUT(x) for(auto a:x) cout << a << " "; cout << endl;
#define OK cout << "@===================ok===================@" <<endl;
#define WTF cout <<"< "<<lo<<" | "<< hi <<" >" << endl;

using namespace std;

int main()
{
    ll a,b;
	cin >> a >> b;
	cout <<1LL*a/__gcd(a,b) *b << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
//大小比較(小)
long long int small(long long int a, long long int b) {
	if (a >= b) {
		return b;
	}
	else {
		return a;
	}
}
int main() {
	long long int n, m, num[2000][2] = {}, result=0;
	scanf("%lld",&n);
	for (int i = 1; i <= n; i++) {
		scanf("%lld%lld", &num[i][0],&num[i][1]);
		result +=(num[i][1]-num[i][0]+1);
	}
	
	printf("%lld", result);
			
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n;cin>>n;
  ll a[n];
  ll s=0,t=0;
  for(ll i=0;i<n;i++){
    cin>>a[i];
    s+=a[i];
    t+=i+1;
  }
  if(s%t!=0){
    cout<<"NO"<<endl;
    return 0;
  }
  s/=t;
  ll cnt=0;
  for(ll i=0;i<n-1;i++){
    if(a[i]<a[i+1]){
      if(a[i+1]-a[i]!=s){
        cout<<"NO"<<endl;
        return 0;
      }
    }
    else{
      if((s+a[i]-a[i+1])%n!=0){
        cout<<"NO"<<endl;
        return 0;
      }
      cnt+=(s+a[i]-a[i+1])/n;
    }
    if(cnt>s){
      cout<<"NO"<<endl;
      return 0;
    }
  }
  cout<<"YES"<<endl;
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

void solve()
{
	int n, l;
	cin >> n >> l;
	int sum = n * (l - 1) + n * (n + 1) / 2;
	if (0 < l) sum -= l;
	if (l + n - 1 < 0) sum -= l + n - 1;
	cout << sum;
}

int main()
{
	fastio;
	solve();

	return 0;
}

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

int n = 0;

void display(int *arr){
  for(int i = 0; i < n; i++){
    std::cout << arr[i] << " ";
  }
  std::cout << std::endl;
}

int main(){

  /*std::vector<int> tmp;
  for(int i = 0; i < 10; i++){
    tmp.push_back(i);
    std::cout << tmp[i] << " ";
  }
  std::cout << std::endl;

  tmp.erase(tmp.end() - 6, tmp.end() - 3);
  for(int i = 0; i < tmp.size(); i++){
    std::cout << tmp[i] << " ";
  }

  std::cout << std::endl;*/
  
  while(1){
    int r;
    std::cin >> n >> r;    
    if(n + r == 0) break;
    std::vector<int> yama;
    for(int i = 0; i < n; i++){
      yama.push_back(i);
      //std::cout << yama[i] << " ";
    }
    //std::cout << std::endl;

    for(int i = 0; i < r; i++){
      int p, c;
      std::cin >> p >> c;
      std::vector<int> tmp;
      //std::cout << n << " " << r << " " << p << " " << c << std::endl;
      for(int j = 0; j < c; j++){
        tmp.push_back(yama[n - p - c + 1 + j]);
        //std::cout << tmp[j] << std::endl;
      }
      yama.erase(yama.end() - (p - 1 + c), yama.end() - (p - 1));
      //display(yama.data());
      for(int j = 0; j < tmp.size(); j++){
        yama.push_back(tmp[j]);
      }
    }
    std::cout << yama[yama.size() - 1] + 1 << std::endl;
    
  }

  return 0;
  
}

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

int main()
{

    int dias;
    cin >> dias;
    int atividades[dias][3];
    int felicidadeDasAtividades[dias][3];

    for (int i = 0; i < dias; i++)
    {
        cin >> atividades[i][0] >> atividades[i][1] >> atividades[i][2];
        felicidadeDasAtividades[i][0] = felicidadeDasAtividades[i][1] = felicidadeDasAtividades[i][2] = 0;
    }

    for (int i = dias - 1; i >= 0; i--)
    {
        if (i == dias - 1)
        {
            felicidadeDasAtividades[i][0] = atividades[i][0];
            felicidadeDasAtividades[i][1] = atividades[i][1];
            felicidadeDasAtividades[i][2] = atividades[i][2];
        }
        else
        {
            if (felicidadeDasAtividades[i + 1][2] >= felicidadeDasAtividades[i + 1][1])
            {
                felicidadeDasAtividades[i][0] = atividades[i][0] + felicidadeDasAtividades[i + 1][2];
            }
            else
            {
                felicidadeDasAtividades[i][0] = atividades[i][0] + felicidadeDasAtividades[i + 1][1];
            }

            if (felicidadeDasAtividades[i + 1][2] >= felicidadeDasAtividades[i + 1][0])
            {
                felicidadeDasAtividades[i][1] = atividades[i][1] + felicidadeDasAtividades[i + 1][2];
            }
            else
            {
                felicidadeDasAtividades[i][1] = atividades[i][1] + felicidadeDasAtividades[i + 1][0];
            }

            if (felicidadeDasAtividades[i + 1][1] >= felicidadeDasAtividades[i + 1][0])
            {
                felicidadeDasAtividades[i][2] = atividades[i][2] + felicidadeDasAtividades[i + 1][1];
            }
            else
            {
                felicidadeDasAtividades[i][2] = atividades[i][2] + felicidadeDasAtividades[i + 1][0];
            }
        }

    }
    int melhorEscolha = 0;
    if (felicidadeDasAtividades[0][0] >= felicidadeDasAtividades[0][1] && felicidadeDasAtividades[0][0] >= felicidadeDasAtividades[0][2])
    {
        cout << felicidadeDasAtividades[0][0] << endl;
    }
    else if (felicidadeDasAtividades[0][1] >= felicidadeDasAtividades[0][0] && felicidadeDasAtividades[0][1] >= felicidadeDasAtividades[0][2])
    {
        cout << felicidadeDasAtividades[0][1] << endl;
    }
    else if (felicidadeDasAtividades[0][2] >= felicidadeDasAtividades[0][0] && felicidadeDasAtividades[0][2] >= felicidadeDasAtividades[0][1])
    {
        cout << felicidadeDasAtividades[0][2] << endl;
    }
}


Measured memory_bytes: 2560
import java.util.*;
public class Main {
	public static void main(String[] args){
		  Scanner sc=new Scanner(System.in);
	      int n=sc.nextInt();
	      int sum=0;
	      int[] L=new int[n*2];
	      for(int i=0;i<L.length;i++){
	        L[i]=sc.nextInt();
	      }
	      Arrays.sort(L);
	      for(int i=0;i<L.length;i+=2){
	        sum+=L[i];
			}
	      sc.close();
	      System.out.println(sum);
	    }
}


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


int main()
{
    int x, n;
    int p[105];
    bool t[105];
    memset(t, true, sizeof(t));
    cin >> x >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> p[i];
        t[p[i]] = false;
    }
    int dx = -1;
    do 
    {
        dx++;
    } while (!t[x - dx] && !t[x + dx]);
    cout << (t[x - dx] ? x - dx : x + dx) << endl;
    return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

int main() {
    int rui[1002];
    rui[0]=0;
    for(int i=1;i<1001;i++){
        rui[i]=rui[i-1]+i;
    }
    int n;
    while(true){
        cin>>n;
        if(n==0)break;
        int ans=0;
        int head=0,tail=0;
        for(int i=1;i<=n;i++){
            tail++;
                while(rui[tail]-rui[head]>=n&&head<tail-1){
                    if(rui[tail]-rui[head]==n){
                       // cout<<tail<<head<<endl;
                        ans++;
                    }
                    head++;
                }

        }
        cout<<ans<<endl;



    }



    return 0;
}



Measured memory_bytes: 3000
#include <iostream>
#include <cstdio>
#include <bitset>
#include <queue>
#include <stack>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <utility>
#include <string>
#include <algorithm>
#include <cmath>
#include <limits>

using namespace std;
using ll=long long;
using vint=vector<int>;
using pint=pair<int,int>;

const double EPS = 1e-9;
const int inf = numeric_limits<int>::max();

#define rep(i,n) for(int i=0;i<int(n);++i)
#define rrep(i,n) for(int i=int(n-1);i>=0;--i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define RREP(i,a,b) for(int i=int(b-1);i>=int(a);--i)
#define SHOW(a) cout << #a << " = " << a << endl
#define ARR(a,n) for(int i=0;i<int(n);++i) cout << #a << "[" << i << "]" << " = " << a[i] << endl

void solve(){
	int a, b, h;
	cin >> a >> b >> h;
	cout << (a + b) * h / 2 << endl;
}

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

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws Exception {
        try (Reader r = new Reader(System.in)) {
            int N = r.i();
            System.out.println((N - 1) / 2);
        }
    }

    public static class Reader implements AutoCloseable {

        private BufferedReader br;

        private String[] buf;

        private int bufidx = -1;

        public Reader(InputStream in) {
            this.br = new BufferedReader(new InputStreamReader(in));
        }

        @Override
        public void close() throws Exception {
            br.close();
        }

        private void readBuf() throws IOException {
            if (bufidx == -1 || bufidx == buf.length) {
                buf = br.readLine().split(" ");
                bufidx = 0;
            }
        }

        public String s() throws IOException {
            readBuf();
            return buf[bufidx++];
        }

        public int i() throws IOException {
            return Integer.parseInt(s());
        }

        public long l() throws IOException {
            return Long.parseLong(s());
        }

        public double d() throws IOException {
            return Double.parseDouble(s());
        }

        public String[] sa() throws IOException {
            readBuf();
            if (bufidx != 0) {
                throw new RuntimeException("illegal read");
            }
            bufidx = -1;
            return buf;
        }

        public int[] ia() throws IOException {
            String[] sa = sa();
            int[] ia = new int[sa.length];
            for (int i = 0; i < sa.length; i++) {
                ia[i] = Integer.parseInt(sa[i]);
            }
            return ia;
        }

        public long[] la() throws IOException {
            String[] sa = sa();
            long[] la = new long[sa.length];
            for (int i = 0; i < sa.length; i++) {
                la[i] = Long.parseLong(sa[i]);
            }
            return la;
        }

        public double[] da() throws IOException {
            String[] sa = sa();
            double[] da = new double[sa.length];
            for (int i = 0; i < sa.length; i++) {
                da[i] = Double.parseDouble(sa[i]);
            }
            return da;
        }

        public int[][] im(int N) throws IOException {
            int[][] im = new int[N][];
            for (int i = 0; i < N; i++) {
                im[i] = ia();
            }
            return im;
        }

        public long[][] lm(int N) throws IOException {
            long[][] lm = new long[N][];
            for (int i = 0; i < N; i++) {
                lm[i] = la();
            }
            return lm;
        }

        public double[][] dm(int N) throws IOException {
            double[][] dm = new double[N][];
            for (int i = 0; i < N; i++) {
                dm[i] = da();
            }
            return dm;
        }

    }

}


Measured memory_bytes: 21076
#include <bits/stdc++.h>
#include <numeric>
#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())

#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
#define LL long long
#define Dev 1000000007

// sort(a.begin(), a.end(), std::greater<int>());
using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> b(n);
    rep(i, n)
    {
        cin >> b[i];
    }
    stack<int> st;
    bool flag = true;
    while (flag)
    {
        flag = false;
        for (int j = b.size() - 1; j >= 0; j--)
        {
            if (b[j] == j + 1)
            {
                st.push(b[j]);
                b.erase(b.begin() + j);
                if (DEBUG)
                    cout << st.top();
                flag = true;
                break;
            }
        }
    }
    if (b.empty() == true)
    {
        while (st.empty() == false)
        {
            cout << st.top() << endl;
            st.pop();
        }
    }
    else
    {
        cout << -1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define int ll
typedef vector<int> vi;
typedef pair<int,int> pii;

signed main(void) {
  int i,j;
  int n,x;
  cin>>n>>x;
  vi a(n);
  rep(i,n)cin>>a[i];
  vector<vi> dp(n+1,vi(n,INF));
  rep(i,n+1)rep(j,n)
    if(i==0)dp[i][j]=a[j];
    else dp[i][j]=min(dp[i-1][j],a[(j-i+n)%n]);
  ll ans=INF*INF;
  rep(i,n){
    ll sum=x*i;
    rep(j,n)sum+=dp[i][j];
    ans=min(ans,sum);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 31616
#include <iostream>
#include <vector>
using namespace std;
vector<int> v[100005];
int n,k,ans;
int dfs(int node,int dep)
{
	int mx=1;
	for (int u:v[node])
	mx=max(mx,dfs(u,dep+1)+1);
	if (mx==k && dep>1)
	{
		ans++;
		mx=0;
	}
	return mx;
}
int main()
{
	scanf("%d%d",&n,&k);
	for (int i=1;i<=n;i++)
	{
		int a;
		scanf("%d",&a);
		if (i==1)
		ans+=(a!=1);
		else
		v[a].push_back(i);
	}
	dfs(1,0);
	printf("%d",ans);
}

Measured memory_bytes: 10368
from _collections import defaultdict
s=input()
X=defaultdict(int)
l=len(s)
for i in s:
    X[i]+=1
ANS=[]
for key in X.keys():
    a=0
    cnt=0
    for i in range(l):
        if s[i]==key:
            a=max(a,cnt)
            cnt=0
        else:
            cnt+=1
    ANS.append(max(a,l-s.rfind(key)-1))
print(min(ANS))

Measured memory_bytes: 3064
import sys
from collections import Counter, deque, defaultdict
from itertools import accumulate, permutations, combinations, takewhile, compress, cycle
from functools import reduce
from math import ceil, floor, log10, log2, factorial
from pprint import pprint

sys.setrecursionlimit(1000000)
# MOD = 10 ** 9 + 7
# N = int(input())
# A,B,C = [int(x) for x in input().split()]
# V = [[0] * 100 for _ in range(100)]
# A = [int(input()) for _ in range(N)]

P, Q, R = [int(x) for x in input().split()]

print(P + Q + R - max([P, Q, R]))


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

struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* cpp template {{{ */

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define rep(i, n) REPS(i, 0, n)
#define REP0(i,n) for (ll i = 0; i <= (ll)(n); ++i)
#define REP1(i,n) for (ll i = 1; i <= (ll)(n); ++i)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << '\n';}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {rep(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}

signed main() 
{
  int a,b,c; cin>>a>>b>>c;
  if(a+b==c||b+c==a||c+a==b) print("Yes");
  else print("No");

  return 0;
}

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

using namespace std;

int main() {
  int A, B, C, K;
  cin >> A >> B >> C >> K;

  int ans = max(A,max(B,C));
  int other = A + B + C - ans;

  for(int i  = 1; i <= K; i++) ans *= 2;

  cout << ans+other << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include <vector>
#include<map>
#include<deque>
#include<string>
#include<cmath>
#include<cstdio>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define max(x,y) (((x)>(y)) ? x:y)
#define min(x,y) (((x)<(y)) ? x:y)
#define FOR(a) for(int i=0;i<a;i++)
#define ender {return 0;}
#define tosasuretu(a) (a*(a+1)/2)
inline ll kaizyo(ll);
ll gcd(ll, ll);
ll combination(ll, ll);
int main(){
	int h,maxh=0, n;
	cin >> n;
	int count = 0;
	FOR(n) {
		cin >> h;
		if (maxh <= h) {
			count++;
			maxh = h;
		}
	}
	cout << count;
	return 0;
}


inline ll kaizyo(ll x) {
	ll ans = 1;
	for (int z = 0; z < x; z++) {
		ans *= (x - z);
	}
	return ans;
}
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	return gcd(b, a%b);
}

Measured memory_bytes: 256
// Ver19.03
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF (1 << 29) * 2
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

int main()
{
  int a, b, cnt = 1, ans = 0;
  scanf("%d%d", &a, &b);
  for (int i = 1; i < b; i += a - 1)
    ans++;
  printf("%d\n", ans);
}

Measured memory_bytes: 128
n,m,k = map(int,input().split())

a = list(map(int,input().split()))

b = list(map(int,input().split()))


c = [0]
d = 0
for i in range(n):
    d += a[i]
    c.append(d)

e = [0]
f = 0
for i in range(m):
    f += b[i]
    e.append(f)


ans = 0
j = m
for i in range(n+1):
    if c[i] > k:
        break
    else:
        while c[i] + e[j] > k:
            j -= 1
    ans = max(i + j,ans)

print(ans)

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define ALL(name) name.begin(),name.end()
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

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

    string T;
    cin >> T;

    REP(i, T.length()) {
        if(T[i] == '?') { T[i] = 'D'; }
    }

    cout << T << endl;

    return 0;
}


Measured memory_bytes: 3748
# import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)


def main():
    N = int(input())

    res = 0

    for i in range(1,N+1):
        if (i % 3 != 0) & (i % 5 != 0):
            res += i

    print(res)



main()


Measured memory_bytes: 9164
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//}

int g[15][15];
const int INF = 1001001001;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,-1,0,1 };

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

//素因数分解
vector<pair<ll, int>>factorize(ll n) {
	vector<pair<ll, int>>res;
	for (ll i = 2;i * i <= n;++i) {
		if (n % i)continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1)res.emplace_back(n, 1);
	return res;
}

int dp[1010][1010];
int bingo[3][3];
bool flag[3][3];

ll n;
ll ans = 0;

void dfs(ll x, int a, int b, int c) {
	if (x > n)return;
	if (a && b && c)ans++;
	dfs(10 * x + 3, 1, b, c);
	dfs(10 * x + 5, a, 1, c);
	dfs(10 * x + 7, a, b, 1);
}

int main() {
	int n;
	cin >> n;
	vector<int>d(n);
	set<int>S;
	rep(i, n) {
		cin >> d[i];
		S.insert(d[i]);
	}
	int ans = S.size();
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <iostream>
#include <map>
#include <random>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
/*---------------------------------------*/

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  string s; cin >> s;
  cout << (s[0]==s[1]&&s[1]==s[2]||s[1]==s[2]&&s[2]==s[3]? "Yes" : "No") << "\n";
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define FAST  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ll long long int 
#define ar array
#define pb push_back
#define fi(a,b) for(int i=a;i<(b);i++)
#define fj(a,b) for(int j=a;j<(b);j++)
#define fk(a,b) for(int k=a;k<(b);k++)
#define lb lower_bound
#define ub upper_bound
//hash base 177013


int main()
{
	FAST;
	//#ifndef ONLINE_JUDGE
	//	freopen("input.txt","r",stdin);
	//	freopen("output.txt","w",stdout);
	//#endif
	//ll testcase;
	//cin>>testcase;
	//while(testcase--)
	{
		string s;
		cin>>s;
		ll ans=0;
		fi(0,(int)s.size())
		{
			ans+=(s[i]-'0');
		}
		if(ans%9==0)
		{
			cout<<"Yes\n";
		}
		else
		{
			cout<<"No\n";
		}
		
		
		
	}
}


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

#define int long long

const int INF = 1e15;

int dp[55555];
int c[22];

int n, m;

signed main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> c[i];
  }

  fill(dp, dp+n+5, INF);
  dp[0] = 0;
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j < m; j++) {
      if (i - c[j] >= 0) {
        dp[i] = min(dp[i], dp[i-c[j]] + 1);
      }
    }
  }

  cout << dp[n] << endl;

  return 0;
}


Measured memory_bytes: 3468
#include<iostream>

using namespace std;

int A[101][101] = {0};

int main(){
    int n, numx, numy, count;
    cin >> n;
    
    for(int i=1;i<=n;++i){
        cin >> numx;
        cin >> count;
        for(int j=0;j<count;++j){
            cin >> numy;
            A[numx][numy] = 1;
        }
    }
    
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            cout << A[i][j];
            if(j!=n){
                cout <<" ";
            }
        }
        cout << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
char s[20];
int main(){
	scanf("%s",s);int l=strlen(s);
	if(l&1)return puts("No"),0;
	for(int i=0;s[i];i++){
		if(i&1&&s[i]!='i')return puts("No"),0;
		if(i%2==0&&s[i]!='h')return puts("No"),0;
	}
	puts("Yes");
	return 0;
} 

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

using namespace std;

int main()
{
	int a, b;
	cin >> a >> b;
	int mi = min(a, b);
	int ma = max(a, b);

	for (int i = 0; i < ma; i++) {
		cout << mi;
	}
	cout << endl;
	return 0;
}


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

#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <stdint.h>
#include <string.h>

//#define _USE_MATH_DEFINES
//#include <math.h>

#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <deque>
#include <string>

#include <algorithm>
#include <functional>
#include <bitset>
#include <functional>
#include <chrono>
#include <random>
#define sqr(x) (x) * (x)

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef int i64;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;
using namespace std::chrono;

const i64 mod = 1000000007ll;
const i64 smod = 998244353ll;
const i64 inf = 1000000007; // 10000000000000007ll;

const double eps = 1e-8;

const i64 MAXN = 300004;

i64 n, k;
i64 a[MAXN];
unordered_map<i64, i64> b;

double val(i64 i) {
    return (double)(1 + i) / 2;
}

int main(int argc, char* argv[]) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed);


    cin >> n >> k;
    for (i64 i = 0; i < n; i++) {
        cin >> a[i];
    }

    double bv = 0;

    for (i64 i = 0; i < k; i++) {
        bv += val(a[i]);
    }

    double v = bv;
    //cerr << v << endl;
    for (i64 i = k; i < n; i++) {
        v -= val(a[i - k]);
        v += val(a[i]);

        //cerr << v << endl;

        if (bv < v) {
            bv = v;
        }
    }

    cout << bv << endl;

    return 0;
}

Measured memory_bytes: 1024
n=int(input())
b=input().split()
for i in range(n-1):
    b[i]=int(b[i])
ans=b[0]
for i in range(n-2):
    if b[i]<b[i+1]:
        ans+=b[i]
    else:
        ans+=b[i+1]
ans+=b[-1]
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<stdio.h>
#include<string>
#include<cmath>
#include<math.h>
#include<vector>
#include<algorithm>
#include<map>
#include<unordered_map>
#pragma warning(disable: 4996)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define PI 3.141592653589793

using namespace std;
using ll = long long;



int main() {

	double a, b, h, m;

	cin >> a >> b >> h >> m;

	double Ac, Bc, C;

	Ac = h * 30;
	Ac += m * 0.5;
	Bc = m * 6;
	C = fabs(Ac - Bc);
	double radian = C * PI / 180.0;
	
	double c;
	c = pow(a, 2) + pow(b, 2) - (2 * a * b * cos(radian));
	printf("%.19f", sqrt(c));
	cout << endl;

	return 0;
}

Measured memory_bytes: 4192
// Package main provides
//
// File:  b.go
// Author: ymiyamoto
//
// Created on Wed Jan  9 00:31:48 2019
//
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)

	for i := range s {
		if i%2 == 0 {
			fmt.Print(string(s[i]))
		}
	}
	fmt.Println()
}


Measured memory_bytes: 2304
#include <stdio.h>

int main(){
	int l,r,d,i,cnt=0;
	scanf("%d %d %d",&l,&r,&d);
	for(i=l;i<=r;i++){
		if(i%d==0){
			cnt++;
		}
	}
	printf("%d\n", cnt);
	return 0;
}

Measured memory_bytes: 1732
using System;

class Program
{
    static void Main(string[] args)
    {
        var N = int.Parse(Console.ReadLine());
        var s = Console.ReadLine().Split(' ');
        var ans = 0;
        for (int i = 0; i < N; i++)
        {
            ans += m1(int.Parse(s[i]));
        }
        Console.WriteLine(ans);
    }

    static int m1(int n)
    {
        var ans = 0;
        while (n % 2 == 0)
        {
            ans++;
            n /= 2;
        }
        return ans;
    }
}


Measured memory_bytes: 13792
from sys import stdin

stdin.readline().rstrip()
S = [int(x) for x in stdin.readline().rstrip().split()]
S.sort()
stdin.readline().rstrip()
T = [int(x) for x in stdin.readline().rstrip().split()]

C = 0
for ti in T:
    for si in S:
        if ti == si:
            C += 1
            break

print(C)


Measured memory_bytes: 6556
alist = []
for i in range(3):
  a = list(input().split( ))
  alist.append(a)

alinelist = []
for i in range(1, 4):
  for j in range(1, 4):
    alinelist.append(alist[i - 1][j - 1])

n = int(input())

blist = []
for j in range(n):
  b = int(input())
  blist.append(b)

bhitlist = []
for k in blist:
  if str(k) in alinelist:
    hitindex = alinelist.index(str(k))
    bhitlist.append(hitindex)

correctlist = [[0, 1, 2], [3, 4, 5], [6, 7, 8], [0, 3, 6], [1, 4, 7], [2, 5, 8], [0, 4, 8], [2, 4, 6]]

bingoflag = False
for m in correctlist:
  bingocount = 0
  for n in m:
    if (n in bhitlist):
      bingocount += 1
    else:
      bingocount = 0
  if bingocount == 3:
    bingoflag = True
    break
  else:
        continue
  break

if bingoflag == True:
  print('Yes')
else:
  print('No')

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

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> d(n);
    for(auto&& i : d){
        cin >> i;
    }
    long long ans = 0;
    for(int i = 0; i < n; i++){
        for(int j = i + 1; j < n; j++){
            ans += d[i] * d[j];
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void)
{
	int n;
	while(cin>>n){
		int date[11][11]={0};
		if(!n) break;
		for(int i=0; i<n; i++){
			for(int j=0; j<n; j++){
				cin >> date[i][j];
			}
		}
		for(int i=0;i<n;i++){
			for(int j=0; j<n; j++){
				date[i][n] += date[i][j];
			}
		}
		for(int i=0;i<=n;i++){
			for(int j=0; j<n; j++){
				date[n][i] += date[j][i];
			}
		}
		for(int i=0; i<=n; i++){
			for(int j=0; j<=n; j++){
				printf("%5d",date[i][j]);
			}
			cout << "\n";
		}
	}
	return 0;
}

Measured memory_bytes: 0