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

//ll mat[1000][1000];
ll x = 1e9 + 7;

bool isSafe(int i, int j, int m, int n){
    if( i < 0 or i >= m or j < 0 or j >= n) return false;
    return true;
}

ll paths(int m, int n, vector<vector<char>>& v){
    // Memoization - Top Down Approach
    // if(i < 1 || j < 1 || v[i-1][j-1] == '#' ) return 0;
    // if(i == 1 && j == 1) return 1;
    
    // 
    // if(mat[i-1][j-1] != 0) return (mat[i-1][j-1])%x;
    // else{
    //     mat[i-1][j-1] = (paths(i-1,j,v))%x+(paths(i,j-1,v))%x;
    // } 
    // return (mat[i-1][j-1])%x ;
    
    ll dp[m][n] = {};
    dp[0][0] = 1;
    for(int i = 0; i < m; i++){
        for(int j = 0; j < n; j++){
            if(isSafe(i,j-1,m,n) && v[i][j] != '#') dp[i][j] += dp[i][j-1];
            if(isSafe(i-1,j,m,n) && v[i][j] != '#') dp[i][j] += dp[i-1][j];
            dp[i][j] %= x;
        }
        
    }
    return dp[m-1][n-1] % x;
    
}

int main(){
    int m,n ; cin >> m >> n;
    vector<vector<char>> v(m, vector<char>(n));
    for(int i = 0; i < m; i++){
        for(int j = 0; j < n; j++){
            cin >> v[i][j];
        }
    }
    
    
    cout << paths(m,n,v)%x ;
    return 0;
}

Measured memory_bytes: 12428
#include<bits/stdc++.h>
using namespace std;
int main(){
  int q;
  cin>>q;
  while(q--){
    int m,n,t,c=0;
    cin>>m>>n;
    t=m*m+n*n;
    for(int i=0;i<2000;i++)
      for(int j=0;j<2000;j++)
        if(i*i+j*j<1)continue;
        else if((m*i+n*j)%(i*i+j*j)==0&&(m*j-n*i)%(i*i+j*j)==0)c++;
    if(c<=4)cout<<'P'<<endl;
  else cout<<'C'<<endl;
  }
}

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

int main() {

  int N;
  cin >> N;

  int count = 0;

  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    int count_ = 0;
    while (a % 2 == 0) {
      a /= 2;
      count_++;
    }
    count += count_;
  }

  cout << count << endl;

}

Measured memory_bytes: 256
#ifdef debug
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

#define vec vector
#define ALL(x) (x).begin(), (x).end()

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

const int inf = 1e9;
const ll inf64 = 1e18;

const int N = 105;

int n;
pii a[2 * N];
vec< int > g[N];
int p[N];
int used[N];

int dfs(int v) {
    if(used[v]) {
        return false;
    }
    used[v] = 1;
    for(int to : g[v]) {
        if(!p[to] || dfs(p[to])) {
            p[to] = v;
            return true;
        }
    }
    return false;
}

int main() {

#ifdef debug
    freopen("input.txt", "r", stdin);
#endif

    scanf("%d", &n);

    for(int i = 1;i <= n+n;i++) {
        scanf("%d %d", &a[i].first, &a[i].second);
    }

    for(int i = 1;i <= n;i++) {
        for(int j = n + 1;j <= n+n;j++) {
            if(a[i].first < a[j].first && a[i].second < a[j].second) {
                g[i].push_back(j - n);
            }
        }
    }

    for(int v = 1;v <= n;v++) {
        fill(used + 1, used + n + 1, 0);
        dfs(v);
    }

    int res = 0;

    for(int i = 1;i <= n;i++) {
        if(p[i]) {
            res++;
        }
    }

    printf("%d\n", res);

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll  long long int
const int  M = 1e9 + 7;
int n, k;

int dp[100002][2];

int f(int sum, int winner, vector<int> &v)
{
	//cout << sum <<  " " << winner << endl;
	if(sum < 0)         // means were on the last stone
	{
		return !(winner);
	}
	if(dp[sum][winner] != -1)
		return dp[sum][winner];
	int temp = winner;
	for(int i = 0; i < n; i++)
	{
		int ans = (sum - v[i] < 0 || dp[sum-v[i]][!winner] == -1) ? f(sum - v[i], !(winner), v) : dp[sum-v[i]][!winner];
		if(ans != temp)
		{
			temp = !(winner);
			break;
		}
	}
	return dp[sum][winner] = temp;
}

int main()
{

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int i, j, wt, m;
	
	cin >> n >> k;
	vector<int> v(n);
	for(i = 0; i < n; i++)
		cin >> v[i];

	memset(dp, -1, sizeof(dp));

	(f(k, 0, v) == 0) ? (cout <<"Second") : (cout << "First");
}


Measured memory_bytes: 12200
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int N;
    cin >> N;
    vector<int>A(N);
    for(int i = 0; i < N; i++) {
        cin >> A[i];
    }
    int ans = 0;
    for(int i = 0; i < N-1; i++) {
        if(A[i]%2 == 0) {
            ans+=A[i]/2;
        }
        else {
            ans+=A[i]/2;
            if(A[i+1]) {
                ans++;
                A[i+1]--;
            }
        }
    }
    ans+=A[N-1]/2;
    cout << ans << endl;
}


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


class Main {
	public static void main (String[] args) {
	    Scanner s=new Scanner(System.in);
	    char a=s.next().charAt(0);
	    if(Character.isUpperCase(a))
		System.out.println('A');
	    if(Character.isLowerCase(a))
		System.out.println('a');
	}
}


Measured memory_bytes: 35480
<?php
//error_reporting(0);
//$N = trim(fgets(STDIN));
list($N,$K) =  explode(" ",trim(fgets(STDIN)));
//$X = explode(" ",trim(fgets(STDIN)));

if (ceil($N/2) >= $K) {
  printf("YES\n");
}
else {
  printf("NO\n");
}


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

int main() {
    ll n, m, ans = 0;
    cin >> n >> m;
    if (n == 1 && m == 1) {
        ans = 1;
    } else if (n == 1) {
        ans = m - 2;
    } else if (m == 1) {
        ans = n - 2;
    } else {
        ans = (n - 2) * (m - 2);
    }
    
    cout << ans << endl;
    return 0;
}

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

int calc(int a[21]) {
  bool spare[10] = {false};
  bool strike[10] = {false};
  int s = 0, p = 0;
  for (int i=0; i<10; i++) {
    s += a[p];
    if (i>0 && (spare[i-1] || strike[i-1])) {
      s += a[p];
    }
    if (p>1 && i>1 && strike[i-1] && strike[i-2]) {
      s += a[p];
    }
    if (a[p] == 10) {
      strike[i] = true;
      p++;
      continue;
    }
    s += a[p+1];
    if (i>0 && strike[i-1]) {
      s += a[p+1];
    }
    if (a[p] + a[p+1] == 10) {
      spare[i] = true;
    }
    p += 2;
  }
  if (spare[9]) {
    s += a[p];
  } else if (strike[9]) {
    s += a[p] + a[p+1];
    if (strike[8]) {
      s += a[p];
    }
  }
  return s;
}

bool compare(const pair<int, int> &l, const pair<int, int> &r) {
  if (l.first < r.first) {
    return true;
  } else if (l.first > r.first) {
    return false;
  } else if (l.second > r.second) {
    return true;
  } else {
    return false;
  }
}

int main() {
  int a[21];
  pair<int,int> s[40];
  int n, m, p, c;
  char buf[100];
  while (1) {
    scanf("%d\n", &n);
    if (!n) break;
    for (int i=0; i<n; i++) {
      fgets(buf, sizeof(buf), stdin);
      p = 0;
      sscanf(buf, "%d%n", &s[i].second, &c);
      p += c;
      m = 0;
      while (1) {
        if (sscanf(buf+p, "%d%n", &a[m], &c) != 1) break;
        ++m;
        p += c;
      }
      s[i].first = calc(a);
    }
    sort(s, s+n, compare);
    for (int i=n-1; i>=0; i--) {
      printf("%d %d\n", s[i].second, s[i].first);
    }
  }
  return 0;
}

Measured memory_bytes: 1048
import java.util.*;
import java.io.*;
 
public class Main{
    static PrintWriter out = new PrintWriter(System.out);
 
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int R = Integer.parseInt(sc.next());
        if(N >= 10){
            System.out.println(R);
        }else{
            System.out.println((100*(10-N)+R));
        }
       
    }
} 

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define all(c) begin(c), end(c)
#define dump(x) cerr << __LINE__ << ":\t" #x " = " << x << endl

using ld = double;
using P = complex<ld>;
using G = vector<P>;
const ld pi = acos(-1);
const ld eps = 1e-10;
const ld inf = 1e12;

ld cross(const P& a, const P& b) { return a.real()*b.imag() - a.imag()*b.real(); }
ld dot(const P& a, const P& b) { return a.real()*b.real() + a.imag()*b.imag(); }

using C = pair<ld, P>;
#define rad first
#define pnt second

C smallest_enclosing_disc(vector<P> ps){
    auto c3 = [](const P &a, const P &b, const P &c){
        ld A = norm(b - c);
        ld B = norm(c - a);
        ld C = norm(a - b);
        ld S = abs(cross(b - a, c - a));
        P p = (A*(B+C-A)*a + B*(C+A-B)*b + C*(A+B-C)*c) / (4*S*S);
        ld r = abs(p - a);
        return make_pair(r, p);
    };

    auto c2 = [](const P &a, const P &b){
        P c = (a + b) / (ld)2;
        ld r = abs(a - c);
        return make_pair(r, c);
    };

    auto in_circle = [](const P &a, const C &c){
        return norm(a - c.pnt) <= c.rad*c.rad + eps;
    };

    int n = ps.size();
    random_shuffle(ps.begin(), ps.end());
    C c = c2(ps[0], ps[1]);
    for(int i = 2; i < n; ++i){
        if(!in_circle(ps[i], c)){
            c = c2(ps[0], ps[i]);
            for(int j = 1; j < i; ++j){
                if(!in_circle(ps[j], c)){
                    c = c2(ps[j], ps[i]);
                    for(int k = 0; k < j; ++k){
                        if(!in_circle(ps[k], c)){
                            c = c3(ps[i], ps[j], ps[k]);
                        }
                    }
                }
            }
        }
    }
    return c;
}




int n,m;
ld r[111], mb[111];
 
bool used[111];

bool chk(int s){
    vector<int> b;
    rep(i,n)if(!used[i]) b.emplace_back(r[i]);
    vector<ld> a;
    for(int i = s; i < m; ++i) a.emplace_back(mb[i]);
    sort(all(a));
    sort(all(b));
    int last = -1;
    rep(i,a.size()){
        bool found = false;
        for(int j = last+1; j < (int)b.size(); ++j){
            if(a[i] < b[j] + eps){
                found = true;
                last = j;
                break;
            }
        }
        if(!found)return false;
    }
    return true;
}

int main(){
    vector<int> ans;
    cin >> n;
    G g(n);
        rep(i,n){
            ld x,y;
            cin >> x >> y;
            g[i] = P(x,y);
        }
    ld res = smallest_enclosing_disc(g).rad;
  printf("%.16f", res);
 
}

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

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

#define rep(i, n) for (int i = 0; i < n; i++)
#define rep_op(i, a, n) for (int i = a; i < n; i++)
#define rep_d(j, n) for (int j = n; j >= 0; j--)
#define rep_d_op(j, n, a) for (int j = n; j >= a; j--)

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;
}

const int MOD = 1000000007;

const vector<int> dx = {1, 0};
const vector<int> dy = {0, 1};
const ll INF = 1LL << 60;

// int max = *std::max_element(vec.begin(), vec.end());
// int sum = accumulate(list, list + size, 0);

int GCD(int a, int b) { return b ? GCD(b, a % b) : a; }

int main()
{
    ll n;
    cin >> n;
    ll ans = 0;
    for (int i = 1; i <= n; i++)
    {
        if (i % 3 != 0 && i % 5 != 0)
        {
            ans += i;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int m = sc.nextInt();
		int x = sc.nextInt();
		int[] masu = new int[n];
		int to0 = 0, toN = 0;

		for (int i = 0; i < m; i++) {
			masu[sc.nextInt()] = -1;
		}

		for (int i = x; i < n; i++) {
			if (masu[i] == -1) {
				toN++;
			}
		}

		for (int i = x; i > 0; i--) {
			if (masu[i] == -1) {
				to0++;
			}
		}

		System.out.print(Math.min(toN, to0));
	}
}

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

int main() {
	
	int n,num = 0;
	char s[100000];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}

	for (int i = 0; i < n; i++) {
		if (i == 0) {
			num++;
			continue;
		}
		if (s[i - 1] == s[i]) {
			continue;
		}
		num++;
	}

	cout << num << endl;

	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric> 
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
ull gcd(ull a, ull b)
{
	return (a % b ? gcd(b, a % b) : b);
}
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	ull ans = 1, t;
	for(int i = 0; i < n; i++)
	{
		cin >> t;
		ans = t / gcd(t, ans) * ans;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main implements Runnable {

    private static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        new Thread(null, new Main(), "", 128 * 1024 * 1024).start();
    }

    public void run() {
        int h = sc.nextInt(), w = sc.nextInt();
        if (h == 1 && w == 1) {
            System.out.println("Yes");
            return;
        }
        boolean[][] s = new boolean[h][w];
        for (int i = 0; i < h; i++) {
            String str = sc.next();
            for (int j = 0; j < str.length(); j++) {
                s[i][j] = str.charAt(j) == '#';
            }
        }
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                if (!s[i][j]) {
                    continue;
                }
                boolean tmp = false;
                for (int k = -1; k <= 1; k++) {
                    for (int l = -1; l <= 1; l++) {
                        if (k == 0 && l == 0 || k != 0 && l != 0) {
                            continue;
                        }
                        if (i + k < 0 || i + k >= h || j + l < 0 || j + l >= w) {
                            continue;
                        }
                        if (s[i][j] == s[i + k][j + l]) {
                            tmp = true;
                            break;
                        }
                    }
                    if (tmp) {
                        break;
                    }
                }
                if (!tmp) {
                    System.out.println("No");
                    return;
                }
            }
        }
        System.out.println("Yes");
    }
}


Measured memory_bytes: 23892
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys# {{{
import os
import time
import re
from pydoc import help
import string
import math
import numpy as np
from operator import itemgetter
from collections import Counter
from collections import deque
from collections import defaultdict as dd
import fractions
from heapq import heappop, heappush, heapify
import array
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy as dcopy
import itertools# }}}

# pre-defined{{{
sys.setrecursionlimit(10**7)
INF = 10**20
GOSA = 1.0 / 10**10
MOD = 10**9+7
ALPHABETS = [chr(i) for i in range(ord('a'), ord('z')+1)]  # can also use string module
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def DP(N, M, first): return [[first] * M for n in range(N)]
def DP3(N, M, L, first): return [[[first] * L for n in range(M)] for _ in range(N)]# }}}

def local_input():
    from pcm.utils import set_stdin
    import sys
    if len(sys.argv) == 1:
        set_stdin(os.path.dirname(__file__) + '/test/' + 'sample-1.in')

def solve():
    N, L = map(int, input().split())
    S = []
    for n in range(N):
        S.append(input())
    S.sort()
    print(''.join(S))

if __name__ == "__main__":# {{{
    try:
        local_input()
    except:
        pass
    solve()
# vim: set foldmethod=marker:}}}


Measured memory_bytes: 14920
import java.io.*;

class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = br.readLine();
        int N = Integer.parseInt(str);
        long mod = 1_000_000_007;
        long[][][][] dp = new long[N+1][4][4][4];
        dp[0][3][3][3] = 1;
        for (int len=0;len<N;len++){
            for (int c1=0;c1<4;c1++){
                for (int c2=0;c2<4;c2++){
                    for (int c3=0;c3<4;c3++){
                        if (dp[len][c1][c2][c3]==0){
                            continue;
                        }
                        for (int a=0;a<4;a++){
                            if (a==2 && c1==1 && c2==0){
                                continue;
                            } else if (a==2 && c1==0 && c2==1){
                                continue;
                            } else if (a==1 && c1==2 && c2==0){
                                continue;
                            } else if (a==2 && c1==1 && c3==0){
                                continue;
                            } else if (a==2 && c2==1 && c3==0){
                                continue;
                            }
                            dp[len+1][a][c1][c2] += dp[len][c1][c2][c3];
                            dp[len+1][a][c1][c2] %= mod;
                        }
                    }
                }
            }
        }
        long ans = 0;
        for (int c1=0;c1<4;c1++){
            for (int c2=0;c2<4;c2++){
                for (int c3=0;c3<4;c3++){
                    ans += dp[N][c1][c2][c3];
                }
            }
        }
        System.out.println(ans%=mod);
    }
}

Measured memory_bytes: 21332
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

double dist(double x1, double y1, double x2, double y2){
    return sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2));
}

int main() {
    int n;
    cin >> n;
    double x[n], y[n];
    rep(i,n)cin >> x[i] >> y[i];

    double ans = 0;

    rep(i,n){
        rep(j,n){
            if(i == j)continue;
            ans += dist(x[i],y[i],x[j],y[j]);
        }
    }
    ans /= n;
    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}
 
 


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

using namespace std;

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

  int x = N%10;

  string ans;

  switch(x) {
    case 2:
    case 4:
    case 5:
    case 7:
    case 9: ans = "hon";
    break;

    case 0:
    case 1:
    case 6:
    case 8: ans = "pon";
    break;

    default: ans ="bon";
  }

  cout << ans << endl;

}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using ll = int_fast64_t;
#define REP(i,b,e) for(ll i=b; i<e; i++)
#define PRINT(vec) printf("[ ");for(auto &i:vec)printf("%ld ",i);puts("]");

int main(){
	ll n, x, m;
	scanf("%ld %ld %ld", &n, &x, &m);
	std::vector<ll> vec;
	vec.push_back(x);
	std::set<ll> st;
	st.insert(x);
	ll ans = x, pre = x, idx = 0;
	REP(I, 2, n+1){
		pre = pre * pre % m;
		if(st.count(pre)){
			idx = I-1;
			int pos;
			REP(i, 0, vec.size()) if(vec[i]==pre) pos = i;
			ll r = 0;
			REP(i, pos, vec.size()) r += vec[i];
			ans += (n-idx)/(vec.size()-pos) * r;
			REP(i, pos, pos+((n-idx)%(vec.size()-pos))) ans += vec[i];
			printf("%ld\n", ans);
			return 0;
		}
		ans += pre;
		vec.push_back(pre);
		st.insert(pre);
	}
	printf("%ld\n", ans);
	return 0;
}



Measured memory_bytes: 6064
var par = [];
function init(n) {
    for (var i = 0; i < n; i++) {
        par[i] = i;
    }
}
function find(x) {
    if (par[x] == x) return x;
    return par[x] = find(par[x]);
}
function isSame(x, y) {
    return find(x) == find(y);
}
function union(x, y) {
    x = find(x);
    y = find(y);
    if (x == y) return;
    par[x] = y;
}

var input = require('fs').readFileSync('/dev/stdin', 'utf8').trim();
var lines = input.split('\n');

var items = lines.shift().trim().split(' ');
var n = +items[0];
var q = +items[1];

init(n);

var line;
while (line = lines.shift()) {
    var com = line.trim().split(' ');
    if (com[0] == 0) {
        union(com[1], com[2]);
    } else {
        console.log(isSame(com[1], com[2]) ? 1 : 0);
    }
}

Measured memory_bytes: 23352
#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

constexpr ll INF = 1e16;
constexpr ll MOD = 1000000007;

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

template<class T> inline bool chmax(T& a, T b) { if(a < b) { a = b; return 1; } else { return 0; }}
template<class T> inline bool chmin(T& a, T b) { if(a > b) { a = b; return 1; } else { return 0; }}


ll max(ll a, ll b) {return a < b ? b : a; }
ll min(ll a, ll b) {return a > b ? b : a; }
double maxf(double a, double b) { return a < b ? b : a; }

template<typename T> inline string toString(const T &a) {
  ostringstream oss; oss << a; return oss.str();
}

ll gcd(ll x, ll y) { return x % y ? gcd(y, x % y) : y; }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

/*
* 積が負になる数: 負数 * 正数
* 積が正になる数: 正数 * 正数 or 負数 * 負数
* 答えが0になる数: 0 * 何でも
*/

int main() {
  int N, R;
  cin >> N >> R;
  cout << (N >= 10 ? R : (R + 100 * (10 - N))) << endl;
}
/*
int main() {
  int N;
  ll K;
  cin >> N >> K;
  vector<ll> A(N);
  rep(i, N) cin >> A[i];
  
  //まず，正，0，負になるペアの個数を数える
  int posct = 0;
  int zeroct = 0;
  int negct = 0;
  rep(i, N) {
    if(A[i] < 0)  ++negct;
    if(A[i] == 0) ++zeroct;
    if(A[i] > 0)  ++posct;
  }
  
  //各符号の組
  int pos_pairct = (posct * posct - posct) / 2 + (negct * negct - negct) / 2;
  int neg_pairct = negct * posct;
  int zero_pairct = (zeroct * zeroct - zeroct) / 2 + (posct * zeroct + negct * zeroct);
  
  sort(A.begin(), A.end());
  
  //順番を区別していったん数えることにする
  //同じインデックス同士は掛けないが，別のインデックスで同じ数なら掛ける
  if(K <= neg_pairct) {
    //負の領域
    //負 * 正 で二分探索
    //負を全部正にして，全部ソートすれば良いのか．筆はなくて生徒みなせばよい．順番が逆になるくらいか
    // int mid = neg_pairct / 2;
    // while(true) {
    //   if(A) 
    // }
  } else if(K <= neg_pairct + zero_pairct) {
    //ゼロの領域
    cout << 0 << endl;
    return 0;
  } else {
    //正の領域
    //昇順
    
    //二分探索で解いてみる    
    int beginIndex = -1;
    rep(i, N) {
      if(A[i] > 0) beginIndex = i;
    }
    int endIndex = N - 1;
    
    int mid = (endIndex - beginIndex) / 2 + beginIndex;
    while(true) {
       
    }
    
  }
}
*/

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

int main(){

int m, f, r;

for(;;){
cin >> m >> f >> r;

    if(m==-1 && f == -1 && r == -1){
        break;
    }

    if(m == -1 || f == -1){
    cout << 'F' << endl;
    }else if(m+f >= 80){
    cout << 'A' << endl;
    }else if (65 <= m+f && m+f <80){
    cout << 'B' << endl;
    }else if (50 <= m+f && m+f < 65){
    cout << 'C' << endl;
    }else if (30 <= m+f && m+f < 50 && 50 <= r){
    cout << 'C' << endl;
    }else if (30 <= m+f && m+f < 50 && r < 50){
    cout << 'D' << endl;
    }else if (m+f < 30){
    cout << 'F' << endl;
    }
    }
}



Measured memory_bytes: 3076
#include<stdio.h>
int main(void){
    int a,b,c,d,i;
    scanf("%d %d %d",&a,&b,&c);
    for (i = 0; i < 6; i++){
        if (b<a){
            d=a;
            a=b;
            b=d;
        }
        if (c<b){
            d=b;
            b=c;
            c=d;
        }
        if (c<a){
            d=a;
            a=c;
            c=d;
        }





    }



    printf("%d %d %d\n",a,b,c);







    return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
const int MAXN=3010;
double p,dp[MAXN][MAXN],ans;
int n;

int main(){
	cin>>n,dp[0][0]=1;
	for(int i=1;i<=n;++i){
		cin>>p;
		for(int j=0;j<=i;++j)
			dp[i][j]=dp[i-1][j]*(1-p)+dp[i-1][j-1]*p;
	}
	for(int i=(n+1)/2;i<=n;++i) ans+=dp[n][i];
	cout<<fixed<<setprecision(10)<<ans<<endl;
	return 0;
} 

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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
ll mod = 1000000007;

int main() {
source:
    ll n, m;
    cin >> n >> m;
    ll a[m];
    rep(i, m) { cin >> a[i]; }
    ll sum = 0;
    rep(i, m) { sum += a[i]; }
    ll remain = n - sum;
    if (remain < 0) {
        cout << -1 << endl;
    } else {
        cout << remain << endl;
    }
    return 0;
}



Measured memory_bytes: 3700
#include <string>
#include <algorithm>
#include <vector> 
#include <math.h>
#include <iostream>
using namespace std;

string twodig(long long n) {
	long long a = pow(2, 40);
	string ans = "";
	for (int i = 0; i < 41; i++) {
		if (n >= a) {
			ans = ans + "1";
			n = n - a;
		}
		else {
			ans = ans + "0";
		}
	a = a / 2;
	}
	return ans;
}

long long number(bool dam[41], int num[41],long long n) {
	long long a = pow(2, 40);
	long long ans = 0;
	for (int i = 0; i < 41; i++) {
		if (!dam[i]) {
			ans = ans + a * num[i];
		}
		else {
			ans = ans + a * (n - num[i]);
		}
		a = a / 2;
	}
	return ans;
}

/*long long dp(bool dam[41], int i, int num[41]) {
	
	if (i == 40) {
		long long a1, a2;
		dam[40] = true;
		a1 = number(dam, num);

		dam[40] = false;
		a2 = number(dam, num);

		return max(a1,a2);
	}
	else {
		long long a1, a2;
		dam[i] = true;
		a1 = dp(dam, i + 1, num);
		dam[i] = false;
		a2 = dp(dam, i + 1, num);
		return max(a1, a2);

	}

}
*/

int main()
{
	long long n, k;
	cin >> n >> k;
	vector<string> a;

	bool ideal[41];
	int num[41];
	for (int i = 0; i < 41; i++) {
		num[i] = 0;
	}

	for (int i = 0; i < n; i++) {
		long long input;
		cin >> input;
		a.push_back(twodig(input));
		for (int j = 0; j < 41; j++) {
			if (a[i][j] == '1') {
				num[j] = num[j] + 1;
			}
		}
	}
	
	for (int i = 0; i < 41; i++) {
		if (num[i] > n - num[i]) {
			ideal[i] = false;
		}
		else {
			ideal[i] = true;
		}
	}
	string ks = twodig(k);
	bool kbool[41];
	for (int i = 0; i < 41; i++) {
		if (ks[i] == '1') {
			kbool[i] = true;
		}
		else {
			kbool[i] = false;
		}
	}

	long long ans = 0;
	long long ma = 0;

	for (int i = 0; i < 41; i++) {
		if (kbool[40 - i] == false) continue;
		bool dam[41];
		for (int j = 0; j < 41 - i; j++) {
			dam[j] = kbool [j];
		}
		for (int j = 41 - i; j < 41; j++) {
			dam[j] = ideal[j];
		}

		dam[40 - i] = false;
		ans = max(number(dam, num,n), number(kbool,num,n));

		ma = max(ma, ans);
	}
	ma = max(ma, number(kbool, num, n));
	cout << ma << endl;
	return 0;

}


Measured memory_bytes: 13556
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);
    
    int N = sc.nextInt();
    int T = sc.nextInt();

    int[] c = new int[N];
    int[] t = new int[N];

    for (int i = 0; i < N; i++) {
      c[i] = sc.nextInt();
      t[i] = sc.nextInt();
    }

    sc.close();

    int min = 1001;

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

      if (t[i] <= T) {
        min = Math.min(min, c[i]);
      }

    }

    if (min == 1001) {
      System.out.println("TLE");
    } else {
      System.out.println(min);
    }

  }

}

Measured memory_bytes: 21332
//g++ t.cpp -o t && t < p.txt
//d>p.txt&&t<p.txt&&t2<p.txt

#include <iostream> // プログラムの耳と口
#include <vector> // 超有能配列秘書
#include <algorithm> // みんな大好きソートと二分探索
#include <queue> // きゅーちゃん、だいすき
#include <string> // to_string
#include <functional> // 関数を変数に入れる子
#include <set> // 値の取得・挿入・削除を高速に
#include <map> // setの妹 これまた優秀
#include <random> // 乱択さん
#include <cassert>

#define DB cerr<<"D"<<endl
using namespace std; using ll=long long; using ld=long double; const int INF=1e9; const ll LINF=1e18; const double dINF = 1e18; const ld ldINF = 1e18; const double EPS = 1e-6;
template<typename T, typename U, typename O> void caut(T a, U b, O c){cout<<"("<<a<<","<<b<<","<<c<<") ";} template<typename T, typename U> void caut(T a, U b){cout<<"("<<a<<","<<b<<") ";} template<typename T> void caut(T a){cout<<"("<<a<<") ";};
using P=pair<ll,ll>;
const ll M = 1e9+7;
ll mod_pow(ll x, ll a) { ll an = 1; while(a > 0) { if (a&1) an = an * x % M; x = x * x % M; a >>= 1;} return an;}
void add(ll& x, ll y) {x+=y; x%=M;}; void mul(ll& x, ll y) {x*=y; x%=M;}; template<typename T, typename U> void chmax(T& x, U y) {if (x<y) x=y;}; template<typename T, typename U> void chmin(T& x, U y) {if (x>y) x=y;}
bool vaild(int x, int y, int hh, int ww){return 0<=x&&x<hh&&0<=y&&y<ww;}
int keta(ll a) {int res=0; while(a>0) res+=(a%10/5)+(a%5), a/=10; return res;}

int main() {
  int n,W; cin>>n>>W;
  ll dp[W+1]={};
  for(int i=0;i<n;i++) {
    ll w,v; cin>>w>>v;
    for(int j=W-w;j>=0;j--) {
      chmax(dp[j+w],dp[j]+v);
    }
  }
  cout<<dp[W]<<endl;
}
// ・配列の大きさok？　・priority_queueはgreater？　・debug消した？
// ・落ち着いて。提出まで4分待ってね……WJ……1/10……2/10……

// Thank you for making problems and running the contest

Measured memory_bytes: 4344
#include<iostream>
#include <string>
#include<algorithm>
#include <set>
#include <cmath>
using namespace std;
typedef long long lint;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rep0(i,n) rep(i,0,n)

int main(void) {
	ios::sync_with_stdio(false);
	int i, j, k, N, result, a, b, c, X;
	cin >> X;
	a = X % 100;
	b = X / 100;
	if (a == 0) cout << '1';
	else {
		for (i = 5; i > 0; i--) {
			b = b - a / i;
			a = a % i;
		}
		if (b >= 0) cout << '1';
		else cout << '0';
	}
	return 0;
}
//
////sort Ｎ個の配列a
//sort(a, a + N); //昇順
//sort(a, a + N, greater<int>()); //降順
//
////最大公約数（ユークリッドの互除法利用）
//int gcd(int a, int b) {
//	if (a == 0) return b;
//	if (b == 0) return a;
//	int m = max(a, b);
//	int n = min(a, b);
//	if (m%n == 0) return n;
//	else return gcd(n, m%n);
//
//}
//
////最小公倍数
//int lca(int a, int b) {
//	if (a == 0) return 0;
//	if (b == 0) return 0;
//	return a * b / gcm(a, b);
//}
//
////n^k(整数)
//int pow_int(int n, int k) {
//	int re = 1;
//	for (int i = 0; i < k; i++) re *= n;
//	return re;
//}



Measured memory_bytes: 256
a, b, k = map(int, input().split())
for i in range(k):
    if i % 2 == 0:
        if a % 2 == 1:
            a -= 1
        a, b = a//2, a//2+b
    else:
        if b % 2 == 1:
            b -= 1
        a, b = a+b//2, b//2
print(a, b)

Measured memory_bytes: 3060
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
#define vvec vector<vector<ll>>
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 1000000007;
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll ac(ll n, ll k) { ll a = 1; rep(i, 1, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }
int D;
vector<int> c(26);
vector<int> last(26, 0);
vector<vector<int>> s(365, vector<int>(26));
void input();
ll score;
int next_num;
void dfs(int nest, int d) {
	ll M = 0, temp = score;
	int prev, n;
	rep(j, 0, 26) {
		score = temp;
		score += s[d - 1][j];
		prev = last[j];
		last[j] = d;
		rep(k, 0, 26)score -= c[k] * (d - last[k]);
		if (nest && d < D)dfs(nest - 1, d + 1);
		if (M < score)M = score, n = j;
		last[j] = prev;
		//printf("%lld %d\n", *score, *next);
	}
	score = M;
	next_num = n;
}
int main()
{
	input();
	rep(i, 1, D + 1) {
		//score = 0;
		dfs(2, i);
		printf("%d\n", next_num + 1);
		//printf("%d\n", score);
	}
	return 0;
}
void input() {
	cin >> D;
	rep(i, 0, 26)cin >> c[i];
	rep(i, 0, D) {
		rep(i2, 0, 26)cin >> s[i][i2];
	}
}

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

main()
{
  //  ios::sync_with_stdio(0);
 //   cout.tie(0);
 //   cin.tie(0);
    long long i,j,k,l,m,n,o,p;

    string s;

   while(cin>>n>>s){
    l=s.size();
    k=90-n;
    for(i=0;i<l;i++){
        if(s[i]>k){
            j=n-(90-s[i]);
            printf("%c",64+j);
        }
        else printf("%c",s[i]+n);
    }
    cout<<endl;
   }

    return 0;

}


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

#define INF 1000000

int func(int N) {
  int sum = 0;
  while(N>0) {
    sum += N%10;
    N /= 10;
  }

  return sum;
}

int main() {
  int N, A, B, min = INF;
  cin >> N;

  for(int i=1; i<=N/2; ++i) {
    A = func(i); B = func(N-i);
    if(min > A+B) min = A+B;
  }

  cout << min << endl;

  return 0;
}


Measured memory_bytes: 256
import sys
input=sys.stdin.readline
def N(): return int(input())
def NM():return map(int,input().split())
def L():return list(NM())
def LN(n):return [N() for i in range(n)]
def LL(n):return [L() for i in range(n)]
n,k=NM()
l=L()
ans=0
for a in range(n+1):
    for b in range(n-a+1):
        for c in range(a+1):
            for d in range(b+1):
                if a+b+c+d>k:
                    continue
                x=l[:a]
                y=l[-1:-b-1:-1]
                x.sort()
                y.sort()
                ans=max(ans,sum(x[c:])+sum(y[d:]))
print(ans)

Measured memory_bytes: 46040
#include <iostream>
#include <cmath>
typedef long long ll;
using namespace std;
long long mod = pow(10,9)+7;
int main()
{
  int n;
  cin>>n;
  
  ll arr[n];
  ll sum=0;
  for(int i=0;i<n;i++)
  {
    cin>>arr[i];
    sum+=arr[i];
  }
  
  ll ans=0;
  for(int i=0;i<n;i++)
  {
    sum-=arr[i];
    ans+=((sum%mod)*(arr[i]%mod))%mod;
  }
  ans%=mod;
  cout<<ans;
}
  

Measured memory_bytes: 5124
# coding: utf-8
# Your code here!
import sys
sys.setrecursionlimit(10**9)

def dfs(num,cost):
    visited[num]=cost
    for item in way[num]:
        if visited[item[0]]==-1:
            dfs(item[0],cost+item[1])
    return
    
N=int(input())

way=[[] for i in range(N)]
visited=[-1]*N
for _ in range(N-1):
    a,b,c=map(int,input().split())
    way[a-1].append([b-1,c])
    way[b-1].append([a-1,c])


Q,K=map(int,input().split())
dfs(K-1,0)
for _ in range(Q):
    x,y=map(int,input().split())
    print(visited[x-1]+visited[y-1])


Measured memory_bytes: 137932
/*
Author : N_o_o_B
Created : April 22 2020 15:30:32 
*/
#include <bits/stdc++.h>
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
*/
#define TRACE
#ifdef TRACE
#define trace(...) { cerr<<"[ "; __trace__(#__VA_ARGS__, __VA_ARGS__);}
#undef endl
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const pair<Arg1,Arg2> &x) {
    return out<<"("<<x.first<<","<<x.second<<")";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const vector<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const set<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
void __trace__(const string name, Arg1&& arg1){
    cerr << name << " : " << arg1 << " ] " << endl;
}
 
template <typename Arg1, typename... Args>
void __trace__(const string names, Arg1&& arg1, Args&&... args){
    const string name = names.substr(0,names.find(','));
    cerr<<name<<" : "<<arg1<<" | ";
    __trace__(names.substr(1+(int)name.size()), args...);
}
#else
    #define trace(args...)
#endif
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vll;
typedef vector<vl> vvl;
//typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
#define fori(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define ford(i,n)  for(int i=n-1;i>=0;i--)
#define trav(x,a) for(auto& x:a)
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define sz(a) (int)a.size()
#define fi first
#define se second
clock_t time_p=clock();
void time_taken()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
//const ll mod=998244353;
const ll mod=1e9+7;
const ll INF=1e18;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cout.precision(12);cout << fixed;

    int n,a,b;
    string s;
    cin >> n >> a >> b >> s;
    int tot=0,over=0;
    fori(i,n){
        if(tot < a+b){
            if(s[i]=='a'){
                tot++;
                cout << "Yes" << endl;
            }
            else if(s[i]=='b'){
                if(over < b){
                    over++;
                    tot++;
                    cout << "Yes" << endl;
                }
                else cout << "No" << endl;
            }
            else {
                cout << "No" << endl;
            }
        }
        else{
            cout << "No" << endl;
        }
    }

    time_taken();
    return 0;
}

Measured memory_bytes: 848
#include <bits/stdc++.h> 
#include <time.h>
#define F(i,a,b) for(long long i=a;i<=(b);++i)
#define dF(i,a,b) for(long long i=a;i>=(b);--i) 
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define pb push_back
#define maxnkp make_pair
#define fi first
#define se second
#define eps 1e-10
#define PI acos(-1.0)
using namespace std;
typedef long long ll;
const int mods = 1e9+7;
const int maxn = 1e3+10; 
const int N = 1e5+10;
const int E = 1e6+10;  
ll n,k,p;
map<string,int> m;

int main(){
	int T;cin>>T;
	while(T--){
		string s;
		cin>>s;
		m[s]++;
	}
	cout<<"AC x "<<m["AC"]<<endl;
	cout<<"WA x "<<m["WA"]<<endl;
	cout<<"TLE x "<<m["TLE"]<<endl;
	cout<<"RE x "<<m["RE"]<<endl;
}


Measured memory_bytes: 3632
def resolve():
    n, m, k = map(int, input().split())
    OK = False
    for i in range(n+1):
        for j in range(m+1):
            if i*m+(n-2*i)*j == k:
                OK = True
    if OK:
        print("Yes")
    else:
        print("No")
resolve()

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

MOD = 2  # type: int


def solve(N: int, a: "List[int]"):
    answer = [0]*(N+1)
    for i in range(N,0,-1):
        for j in range(2*i,N+1,i):
            answer[i] += answer[j]
        if a[i-1]==1:
            answer[i]= 1 if answer[i]%2==0 else 0
        else:
            answer[i]= 0 if answer[i]%2==0 else 1
    print(sum(answer))

    answer2 = []
    for index,ans in enumerate(answer):
        if ans == 1:
            answer2.append(index)

    print(*answer2)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, a)

if __name__ == '__main__':
    main()


Measured memory_bytes: 15868
A, B, C = 1, 2, 3
while True:
    try: n = input().split(',')
    except:
        if A == 1:
            print('A')
        elif B == 1:
            print('B')
        else:
            print('C')
        break
    if 'A' in n and 'B' in n:
        A, B = B, A
    elif 'A' in n and 'C' in n:
        A, C = C, A
    elif 'B' in n and 'C' in n:
        B, C = C, B


Measured memory_bytes: 5564
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;

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;}

const ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

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


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;
const int inf = 1000000000; //10^9
const ll MOD = 1e9 + 7;
//加算代入演算子は+=！！！！！
//int 2^31 10^9まで
int main()
{
    string s;
    cin >> s;
    vector<int> vec(4);
    rep(i, 4)
    {
        vec[i] = s[i] - '0';
    }

    for (int bit = 0; bit < (1 << 3); bit++) //2^n繰り返す
    {
        int tmp = vec[0];
        for (int k = 0; k < 3; k++)
        {
            if (bit & (1 << k)) //1が立っていればホニャララ
                tmp += vec[k + 1];
            else
                tmp -= vec[k + 1];
        }
        if (tmp == 7)
        {
            cout << vec[0];
            for (int k = 0; k < 3; k++)
            {
                if (bit & (1 << k))
                    cout << '+';
                else
                    cout << '-';
                cout << vec[k + 1];
            }
            cout << "=7" << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if (a == b && a != c)
    {
        cout << "Yes" << "\n";
    }
    else if (a == c && a != b)
    {
        cout << "Yes" << "\n";
    }
    else if (b == c && b != a)
    {
        cout << "Yes" << "\n";
    }
    else
    {
        cout << "No" << "\n";
    }
    return 0;
}


Measured memory_bytes: 256
import sys
input=sys.stdin.readline

S = input().strip()
n = S.count("N")
w = S.count("W")
e = S.count("E")
s = S.count("S")

if (n == 0 and s == 0) or (n > 0 and s > 0):
    if (w == 0 and e == 0) or (w > 0 and e > 0):
        print("Yes")
        exit()
print("No")


Measured memory_bytes: 3060
N = int(input().strip())
D = list(map(int, input().strip().split(" ")))
d = list(set(D))

if D[0] != 0:
    print(0)
    exit()
if min(d) > 0 or max(d) >= len(d):
    print(0)
    exit()

c = 1
x = [0] * len(d)
for i in D:
    x[i] += 1
if x[0] != 1:
    print(0)
    exit()
for i in range(1,len(d)):
    c *= x[i-1]**x[i]

print(c % 998244353)


Measured memory_bytes: 59884
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.Calendar;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.Map.Entry;

final class Main {

    private Main() {
    }

    public static void main(final String[] argv) throws IOException {
        final BufferedReader inputReader =
                new BufferedReader(new InputStreamReader(System.in));
        String[] inputs = inputReader.readLine().split(" ");
        HashMap<String, Integer> map = new HashMap<String, Integer>();
        int maxCount = 0;
        int maxLength = 0;
        String maxLengthString = "";
        for (String token : inputs) {
            if (!map.containsKey(token)) {
                map.put(token, 1);
            } else {
                map.put(token, map.get(token) + 1);
            }
            if (maxCount < map.get(token)) {
                maxCount = map.get(token);
            }
            if (maxLength < token.length()) {
                maxLength = token.length();
                maxLengthString = token;
            }
        }
        for (Entry<String, Integer> e : map.entrySet()) {
            if (e.getValue() == maxCount) {
                System.out.print(e.getKey());
                break;
            }
        }
        System.out.println(" " + maxLengthString);
    }
}

Measured memory_bytes: 9352
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <utility>
#include <memory>
#include <functional>
#include <deque>
#include <cctype>
#include <ctime>
#include <numeric>
#include <list>
#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


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

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

void mainmain(){
	int n;
	cin>>n;
	int K;
	cin>>K;
	vll v(n);
	rep(i,n) cin>>v[i];
	vll a(n);
	vll b(n);
	rep(i,n){
		if(i){
			a[i]+=a[i-1];
			b[n-1-i]+=b[n-i];
		}
		a[i]+=max(v[i],0LL);
		b[n-1-i]+=max(v[n-1-i],0LL);
	}
	// rep(i,n) cout<<a[i]<<" ";
	// cout<<endl; 
	// rep(i,n) cout<<b[i]<<" ";
	// cout<<endl; 
	ll sum = 0;
	ll ans = 0;
	// cout<<n<<endl;
	rep(i,n){
		sum += v[i];
		// cout<<"sum "<<sum<<endl;
		// cout<<v[i]<<" "<<ans<<endl;
		if(i+1>=K){
			maxs(ans, sum+(i+1<n?b[i+1]:0LL)+(i-K>=0?a[i-K]:0LL));
			maxs(ans, (i+1<n?b[i+1]:0LL)+(i-K>=0?a[i-K]:0LL));
			sum -= v[i-(K-1)];
		}
	}
	cout<<ans<<endl;
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}

Measured memory_bytes: 2688
import math
import copy
import sys
import fractions
import numpy as np
from functools import reduce

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum

def getInputListInt():
    outputoData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData

def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList

def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList

# ===CODE===

n, = map(int, input().split())
data = getInputListInt()

ans = 0
tmpans = 0
for i in range(n-1):
    if data[i] >= data[i+1]:
        tmpans += 1
    else:
        ans = max(ans, tmpans)
        tmpans = 0

ans = max(ans, tmpans)
print(ans)

Measured memory_bytes: 24444