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

vector<vector <ll>>v;
// vector<vector <ll>>dp;
ll dp[1005][10005] = {};
bool compare(vector<ll>a,vector<ll>b){
ll w1 = a[0],s1=a[1],w2=b[0],s2=b[1];
return w1+s1 > w2+s2;
}
void solve(){
ll n;cin>>n;
v.resize(n,vector<ll>(3));
// dp.resize(1001,vector<ll>(10001,0));
for(ll i=0;i<n;i++){
cin>>v[i][0]>>v[i][1]>>v[i][2];
}
sort(v.begin(),v.end(),compare);
    for(int j = 0; j <= 10000; j++)
    {
        if(v[0][1] >= j)
            dp[0][j] = v[0][2];
        else dp[0][j] = 0;
    }

for(int i = 1; i < n; i++)
{
    for(int j = 0; j <= 10000; j++)
    {
        ll op1 = dp[i-1][j];
        ll op2 = (v[i][1] >= j) ? (v[i][2] + ((j + v[i][0] > 10000)?0:dp[i-1][j+v[i][0]])) : 0;
        dp[i][j] = max(op1, op2);
    }
}
cout<< dp[n-1][0]<<endl;


}

int main(){
// cin.tie(0);
// cout.tie(0);
// cin.sync_with_stdio(0);
// cout.sync_with_stdio(0);
/*
    #ifndef ONLINE_JUDGE
        freopen("input.txt",  "r",  stdin);
        freopen("output.txt", "w", stdout);
    #endif
//*/
// cout.precision(10);
int t=1;//cin>>t;
while(t--){
    solve();
}
return 0;
}


Measured memory_bytes: 81836
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        String s = scanner.next();
        int t = s.length();
        for (int i = 1; i < s.length(); i++) {
            if (s.charAt(i - 1) != s.charAt(i)) {
                t = Math.min(t, Math.max(i, s.length() - i));
            }
        }
        System.out.println(t);
    }
}

Measured memory_bytes: 24736
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define pii pair<int,int>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
#define mat vector<vector<double>>
const int inf = 1 << 30;
const ll linf = 1e18;
const db EPS = 1e-7;
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}

bool prm[200010];

void prime(){
    for(int i = 2; i <= 2e5; i++){
        prm[i] = true;
    }
    for(int i = 2; i <= 2e5; i++){
        if(prm[i]){
            for(int j = i * 2; j <= 2e5; j += i){
                prm[j] = false;
            }
        }
    }
}
int X;
int main(){
    cin >> X;
    prime();
    while(!prm[X]) X++;
    cout << X << endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <chrono>
#include <math.h>
using namespace std;

using lli = long long int;
using Vint = std::vector<int>;
using Vlli = std::vector<lli>;
using Wint = std::vector<Vint>;
using Wlli = std::vector<Vlli>;
using Vbool = std::vector<bool>;
using pii = std::pair<int, int>;
using pll = std::pair<lli, lli>;

constexpr int MOD = 1e9 + 7;
constexpr int INFi = 2e9 + 1;
constexpr lli INFl = (lli)(9e18) + 1;
const vector<pii> DXDY = {std::make_pair(1, 0), std::make_pair(-1, 0), std::make_pair(0, 1), std::make_pair(0, -1)};
constexpr char BR = '\n';

#define FOR(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define FOReq(i, a, b) for(int (i) = (a); (i) <= (b); (i)++)
#define rFOR(i, a, b) for(int (i) = (b); (i) >= (a); i--)
#define FORstep(i, a, b, step) for(int (i) = (a); i < (b); i += (step))
#define REP(i, n) FOR(i, 0, n)
#define rREP(i, n) rFOR(i, 0, (n-1))
#define vREP(ele, vec) for(auto &(ele) : (vec))
#define vREPcopy(ele, vec) for(auto (ele) : (vec))
#define SORT(A) std::sort((A).begin(), (A).end())
// 座標圧縮 (for vector) : ソートしてから使うのが一般的 ; SORT(A) => COORDINATE_COMPRESSION(A)
#define COORDINATE_COMPRESSION(A) (A).erase(unique((A).begin(),(A).end()),(A).end())



template <class T> inline int argmin(std::vector<T> vec){return min_element(vec.begin(), vec.end()) - vec.begin();}
template <class T> inline int argmax(std::vector<T> vec){return max_element(vec.begin(), vec.end()) - vec.begin();}
template <class T> inline void chmax(T &a, T b){a = max(a, b);}
template <class T> inline void chmin(T &a, T b){a = min(a, b);}
inline int toInt(string &s){int res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
inline int toInt(const string s){int res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
inline long long int toLong(string &s){lli res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
inline long long int toLong(const string s){lli res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
template <class T> inline std::string toString(T n){
  if(n == 0) return "0";
  std::string res = "";
  if(n < 0){n = -n;while(n != 0){res += (char)(n % 10 + '0'); n /= 10;}
  std::reverse(res.begin(), res.end()); return '-' + res;}
  while(n != 0){res += (char)(n % 10 + '0'); n /= 10;} std::reverse(res.begin(), res.end()); return res;
}

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



int main(void){
  int n; scanf("%d", &n);
  Vint A(n); REP(i, n) scanf("%d", &A[i]);
  int mx = -1;
  REP(i, n) chmax(mx, A[i]);
  int r = mx, mn_abs_mx_minus_r_and_r = 0;
  REP(i, n){
    int tmp = min(A[i], mx - A[i]);
    if(tmp >= mn_abs_mx_minus_r_and_r){
      r = A[i];
      mn_abs_mx_minus_r_and_r = tmp;
    }
  }
  printf("%d %d\n", mx, r);
  return 0;
}

Measured memory_bytes: 640
N, M, X = map(int, input().split())
A = list(map(int, input().split()))

left_cost = 0
right_cost = 0
for a in A:
  if a < X:
    left_cost += 1
  elif a > X:
    right_cost += 1

if left_cost < right_cost:
  print(left_cost)
else:
  print(right_cost)

Measured memory_bytes: 38384
def main(n, m, h, roads):
    is_good_peaks = [True] * n
    for road in roads:
        a, b = road[0] - 1, road[1] - 1
        if h[a] <= h[b]:
            is_good_peaks[a] = False
        if h[b] <= h[a]:
            is_good_peaks[b] = False
    print(sum(is_good_peaks))


if __name__ == "__main__":
    n, m = map(int, input().split())
    h = tuple(map(int, input().split()))
    roads = []
    for _ in range(m):
        roads.append(tuple(map(int, input().split())))
    main(n, m, h, roads)


Measured memory_bytes: 27268
#include<bits/stdc++.h> 
#include<random> 
#define int long long 
#define pp pair<int,int> 
#define ss second 
#define ff first 
#define pb push_back 
#define mod 1000000007 
using namespace std; 
void fastio() 
{ 
    #ifndef ONLINE_JUDGE 
    freopen("INPUT.txt","r",stdin); 
    freopen("OUTPUT.txt","w",stdout); 
    #endif 
    ios_base :: sync_with_stdio(false); 
    cin.tie(NULL) ; 
    cout.tie(NULL); 
}

signed main() 
{ 
    fastio(); 
    int t=1;
  //  cin>>t;
    while(t--)
    {
       
       int c=1,d=0;
       int a,b;
       cin>>a>>b;
       while(c<b)
       {
           c+=a;
           c--;
           d++;
       }
       cout<<d;
    }
}


Measured memory_bytes: 3628
h,w = map(int, input().split())
l = [None]*h
for i in range(h):
    l[i] = list(input())

from collections import deque
def solve():
    dx = [1, 0, -1, 0]
    dy = [0, 1, 0, -1]

    Q = deque()

    cnt=h*w
    for x in range(w):
        for y in range(h):
            if l[y][x]=="#":
                cnt-=1
                Q.append([x,y])
    if cnt==0:
        return 0

    ans=0
    while True:
        nxtQ = deque()

        ans+=1
        while Q:
            p = Q.popleft()
            for i in range(4):
                nx = p[0] + dx[i]
                ny = p[1] + dy[i]

                if 0 <= nx < w and 0 <= ny < h:
                    if l[ny][nx]==".":
                        l[ny][nx] = "#"
                        nxtQ.append([nx,ny])
                        cnt-=1
        Q=nxtQ
        if cnt<=0:
            return ans

print(solve())

Measured memory_bytes: 163036
import java.util.Scanner;
public 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=0;i<H;i++){
                for(int j=0;j<W;j++){
                    if(i%2==0){
                        if(j%2!=0)System.out.print(".");
                        else System.out.print("#");
                    }
                    else{
                        if(j%2==0)System.out.print(".");
                        else System.out.print("#");
                    }
                }
                System.out.print("\n");
            }
            System.out.print("\n");
        }
    }
}


Measured memory_bytes: 35136
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define mod 1000000007
typedef long long ll;
using namespace std;

int main(){
  int r;
  cin >> r;
  cout << 3*r*r << endl;

  return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
const int N = 3e5+5, M = 1e4+5, OO = 0x3f3f3f3f;
typedef  long long LL;
typedef  long double LD;
#define PI 3.14159265358979323846
#define INF LONG_MAX
const int  MOD = 1e9+7;
int main()
{
    int n; cin>>n;
    LL s=0;
    for (int x=1; x<=n; ++x) {
        if (x%3==0 && x%5==0) continue;
        else if (x%3==0) continue;
        else if (x%5==0) continue;
        else s+=x;
    }
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef int64_t Int;

int main(){ 
  int N, t;
  Int r,g,b,C;
  cin >> N;
  string S;
  cin >> S;
  t = 0;
  r = 0;
  g = 0;
  b = 0;

  rep(i,N) {
      if (S[i] == 'R') r++;
      else if (S[i] == 'G') g++;
      else if (S[i] == 'B') b++;
  }


  C = r * g * b;
  
  rep(i,N) {
    for (int j = i + 1; 2 * j < N + i; j++) {
      if (S[i] != S[j] && S[i] != S[2 * j - i] && S[j] != S[2 * j - i]) t++; 
    }
  }

  cout << C - t << endl;

}


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

using ll = long long;
using pii = pair<int, int>;
using pli = pair<ll, int>;
#define X first
#define Y second

const int N = 100005;
const ll inf = ll(1e18) + 5, M = ll(1e9) + 7;

vector<pii> e[N];
vector<int> de[N], re[N];

int n, m, s, t, fc[N], gc[N];
ll d[N], r, fd[N], gd[N];
priority_queue<pli, vector<pli>, greater<pli>> pq;

ll f(int x){
	if(fc[x]) return fd[x];
	fc[x] = 1;
	if(x == s) return fd[x] = 1;
	for(int i : re[x]) fd[x] = (fd[x] + f(i)) % M;
	return fd[x];
}

ll g(int x){
	if(gc[x]) return gd[x];
	gc[x] = 1;
	if(x == t) return gd[x] = 1;
	for(int i : de[x]) gd[x] = (gd[x] + g(i)) % M;
	return gd[x];
}

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	cin >> n >> m >> s >> t;
	for(int x, y, z; m--; ){
		cin >> x >> y >> z;
		e[x].emplace_back(y, z);
		e[y].emplace_back(x, z);
	}
	fill(d + 1, d + n + 1, inf);
	d[s] = 0;
	pq.emplace(0LL, s);
	while(!pq.empty()){
		ll c; int x;
		tie(c, x) = pq.top();
		pq.pop();
		if(c > d[x]) continue;
		for(pii i : e[x]){
			if(d[i.X] < c + i.Y) continue;
			if(d[i.X] > c + i.Y){
				d[i.X] = c + i.Y;
				pq.emplace(c + i.Y, i.X);
				re[i.X].clear();
			}
			re[i.X].push_back(x);
		}
	}
	for(int i = 1; i <= n; i++) for(int j : re[i]) de[j].push_back(i);
	r = f(t) * f(t) % M;
	for(int i = 1; i <= n; i++){
		if(d[i] * 2 == d[t]) r = (r - (f(i) * g(i) % M) * (f(i) * g(i) % M) % M + M) % M;
		for(int j : de[i]) if(d[i] * 2 < d[t] && d[j] * 2 > d[t])
			r = (r - (f(i) * g(j) % M) * (f(i) * g(j) % M) % M + M) % M;
	}
	cout << r << endl;
}

Measured memory_bytes: 27260
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N, x;
  cin>>N>>x;
  if(N==2) {
    if(x==2) {
      cout<<"Yes"<<endl;
      cout<<1<<endl;
      cout<<2<<endl;
      cout<<3<<endl;
    }
    else {
      cout<<"No"<<endl;
    }
    return 0;
  }
  if(x-2>=1 && x+1<=2*N-1) {
    cout<<"Yes"<<endl;
    vector<ll> arr(2*N-1);
    for(int i=0;i<2*N-1;++i) arr[i] = -1;
    arr[N-2] = x-1;
    arr[N-1] = x;
    arr[N] = x+1;
    arr[N+1] = x-2;
    vector<ll> arr1;
    for(int i=1;i<=2*N-1;++i) {
      if(x-2<=i && i<=x+1) continue;
      arr1.push_back(i);
    }
    int index = 0;
    for(int i=0;i<2*N-1;++i) {
      if(arr[i]==-1) {
        arr[i] = arr1[index];
        index++;
      }
    }
    for(int i=0;i<2*N-1;++i) cout<<arr[i]<<endl;
  }
  else if(x-1>=1 && x+2<=2*N-1) {
    cout<<"Yes"<<endl;
    vector<ll> arr(2*N-1);
    for(int i=0;i<2*N-1;++i) arr[i] = -1;
    arr[N-2] = x+2;
    arr[N-1] = x;
    arr[N] = x-1;
    arr[N+1] = x+1;
    vector<ll> arr1;
    for(int i=1;i<=2*N-1;++i) {
      if(x-1<=i && i<=x+2) continue;
      arr1.push_back(i);
    }
    int index = 0;
    for(int i=0;i<2*N-1;++i) {
      if(arr[i]==-1) {
        arr[i] = arr1[index];
        index++;
      }
    }
    for(int i=0;i<2*N-1;++i) cout<<arr[i]<<endl;
  }
  else cout<<"No"<<endl;
}



Measured memory_bytes: 6924
#include<cstdio>
#include<cstring>
#include<algorithm>

using namespace std;
int n;
int sum[300000];

int main(void){
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		memset(sum,0,sizeof(sum));
		for(int i=0;i<n;i++){
			int h,m,s;
			scanf("%02d:%02d:%02d",&h,&m,&s);
			sum[h*60*60+m*60+s]++;
			scanf("%02d:%02d:%02d",&h,&m,&s);
			sum[h*60*60+m*60+s]--;
		}
		int res=sum[0];
		for(int i=0;i<=24*60*60;i++){
			sum[i+1]+=sum[i];
			res=max(res,sum[i+1]);
		}
		printf("%d\n",res);
	}
	return 0;

}

Measured memory_bytes: 2208
A,B=map(int,input().split())
N = input()

if N.count("-")==1:
  temp=N.split("-")
  left=temp[0]
  right=temp[1]
  if (len(left)==A)and(len(right)==B):
    print("Yes")
  else:
    print("No")
else:
  print("No")
  
  

Measured memory_bytes: 2940
n = int(input())
a = list(map(int, input().split()))
dp = {}
dp[0,0] = 0
dp[0,1] = -float('inf')
for i in range(1, n+1):
    dp[i, 0] = max(dp[i-1, 0] + a[i-1], dp[i-1, 1] - a[i-1])
    dp[i, 1] = max(dp[i-1, 0] - a[i-1], dp[i-1, 1] + a[i-1])
print(dp[n, 0])

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

string s;
int n;

bool check(int len)
{
	for(int i=0;i<s.size()-len;++i) {
		if(s.find(s.substr(i,len),i+len)!=string::npos) return 1;
	}
	return 0;
}

int main()
{
	scanf("%d",&n);
	cin>>s;
	int l=0,r=(n+2)>>1;
	while(l<r) {
		int mid=(l+r+1)>>1;
		if(check(mid)) l=mid;
		else r=mid-1;
	}
	printf("%d",l);
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);

		int data = sc.nextInt();
		for (int i = 1; ; i++)
		{
			if (data == 0)
			{
				break;
			}

			System.out.println("Case " + i + ": " + data);

			data = sc.nextInt();
		}
	}
}



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

int main(){
    int N, maxNum=0, sum=0;
    cin >> N;
    vector<int> p(N);

    for(int i=0; i<N; i++){
	cin >> p[i];
	sum += p[i];
	maxNum = max(maxNum, p[i]);
    }

    sum -= maxNum/2;
        
    cout << sum<< endl;    
}


Measured memory_bytes: 256
import java.util.*;

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

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int L = sc.nextInt();
        String[] S = new String[N]; 
        
        //文字列を格納し、辞書順に並び替え
        for(int i = 0; i < N; i++)S[i] = sc.next();
        Arrays.sort(S);

        for(int i = 0; i < N; i++)System.out.print(S[i]);
    }
}


Measured memory_bytes: 23380
// Author: getharshkumar

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

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

Measured memory_bytes: 256
[<AutoOpen>]
module Program

open System

let read f = stdin.ReadLine() |> f
let reada f = stdin.ReadLine().Split() |> Array.map f
let reads f = stdin.ReadLine().Split() |> Array.toList |> List.map f

[<EntryPoint>]
let main _ =
    let [n;m] = reads int
    let xs = reads int

    let mutable ss = Set.ofList (List.zip xs [1..n])
    for i = 1 to m do
        let (x, y) as a = Set.maxElement ss
        ss <- Set.remove a ss
        ss <- Set.add (x / 2, y) ss

    Set.fold (fun s (x, y) -> s + int64 x) 0L ss
    |> printfn "%i"

    0

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

const int INF = 1 << 10;
const int MAX_N = 110;
const int DONE = 2;
const int TOUCHED = 1;
const int NOT_TOUCHED = 0;
int G[MAX_N][MAX_N];
int D[MAX_N];
int V[110];

int main() {
  int n, i, j, u, k, v, d;
  queue<int> q;

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

  for (i = 0; i < n; ++i) {
    cin >> u >> k;
    for (j = 0; j < k; ++j) {
      cin >> v;
      G[u - 1][v - 1] = 1;
    }
  }

  D[0] = 0;
  V[0] = TOUCHED;
  q.push(0);
  while (!q.empty()) {
    i = q.front(); q.pop();
    for (j = 0; j < n; ++j) {
      if (G[i][j] && V[j] != DONE) {
        if (V[j] == NOT_TOUCHED) {
          V[j] = TOUCHED;
          q.push(j);
        }
        D[j] = min(D[j], D[i] + 1);
      }
    }
    V[i] = DONE;
  }

  for (i = 0; i < n; ++i) {
    d = D[i] == INF ? -1 : D[i];
    cout << i + 1 << ' ' << d << '\n';
  }

  return 0;
}


Measured memory_bytes: 3152
#include<bits/stdc++.h>
using namespace std;
#define MaxN 100003

int N, K;
int a[MaxN], f[MaxN];

inline int Rd() {
    int x = 0; char ch = getchar();
    while(ch < '0' || ch > '9') ch = getchar();
    while(ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
    return x;
}
inline void ChkMin(int &aa, int bb) {
    if(aa > bb) aa = bb;
    return;
}

int main() {
    N = Rd(), K = Rd();
    for(register int i = 1; i <= N; ++i)
        a[i] = Rd();
    memset(f, 127, sizeof f), f[1] = 0;
    for(register int i = 2; i <= N; ++i) {
        int Eg = max(1, i - K);
        for(register int j = i - 1; j >= Eg; --j)
            ChkMin(f[i], f[j] + abs(a[i] - a[j]));
    }
    cout << f[N] << endl;
    return 0;
}


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

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
const int INF = 1e9 + 7;

vector<int> hv[200005];
int h, w, n;

int main()
{
	scanf("%d%d%d", &h, &w, &n);
	rep(i, n) {
		int x, y;
		scanf("%d%d" ,&x, &y);
		hv[x].push_back(y);
	}
	int clen = 1;
	for(int i = 2; i <= h; i ++) {
		rep(j, hv[i].size()) if(hv[i][j] <= clen) {
			printf("%d\n", i - 1);
			return 0;
		}
		clen ++;
		rep(j, hv[i].size()) if(hv[i][j] == clen) {
			clen --;
			break;
		}
	}
	printf("%d\n", h);
	return 0;
}

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

#define NREP() for(ll i = 0; i < n; i++)
#define MREP() for(ll j = 0; j < m; j++)
#define REP(i, x, y) for(ll i = x; i < y; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define MSGF(x, n) MSG(fixed << setprecision(n) << x)
#define END(x) cout << x << endl; exit(0);
#define IPT(v, n) REP(i, 0, n){ cin >> v[i]; }
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<ull> vul;
typedef vector<vector<ull>> vvul;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;

const static ll MOD = 1e9 + 7;
const static ll INF = 1LL << 30;

ll a, b, c, d, k, l, m, n, h, w, q, x, y;
string s, t;

ll ans = 0;
ll sum = 0;
ll cnt = 0;
ll cur = 0;
ll tmp = 0;
ll mini = INF;
ll maxi = 0;

double ave = 0.0;

ll mod_pow(ll base, ll power) {
    if (power == 0) return 1;
    if (power == 1) return base % MOD;
    if (power % 2 == 0) return ((mod_pow(base % MOD, (power / 2)) % MOD) * (mod_pow(base, (power / 2)) % MOD)) % MOD;
    return (base % MOD * (mod_pow(base % MOD, power - 1) % MOD)) % MOD;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    cin >> n;
    vl s(n);
    NREP() {
        cin >> s[i];
        sum += s[i];
    }
    sort(ALL(s));
    if (sum % 10 != 0) {
        END(sum)
    }

    NREP() {
        if (s[i] % 10 != 0) {
            END(sum - s[i])
        }
    }

    MSG(0)

}


Measured memory_bytes: 256
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define mp make_pair
#define ALL(obj) (obj).begin(),(obj).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n) 
#define SIZE(x) ((int)(x).size())
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef pair<int, int> pint;
typedef pair<lint, lint> plint;
typedef vector<lint> vec;
typedef vector<vector<lint>> matrix;
typedef priority_queue<lint> p_que;
typedef priority_queue<lint, vector<lint>, greater<lint>> p_que_rev;
const lint INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};

lint gcd(lint a, lint b) {
    lint r;
    while (b != 0) {
        r = a % b;
        a = b; 
        b = r;
    }
    return a;
}

lint lcm(lint a, lint b) {
    return (a / gcd(a, b)) * b;
}

lint power(lint x, lint n, lint mod = MOD) {
    lint ret = 1;
    while(n > 0) {
        if(n & 1){
            (ret *= x) %= mod;
        }
        (x *= x) %= mod;
        n >>= 1;
    }
    return ret;
}

vector<lint> make_power(int n, lint base){
    lint num = 1;
    vector<lint> ret;
    for (int i=0; i<=n; ++i){
        ret.push_back(num);
        num *= base;
    }
    return ret;
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    int a = n / k;
    int b = n % k;
    cout << b << endl;
    return 0;
}

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

int main(){
  ios_base::sync_with_stdio(false);

  string s;
  int a = 0, b = 0, c = 0;

  cin >> s;

  for(int i=0;i<s.size();i++){
    if(s[i] == 'a')a++;
    if(s[i] == 'b')b++;
    if(s[i] == 'c')c++;
  }

  if(a & b & c){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define F first
#define S second
#define vll vector<ll>
#define fast ios:: sync_with_stdio(false),cin.tie(0);
#define COUT cout<<fixed<<setprecision(12)
#define SET set<ll,greater<ll>>gquiz
#define ITERATOR set<ll,greater<ll>> :: iterator itr
#define V vector<ll>vector
#define sz size()
//#define A vector<pair<ll,ll>>vect
ll N=100000,M=100000;
#define B vect.push_back(make_pair(N,M));
ll MOD=1000000007;
 
bool isprime(ll n){if(n==1 || (n!=2 && n%2==0))return false; if(n==2)return true; 
		for(ll i=3;i<=sqrt(n);i+=2)if(n%i==0)return false; return true; }
ll gcd(ll a,ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
/*
ll ncr(ll n,ll r)
{
	if(n==1 || r==0)
	return 1;
	if(r>n/2)
	r=n-r;
	ll ans=1;
	for(ll i=1;i<=r;i++)
	{
		ans=((ans * n )/i);
		n--;
	}
	return ans;
}
*/
ll pow1(ll n,ll k,ll mm){
    if(k==0)return 1;
    if(k%2==0)return (pow1((n%mm)*(n%mm),k/2,mm))%mm;
    return ((n%mm)*(pow1((n%mm)*(n%mm),k/2,mm)%mm))%mm;
}
ll pow(ll a,ll b,ll m)
{
	ll ans=1;
	while(b>0)
	{
		if(b&1)
			ans=(ans*a)%m;
		b=b/2;
		a=(a*a)%m;
	}
	return ans;
}
 
ll modinv(ll k)
{
	return pow(k,MOD-2,MOD);
}

ll ncr(ll n,ll c)
{
    ll t=1;
    c=min(c,n-c);
    for(ll i=1;i<=c;i++)
    {
     	t=(t*(n-i+1))%MOD;
        t=(t*modinv(i))%MOD;
	}
    return t;
}
int main()
{
	fast;
	ll n,m;
	cin>>n>>m;
	ll sum=0;
	if(n>=2)
	{
	    sum=sum+ncr(n,2);
	}
	if(m>=2)
	{
	    sum=sum+ncr(m,2);
	}
	cout<<sum;
}
	

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys

#n= int(input())
#tmp= float(input())
s= input()
p= input()

slen=len(s)
plen=len(p)


for i in range(slen):
    for j in range(plen):
        if(s[(i+j)%slen]!=p[j]):
            break
        if(j==plen-1):
            print("Yes")
            sys.exit()
print("No")





Measured memory_bytes: 5568
import sys
a, b, c, d = map(int, input().split())
times = (a//d) + 1
if  d >= a :
    if b >= c :
        print("Yes")
        sys.exit()
    else :
        print("No")
        sys.exit()
if a%d == 0 :
    times -= 1
if times * b >= c :
    print("Yes")
else :
    print("No")


Measured memory_bytes: 9180
//templates
#include <iostream>
#include <algorithm>
#include <string>
#include <numeric>
#include <vector>
#include <unordered_map>
#include <map>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <sstream>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define ALL(x) (x).begin(),(x).end()
#define sort_key(struct_name,key_name) [](const struct_name &x, const struct_name &y){return x.key_name < y.key_name;}
#define pb(x) push_back(x)
typedef long long ll;
const long long MOD = 1e9 + 7;
using namespace std;

//main
int main(){
    ll N; cin >> N;
    cout << N*(N-1)/2 << endl;
}


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

int main(){
    int a,b,ans;
    cin>>a>>b;
   for(int i=0;i<30;i++){
    if(a*i-(i-1)>=b){
        ans=i;
        break;
    }
   }
   cout<<ans<<endl;
   
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
#define si(x) scanf("%d",&x)
#define sf(x) scanf("%lf",&x)
#define sl(x) scanf("%lld",&x)
#define pr(x) printf("%d\n",x)
#define prll(x) printf("%lld\n",x)
 
#define ll long long int
#define ull unsigned long long int
#define F first
#define S second
 
#define rep(i,x,y) for(int i=x;i<y;i++)
#define ii pair<int,int> 
#define pll pair<ll,ll> 
#define vi vector<int> 
#define vvi vector< vi > 
#define vl vector<long long int>
#define vvl vector< vl >
#define vii vector< ii >
#define vvii vector< vii >
#define priority_queue pq;
#define sz(a) ll((a).size()) 
#define pb push_back 
#define mp make_pair
 
#define ROUNDOFFINT(d) d = (int)((double)d + 0.5)
#define SET(a,b) memset(a,b,sizeof(a))
#define all(c) (c).begin(),(c).end() 
#define tr(i,c) for(typeof((c).begin()) i = (c).begin(); i != (c).end(); i++) 
#define present(c,x) ((c).find(x) != (c).end()) 
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define ison(x,i) (((x) >> (i)) & 1)	//checks if ith bit is on
#define set0(x,i) (x & ~(1 << i))		//set ith bit in x to be zero
#define clr(a) memset(a,0,sizeof(a))
 
#define MOD 1000000007
#define INF 4000000000000000000
#define MAX 100000+5
using namespace std;



int main()
{
	string s;
	int n,l;
	si(n); si(l);
	vector<string> v;
	rep(i,0,n)
	{
		cin>>s;
		v.pb(s);
	}
	sort(all(v));
	rep(i,0,v.size())
	cout<<v[i];
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define nl "\n"
#define rep(i,n) for(ll i=0; i<(n); i++)
typedef vector<ll> vl;
typedef vector<vector<ll>> matrix;//matrix A(n, vl(m)); //n*m行列
typedef vector<string> vs;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define sortup(V) sort(V.begin(), V.end())
#define sortdown(V) sort(V.rbegin(), V.rend())
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if(b<a){a=b;return 1;}return 0;}
#define MOD 1000000007 //998244353


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

    // solution comes here
    ll N, ans=1;
    cin >> N;
    vl C={0,0,0};
    rep(i, N){
        ll A, cnt=0;
        bool first=true;
        cin >> A;
        rep(j, 3) if(C[j]==A){
            cnt++;
            if(first)C[j]++;
            first = false;
        }
        ans *= cnt;
        ans %= MOD;
    }

    cout << ans << nl;
}

Measured memory_bytes: 256
import static java.util.stream.Collectors.toSet;

import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;
import java.util.stream.LongStream;

public class Main {
    static final long MOD = 998244353;

    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final long num = scanner.nextLong();

        final String prefix = num <= 999 ? "ABC" : "ABD";
        final long n = num <= 999 ? num : num - 999;

        System.out.println(prefix);
    }

    long c(final long p, final long q) {
        if (q == 1) {
            return p;
        }

        if (q * 2 < p) {
            return c(p, p - q);
        }

        long result = 1;
        final Set<Long> hashSet = new TreeSet<>(LongStream.rangeClosed(2, q).boxed().collect(toSet()));
        for (long i = p; i > p - q; --i) {
            final long i_ = i;
            final Long div = hashSet.stream().filter(k -> i_ % k == 0).findFirst().orElse(1L);
            hashSet.remove(div);
            result *= (i / div);
            if (result > MOD) {
                result = result % MOD;
            }
        }
        return result;
    }
}


Measured memory_bytes: 21844
from math import sin,cos,pi
N = int(input())
xy = [list(map(int,input().split())) for _ in range(N)]
ans = 0
for n in range(10**5):
    Rx = cos(2*pi*n/10**5)
    Ry = sin(2*pi*n/10**5)
    X = 0
    Y = 0
    for x,y in xy:
        if Rx*x+Ry*y > 0:
            X += x
            Y += y
    ans = max(ans,(X**2+Y**2)**0.5)
print(ans)

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

int leader[1000];
int dp[1000][8];

const int MOD = 10007;

int solve(int d, int s) {
  if(((s >> leader[d]) & 1) == 0) return 0;
  int &res = dp[d][s];
  if(res != -1) return res;
  int ans = 0;
  for(int t = 0; t < (1 << 3); ++t) {
    if((s & t) == 0) continue;
    ans += solve(d - 1, t);
    ans %= MOD;
  }
  return res = ans;
}

int main() {
  int N; cin >> N;
  string s; cin >> s;
  for(int i = 0; i < (int)s.size(); i++) {
    string t = "JOI";
    leader[i] = t.find(s[i]);
  }
  for(int i = 0; i < N; ++i) {
    for(int S = 0; S < (1 << 3); ++S) dp[i][S] = -1;
  }
  for(int S = 0; S < (1 << 3); ++S) {
    if((S & 1) && ((S >> leader[0]) & 1)) dp[0][S] = 1;
    else dp[0][S] = 0;
  }
  int ans = 0;
  for(int i = 0; i < (1 << 3); ++i) ans += solve(N-1, i);
  ans %= MOD;
  cout << ans << endl;
}

Measured memory_bytes: 1308
#include <string>
#include <iostream>
using namespace std;
int main(){
	int N,a,b,i,c;
	string s,t;
	for(cin>>N,getline(cin,s);N--;){
		getline(cin,s);
		for(a=1;a<26;a++){
			if(a%2==0||a%13==0)continue;
			for(b=0;b<26;b++){
				for(t=s,i=0;i<t.length();i++){
					if(t[i]<'a'||'z'<t[i])continue;
					c=t[i]-'a'+b;for(;c%a;)c+=26;
					t[i]=c/a%26+'a';
				}
				if(t.find("this")!=-1||t.find("that")!=-1){cout<<t<<endl;goto n;}
			}
		}	
	n:;}
}

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

int main(){
  int n,cnt=1;
  string s;
  char x;
  cin>>n>>s;
  x=s[0];
  for(int i=1;i<n;i++){
    if(x!=s[i]){
      cnt++;
      x=s[i];
    }   
  }
  cout<<cnt;
}


Measured memory_bytes: 512
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;

public class Main{

	static PrintWriter out;
	static InputReader ir;

	static void solve(){
		int n=ir.nextInt();
		int[] a=ir.nextIntArray(n);
		int[] b=new int[n];
		b[0]=a[0];
		int p=1;
		for(int i=0;i<n-1;i++){
			if(a[i]!=a[i+1])
				b[p++]=a[i+1];
		}
		int cnt=1;
		for(int i=1;i<p-1;i++){
			if((long)(b[i-1]-b[i])*(b[i+1]-b[i])>0){
				cnt++;
				i++;
			}
		}
		out.println(cnt);
	}

	public static void main(String[] args) throws Exception{
		ir=new InputReader(System.in);
		out=new PrintWriter(System.out);
		solve();
		out.flush();
	}

	static class InputReader {

		private InputStream in;
		private byte[] buffer=new byte[1024];
		private int curbuf;
		private int lenbuf;

		public InputReader(InputStream in) {this.in=in; this.curbuf=this.lenbuf=0;}

		public boolean hasNextByte() {
			if(curbuf>=lenbuf){
				curbuf= 0;
				try{
					lenbuf=in.read(buffer);
				}catch(IOException e) {
					throw new InputMismatchException();
				}
				if(lenbuf<=0) return false;
			}
			return true;
		}

		private int readByte(){if(hasNextByte()) return buffer[curbuf++]; else return -1;}

		private boolean isSpaceChar(int c){return !(c>=33&&c<=126);}

		private void skip(){while(hasNextByte()&&isSpaceChar(buffer[curbuf])) curbuf++;}

		public boolean hasNext(){skip(); return hasNextByte();}

		public String next(){
			if(!hasNext()) throw new NoSuchElementException();
			StringBuilder sb=new StringBuilder();
			int b=readByte();
			while(!isSpaceChar(b)){
				sb.appendCodePoint(b);
				b=readByte();
			}
			return sb.toString();
		}

		public int nextInt() {
			if(!hasNext()) throw new NoSuchElementException();
			int c=readByte();
			while (isSpaceChar(c)) c=readByte();
			boolean minus=false;
			if (c=='-') {
				minus=true;
				c=readByte();
			}
			int res=0;
			do{
				if(c<'0'||c>'9') throw new InputMismatchException();
				res=res*10+c-'0';
				c=readByte();
			}while(!isSpaceChar(c));
			return (minus)?-res:res;
		}

		public long nextLong() {
			if(!hasNext()) throw new NoSuchElementException();
			int c=readByte();
			while (isSpaceChar(c)) c=readByte();
			boolean minus=false;
			if (c=='-') {
				minus=true;
				c=readByte();
			}
			long res = 0;
			do{
				if(c<'0'||c>'9') throw new InputMismatchException();
				res=res*10+c-'0';
				c=readByte();
			}while(!isSpaceChar(c));
			return (minus)?-res:res;
		}

		public double nextDouble(){return Double.parseDouble(next());}

		public int[] nextIntArray(int n){
			int[] a=new int[n];
			for(int i=0;i<n;i++) a[i]=nextInt();
			return a;
		}

		public long[] nextLongArray(int n){
			long[] a=new long[n];
			for(int i=0;i<n;i++) a[i]=nextLong();
			return a;
		}

		public char[][] nextCharMap(int n,int m){
			char[][] map=new char[n][m];
			for(int i=0;i<n;i++) map[i]=next().toCharArray();
			return map;
		}
	}
}

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

#define sswap(x, y) { x+=y; y=x-y; x-=y; }
#define LSOne(S) ((S) & (-S))

#define EPS 1e-6
#define MOD 1000000007

#define fi first
#define se second
#define pb push_back
#define ende '\n'

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define mset(x, y) memset(&x, (y), sizeof(x))

using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
	int n, d;
	cin >> n >> d;
	cout << n/(2*d+1) + (n%(2*d+1) ? 1 : 0) << ende;
  return 0;
}


Measured memory_bytes: 256
# 配列の中がすべて奇数になるまでの試行回数最大値を求める
N = gets.strip.to_i
arr = gets.strip.split(' ').map(&:to_i)

# def single_check target
#   count = 0
#   while target % 2 == 0
#     target = target / 2
#     count += 1
#   end
#   count
# end

arr.select!{|v| v % 2 == 0}
total = 0
arr.each do |target|
  count = 0
  while target % 2 == 0
    target = target / 2
    count += 1
  end
  total += count
end

puts total


Measured memory_bytes: 2428
let solve d n m =
  let dp = Array.make (n + 1) max_int in
  dp.(0) <- 0;
  for j = 1 to n do dp.(j) <- dp.(j-1) + d.(0) done;
  for i = 1 to m - 1 do
    for j = d.(i) to n do
      if dp.(j - d.(i)) + 1 < dp.(j) then dp.(j) <- dp.(j - d.(i)) + 1;
    done
  done;
  dp.(n)

let () =
  let n, m = Scanf.scanf "%d %d " (fun n m -> n, m) in
  let d = Array.init m (fun _ -> Scanf.scanf "%d " (fun i -> i)) in
  solve d n m |> Printf.printf "%d\n"

Measured memory_bytes: 2764
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import numpy as np

N, K = map(int, input().split())
h = list(map(int, input().split()))
# 高速化のためにnumpy使う
h = np.array(h)

# dp[i] = 足場iに移動するのに必要な最小コスト
dp = [0 for _ in range(N)]
# 高速化のためにnumpy使う
dp = np.array(dp)

# DP配列更新
"""
TLEだったやつ
for i in range(1, N):
    # 最小コストで更新する
    max_k = min([i, K]) + 1
    dp[i] = min([dp[i - k] + abs(h[i] - h[i - k]) for k in range(1, max_k)])
"""
for i in range(1, N):
    # 最小コストで更新する
    # K個まとめて移動コストを計算することで高速化
    # ただしマイナスからスタートするような値はスキップする
    s = max(0, i - K)
    dp[i] = np.min(dp[s:i] + np.abs(h[s:i] - h[i]))

print(dp[-1])


Measured memory_bytes: 22820
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <cstdio>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
using namespace std;

#define db(x) cerr << #x << " = " << x << endl;

typedef long long   ll;
typedef long double ld;
typedef pair < int, int > pii;
typedef pair < ll,  ll  > pll;

const ll   MOD       = 1000000007;
const ll   INF       = 1000000007ll*1000000007ll;
const ll   N         = 1000002;
const ll   logN      = 20;
const ld   PI        = acos(-1);
const ll   HashPrime = 31;

inline void No() {
    cout << "NO\n";
}
inline void Yes() {
    cout << "YES\n";
}

#define fi first
#define se second

void solve() {
  int a, b, x;
  cin >> x >> a >> b;
  cout << (x-a)%b << endl;
}

int main() {
  ll t = 1;
//  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}


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

int main()
{
    long n, m;
    scanf("%ld %ld", &n, &m);
    char *a = (char *)malloc(sizeof(char) * (m + 1));
    char *b = (char *)malloc(sizeof(char) * (n + 1));
    for (int i = 0; i < m; i++)
    {
        a[i] = n + '0';
    }
    for (int i = 0; i < n; i++)
    {
        b[i] = m + '0';
    }
    if (strcmp(a, b) <= 0)
    {
        printf("%s", a);
    }
    else
    {
        printf("%s", b);
    }

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
const int N=1000005,mu=1000000007;
void reduce(int &x) { x+=x>>31&mu; }
int f[N],n,sum,ans; 
int main(){
	scanf("%d",&n);
	if (n==1){
		puts("1");
		return 0;
	}
	f[0]=1;
	int t=1ll*(n-1)*(n-1)%mu;
	ans=t+1;
	for (int i=1;i<=n;i++){
		reduce(f[i]+=f[i-1]-mu);
		if (i-3>=0) reduce(sum+=f[i-3]-mu);
		reduce(f[i]+=sum-mu);
		if (i<n-1) reduce(ans+=f[i]*1ll*t%mu-mu);
		else if (i==n-1) reduce(ans+=f[i]*1ll*(n-1)%mu-mu);
		else reduce(ans+=f[i]-mu);
		if (i<n-1) reduce(ans+=f[i]*1ll*(i+1)%mu-mu);
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	std::string s; cin >> s;
	
	const int n = (int)s.size();
	const int MOD = 1e9 + 7;
	auto dp = make_v<i64>(n + 1, 13); dp[0][0] = 1;
	for(int i = 0; i < n; i++) {
		if(s[i] == '?') {
			for(int D = 0; D < 10; D++) {
				for(int j = 0; j < 13; j++) (dp[i + 1][(j * 10 + D) % 13] += dp[i][j]) %= MOD;
			}
		} else {
			int D = s[i] - '0';
			for(int j = 0; j < 13; j++) (dp[i + 1][(j * 10 + D) % 13] += dp[i][j]) %= MOD;
		}
	}
	printf("%lld\n", (dp[n][5] + MOD) % MOD);
	return 0;
}


Measured memory_bytes: 13568
#include<iostream>
#include<string>
using namespace std;
int main(){
    long long N, A, B, C, D; cin >> N >> A >> B >> C >> D;
    string S;cin >> S;
    string ans = "Yes";

    if(C>D){
        for(long long i=B-2; i<D-1; i++){
            if(S[i]=='.'&&S[i+1]=='.'&&S[i+2]=='.'){
                ans="Yes";
                break;
            }else{
                ans="No";
            }
        }
        for(long long i=A; i<C-1; i++){
            if(S[i]=='#'&&S[i+1]=='#'){
                ans = "No";
                break;
            }
        }

    }else{
        for(long long i=A; i<D-1; i++){
            if(S[i]=='#'&&S[i+1]=='#'){
                ans = "No";
                break;
            }
        }
    }
    cout << ans << endl;
}

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

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<string> vst;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;


const ll mod=1e9+7;
const ll inf=1e16; 

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m;i>=n;i--)

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

 ll x;
  cin >> x;
 
  if(x==2) {
    cout << x << endl;
    return 0;
  }
  
   if(x%2==0) x++;
  
  while(true){
    bool flag=true;
  
  for(int i=3;i*i<=x;i+=2) {

    if(x%i==0) {
    flag=false;
    break;
  }
  }
    if(flag) {
      cout << x << endl;
      return 0;
    }
    else {
    x+=2;
    
    }
  }
  
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
#define int long long
const int inf = 999999999999999999;
typedef long long ll;
typedef long double ld;
struct A {
	int v, w;
};
A a[100];
int dp[10001];
signed main() {
	int n, w;
	cin >> n >> w;
	for (int i = 0; i < n; i++) 
		cin >> a[i].v >> a[i].w;
	fill(dp, dp + 10001, inf);
	dp[0] = 0;
	for (int i = 0; i < n; i++)
		for (int j = 10000; j >= 0; j--)
			if (dp[j] != inf)
				if (dp[j] + a[i].w <= w)
					dp[j + a[i].v] = min(dp[j + a[i].v], dp[j] + a[i].w);
	int ans = 0;
	for (int i = 0; i <= 10000; i++)
		if (dp[i] <= w)
			ans = i;
	cout << ans << endl;
	getchar(); getchar();
}

Measured memory_bytes: 3180
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner inputData = new Scanner( System.in);
//			各面(S1~S6)の値を取得する処理
		int[] dice_surface = new int[7];
		for( int count=1; count<=6; count++) {
			dice_surface[count] = inputData.nextInt();
		}
		Dice dice = new Dice(dice_surface);
//		質問の数 q を取得する
		int q = inputData.nextInt();
//		質問の数だけ処理を回す
		for( int count=1; count<=q; count++) {
//			質問の上面/前面を取得する
			int surface_top = inputData.nextInt();
			int surface_front = inputData.nextInt();
			while( true) {
				if( dice.getTop() == surface_top && 
						dice.getFront() == surface_front) {
					break;
				}
				dice.roll_random();
			}
			dice.outSurfaceRight();
		}
	}
}

//サイコロに関するクラス
class Dice {
//		配列のインデックスをサイコロの番号と合わせる為(roll時の値保管用の為)7つ用意
	public static int[] surface = new int[7];
	
	public Dice() {
		// TODO 自動生成されたコンストラクター・スタブ
	}
	public Dice(int[] surface_in) {
		// TODO 自動生成されたコンストラクター・スタブ
		surface = surface_in;
	} 
	public void outSurface() {
		System.out.println( surface[1]);
	}
//	ダイスの右側の面を出力する
	public void outSurfaceRight() {
		System.out.println( surface[3]);
	}
	
//	ダイスの上面を取得する
	public int getTop() {
		return surface[1];
	}
//	ダイスの前面を取得する
	public int getFront() {
		return surface[2];
	}
	
//	ダイスをランダムに回す
	public void roll_random() {
		int random = (int)( Math.random() * 4) + 1;
		switch( random) {
		case 1:
			roll_N();
			break;
		case 2:
			roll_S();
			break;
		case 3:
			roll_W();
			break;
		case 4:
			roll_E();
			break;
		default :
			break;
		}
	}
	
	public void roll_N() {
		surface[0] = surface[1];
		surface[1] = surface[2];
		surface[2] = surface[6];
		surface[6] = surface[5];
		surface[5] = surface[0];
	}
	public void roll_S() {
		surface[0] = surface[1];
		surface[1] = surface[5];
		surface[5] = surface[6];
		surface[6] = surface[2];
		surface[2] = surface[0];
	}
	public void roll_W() {
		surface[0] = surface[1];
		surface[1] = surface[3];
		surface[3] = surface[6];
		surface[6] = surface[4];
		surface[4] = surface[0];
	}
	public void roll_E() {
		surface[0] = surface[1];
		surface[1] = surface[4];
		surface[4] = surface[6];
		surface[6] = surface[3];
		surface[3] = surface[0];
	}
}


Measured memory_bytes: 26468
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    if(s[0]=='S')
        cout<<"Cloudy";
    else if(s[0]=='C')
        cout<<"Rainy";
    else if(s[0]=='R')
        cout<<"Sunny";
}


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

int main(){
    int N;
    int a[110]; //最大１００こだが余裕を持たせる
    cin >> N;
    for (int i = 0; i < N; ++i) cin >> a[i];

    sort(a, a + N, greater<int>());     //a[0:N]をソート
    int Alice = 0;
    int Bob = 0;
    for(int i = 0; i < N; ++i) {
        if(i % 2 == 0) {
            Alice += a[i];
        }
        else {
            Bob += a[i];
        }
    }
    cout << Alice - Bob << endl;
    }

Measured memory_bytes: 256