akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch(int );
void init(void );
void printList(void );
void deleteNode(NodePointer );
void deleteFirst(void );
void deleteLast(void );
void delete(int );
void insert(int );

int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {insert(key); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
	if ( com[6] == 'F' ) deleteFirst();
	else if ( com[6] == 'L' ) deleteLast();
      } else {
	delete(key); nd++; 
      }
      size--;
    }
  }

  printList();
  return 0;
}

NodePointer listSearch(int key){
  /* your code */
  NodePointer cul = nil->next;
  
  while(cul != nil && cul->key != key){
    
    cul = cul->next;
  }

  return cul;
}

void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t){
  /* your code */
  if(t == nil) return ;
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst(){
  NodePointer t = nil->next;
  if ( t == nil ) return;
  deleteNode(t);
}

void deleteLast(){
  /* your code */
  deleteNode(nil->prev);
}

void delete(int key){
  /* your code */
  deleteNode(listSearch(key));
}


void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;
  

  /* your code */

  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}



Measured memory_bytes: 33108
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<cctype>
#include <fstream>
#include <time.h>
#include <iterator>





#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define fil(x,y) memset(x,y,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()
using namespace std;
int MOD = (ll)1000000000 + 7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 500050;

int X[11][11], N, D;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int L, R; cin >> L >> R;
	if ((R - 1)*R < 2019) {
		int ans = (L*(L + 1) % 2019);
		print(ans);
		return 0;
	}
	else {
		int ans = INF;
		R = min(R, L + 4050);
		FOR(i, L, R) {
			FOR(j, i + 1, R+1) {
				ans = min(ans, i*j % 2019);
			}
		}
		print(ans);
	}
}

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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int h,w,d;
char col[] = "RGBY";

int main(){
  cin>>h>>w>>d;
  REP(y,h){
    REP(x,w){
      int a = x+y;
      int b = x-y+2521*d;
      int id = (a/d) % 2;
      id += 2*((b/d) % 2);
      putchar(col[id]);
    }
    puts("");
  }
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
using namespace std;
typedef long long LL;
const double eps = 1e-10;
const int maxn = 5000 +100;
int n,k,a[maxn];
bitset<maxn> sum;
bool judge(int x) {
    if(a[x]>=k)return 1;
    sum.reset(); sum[0]=1;
    for(int i=1;i<=n;++i) if(i!=x)sum|=sum<<a[i];
    for(int i=k-1;i>=k-a[x];--i)
        if(sum[i]) return 1;
    return 0;
}

void solve() {
    int l=0,r=n+1;
    while(l<r) {
        int mid=l+r>>1;
        if(judge(mid)) {
            r=mid;
        }
        else l=mid+1;
    }
    cout << l-1 << endl;
}
int main() {
#ifdef ac
    freopen("in.txt" , "r" , stdin);
//    freopen("out.txt" , "w" , stdout);
#endif
    cin >> n >> k;
    for(int i=1;i<=n;++i) cin >> a[i];
    sort(a+1, a+n+1);
    solve();
    return 0;
}


Measured memory_bytes: 256
/*
 *  - dp[i][j] の意味がトリッキーなので、色々バグらせやすい。今回は ret を出す際にバグった。
 *  - inf を LLONG_MAX にすると、オーバフローして判定が大小判定がバグる。
 */


#include <bits/stdc++.h>

typedef long long ll;

using namespace std;

#define swap(a, b)    do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while(0)
#define repd(i, a, b) for(typeof(b) i = a; i < (b); ++i)
#define rep(i, n)     repd(i, 0, n)
#define dump(x)       cerr << #x << " = " << (x) << endl
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl
#define YesNo(x)      cout << ((x) ? "Yes" : "No") << endl
#define YESNO(x)      cout << ((x) ? "YES" : "NO") << endl
#define absi(x)       ( ((x) >= 0) ? (x) : (-(x)) )

#define MAX_V 100000
const ll inf = 0x0FFFFFFFFFFFFFFF;

int main(int argc, const char* argv[]) {
	ll n, c;
	cin >> n >> c;
	vector<ll> w(n), v(n);
	rep(i, n) {
		cin >> w[i] >> v[i];
	}
 
	/*
	 *  dp[i][j] = i 番目までの品物で合計価値 j 以上、を満たす重さ合計の最小値
	 */
	vector<vector<ll>> dp(n + 1, vector<ll>(MAX_V + 1, inf));
	rep(i, n + 1) {
		dp[i][0] = 0;
	}

	rep(i, n) {
		rep(j, MAX_V) {
			dp[i+1][j+1] = min( dp[i][j+1], ( (j + 1 - v[i] >= 0) ? (dp[i][j + 1 - v[i]] + w[i]) : inf ) );
		}
	}

	ll ret = 0;
	rep(j, MAX_V + 1) {
		if(dp[n][j] <= c) {
			ret = j;
		}
	}

	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 80256
import sys
H, W, *A = sys.stdin.read().split()
H = int(H); W = int(W)

rW = range(W)
rrW = range(W-1, -1, -1)
rH = range(H)

INF = 4000
dist = [[INF]*W for i in rH]
S = []
push = S.append
for di, Ai in zip(dist, A):
    chg = 0
    for j, a in enumerate(Ai):
        if a == '#':
            di[j] = 0
            chg = 1
    if chg:
        push(di)
for di in S:
    cur = INF
    for j in rW:
        if not di[j]:
            cur = -j
        else:
            di[j] = cur+j
    cur = INF
    for j in rrW:
        if not di[j]:
            cur = j
        elif cur-j < di[j]:
            di[j] = cur-j
for j in rW:
    cur = INF
    for di in dist:
        if cur+1 < di[j]:
            di[j] = cur = cur+1
        else:
            cur = di[j]
    cur = INF
    for di in reversed(dist):
        if cur+1 < di[j]:
            di[j] = cur = cur+1
        else:
            cur = di[j]
sys.stdout.write("%d\n" % max(max(di) for di in dist))

Measured memory_bytes: 42732
import sys

sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():
    N = int(input())
    LL = []
    for i in range(N):
        L = list(map(int, input().split()))
        LL.append(L + [sum(L)])

    LL = sorted(LL, key=lambda x: x[2],reverse=True)

    cntA = 0
    cntT = 0
    for i in range(len(LL)):
        if i % 2 == 0:
            cntT += LL[i][0]
        else:
            cntA += LL[i][1]
    print(cntT - cntA)


resolve()

Measured memory_bytes: 63964
#include/*\~CeLaMbDa\*/<stdio.h>

int main(int argc, char** args) {
	char a = getchar();
	bool Ctag = false, Ftag = false;
	while(a != '\n' && a != EOF) {
		if(a == 'C') {
			Ctag = true;
		} else if(a == 'F' && Ctag) {
			Ftag = true;
		}
		a = getchar();
	}
	if(Ctag && Ftag) {
		printf("Yes");
	} else {
		printf("No");
	}
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
 
int main(){
  string X;
  cin >> X;
  int L = X.size();
  vector<int> num(L+1);
  num.at(0)=0;
  int ans=0;
  for(int i=0; i<L; i++){
    if(X.at(i)=='S') num.at(i+1)=num.at(i)+1;
    else if(num.at(i)>0){
      num.at(i+1)=num.at(i)-1;
      ans++;
    }
    else num.at(i+1)=num.at(i); 
  }
  cout << L-ans*2 << endl;
}

Measured memory_bytes: 1412
#include <stdio.h>
#include <iostream>
#include <math.h>
using namespace std;

int main() {
  int n,l,min,sum=0;
  cin >> n >> l;
  min = 2*l;

  for(int i=1; i<=n;i++){
      int a = l + i - 1;
       //cout << " a " <<a <<endl;
      if(abs(a) < abs(min)){
          min = a;
        //cout << min << endl;
      }
    sum += a;
  }
  //cout << sum << endl;
  //cout << min << endl;
  sum = sum - min;
  cout << sum << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
#ifndef LOCAL
#define cerr if(0)cout
#endif
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
inline string getstr(string &s,int l,int r){string ret="";for(int i=l;i<=r;i++)ret.push_back(s[i]);return ret;}
int modpow(int x,int y,int md=mod){if(y==0)return 1;int ret=modpow(x,y>>1,md);ret=(ll)ret*ret%md;if(y&1)ret=(ll)ret*x%md;return ret;}
int n,m;
string s[205];
int dist[205];
queue<int>q;
int bfs(int x){
	memset(dist,inf,sizeof dist);
	q.push(x);dist[x]=1;
	while(!q.empty()){
		int p=q.front();q.pop();
		for(int j=1;j<=n;j++){
			if(s[p][j]=='1'||s[j][p]=='1'){
				if(dist[j]>dist[p]+1){
					dist[j]=dist[p]+1;
					q.push(j);
				}else if(dist[j]==dist[p]){
					return inf;
				}
			}
		}
	}
	return *max_element(dist+1,dist+n+1);
}
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>s[i];s[i]=" "+s[i];
	}
	int ans=-1;
	for(int i=1;i<=n;i++){
		ans=max(ans,bfs(i));
	}
	if(ans<inf){
		cout<<ans<<endl;
	}else{
		cout<<-1<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
from math import sqrt
N=int(input())
cnt=[0]*(N+1)
sn=int(sqrt(N))+1
for i in range(1,sn+1):
  for j in range(1,sn+1):
    for k in range(1,sn+1):
      l=i**2+j**2+k**2+i*j+j*k+k*i
      if l<N+1:
        cnt[l]+=1

for i in range(1,N+1):
  print(cnt[i])

Measured memory_bytes: 9436
#import<cstdio>
#import<map>
#define I(M,A)for(i=0;i<M;i++)scanf("%d",&x),A[i+1]=A[i]+x;
main(){for(int n[1501],m[1501],o,a,b,i,j,x;scanf("%d%d",&a,&b),a;printf("%d\n",o)){std::map<int,int>z;*n=*m=o=0;I(a,n)I(b,m)for(i=0;i<=a;i++)for(j=0;j<=b;)z[n[i]+m[j++]]++;for(typeof(z.begin())p=z.begin();p!=z.end();)o+=p->second*(p++->second-1)/2;}}

Measured memory_bytes: 18000
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1000000007
#define INF 1e9
#define PIE 3.14159265358979323

template <class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}

using namespace std;
//#inculude <bits/stdc++.h>
#define int long long

signed main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    if (n == 2) {
        cout << max(a[0], a[1]) << endl;
        return 0;
    }
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());
    queue<int> q;
    q.push(a[1]);
    int cnt = 0;
    int ans = a[0];
    for (int i = 2; i < n; i++) {
        ans += q.front();
        q.push(a[i]);
        cnt++;
        if (cnt == 2) {
            q.pop();
            cnt = 0;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5616
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)

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

int main() {
    int h, w; cin >> h >> w;
    char s[21][21];
    REP(i, h) REP(j, w) cin >> s[i][j];
    int ans = 0;
    int d[21][21];

    REP(i, h) {
        REP(j, w) {
            queue <P> Q;

            REP(k, 21) REP(l, 21) d[k][l] = INF;

            if (s[i][j] == '#') continue;
            Q.push({i, j});
            d[i][j] = 0;

            while (!Q.empty()) {
                int y = Q.front().first;
                int x = Q.front().second;

                Q.pop();

                for (int k = 0; k < 4; ++k) {
                    int ny = y + dy[k]; // dy[4] = { -1, 0, 0, 1 };
                    int nx = x + dx[k]; // dx[4] = { 0, -1, 1, 0 };
                    if (0 <= ny && ny < h && 0 <= nx && nx < w && s[ny][nx] == '.' && d[ny][nx] == INF) {
                        Q.push({ny, nx});
                        d[ny][nx] = d[y][x] + 1;
                    }
                }
            }
            REP(k, h) {
                REP(l, w) {
                    if (d[k][l] == INF) continue;
                    if (s[k][l] == '#') continue;
                    ans = max(ans, d[k][l]);
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<utility>
using namespace std;
pair<double,double> solve(double a[6]){
    double x,y;
    if(a[0]==0){
        y=a[2]/a[1];
        x=(a[5]-a[4]*y)/a[3];
    }else if(a[1]==0){
        x=a[2]/a[0];
        y=(a[5]-a[3]*x)/a[4];
    }else if(a[3]==0){
        y=a[5]/a[4];
        x=(a[2]-a[1]*y)/a[0];
    }else if(a[4]==0){
        x=a[5]/a[3];
        y=(a[2]-a[0]*x)/a[1];
    }else{
        y=(a[2]-(a[5]*(a[0]/a[3])))/(a[1]-(a[4]*(a[0]/a[3])));
        x=(a[2]-a[1]*y)/a[0];
    }
    return make_pair(x,y);
}

typedef pair<double,double> V;
int main(){
    int n;
    scanf("%d",&n);
    double x[3],y[3];
    for(int i=0;i<n;i++){
        for(int j=0;j<3;j++){
            scanf("%lf%lf",&x[j],&y[j]);
        }
        V va=V(x[1]-x[0],y[1]-y[0]),vb(x[2]-x[0],y[2]-y[0]);
        V vlia=V(-va.second,va.first),vlib=V(-vb.second,vb.first),vhalfa=V(va.first/2,va.second/2),vhalfb=V(vb.first/2,vb.second/2);
        double a[6];
        a[0]=vlia.first,a[1]=-vlib.first,a[2]=-(vhalfa.first)+vhalfb.first,a[3]=vlia.second,a[4]=-vlib.second,a[5]=-(vhalfa.second)+vhalfb.second;
        double t=solve(a).first;
        V ans=V(vhalfa.first+t*vlia.first+x[0],vhalfa.second+t*vlia.second+y[0]);
        double r=sqrt((x[0]-ans.first)*(x[0]-ans.first)+(y[0]-ans.second)*(y[0]-ans.second));
        printf("%.3lf %.3lf %.3lf\n",rint(ans.first*1000)/1000.0,rint(ans.second*1000)/1000.0,rint(r*1000)/1000.0);
    }
}

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

using namespace std;

#ifdef SG
	#include <debug.h>
#else
	#define show(...)
	#define debug(...)
	#define deepen(...)
	#define timer(...)
#endif

#define ARG4(_1,_2,_3,_4,...) _4

#define forn3(i,l,r) for (int i = int(l); i < int(r); ++i)
#define forn2(i,n) forn3 (i, 0, n)
#define forn(...) ARG4(__VA_ARGS__, forn3, forn2) (__VA_ARGS__)

#define ford3(i,l,r) for (int i = int(r) - 1; i >= int(l); --i)
#define ford2(i,n) ford3 (i, 0, n)
#define ford(...) ARG4(__VA_ARGS__, ford3, ford2) (__VA_ARGS__)

#define ve vector
#define pa pair
#define tu tuple
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define fs first
#define sc second
#define all(a) (a).begin(), (a).end()
#define sz(a) ((int)(a).size())

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef unsigned char uc;
typedef pa<int, int> pii;
typedef pa<int, ll> pil;
typedef pa<ll, int> pli;
typedef pa<ll, ll> pll;
typedef ve<int> vi;

const ld pi = 3.1415926535897932384626433832795l;

template<typename T> inline auto sqr (T x) -> decltype(x * x) {return x * x;}
template<typename T1, typename T2> inline bool umx (T1& a, T2 b) {if (a < b) {a = b; return 1;} return 0;}
template<typename T1, typename T2> inline bool umn (T1& a, T2 b) {if (b < a) {a = b; return 1;} return 0;}

ll gcd(ll a, ll b) {
	if (a == b)
		return a;
	if (a > b)
		swap(a, b);
	if (b % a == 0) {
		return (b / a) * 2 * a - a;
	}
	return (b / a) * 2 * a + gcd(b % a, a);
}

int main () {
	cout.setf(ios::showpoint | ios::fixed);
	cout.precision(20);
#ifdef SG
	freopen((problemname + ".in").c_str(), "r", stdin);
//	freopen((problemname + ".out").c_str(), "w", stdout);
#endif
	ll n, x;
	cin >> n >> x;
	cout << n + gcd(x, n - x) << endl;	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

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

  ll ans = 0;

  reps1(i, n) {
    ll cnt = 0;
    rep(j, 26) {
      if (s.substr(0, i).find('a'+j) != string::npos && s.substr(i, n-i).find('a'+j) != string::npos)
        cnt++;
    }
    chmax(ans, cnt);
  }

  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 3592
#include<iostream>
#include<cstring>
#include<stdio.h>

using namespace std;
int main(){
    char str[1001];
    scanf("%s",str);
    int q;
    scanf("%d",&q);
    for(int i=0;i<q;i++){
        char inst[10]={};
        scanf("%s",inst);
        int a=0,b=0;
        scanf("%d %d",&a,&b);
        if(strcmp(inst,"print")==0){
            for(int i=a;i<=b;i++){
                cout<<str[i];
            }
            cout<<endl;
        }else if(strcmp(inst,"reverse")==0){
            for(int i=a;i<(a+(b-a+1)/2);i++){
                char temp=str[i];
                str[i]=str[b-(i-a)];
                str[b-(i-a)]=temp;
            }
        }else if(strcmp(inst,"replace")==0){
            char repstr[1000]={};
            scanf("%s",repstr);
            for(int i=a;i<=b;i++){
                str[i]=repstr[i-a];
            }
        }
    }
}


Measured memory_bytes: 3248
using System;
using System.Collections.Generic;
using System.Windows;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    public class Program
    {
        static void Main(string[] args)
        {
            var r1 = ReadSplit();
            var r2 = ReadSplit();
            var S = r1[0];
            var T = r1[1];
            var A = r2[0].ToInt();
            var B = r2[1].ToInt();
            var U = Read();
            if (S == U)
            {
                Write((A - 1).ToString() + " " + B.ToString());
            }
            else
            {
                Write(A.ToString() + " " + (B - 1).ToString());
            }
            Read();
        }

        public static string Read()
        {
            return Console.ReadLine();
        }

        public static string[] ReadSplit()
        {
            return Console.ReadLine().Split(' ');
        }

        public static void Write(object str)
        {
            Console.WriteLine(str);
        }
    }
}

public static class Extentions
{
    public static int ToInt(this object obj)
    {
        return int.Parse(obj.ToString());
    }

    public static decimal ToDecimal(this object obj)
    {
        return decimal.Parse(obj.ToString());
    }

    public static double ToDouble(this object obj)
    {
        return double.Parse(obj.ToString());
    }
}



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

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

  int k, x;
  cin >> k >> x;

  if (k * 500 >= x) cout << "Yes\n";
  else cout << "No\n";

  return (0);
}

Measured memory_bytes: 3632
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

ans = sum(B)

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

print(ans)

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

using namespace std;

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

	int N = S.size();
	int ans = N;

	for(int i = 1; i < N; i++)
	{
		if(S[i-1] != S[i])
		{
			ans = min(max(i,N-i), ans);
		}
	}

	cout << ans << endl;

	return 0;
}

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

bool equal(string a, string b) {
    for (int i = 0; i < 8; i++) {
        if (a[i] == '*') continue;
        if (a[i] != b[i]) return false;
    }
    return true;
}

int main() {
    while (true) {
        int n, m;
        cin >> n >> m;
        if (!n) return 0;
        string num[n];
        int money[n];
        for (int i = 0; i < n; i++) {
            cin >> num[i] >> money[i];
        }

        int sum = 0;
        for (int i = 0; i < m; i++) {
            string res;
            cin >> res;
            for (int j = 0; j < n; j++) {
                if (equal(num[j], res)) {
                    sum += money[j];
                }
            }
        }
        cout << sum << endl;
    }
}

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

using namespace std ;

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0); 
	int n ;
	cin>>n ;
	int arr[n] ;
	int ans = 0 ;
	for(int i = 0 ; i < n-1 ; ++i)
	{
		int x ;
		cin>>x ;
		if(i == 0)
		{
			ans += 2*x ;
			arr[i] = x ;
			arr[i+1] = x ;
			continue ;
		}
		else
		{
			if(x <= arr[i])
				ans -= (arr[i] - x) ;
			arr[i+1] = x ;
			ans += x ;
		}
	}
	return cout<<ans<<"\n" ,0  ;
}

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

using ll = long long;
#define REP(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}

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

  char tmp = S[K - 1];

  REP(i, N) {
    if(S.at(i) != tmp) S.at(i) = '*';
  }

  cout << S << endl;
}

Measured memory_bytes: 256
// スタックサイズ: 100MB

#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
using namespace std;

typedef int64_t ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define all(v) (v).begin(), (v).end()
ll pw(ll x, ll y) { ll r = 1;  rep(i, y) { r *= x; }; return r; }


int main() {

	string s;
	cin >> s;
	if (s == "A") cout << "T" << endl;
	if (s == "T") cout << "A" << endl;
	if (s == "G") cout << "C" << endl;
	if (s == "C") cout << "G" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//cervello|Phoenix
using namespace std;
#define ll long long int
#define eb emplace_back
#define mk make_pair
#define all(x) x.begin(),x.end()
#define mod 1000000007

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  ll n,k; cin>>n>>k;
  vector<ll> a(n); int pos=0;
  for(int i=0;i<n;i++){
  	cin>>a[i];
  	if(a[i]>=0)
  		pos++;
  }
  ll ans=1;
  sort(all(a));
  int l=0, r=n-1;
  if(pos==0&&k%2){
  	while(k){
  		while(a[r]<0)
  			a[r]+=mod;
  		ans=((ans%mod)*(a[r]%mod))%mod;
  		r--;
  		k--;
  	}
  	cout<<ans<<"\n";
  	return 0;
  }
  while(k){
  	if(k%2){
  		while(a[r]<0)
  			a[r]+=mod;
  		ans=((ans%mod)*(a[r]%mod))%mod;
  		r--;
  		k--;
  	}
  	else{
  		ll v1=a[l]*a[l+1];
  		ll v2=a[r]*a[r-1];
  		if(v1>v2){
  			while(v1<0)
  				v1+=mod;
  			ans=((ans%mod)*(v1%mod))%mod;
  			l+=2;
  		}
  		else{
  			while(v2<0)
  				v2+=mod;
  			ans=((ans%mod)*(v2%mod))%mod;
  			r-=2;
  		}
  		ans%=mod;
  		k-=2;
  	}
  }
  cout<<ans<<"\n";
  return 0;
}

Measured memory_bytes: 4684
import math
x1,y1,x2,y2 = map(int,input().split())
x3,y3 = x2 - (y2 - y1), y2 + (x2 - x1)
x4,y4 = x3 - (x2 - x1), y3 - (y2 - y1)
print(str(x3)+' '+str(y3)+' '+str(x4)+' '+str(y4))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define inf 1e16
#define M 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
#define mx 100010
ll par[mx],len[mx];

ll find(ll v){
	if(v==par[v])return v;
	return par[v]=find(par[v]);
}

void join(ll a,ll b){
	a=find(a);b=find(b);
	par[b]=par[a],len[a]+=len[b];
}
int main(){
	IOS;
	ll n,m;cin>>n>>m;
	rep(i,0,mx)par[i]=i,len[i]=i;
	vll v(m+1,-1);
	v[m]=0;
	vvll p(mx);
	rep(i,0,n){
		ll a,b;cin>>a>>b;
		if(a<=m)p[b].pb(a);
	}
	vll idx(m+1);
	rep(i,0,m+1)idx[i]=i;
	rep(i,0,mx)sort(all(p[i]));
	for(ll i=mx;i>=0;i--){
		if(p[i].size()>0)
		rep(j,0,p[i].size()){
			ll t=m-p[i][j];
			if(v[t]==-1){
				v[t]=i;
				// cout<<i<<" "<<j<<" "<<t<<"\n";
				join(par[t-1],par[t]);
			}
			else{
				ll x=find(par[t]);
				if(v[x]==-1)v[x]=i;
				// cout<<i<<" "<<j<<" "<<x<<"\n";
				join(par[x-1],par[x]);
			}
		}
	}
	ll ans=0;
	rep(i,0,m+1){if(v[i]!=-1)ans+=v[i];}
	cout<<ans;
	return 0;
}



Measured memory_bytes: 7168
n = gets.to_i
num = Array.new(1+10**7, 0)
num[n] += 1
for i in 2..10**7+1
  if n % 2 == 0
    n /= 2
  else
    n *= 3
    n += 1
  end
  if num[n] == 0
    num[n] += 1
  else
    puts i
    exit
  end
end


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

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

#define REP(i,n) for(ll i=0;i<n;++i)
#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()
{
    string S;
    cin >> S;
    bool a = false, b = false, c = false;
    REP(i, S.length()) {
        if(S[i] == 'a') { a = true; }
        else if(S[i] == 'b') { b = true; }
        else if(S[i] == 'c') { c = true; }
    }
    if(a && b && c) { printf("Yes\n"); }
    else { printf("No\n"); }
    return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
h = list(map(int, input().split()))
ab_list = [list(map(int, input().split())) for _ in range(m)]


all_temboudai = {i for i in range(1, n+1)}

for a, b in ab_list:
    if h[a-1] > h[b-1]:
        if b not in all_temboudai:
            continue
        all_temboudai.discard(b)
    elif h[a-1] < h[b-1]:
        if a not in all_temboudai:
            continue
        all_temboudai.discard(a)
    elif h[a-1] == h[b-1]:
        if a in all_temboudai:
            all_temboudai.discard(a)
        if b in all_temboudai:
            all_temboudai.discard(b)

print(len(all_temboudai))


Measured memory_bytes: 40488
//ABC155B
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
#include <unordered_map>
using namespace std;

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i=0;i<n;i++){
		cin >> a.at(i);
	}
	for(int i=0;i<n;i++){
		if(a.at(i)%2 == 0){
			if(a.at(i)%3 != 0 && a.at(i)%5 != 0){
				cout << "DENIED" << endl;
				return 0;
			}
		}
	}
	cout << "APPROVED" << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace ITP1_7_A
{
    public class Program
    {
        static void Main(string[] args)
        {
            string[] input;
            while(!(input = Console.ReadLine().Split(' ')).All( s => s == "-1"))
            {
                var ex1 = Convert.ToInt32(input[0]);
                var ex2 = Convert.ToInt32(input[1]);
                var ex3 = Convert.ToInt32(input[2]);
                var total = ex1 + ex2;
                Console.WriteLine
                    (
                        ex1 == -1 || ex2 == -1 ? "F" :
                        80 <= total ? "A" :
                        65 <= total ? "B" :
                        50 <= total ? "C" :
                        30 <= total && 50 <= ex3  ? "C" :
                        30 <= total ? "D" :
                        "F"
                    );
            }
        }
    }
}

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

using namespace std;

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

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

	ll max_n = 1010101;
	vector<bool> isPrime(max_n, true);
	isPrime[0] = false;
	isPrime[1] = false;
	for(int i = 2; i < max_n; i++){
		if(isPrime[i]){
			for(int j = 2 * i; j < max_n; j += i) isPrime[j] = false;
		}
	}

	ll a, b;
	cin >> a >> b;

	ll rema = a, remb = b;
	ll ans = 1;
	for(int i = 2; i < max_n; i++){
		if(!isPrime[i]) continue;
		if(rema % i == 0 && remb % i == 0){
			ans++;
		}
		while(rema % i == 0) rema /= i;
		while(remb % i == 0) remb /= i;
	}

	if(rema > 1 && remb > 1 && rema == remb) ans++;
	cout << ans << endl;	
}


Measured memory_bytes: 512
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_4_B&lang=jp

"""
import sys
from collections import deque


def bfs(u, result, out_edge, in_degree, processed):
    q = deque()
    q.append(u)
    processed[u] = True
    while q:
        u = q.popleft()
        result.append(u)
        for e in out_edge[u]:
            in_degree[e] -= 1
            if in_degree[e] == 0 and processed[e] == False:
                processed[e] = True
                q.append(e)





def solve(V, in_degree, out_edge):
    result = []
    processed = [False for _ in range(V)]

    for i, u in enumerate(in_degree):
        if u == 0 and processed[i] == False:
            bfs(i, result, out_edge, in_degree, processed)
    return result


def main(args):
    V, E = [int(x) for x in input().split(' ')]
    in_degree = [0 for _ in range(V)]
    out_edge = [[] for _ in range(V)]
    for _ in range(E):
        s, t = [int(x) for x in input().split(' ')]
        out_edge[s].append(t)
        in_degree[t] += 1

    result = solve(V, in_degree, out_edge)
    print('\n'.join(map(str, result)))


if __name__ == '__main__':
    main(sys.argv[1:])

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

class Main {

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

        try {

            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

            String dateString = br.readLine();
            String convertTo2018 = "2018" + dateString.substring(4, 10);

            System.out.println(convertTo2018);
        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }
}

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

int main(){
  int a,b;
  cin >> a >> b;
  if(a+b>=a-b && a+b>=a*b)
    cout << a+b;
  else if(a*b>=a+b && a*b>=a-b)
    cout << a*b;
  else cout << a-b;
}

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

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> H(N);
  rep(i, N) cin >> H[i];

  // A[i] = i から1本の道を使って辿り着ける展望台のリスト
  vector<vector<int>> A(N);

  rep(i, M) {
    int a, b;
    cin >> a >> b;
    // 1-indexed -> 0-indexed
    --a;
    --b;
    // a <-> b は双方向で行き来できるので、
    // a の隣接リストに b を、
    // b の隣接リストに a を、それぞれ追加
    A.at(a).push_back(b);
    A.at(b).push_back(a);
  }

  int ans = 0;
  rep(i, N) {
    // max = i から1本の道を使って辿り着ける展望台の高さの最大値
    int max = 0;
    for (int next : A[i]) {
      if (H.at(next) > max) max = H.at(next);
    }

    // i 番目の展望台の高さが max より高ければ条件を満たすので、答えを加算
    // 辿り着ける先がないときも、max = 0 となるので OK

    if (H.at(i) > max) ++ans;
  }

  cout << ans << endl;
}


Measured memory_bytes: 8716
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define max(a,b) ((a>b)? (a):(b))
int main()
{
  int n;
  cin>>n;
  vector<pair<int,pair<int,int>>> vec;
  for(int i=0;i<n;i++){
    int x,y,h;
    cin>>x>>y>>h;
    vec.push_back(make_pair(h,make_pair(x,y)));
  }
  sort(vec.begin(),vec.end());
  reverse(vec.begin(),vec.end());
  for(int cx=0;cx<=100;cx++){
    for(int cy=0;cy<=100;cy++){
      int x_tmp=vec[0].second.first,y_tmp=vec[0].second.second,h_tmp=vec[0].first;
      int H=h_tmp+abs(x_tmp-cx)+abs(y_tmp-cy);
      bool flag=true;
      for(auto &r:vec){
        int x=r.second.first,y=r.second.second,h=r.first;
        if(h!=max(H-abs(cx-x)-abs(cy-y),0)) {
          flag=false;
          break;
        }
      }
      if(flag){
        cout<<cx<<" "<<cy<<" "<<H;
        return 0;
      }
    }
  }
  cout<<"error";
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  int N, M; cin >> N >> M;
  string S; cin >> S;
  reverse(all(S));
  int count1=0;
  rep(i,(int)S.size()){
    if(S[i]=='1'){
      count1++;
      if(count1 == M){
        cout << -1 << endl;
        return 0;
      }
    }
    else { // S[i] == '0'
     count1 = 0;
    }
  }

  vector<int> ans;
  int pos = 0;
  int nextpos;
  while(pos != N){
    nextpos = min(N, pos+M);
    while(S[nextpos]=='1'){
      nextpos--;
    }
    ans.pb(nextpos-pos);
    pos = nextpos;
  }
  reverse(all(ans));
  rep(i,(int)ans.size()){
    if(i!=0) cout << " ";
    cout << ans[i];
  }
  cout << endl;
  return 0;
}


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

int main()
{
    int x[10000];
    int i = 0;
    
    do
    {
    cin >> x[i];
    i++;
    }
    while(x[i-1] != 0);

    for(int j=0; j<i-1; j++)
    {
    cout << "Case " << j+1 << ": " << x[j] << endl; 
    }

    return 0;
}



Measured memory_bytes: 3100
#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>;
int main(int argc, const char * argv[]) {



    cin.tie(0);
    ios::sync_with_stdio(false);

    double a,b,h,m;
    cin>>a>>b>>h>>m;
    double ml=m*6;
    double hl=0.5*m+h*30;
    double kaku=max(ml,hl)-min(ml,hl);
    double ans;
    ans=pow(a,2)+pow(b,2)-2*a*b*cos(kaku/180*M_PI);
    ans=sqrt(ans);
    cout<<fixed<<setprecision(16)<<ans<<endl;

    return 0;
}


Measured memory_bytes: 4244
#include <iostream>

using namespace std;

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

    int n = 0;
    for(int i = a;i <= b;i++)
    {
        if((c % i) == 0)
        {
            n++;
        }
    }
    cout << n << endl;
    
    return 0;
}

Measured memory_bytes: 1164
#include <stdio.h>
int main(void){
        int i,j,k;
        int n,m,l;
        int a[100][100],b[100][100];
        long int c[100][100] = {};
        scanf("%d %d %d",&n,&m,&l);

        for(i=0;i<n;i++){
                for(j=0;j<m;j++)
                        scanf("%d",&a[i][j]);
        }
        for(i=0;i<m;i++){
                for(j=0;j<l;j++)
                        scanf("%d",&b[i][j]);
        }

        for(i=0;i<n;i++){
                for(j=0;j<l;j++)
                        for(k=0;k<m;k++)
                                c[i][j] += a[i][k]*b[k][j];
        }

        for(i=0;i<n;i++){
                for(j=0;j<l;j++){
                        printf("%lu",c[i][j]);
                        if(j<l-1)
                                printf(" ");
                }puts("");
        }

        return 0;
}


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

int main(){
  int N;
  cin >>N;
  vector<int> W(N);
  for(int i=0; i<N; i++){
      cin >> W.at(i);
  }
  vector<int> ruiseki(N+1);
  for(int i=0; i<N; i++){
      ruiseki.at(i+1)=ruiseki.at(i)+W.at(i);
  }
  int ans=ruiseki.at(N);
  for(int i=0;i<N; i++){
      if(ruiseki.at(N)-2*ruiseki.at(i)>=0){
          ans=min(ans, ruiseki.at(N)-2*ruiseki.at(i));
      }
      else{
          ans=min(ans, 2*ruiseki.at(i)-ruiseki.at(N));
      }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
#pragma GCC target("avx2")  //Enable AVX

using namespace std;

using ll = long long;

#define mp make_pair

const int p = 1e9 + 7;


int mul(int a, int b) {
    return (1LL * a * b) % p;
}

int add(int a, int b) {
    int s = (a+b);
    if (s>=p) s-=p;
    return s;
}

int sub(int a, int b) {
    int s = (a+p-b);
    if (s>=p) s-=p;
    return s;
}

int po(int a, int deg)
{
    if (deg==0) return 1;
    if (deg%2==1) return mul(a, po(a, deg-1));
    int t = po(a, deg/2);
    return mul(t, t);
}

int inv(int n)
{
    return po(n, p-2);
}

struct DSU {
    vector<int> sz;
    vector<int> parent;

    void make_set(int v) {
        parent[v] = v;
        sz[v] = 1;
    }

    int find_set(int v) {
        if (v == parent[v])
            return v;
        return parent[v] = find_set(parent[v]);
    }

    void union_sets(int a, int b) {
        a = find_set(a);
        b = find_set(b);
        if (a != b) {
            if (sz[a] < sz[b])
                swap(a, b);
            parent[b] = a;
            sz[a] += sz[b];
        }
    }

    DSU(int n) {
        sz.resize(n);
        parent.resize(n);
        for (int i = 0; i < n; i++) make_set(i);
    }
};



int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);

    ll n, a, b;
    cin>>n>>a>>b;
    ll rat = n/(a+b);
    n%=(a+b);
    cout<<rat*a + min(a, n);

}

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

int main() {
    int X, A, B;
    cin >> X >> A >> B;
    X -= A;
    while (X-B >= 0) {
        X -= B;
    }
    cout << X << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned ui;
typedef unsigned long long ul;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef pair<bool, bool> pbb;
typedef vector<int> vi;
#define pb push_back
#define fi first
#define se second
#define mid ((l + r) >> 1)
#define ls (i << 1)
#define rs (i << 1 | 1)
#define enum(i, j, k) for(int i = j; i <= k; i ++)
#define open(i, j, k) for(int i = j; i <  k; i ++)
#define dec(i, j, k)  for(int i = j; i >= k; i --)
#define ae(x) for(node *p = h[x]; p; p = p->nxt)
template <class T> bool chkmin(T &x, T y)
{ return y < x ? x = y, true : false; }
template <class T> bool chkmax(T &x, T y)
{ return y > x ? x = y, true : false; }
int _()
{
	int ret = 0; bool f = true; char ch = getchar();
	while(!isdigit(ch)) { if(ch == '-') f = false; ch = getchar(); }
	do { ret = ret * 10 + ch - '0'; ch = getchar(); } while(isdigit(ch));
	return f ? ret : -ret;
}
void _(int x)
{
	if(x < 10) { putchar(x + '0'); return ; }
	_(x / 10); putchar(x % 10 + '0');
}
void __init()
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cout << fixed << setprecision(16);
	srand(time(0) ^ ui(ul(new char)));
}
/* default code ends here */
#define maxn 100100
int n, m;
struct node
{
	int v;
	node *nxt;
} e[2 * maxn], *h[maxn];
int z;
void adde(int u, int v)
{
	e[++z] = (node){v, h[u]};
	h[u] = &e[z];
}
int r[maxn];
int root;
int fa[maxn];
void bfs()
{
	queue<int> que;
	que.push(root);
	while(!que.empty())
	{
		int x = que.front();
		que.pop();
		ae(x)
		{
			r[p->v] --;
			if(r[p->v] == 0)
			{
				fa[p->v] = x;
				que.push(p->v);
			}
		}
	}
}
int main()
{
//	freopen("in", "r", stdin);
//	freopen("out", "w", stdout);
	__init();
	cin >> n >> m;
	m = n + m - 1;
	int u, v;
	enum(i, 1, m)
	{
		cin >> u >> v;
		adde(u, v);
		r[v] ++;
	}
	enum(i, 1, n)
		if(r[i] == 0)
		{
			root = i;
			break;
		}
	bfs();
	enum(i, 1, n)
		cout << fa[i] << ' ';
	cout << '\n';
	return 0;
}

















































Measured memory_bytes: 4992
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m, x;
    cin >> n >> m >> x;

    int cost1 = 0; 
    int cost2 = 0;
    REP(i, m) {
        int a;
        cin >> a;
        if(a < x) cost1++;
        else cost2++;
    }
    cout << min(cost1, cost2) << endl;
    
    return 0;
}


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

int main(void) {
	int N, M;
	scanf("%d%d", &N, &M);
	int H[100010];
	for (int i = 0; i < N; i++) {
		scanf("%d", &H[i]);
	}
	int A[100010], B[100010];
	set<int> badTowers;
	for (int i = 0; i < M; i++) {
		scanf("%d%d", &A[i], &B[i]);
		int H_A = H[A[i] - 1];
		int H_B = H[B[i] - 1];
		// cout << H_A << " " << H_B << endl;
		if (H_A == H_B) {
			badTowers.insert(A[i]);
			badTowers.insert(B[i]);
		} else if (H_A > H_B){
			badTowers.insert(B[i]);
		} else {
			badTowers.insert(A[i]);
		}
	}
	printf("%zu", N - badTowers.size());
	return 0;
}


Measured memory_bytes: 7540
/// * BISMILLAH * ///
#include<bits/stdc++.h>
/// Try to solve it, even though you may not solve it  ----- Aspot ///
using namespace std;
int main()
{
string s;
cin >> s;
sort(s.begin(), s.end());
if (s == "abc")
cout << "Yes";
else
cout << "No";
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define SZ(x) ((int)x.size())
#define ALL(x) x.begin(),x.end()
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> T gcd(T a, T b){return !b?a:gcd(b,a%b);}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 266666;
Pii ans[N];int sz;
int n,a[N];
void solve(int S){
	vector<Pii> cur;bool first=1;
	per(i,n,1)if(S>>i-1&1){
		if(first){
			first=0;cur={mp(i,1),mp(i,0)};
		}
		else{
			vector<Pii>nxt={mp(i,1)};
			nxt.insert(nxt.end(),ALL(cur));
			nxt.pb(mp(i,1));
			nxt.pb(mp(i,0));
			per(i,SZ(cur)-1,0)nxt.pb(cur[i]);
			nxt.pb(mp(i,0));
			cur=nxt;
		}
	}
	else cur.insert(cur.begin(),mp(i,1)),cur.insert(cur.end(),mp(i,1));
	int x=0,y=1;
	for(auto i:cur){
	//	cerr<<i.fi<<' '<<i.se<<endl;
		if(y!=i.se)ans[++sz]=mp(x,y^1),y^=1;
		int tar=x<i.fi?i.fi:i.fi-1;
		while(x!=tar)ans[++sz]=mp(x+(tar>x?1:-1),y),x=ans[sz].fi;
	}
	Pii i(0,1);
	if(y!=i.se)ans[++sz]=mp(x,y^1),y^=1;
	while(x!=0)ans[++sz]=mp(x-1,y),x--;
}
void GG(){puts("Impossible");exit(0);}
int main() {
	char ss[1<<8|3];read(n);scanf("%s",ss);
	rep(i,0,(1<<n)-1)a[i]=ss[i]=='1';
	if(!a[0])GG();
	rep(s,1,(1<<n)-1)if(!a[s])rep(i,0,n-1)if(~s>>i&1)
		if(a[s^(1<<i)])GG();
	ans[++sz]=mp(0,1);
	rep(s,1,(1<<n)-1)if(!a[s]){
		bool ok=1;rep(i,0,n-1)if(s>>i&1)ok&=a[s^(1<<i)];
		if(ok)solve(s);
	}
	printf("Possible\n%d\n",sz-1);
	rep(i,1,sz)printf("%d %d\n",ans[i].fi,ans[i].se);
	return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
           
            while(true){
            int H = sc.nextInt();
            int W = sc.nextInt();
            if(H == 0 && W == 0){
                break;
            }
            for(int i = 1 ; i <= H ; i++){

                
                for(int j = 1 ; j <= W ;j ++){
                    System.out.print("#");
                    if(j == W){
                        System.out.println();
                    }
                }
                if(i == H){
                    System.out.println();
                }
            }
            }
        
    }
}


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

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

long long MOD = 1000000000 + 7;

int main(){
  cout << setprecision(10);
  int N,K,C;
  cin >> N >> K >> C;
  string S; cin >> S;

  if(N == 1){
    if(K == 1){
      cout << 1 << endl;
    } else { 
      cout << endl;
    }
    return 0;
  }


  vector<int> left(N,0);
  vector<int> right(N,0);

  for(int i = 0; i < N; i++){
    if(S[i] == 'x'){
      if(i > 0){
        left[i] = left[i-1];
      } else { 
        left[i] = 0;
      }
    }
    if(S[i] == 'o'){
      if(i >= C+1){
        left[i] = left[i-C-1] + 1;
      } else { 
        left[i] = 1;
      }
    }
  }

  for(int i = N-1; i >= 0; i--){
    if(S[i] == 'x'){
      if(i < N-1){
        right[i] = right[i+1];
      } else { 
        right[i] = 0;
      }
    }
    if(S[i] == 'o'){
      if(i + C + 1 < N){
        right[i] = right[i+C+1] + 1;
      } else {
        right[i] = 1;
      }
    }
  }

  int num = 0;
  for(int i = 0; i < N; i++){

    if(i == 0){
      if(right[i+1] < K){
        cout << i + 1 << endl;
        num++;
      }
    }

    if(i == N-1){
      if(left[i-1] < K){
        cout << i + 1 << endl;
        num++;
      }
    }

    if(i > 0 && i < N-1){
      if(left[i-1] + right[i+1] < K){
        cout << i+1 << endl;
        num++;
      }
    }
  }

  if(num == 0){
    cout << endl;
  }
}


Measured memory_bytes: 5240