akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double lld;
ll MOD = (1e9)+7;
const int dr[] = {+1, -1, +0, +0, +1, -1, +1, -1};
const int dc[] = {+0, +0, +1, -1, +1, -1, -1, +1};
const int kx[] = {+1, +2, -1, -2, +1, +2, -1, -2};
const int ky[] = {+2, +1, +2, +1, -2, -1, -2, -1};
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
inline void fastIO(){
  ios_base::sync_with_stdio(0);cin.tie(0);
}
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void debug_out() { cerr << endl; }
template<typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << ' ' << H; debug_out(T...); }

#ifdef LOCAL
#define debug(...) cerr << "(" << #__VA_ARGS__ << "):", debug_out(__VA_ARGS__)
#else
#define debug(...) 47
#endif

int main(){
  fastIO();
  int h,w,m;
  int maxX=0,maxY=0;
  int posX=0,posY;
  cin>>h>>w>>m;
  map<int,int>cols;
  map<int,int>rows;
  map<pair<int,int>,int>coord;
  for(int i=0;i<m;i++){
    int x,y;
    cin>>x>>y;
    cols[x]++,rows[y]++;
    if(cols[x]>maxX)posX=x;
    if(rows[y]>maxY)posY=y;
    maxX=max(maxX,cols[x]);
    maxY=max(maxY,rows[y]);
    coord[make_pair(y,x)]++;
  }
  /*
  cout<<"--------"<<endl;
  cout<<maxX<<" "<<maxY<<endl;
  cout<<posX<<" "<<posY<<endl;
  */
  int tempMaxX=0;
  for(int i=0;i<=303030;i++){
    int num=cols[i]-coord[make_pair(posY,i)];
    tempMaxX=max(tempMaxX,num);
  }
  int tempMaxY=0;
  for(int i=0;i<=303030;i++){
    int num=rows[i]-coord[make_pair(i,posX)];
    tempMaxY=max(tempMaxY,num);
  }
  cout<<max(tempMaxY+maxX,tempMaxX+maxY)<<endl;
  return 0;
}


Measured memory_bytes: 88668
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
const int MOD = 1e9 + 7 ;
int mpow(int a,int b,int p=MOD){a=a%p;int res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}
const int N=1e5+3;
int dp[N][13];
int32_t main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      string s;
      cin>>s;
      s='0'+s;
      int n=s.length();
      dp[0][0]=1;
      for(int i=1;i<n;i++)
      {
            if(s[i]=='?'){
                  for(int j=0;j<=9;j++)
                  {
                        for(int k=0;k<13;k++)
                        {
                              dp[i][(k*10+j)%13]+=dp[i-1][k];
                              dp[i][(k*10+j)%13]%=MOD;
                        }
                  }
            }
            else{
                  for(int k=0;k<13;k++)
                  {
                        dp[i][(k*10+s[i]-'0')%13]+=dp[i-1][k];
                        dp[i][(k*10+s[i]-'0')%13]%=MOD;
                  }
            }
      }
      cout<<dp[n-1][5];
}
// I never lose. I either win or I learn

Measured memory_bytes: 10604
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

const (
	initialBufSize = 1e4
	maxBufSize     = 1e6 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

func main() {
	N, A, B := nextInt(), nextInt(), nextInt()
	if A > B || (N == 1 && B-A > 1) {
		fmt.Println(0)
	} else if A == B {
		fmt.Println(1)
	} else {
		N -= 2
		var ans int
		ans = (B-A)*N + 1
		fmt.Println(ans)
	}
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func abs(a int) int {
	if a > 0 {
		return a
	} else {
		return -a
	}
}

func pow(p, q int) int {
	res := p
	if q == 0 {
		return 1
	}
	for i := 0; i < q-1; i++ {
		res *= p
	}
	return res
}

func MinOf(vars ...int) int {
	min := vars[0]
	for _, i := range vars {
		if min > i {
			min = i
		}
	}
	return min
}

func MaxOf(vars ...int) int {
	max := vars[0]
	for _, i := range vars {
		if max < i {
			max = i
		}
	}
	return max
}

func gcdof2numbers(a int, b int) int {
	if b == 0 {
		return a
	}
	return gcdof2numbers(b, a%b)
}

func lcmof2numbers(a int, b int) int {
	return a / gcdof2numbers(a, b) * b
}

// マイナスの場合は考慮していない
func fuctorial(a int) int {
	if a == 1 || a == 0 {
		return 1
	} else {
		return fuctorial(a-1) * a
	}
}

func NextPermutation(x sort.Interface) bool {
	n := x.Len() - 1
	if n < 1 {
		return false
	}
	j := n - 1
	for ; !x.Less(j, j+1); j-- {
		if j == 0 {
			return false
		}
	}
	l := n
	for !x.Less(j, l) {
		l--
	}
	x.Swap(j, l)
	for k, l := j+1, n; k < l; {
		x.Swap(k, l)
		k++
		l--
	}
	return true
}

// 素因数分解したmapを返す
func primeFuctorize(n int) map[int]int {
	pf := map[int]int{}
	for i := 2; i*i <= n; i++ {
		for n%i == 0 {
			pf[i]++
			n /= i
		}
	}
	if n != 1 {
		pf[n]++
	}
	return pf
}


Measured memory_bytes: 640
#include <stdio.h>
 
int main(void){
  int A, B, C;
  scanf("%d %d %d", &A, &B, &C);
  
  A = A - B;
  C = C - A;
  
  if(C < 0) C = 0;
  printf("%d\n", C);
  
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
#define MAX 100005
#define NIL -1

struct Node
{
    int p, l, r;
};

Node T[MAX];
int n, D[MAX];

void print(int u) {
    int i, c;
    cout << "node " << u << ": ";
    cout << "parent = " << T[u].p << ", ";
    cout << "depth = " << D[u] << ", ";

    if (T[u].p == NIL) cout << "root, ";
    else if (T[u].l == NIL) cout << "leaf, ";
    else cout << "internal node, ";

    cout << "[";

    for (i=0, c=T[u].l; c!=NIL; i++, c=T[c].r) {
        if (i) cout << ", ";
        cout << c;
    }
    cout << "]" << endl;
}

// 再帰的に深さを求める
int rec(int u, int p) {
    D[u] = p;
    if (T[u].r != NIL) rec(T[u].r, p);  // 右の兄弟に深さを設定
    if (T[u].l != NIL) rec(T[u].l, p+1);  // 最も左の子に自分の深さ+1を設定
}

int main() {
    int i, j, d, v, c, l, r;
    cin >> n;
    for (i=0; i<n; i++) T[i].p = T[i].l = T[i].r = NIL;

    for (i=0; i<n; i++) {
        cin >> v >> d;
        for (j=0; j<d; j++) {
            cin >> c;
            if (j==0) T[v].l = c;
            else T[l].r = c;
            l = c;
            T[c].p = v;
        }
    }
    for (i=0; i<n; i++) {
        if (T[i].p == NIL) r=i;
    }

    rec(r, 0);
    for (i=0; i<n; i++) print(i);
    return 0;
}


Measured memory_bytes: 7776
/**
 *		author:  zvm
 *		created: 27.09.2020 18:42:56
**/

#include <bits/stdc++.h>

using namespace std ;

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

	int n ;
	cin >> n ;

	map<int,int> freq ;
	for( int i = 0, val ; i < n ; ++i ) {
		cin >> val ;
		freq[val]++ ;
	}

	int ans = 0 ;
	for( auto& p : freq ) {
		int val = p.first ;
		int count = p.second ;
		ans += ( count < val ? count : count-val );
	}

	cout << ans << endl ;
}


Measured memory_bytes: 8132
import java.util.*;
class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int A = sc.nextInt();
int B = sc.nextInt();
if(B<0){
if(A-B>A*B){
System.out.println(A-B);
}else{
System.out.println(A*B);
}
}else{
if(A+B>A*B){
System.out.println(A+B);
}else{
System.out.println(A*B);
}
}
}}

Measured memory_bytes: 22100
import java.util.*;

public class Main {

    static long mod = 1_000_000_007;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] s = sc.next().toCharArray();
        int n = s.length;
        long[][] dp = new long[n+1][13];
        dp[0][0] = 1;
        int r = 1;
        for (int i = 1; i <= n; i++) {
            int idx = n - i;
            for (int j = 0; j < 10; j++) {
                if(s[idx] == '?' || Character.getNumericValue(s[idx]) == j){
                    int tr = (r * j) % 13;
                    for (int k = 0; k < 13; k++) {
                        dp[i][(k+tr)%13] = (dp[i][(k+tr)%13] + dp[i-1][k]) %mod;
                    }
                }
            }
            r = r*10%13;
        }
        System.out.println(dp[n][5]);
        sc.close();

    }

}


Measured memory_bytes: 38808
#include <iostream>
#include <string.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <functional>
#include <cassert>
#include <utility>
#include <stack>
#include <queue>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef pair<int,int> Pi;
typedef long long int ll;
const int INF=(ll)(1<<30)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

ll n;
ll t[110];

int main(){
	cin>>n;
	REP(i,n)
		cin>>t[i];
		
	ll ans=t[0];
	for(int i=1;i<n;i++)
		ans=lcm(ans,t[i]);
	
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <map>
#include <set>
#include <queue>
using _loop_int = int;
#define REP(i,n) for(_loop_int i=0; i<(_loop_int)(n); i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a); i<(_loop_int)(b); i++)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1; i>=(_loop_int)(a); i--)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int main(){
    int N, K, h;
    cin >> N >> K;
    int ans=N;
    REP(i, N){
        cin >> h;
        if (K > h)
        {
            ans -=1;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
// #define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    string s;
    cin>>s;
    int l=s.length()-2;
    while(true){
        bool f=true;
        rep(i,l/2){
            if(s[i]!=s[i+l/2])f=false;
        }
        if(f){
            cout<<l<<endl;
            return;
        }
        l-=2;
    }
}

Measured memory_bytes: 256
// #include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <limits.h>
#include <string>
#include <stack>
#include <deque>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <time.h>
#include <cassert>
#include <fstream>
#include <stdio.h>
#include<unordered_map>

typedef long long ll;
typedef std::pair<int, int> Pii;
typedef std::pair<long long, long long> Pll;
typedef std::pair<double, double> Pdd;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define mapa make_pair
#define all(a) a.begin(), a.end()
#define MM << " " <<

template<typename T>
using MaxHeap = std::priority_queue<T>;
template<typename T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<typename T>
inline bool chmax(T &a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
template<typename T>
inline bool chmin(T &a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

template<typename T>
std::vector<T> vec(int len, T elem) { return std::vector<T>(len, elem); }
template<typename T>
void vdeb(std::vector<T> &da) {
	for (int i = 0;i < da.size();i++) {
		if (i == da.size() - 1) std::cout << da[i];
		else std::cout << da[i] << ' ';
	}
	std::cout << std::endl;
}
template<typename T>
void vdeb(std::vector<std::vector<T>> &da) {
	for (int i = 0;i < da.size();i++) vdeb(da[i]);
	std::cout << std::endl;
}

using namespace std;

bool solve(){
	int n; cin >> n;
	vector<int> da(n);
	rip(i,n,0) cin >> da[i];
	map<int, int> mp;
	rip(i,n,0){
		if(mp.count(da[i])) ++mp[da[i]];
		else mp[da[i]] = 1;
	}
	if(mp.size() > 2) return false;
	if(mp.size() == 1 && (*mp.cbegin()).first == n-1) return  true;
	Pii a = *mp.cbegin(), b = *(--mp.cend());
	if(mp.size() == 1) --a.first, a.second = 0;
	if(b.first - a.first != 1 || b.first <= a.second) return false;
	// cout << a.first MM a.second MM b.first MM b.second << endl;
	return n - a.second >= (b.first-a.second)*2 && b.first <= n;
}

int main(){
	printf((solve())?"Yes\n":"No\n");
}

Measured memory_bytes: 5376
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;

using namespace std;

int main(void){
    ll N, M;
    vector< pair<ll, ll> > vec;
    cin >>N >>M;
    ll A;
    rep(i, N){
        cin >> A;
        vec.push_back({A, 1});
    }
    ll B, C;
    rep(i, M){
        cin >> B >> C;
        vec.push_back({C, B}); //BiとCi逆だった！(泣いちゃう)
    }
    sort(all(vec)); //pairはデフォルトでfirstでsortされるよ！
    ll count=0;
    ll index = vec.size()-1; //vec.size()!=1だから死なない
    rep(i, N){
        count += vec[index].first;
        vec[index].second--;
        if(vec[index].second == 0) index--;
    }
    cout << count <<endl;
    return 0;
}


Measured memory_bytes: 6000
n = int(input())
data = []
for i in range(n):
    xi,yi,hi = map(int,input().split())
    data.append((xi,yi,hi))
lst = [[] for _ in range(n)]
data.sort(key = lambda x:x[2],reverse = True)
x,y,h = data[0]
for i in range(101):
    for j in range(101):
        lst[0].append((i,j,h+abs(i-x)+abs(j-y)))
for i in range(1,n):
    xi,yi,hi = data[i]
    if hi > 0:
        for x,y,h in lst[i-1]:
            if abs(x-xi)+abs(y-yi)+hi == h:
                lst[i].append((x,y,h))
    else:
        for x,y,h in lst[i-1]:
            if abs(x-xi)+abs(y-yi) >= h:
                lst[i].append((x,y,h))
print(*lst[n-1][0])

Measured memory_bytes: 4852
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <stack>
#include <vector>

using namespace std;

using Pair = pair<int, int>;
using lint = long long;

// const int mod = 1e9 + 7;
// const int mod = 998244353;

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

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

int main(){
  string s;
  cin>>s;
  int n = s.size();
  int x, y;
  cin >> x >> y;

  int st = 0;
  while(s[st]=='F'){
    st++;
    x--;
  }
  int w = 0;
  vector<vector<int>> m(2, vector<int>());
  for (int i = st; i < n; i++) {
    if (s[i] == 'T') {
      w = 1 - w;
    } else if (s[i] == 'F') {
      if(i>0&&s[i-1]=='F'){
        m[w][m[w].size() - 1]++;
      }else {
        m[w].push_back(1);
      }
    }
  }

  bool ret = true;
  for (int i = 0; i < 2;i++){
    int s;
    if (i == 0) s = x;
    else
      s = y;
    int sum = 0;
    for (int j = 0;j<m[i].size();j++){
      sum += m[i][j];
    }
    if ((sum - s) % 2 == 1||sum<s) ret = false;
    else {
      s = (sum - s) / 2;

      auto dp = make_v<bool>(2, s+1);

      dp[1][0] = true;
      for (int j = 0; j < m[i].size(); j++) {
        int t = j % 2;
        for (int k = 0;k<s+1;k++)
          dp[t][k] = dp[1 - t][k];
        for (int k = 0; k < s+1; k++) {
          if (dp[1 - t][k] && k + m[i][j] <= s) dp[t][k + m[i][j]] = true;
        }
      }
      if (dp[(m[i].size() - 1) % 2][s] == false) ret = false;
    }
  }
  if (ret) cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; scanf("%lld", &x);
#define int2(x, y) int x, y; scanf("%lld %lld", &x, &y);

//int dxy[5] = {0, 1, 0, -1, 0};
// assign

signed main()
{
    int2(n, m);
    while (n) {
        vi a(21, 0), b(21, 0);
        rep(i, n) {
            int tmp;
            cin >> tmp;
            a[tmp]++;
        }
        rep(i, m) {
            int tmp;
            cin >> tmp;
            b[tmp]++;
        }
        int ans = 0;
        rep(i, 21) {
            ans += i * ((a[i] < b[i]) ? b[i] : a[i]);
        }
        cout << ans << endl;
        cin >> n >> m;
    }
    return 0;
}

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

int main()
{
  int n;
  cin >> n;
  
  int a[n+2];
  a[0] = 0;
  a[n+1] = 0;
  rep1(i,n) cin >> a[i];

  ll sum = 0;
  for(int i = 0; i <= n; i++) sum += abs(a[i] - a[i+1]);
  
  for(int i = 0; i < n; i++)
  {
    cout << sum - abs(a[i+1] - a[i]) - abs(a[i+1] - a[i+2]) + abs(a[i] - a[i+2]) << endl;
  }
  
}

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

 int main(void){
     int A,B,C;
     cin >> A>>B>>C;
     if(A+B+C != 17){
         cout << "NO" << endl;
     }else{
         cout << "YES" << endl;
     }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
using namespace std;
int main()
{
    int a[3];
    cin>>a[0]>>a[1]>>a[2];
    if(a[0]%2==0||a[1]%2==0||a[2]%2==0)cout<<0<<endl;
    else{
        sort(a, a+3);
        cout<<(long long)a[0]*a[1]<<endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <list>       // ヘッダファイルインクルード
using namespace std;
#define ll int64_t
#define ALL(a)  (a).begin(),(a).end()

const ll mod = 1000000007;
const ll LINF = 1e13;
const ll LLINF = 1e18;
const ll ALPHABET = 26;

template <class T>
void Swap(T& r, T& l) {
  T tmp = r;
  r = l;
  l = tmp;
}

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x; //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいい
  return is;
}



// check
// 問題文を復唱する
// cぐらいから問題文を読み替える
// 読み替える

// DP?
// 配置?
// 詰めるのは最後で良い
// 左右二回試せば


int main() {
  ll n, k, h, w, m;
  cin >> n >> k;

  vector<ll> v(n, 0);
  cin >> v;

  vector<ll> v2(n, 0);
  copy(v.begin(),v.end(),v2.begin());
  reverse(v2.begin(),v2.end());



  //k<100
  // n<50

  ll ans = 0; 
  for (int i = 0; i <= k; i++) { //i回 引き抜きを行う k-i回 捨てれる //10^2

    cerr << i << "回取り出す " << k-i <<"回捨てれる" <<endl;

    if (i>n)break;


    for (int j = 0; j <= i; j++) {//左からjこ 右からi-jこ //最大10^2
      int left = j;
      int right = i - j;

      vector<ll> tmp;

      for (int l = 0; l < left; l++) { //最大k
          tmp.push_back(v[l]);
      }

      for (int r = 0; r < right; r++) { //最大k
          tmp.push_back(v2[r]);
      }

      ll sum = 0;
      for(auto p:tmp){
        sum+=p;
      }

      sort(tmp.begin(),tmp.end());

      for(int p=0;p<k-i;p++){
        if (p >= tmp.size())break;
        if (tmp[p] <0)sum -= tmp[p];
      }

      if (sum > ans){ans = sum;}

    }

    cerr << ans <<endl;


  }



  cout << ans << endl;


  // cout << (true? "Yes":"No");


}




















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

#define whole(f, x, ...)                                 \
  ([&](decltype((x)) whole) {                            \
    return (f)(begin(whole), end(whole), ##__VA_ARGS__); \
  })(x)

using namespace std;
using ll = long long;

void solve() {
  int n, k, r, s, p;
  cin >> n >> k >> r >> s >> p;
  string str;
  cin >> str;

  const auto get_point = [=](char c) {
    switch (c) {
      case 'r':
        return p;
      case 's':
        return r;
      case 'p':
        return s;
    }
  };
  vector<vector<char>> st(k);
  for (int i = 0; i < n; i++) {
    st[i % k].push_back(str[i]);
  }

  ll ans = 0;
  for (auto& ss : st) {
    ans += get_point(ss[0]);
    int l = 0;
    for (int i = 1; i < ss.size(); i++) {
      if (ss[i] == ss[i - 1]) {
        ++l;
      } else {
        l = 0;
      }
      if (l % 2 == 0) {
        ans += get_point(ss[i]);
      }
    }
  }

  cout << ans << endl;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);

  solve();
  return 0;
}


Measured memory_bytes: 5200
#include<bits/stdc++.h>//头文件
using namespace std;
string a,b,c;
int main(){
    cin>>a>>b>>c;//输入这三个单词（好像是字符串）
    cout<<a[0]<<b[0]<<c[0]<<endl;//输出第一位
    return 0;//完美结束
}

Measured memory_bytes: 256
s=input();ans='NO'
if s == 'keyence':
    ans = 'YES'
l = len(s)
if len(s) >= 8:
    i = 0
    while i < 8:
        s0 = s[:i]+s[i+(len(s)-7):]
        if s0 == 'keyence':
            ans = 'YES'
            break
        i += 1
print(ans)

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

int main(){
	int n;
	int res;
	double x;
	int x1, x2;
	cin >> n;

	x = n/1.08;
	x1 = (int) x;
	x2 = x1+1;

	if(((int) (x1*1.08)) == n){
		res = x1;
	}else if(((int) (x2*1.08)) == n){
		res = x2;
	}else{
		cout << ":(" << endl;
		return 0;
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>



int main (void) {
    int a, b, c, a2, b2, c2;
    int triangle, tright, tacute, tobtuse;
    double ra, rb, rc;

    triangle = tright = tacute = tobtuse = 0;

    while (scanf("%d%d%d", &a, &b, &c) == 3) {
        if (a + b <= c || b + c <= a || c + a <= b) break;
        triangle++;
        a2 = a * a;
        b2 = b * b;
        c2 = c * c;
        if (a2 + b2 == c2 || b2 + c2 == a2 || c2 + a2 == b2) {tright++;
            continue;
        }
        ra = acos((double)(b2 + c2 - a2) / (2 * b * c));
        rb = acos((double)(c2 + a2 - b2) / (2 * c * a));
        rc = M_PI - ra - rb;
        if (ra > M_PI_2 || rb > M_PI_2 || rc > M_PI_2) {
            tobtuse++;
        }
        else {
            tacute++;
        }
    }
    printf("%d %d %d %d\n", triangle, tright, tacute, tobtuse);
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <string>

using namespace std;

int gcd(int p, int q) {
    if (p % q == 0)return q;
    return gcd(q, p % q);
}

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

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

    int min,dif;
    min = a[n - 1] - a[0];

    for (int i = 0; i < n-1; i++) {
        dif = a[i] + k - a[i + 1];
        if (dif < min) min = dif;
    }

    cout << min;
    
    return 0;
}



Measured memory_bytes: 4048
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {
            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }

        
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var n = Read();
            var a = new long[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = Read();
            }

            var answer = -1;
            long next =1;
    
            for (int i =1; i <= n; i++)
            {         
                if (a[next - 1] == 2)
                {
                    answer = i;
                    break;
                }
                next = a[next-1];
            }
            Console.WriteLine(answer);
     
            Console.Out.Flush();
        }
    }
}

Measured memory_bytes: 15292
A, B, C, X, Y = list(map(int, input().split()))
for num_c in range(0, 2 * max(X, Y) + 1, 2):
    num_a = X - num_c // 2 if X - num_c // 2 > 0 else 0
    num_b = Y - num_c // 2 if Y - num_c // 2 > 0 else 0
    if num_c == 0:
        min_money = A * num_a + B * num_b
    else:
        if (A * num_a + B * num_b + C * num_c) < min_money:
            min_money = A * num_a + B * num_b + C * num_c
print(min_money)


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long
#define pii pair<int,int>
#define all(x) begin(x), end(x)
#define loop(i,n) for(int i=0; i<n; i++)
#define rep(i,a,b,c) for(int i=a; i<b; i+=c)
#define brep(i,a,b,c) for(int i=a; i>b; i-=c)
#define tc(t) int t; cin>>t; while(t--)
#define sz(v) int((v).size())
#define pb push_back


using namespace std;

void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {std::cout << x;}
void __print(unsigned x) {std::cout << x;}
void __print(unsigned long x) {std::cout << x;}
void __print(unsigned long long x) {std::cout<< x;}
void __print(float x) {std::cout << x;}
void __print(double x) {std::cout << x;}
void __print(long double x) {std::cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i : x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
template <typename T> inline void inp(T &any) {cin >> any;} template <typename T, typename... U>inline void inp(T &a, U &...b) {cin >> a; inp(b...);}
#define rin(args...) ll args; inp(args);
#ifndef ONLINE_JUDGE
#define debug(x...) cout << "[" << #x << "] = ["; _print(x)
#define matdeb(mat,row,col) cout << #mat << "::" << endl; printmat(mat,row,col); printpartition;
#define debugv(v,n) cout << #v << ":" << endl; printv(v,0,n-1); printpartition;
#else
#define debug(x...)
#define matdeb(mat,row,col)
#define debugv(v,n)
#endif

const int maxm = 1000000000 + 7;

double startTime;
double getCurrentTime() {
	return ((double)clock() - startTime) / CLOCKS_PER_SEC;
}



int main()
{

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

   string a;
   cin>>a;
   
   int cnt=0;
   int max_cnt=0;

   loop(i,a.length())
   {
   	   if(a[i] == 'R')
   	   {
   	   	   cnt++;
   	   	   max_cnt=cnt;
   	   }

   	   if(a[i] == 'S')
   	   {
          cnt=0;
   	   }
   }


   __print(max_cnt);


}

Measured memory_bytes: 3612
h, w, k = map(int, input().split())
s = []
for _ in range(h):
    s.append(list(map(int, list(input()))))

def vertical_line(h, w, k, s):
    ans = 0
    mark = [0 for _ in range(h)]
    for i in range(w):
        for j in range(h):
            mark[j] += s[j][i]
            if mark[j] > k:
                ans += 1
                mark = [s[l][i] for l in range(h)]
                break
    return ans

from copy import deepcopy
ans = []
for i in range(2 ** (h - 1)):
    s_copy = deepcopy(s)
    flag = False
    h_copy = h
    for j in range(h - 2, -1, -1):
        if i % 2 == 1:
            h_copy -= 1
            for l in range(w):
                s_copy[j][l] += s_copy[j+1][l]

                if s_copy[j][l] > k:
                    flag = True
                    break

            del s_copy[j+1]

        if flag:
            break

        i //= 2

    if flag:
        continue

    ans.append(h_copy - 1 + vertical_line(h_copy, w, k, s_copy))
print(min(ans))

Measured memory_bytes: 66268
#include <bits/stdc++.h>
#define INF 1000000000
using namespace std;

int main() {

int n; cin>>n;
  vector<int> A(n);
  for(int i=0; i<n; i++){
    cin>>A[i];}
  sort(A.begin(),A.end());
  for(int i=0; i<n-1; i++){
 
    A[n-1]-=A[i];  }
  if(A[n-1]>=0)cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
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; }



int main() {
  ll n,x;
  scanf("%lld%lld", &n,&x);
  ll a[n];
  for (int i = 0; i < n; ++i) {
    scanf("%lld", &a[i]);
  }

  ll ans = 0;

  if(a[0]>x){
    ans += a[0]-x;
    a[0] = x;
  }

  FOR(i,0,n-2){
    if(a[i]+a[i+1]>x){
      ans += a[i]+a[i+1]-x;
      a[i+1] = x-a[i];
    }
  }

  cout << ans << endl;



}



Measured memory_bytes: 1024
#include<stdio.h>
//#include<math.h>
int main(){
  double d[10],i;
  int j;
  while(scanf("%lf",&d[0])!=EOF){
    for(j=1;j<6;j++)scanf(",%lf",&d[j]);
    d[6]=d[2]-d[0];
    d[8]=d[7]=d[3]-d[1];
    d[9]=-1*d[6];
    i=(d[7]*(d[4]-d[0])-d[6]*(d[5]-d[1]))/(d[9]*d[6]-d[8]*d[7]);
    //printf("%f\n",i);
    printf("%f %f\n",d[4]+i*2*d[8],d[5]+i*2*d[9]);
  }
  return 0;
}
    

Measured memory_bytes: 652
#include<stdio.h>

int main(){
    int x[10000];
    int max=0;
    for(int i=0;i<10000;i++){
        scanf("%d",&x[max]);
        if(x[max]==0){
            break;
        }
        max++;
    }
    for(int i=0;i<max;i++){
        printf("Case %d: %d\n",i+1,x[i]);
    }
    return 0;
}


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

int n, last, sum, cnt, a[200005], b[200005];
int main() {
	int i, j;
	cin >> n;
	for(i=1; i<=n; i++) {
		scanf("%d", &a[i]);
		if(a[i]) last = i;
	}
	b[last] = 1;
	for(i=last-1; i>0; i--) {
		sum = 0;
		for(j=i; j<=last; j += i) sum += b[j];
		if(sum % 2 != a[i]) b[i] = 1;
	}
	for(i=1; i<=last; i++) cnt += b[i];
	cout << cnt <<endl;
	for(i=1; i<=last; i++) if(b[i]) printf("%d ", i);
	return 0;
}


Measured memory_bytes: 2432
#include<stdio.h>
int main(){
   int X,Y;
   int ans;
   scanf("%d",&X);
   scanf("%d",&Y);
   int i,j;
   int judg=0;
   for(i=0;i<=100;i++){
      for(j=0;j<=100;j++){
         if(i+j==X&&2*i+4*j==Y){
            printf("Yes");
            judg++;
         }

      }

   }
   if(judg==0){
      printf("No");
   }
   return 0;
}


Measured memory_bytes: 3200
from itertools import permutations

if __name__ == "__main__":
    n = int(input())
    x = [0 for i in range(n)]
    y = [0 for i in range(n)]

    for i in range(n):
        x[i],y[i] = map(int,input().split(' '))

    ans = 0
    for perm in permutations(range(n)):

        for i in range(len(perm)-1):
            # print(((x[perm[i]]-x[perm[i]+1])**2 + (y[perm[i]]-y[perm[i]+1])**2)**0.5)
            ans +=  ((x[perm[i]]-x[perm[i+1]])**2 + (y[perm[i]]-y[perm[i+1]])**2)**0.5
    # print(ans)
    print(ans/len(list(permutations(range(n)))))

Measured memory_bytes: 8180
#include <stdio.h>

#define M 1000000007

unsigned gcd(unsigned s, unsigned t)
{
  unsigned r;
  if (t == 0) return s;
  for ( ;(r = s % t) != 0; s = t, t = r);
  return t;
}

int inverse(unsigned long x)
{
  int n = M - 2;
  unsigned long res = 1LL;
  while (n > 0) {
    if (n & 1) {
      res = res * x % M;
    }
    x = x * x % M;
    n /= 2LL;
  }
  return res;
}

int
main(int ac, char *av[])
{
  int n;
  unsigned A[10000];
  unsigned L[10000];
  unsigned long a, u, g, ll = 1, z = 0;

  scanf("%d", &n);

  for (int i = 0; i < n; ++i) {
    scanf("%u", &A[i]);
    L[i] = 1;
  }

  for (int i = 0; i < n; ++i) {
    a = A[i];

    g = inverse(gcd(L[i], a));

    u = a * g % M;

    z = (z * u + ll * g) % M;

    ll = (ll * u) % M;

    for (int j = i + 1; j < n; ++j) {
      L[j] = (unsigned long) L[j] * u % A[j];
    }
  }

  printf("%lu\n", z);

  return 0;
}


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

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    int A, B, C;
    int K;
    int maior = 0;
    int soma = 0;
    cin >> A >> B >> C;
    cin >> K;
    for (int i = 0; i < K; i++)
    {
        if (A >= B && A >= C)
        {
            A *= 2;
            maior = A;
            soma = B + C;
        }
        else if (B >= A && B >= C)
        {
            B *= 2;
            maior = B;
            soma = A + C;
        }
        else
        {
            C *= 2;
            maior = C;
            soma = A + B;
        }
    }
    cout << maior + soma << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
int a, b, n, g, x, y, f, fx, fy, now;
char s[1000001];
long long u[1000000];
long long d[1000000];
long long p;
long long q = 10000000;
int uu, dd;
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf(" %s", s);
		g = 0;
		x = 0;
		a = 0;
		while (s[g] != NULL)g++;
		for (int j = 0; j < g; j++) {
			if (s[j] == ')')x++;
			if (s[j] == '(')x--;
			if (x > a)a = x;
		}
		b = a - x;
		if (b < 0)b = 0;
		y += x;
		if (x <= 0) {
			p = a;
			p *= q;
			p -= x;
			u[uu] = p;
			uu++;
		}
		if (x > 0) {
			p = b;
			p *= q;
			p += x;
			d[dd] = p;
			dd++;
		}
	}
	if (y != 0) {
		printf("No\n");
		return 0;
	}
	std::sort(d, d + dd);
	std::sort(u, u + uu);
	for (int i = 0; i < uu; i++) {
		fx = u[i] % q;
		fy = u[i] / q;
		if (now < fy)f++;
		now += fx;
	}
	now = 0;
	for (int i = 0; i < dd; i++) {
		fx = d[i] % q;
		fy = d[i] / q;
		if (now < fy)f++;
		now += fx;
	}
	if (f)printf("No\n");
	else printf("Yes\n");
}

Measured memory_bytes: 9400
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <string.h>
#include <stack>
#include <map>
#include <unordered_map>
#include <climits>
using namespace std;
const int INF = 1e9;
#define ll long long
#define int ll
#define fast                      \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0);
#define testcase \
    int t;       \
    cin >> t;    \
    while (t--)
#define pb push_back
#define endl "\n"
#define deb1(x) cout << #x << ": " << x << endl
#define deb2(x, y) cout << #x << ": " << x << " | " << #y << ": " << y << endl
#define deb3(x, y, z) cout << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl
#define deb4(x, y, z, w) cout << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << " | " << #w << ": " << w << endl
#define deb5(a, b, c, d, e) cout << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(a) int((a).size())
#define pii pair<int, int>
#define fi first
#define se second
#define ld long double
#define vii vector<int>
#define all(v) v.begin(), v.end()
#define prec(n) fixed << setprecision(n)
const int MOD = (int)1e9 + 7;
const int MOD2 = 1007681537;
const ll LINF = (ll)1e18;
const ld PI = acos((ld)-1);
const ld EPS = 1e-12;
inline ll gcd(ll a, ll b)
{
    ll r;
    while (b)
    {
        r = a % b;
        a = b;
        b = r;
    }
    return a;
}
inline ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
inline ll fpow(ll n, ll k, int p = MOD)
{
    ll r = 1;
    for (; k; k >>= 1)
    {
        if (k & 1)
            r = r * n % p;
        n = n * n % p;
    }
    return r;
}
template <class T>
inline int chkmin(T &a, const T &val) { return val < a ? a = val, 1 : 0; }
template <class T>
inline int chkmax(T &a, const T &val) { return a < val ? a = val, 1 : 0; }
inline void addmod(int &a, int val, int p = MOD)
{
    if ((a = (a + val)) >= p)
        a -= p;
}
inline void submod(int &a, int val, int p = MOD)
{
    if ((a = (a - val)) < 0)
        a += p;
}
inline int mult(int a, int b, int p = MOD) { return (ll)a * b % p; }
inline int inv(int a, int p = MOD) { return fpow(a, p - 2, p); }

template <class T>
inline void get_arr(T arr[], int n)
{
    for (int i = 0; i < n; i++)
        cin >> arr[i];
}
template <class T>
inline void print_arr(T arr[], int n)
{
    for (int i = 0; i < n; i++)
        cout << arr[i] << " ";
    cout << endl;
}

int32_t main()
{
    int n, k;
    cin >> n >> k;
    int arr[n];
    get_arr(arr, n);
    vector<bool> dp(k + 1);
    for (int i = 0; i <= k; i++)
    {
        for (int j = 0; j < n; j++)
        {
            if (i - arr[j] >= 0 && !dp[i - arr[j]])
            {
                dp[i] = true;
            }
        }
    }
    cout << (dp[k] ? "First":"Second");
}


Measured memory_bytes: 256
#pragma GCC optimize("trapv")
//#pragma GCC target("avx,avx2,fma")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
#define pb push_back
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using vi = vector<ll>;
using pi = pair<ll, ll>;
using vpi = vector<pi>;
const int maxn = 2e5 + 55;
const int mod = 1e9 + 7;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	string s, t;
	cin >> s >> t;
	cout << t << s;
}


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

int main(){
  int N, M;
  cin >> N >> M;
  int L_max=1, R_min=N;
  int ANS;
  vector<int> L(M);
  vector<int> R(M);
  
  
  for(int i=0;i<M;i++){
    cin >> L.at(i) >> R.at(i);
    if(L.at(i)>L_max){
      L_max = L.at(i);
    }
    if(R.at(i)<R_min){
      R_min = R.at(i);
    }
  }
  
  ANS = R_min - L_max + 1;
  
  if(ANS<0){
    ANS = 0;
  }
  
  cout << ANS << endl;
}


Measured memory_bytes: 1024
n = int(input())
c = 0

def devisor(n):
    if n == 2:
        return 1
    else:
        if n < 2 or n % 2 == 0:
            return 0
        elif pow(2,n-1,n) == 1:
            return 1
        else: return 0

for i in range(n):
    x = int(input())
    c += devisor(x)

print(c)

Measured memory_bytes: 7652
# ABC 119 B

# input
n = gets.to_i
x = Array.new(n)
u = Array.new(n)
(0..n-1).each do |i|
    x[i],u[i] = gets.chomp.split(" ")
    x[i] = x[i].to_f
end

sum = 0
(0..n-1).each do |i|
    if u[i] == "JPY"
        sum += x[i]
    else
        sum += x[i] * 380000.0
    end
end

puts sum


Measured memory_bytes: 1916
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#define ll long long
#define out(a) printf("%d",a)
#define rep(i,a,b) for (int i=a;i<=b;i++)
using namespace std;
int n,a,b;
int read()
{
	int s=0,t=1; char c;
	while (c<'0'||c>'9') {if (c=='-') t=-1; c=getchar();}
	while (c>='0'&&c<='9') {s=s*10+c-'0'; c=getchar();}
	return s*t;
}
int main()
{
	n=read(); a=read(); b=read();
	n-=a; n-=n/b*b;
	out(n);
	
}

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

//#define rep(i, n)     for(auto i = 0; i != n; ++i)
#define REP(i, k, n)  for(auto i = k; i != n; ++i)
//#define rrep(i, n)    for(auto i = n; i != 0; --i)
#define RREP(i, n, k) for(auto i = n; i != k; --i)

#define debug(x) cerr << #x << " " << x << endl
#define spc << " " <<

#define mp make_pair
#define mt make_tuple

using ll = long long;
using Pii = pair<int, int>;
using Tiii = tuple<int, int, int>;
template<typename T>using V = vector<T>;
using Vi = vector<int>;
using VVi = vector<vector<int>>;

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

int h, w;
V<V<bool>> wall;
//V<V<bool>> closed;
int start_x, start_y, goal_x, goal_y;
const int DEF = 1000000;
int ans = DEF;

void dfs(int y, int x, int num) {
//    cout << y spc x spc num << endl;
//    if (closed[y][x]) return;
//    closed[y][x] = true;

    if (y==goal_y && x==goal_x) {
        ans = min(ans, num);
        return;
    }
    else if (num == 10) return;

    REP(dir, 0, 4) {
//        cout << dir << endl;
        int nx = x, ny = y;
        if (0==nx+dx[dir] || nx+dx[dir]==w+1
        || 0==ny+dy[dir] || ny+dy[dir]==h+1) continue;
        if (wall[ny+dy[dir]][nx+dx[dir]]) continue;

        while (true) {
            int next_x = nx+dx[dir], next_y = ny+dy[dir];
            if (nx == goal_x && ny == goal_y) {
                dfs(goal_y, goal_x, num+1);
                break;
            }

            if (0==next_x || next_x==w+1 || 0==next_y || next_y==h+1) break;

            if (wall[next_y][next_x]) {
                wall[next_y][next_x] = false;
                dfs(ny, nx, num+1);
                wall[next_y][next_x] = true;
                break;
            }

            nx += dx[dir], ny += dy[dir];
        }
    }

//    closed[y][x] = false;
}

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

   while (cin >> w >> h, w) {
       wall = V<V<bool>>(h + 1, V<bool>(w + 1, false));
       REP(hi, 1, h + 1) REP(wi, 1, w + 1) {
               int buff;
               cin >> buff;
               if (buff == 1) wall[hi][wi] = true;
               if (buff == 2) {
                   start_x = wi;
                   start_y = hi;
               }
               if (buff == 3) {
                   goal_x = wi;
                   goal_y = hi;
               }
       }

       ans = DEF;
//       closed = V<V<bool>>(h+1, V<bool>(w+1, false));
       dfs(start_y, start_x, 0);

       if (ans != DEF) cout << ans << endl;
       else cout << -1 << endl;
   }

   return 0;
}



Measured memory_bytes: 3012
def f(h):
  if len(h) == 0:
    return 0

  if 0 in h:
    i = h.index(0)
    return f(h[0:i]) + f(h[i+1:])
  else:
    return 1 + f([ x-1 for x in h ])

if __name__ == "__main__":
  N = int(input())
  h = list(map(int, input().split()))
  print( f(h) )


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(ll i = n;i >= 0;--i)
#define FOR(i,m,n) for(ll i = m, i##_len=(n);i <i##_len; ++i)
#define all(x) (x).begin(),(x).end()
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; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;
#include <iostream>
#include <string>

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

    if(s =="ABC"){
        cout<<"ARC"<<endl;
    }
    else{
        cout<<"ABC"<<endl;
    }

    return 0;
}


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

using namespace std;

int main()
{
  string S, T;
  cin >> S >> T;

  for( int i = 0, n = S.size(); i < n; ++i )
  {
    if( S == T )
    {
      cout << "Yes";
      return 0;
    }

    S = S[ S.size() - 1 ] + S.substr(0, S.size() - 1 );
  }

  cout << "No";
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    char s[200000],t[200000];
    cin>>s;
    int sum=0;
    cin>>t;
    for(int i=0;t[i]!='\0';i++)
    {
        if(t[i]!=s[i])
        {
            sum++;
        }
    }
    cout<<sum;

    return 0;
}


Measured memory_bytes: 3980
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define vv(T) vector<vector<T>>
using namespace std;
using ll = long long;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using vll = vector<long long>;
using vvll = vector<vector<long long>>;
using vbool = vector<bool>;
using vvbool = vector<vector<bool>>;
using qint = queue<int>;
using sint = stack<int>;
using pii = pair<int, int>;

class UnionFind{
    vector<int> parent;
    // UnionFind木の実装
public:
    UnionFind(int N) : parent(N, -1) {} // コンストラクタ
    int root(int x){
        // 根を求める。
        if(parent[x] < 0) return x;
        return parent[x] = root(parent[x]);
    }
    void unite(int x, int y){
        // xとyの木を結合する。
        int rx = root(x);
        int ry = root(y);
        if(rx == ry) return;
        if(-parent[rx] > -parent[ry]){
            // 小さい方の木を大きい方につなげる。
            parent[rx] += parent[ry];
            parent[ry] = rx;
        }
        else{
            parent[ry] += parent[rx];
            parent[rx] = ry;
        }
        return;
    }
    bool isSame(int x, int y){
        // 同じ木にあるか?
        return root(x) == root(y);
    }
    int size(int x){
        // xの木に属する要素はいくつか?
        return -parent[root(x)];
    }
};

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

    UnionFind uf(n);

    rep(i, m){
        int a, b;
        cin >> a >> b;
        a--; b--;
        uf.unite(a, b);
    }

    int ans = 0;
    rep(i, n){
        ans = max(ans, uf.size(i));
    }

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

Measured memory_bytes: 3988
#include <bits/stdc++.h>
#define pi 3.14159
using namespace std;
typedef long long LL;
const LL MOD = 1e9 + 7;
const int N = 1e5 + 7, M = 1e7, OO = 0x3f3f3f3f;
#define AC ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin.sync_with_stdio(0);
int main()
{
int n;
scanf("%d",&n);
(n>=30)?printf("Yes\n"):printf("No\n");



    return 0;
}


Measured memory_bytes: 3652
import sys
N, M, Q = map(int, sys.stdin.readline().split())
 
LR = [[0 for _ in range(N+2-i)] for i in range(N+2)]
for i in range(M):
  L, R = map(int, sys.stdin.readline().split())
  LR[L][R-L+1] += 1
 
for i in range(2,N+2):
  for j in range(1,N-i+2):
    LR[j][i] += LR[j][i-1] + LR[j+1][i-1] - LR[j+1][i-2]
 
for i in range(Q):
  p, q = map(int, sys.stdin.readline().split())
  sys.stdout.write(str(LR[p][q-p+1])+"\n")

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

int main() {
    int X, Y, Z, K;
    cin >> X >> Y >> Z >> K;
    long A[X], B[Y], C[Z];
    vector<long> A_and_B, result;
    for (int i=0; i<X; i++) cin >> A[i];
    for (int i=0; i<Y; i++) cin >> B[i];
    for (int i=0; i<Z; i++) cin >> C[i];

    for (int i=0; i<X; i++) for (int j=0; j<Y; j++) A_and_B.push_back(A[i]+B[j]);
    sort(A_and_B.begin(), A_and_B.end(), greater<>());
    A_and_B.resize(K);

    for (int i=0; i<K; i++) for (int j=0; j<Z; j++) result.push_back(A_and_B[i]+C[j]);
    sort(result.begin(), result.end(), greater<>());
    result.resize(K);

    for (int i=0; i<K; i++) cout << result[i] << endl;
}

Measured memory_bytes: 43236
package main

import "fmt"

func main() {
	var n, k, x, y int
	fmt.Scanf("%d\n%d\n%d\n%d\n", &n, &k, &x, &y)

	if n-k > 0 {
		fmt.Println(k*x + (n-k)*y)
	} else {
		fmt.Println(n * x)
	}
}


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

int main(){
  int A,B,C,D;
  cin>>A >>B >>C >>D;
  if( A+B<C+D )       cout <<"Right"<<endl;
  else if( A+B==C+D ) cout <<"Balanced"<<endl;
  else 				  cout <<"Left"<<endl;
}

Measured memory_bytes: 256