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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int x, y;
  cin >> x >> y;
  int res;
  if (x >= 0) {
    if (y > x) res = y - x;
    else if (0 < y && y < x) res = x - y + 2;
    else if (-x <= y && y <= 0) res = 1 + y + x;
    else res = 1 - y - x;
  } else {
    if (y >= -x) res = 1 + y + x;
    else if (0 < y && y < -x) res = 1 - x - y;
    else if (x < y && y <= 0) res = y - x;
    else res = x - y + 2;
  }
  cout << res << "\n";
  return 0;
}

Measured memory_bytes: 384
//                          VIVEK UPADHYAY
//                          MANIT, BHOPAL(M.P)
/**********************************************************************************************/
/**********************************************************************************************/
//                        $$ JAB-TAK TODEGA NHI,
//                           TAB -TAK CHODEGA NHI :D

// g++ -std=c++11 file_name.cpp
// ./file_name.out
#include<iostream>
#include<algorithm>
#include<vector>
#include<list>
#include<cstdlib>
#include<unistd.h>
#include<string>
#include<cstring>
#include<stack>
#include<queue>
#include<utility>
#include<cmath>
#include<set>
#include<unordered_map>
#include<cstdio>
#include<map>
#include<numeric>
using namespace std;
#define F first
#define S second
#define mk(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define LINE cout<<"\n" ;
#define ok cout<<"ok\n" ;
#define dbg(x) cout<<#x<<" = "<<(x)<<"\n";
#define fill(A, VAL) memset(A, VAL, sizeof(A))
#define sz(a) ((int) a.size())
typedef long long ll ;
const int MAXN = 5*1e5 + 10;
bool compare(pair<int,int> a , pair<int,int> b){
    return a.S < b.S ;
}
int main () {
    
    int N , M ;
    cin >> N >> M ;
    pair<int,int> p[M] ;
    for(int i =0 ; i < M ;i++)
        cin >> p[i].F >> p[i].S ;
    int cnt[N + 2] ;
    for(int i =0 ; i < N + 2 ;i++)
        cnt[i] =0 ;
    for(int i = 0 ; i < M ;i++){
        cnt[p[i].F]++ ; cnt[p[i].S + 1]-- ; }
    for(int i = 1 ; i <= N ;i++)
        cnt[i] = cnt[i] + cnt[i - 1] ;

    int c =0 ;
    for(int i =1;i<=N;i++)
        if(cnt[i] >= M) c++ ;
    cout<<c<<endl;
    return 0 ;
}


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

int main(){
    int a, b;
    cin >> a >> b;
    int ans = 0;
    for(int i = 0; i < 2; i++){
        if(a >= b) {
            ans += a;
            a--;
        } else {
            ans += b;
            b--;
        }
    }
    cout << ans << endl;
    return 0;
}

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

string str;

int main(){
	cin >> str;
	if(str.size() == 1){
	       	cout << str[0] - '0' << endl;
	       	return 0;
	}
	for(int i=0;i<str.size();i++){
			for(int j=i+1;j<str.size();j++){
				if(str[j] != '9'){
					cout << (str.size() - 1) * 9 + str[i] - 1 - '0' << endl;
					return 0;
				}
			}
			cout << (str.size() - 1) * 9 + str[i] - '0' << endl;
			return 0;
	}
	cout << 9 * str.size() << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
ll pow(int a,int b){
  ll ans=1;
  for(int i=0; i<b;i++){
    ans *=a;
  }
  return ans;
}
ll num(ll i,ll j,ll n){//iで始まりjで終わる数の個数を数える
  ll s=1;
  ll count=0;
  if(10*i+j<=n) count++;
  while((i+1)*pow(10,s+1)-10+j<=n){//まだ一桁のは数えてない
    count += pow(10,s);
    s++;
  }
  if((n/10)-i*pow(10,s)>=0){
    count +=( (n/10)-i*pow(10,s) );
  }
  if(n%10>=j&&n>=i*pow(10,s+1)) count++;
  if(i==j&&i<=n) count++;
  return count;
}
int main(){
  vector<vector<ll>> kosu(10, vector<ll>(10));
  ll n;
  cin>>n;
  for(int i=1; i<10;i++){
    for(int j=1; j<10; j++){
      kosu.at(i).at(j)=num(i,j,n);
    }
  }
  ll ans=0;
  for(int i=1; i<10; i++){
    for(int j=1; j<10; j++){
      ans +=kosu.at(i).at(j)*kosu.at(j).at(i);
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
c=[]
for i in range(3):
  a,b=map(int,input().split())
  c.append(a)
  c.append(b)
c=sorted(c)
ans='YES'
for j in range(1,5):
  cnt=0
  for i in range(6):
    if c[i]==j:
      cnt+=1
  if cnt>2:
    ans='NO'
    break

print(ans)


Measured memory_bytes: 3060
var fs = require('fs');

// class Stdin
function Stdin() {
  this.__input = null;
  this.__lines = [];
  this.__index = 0;
}
Stdin.prototype.init = function() {
  this.__input = fs.readFileSync('/dev/stdin', 'utf-8');
  this.__lines = this.__input.split("\n");
  this.__index = 0;
}
Stdin.prototype.readline = function() {
  if(this.__index === this.__lines.length) this.init();
  return this.__lines[this.__index++];
};
Stdin.prototype.readlines = function() {
  if(this.__index === this.__lines.length) this.init();
  cur = this.__index; this.__index = this.__lines.length;
  return this.__lines.slice(cur);
};
var stdin = new Stdin;

Array.prototype.imap = function() { return this.map((x)=>parseInt(x)); }
Array.prototype.fmap = function() { return this.map((x)=>parseFloat(x)); }
Array.prototype.smap = function() { return this.map((x)=>String(x)); }
Array.prototype.ffill = function(cb) {
  for(var i=0; i<this.length; ++i) { this[i] = cb(i); } return this;
}
Array.prototype.max = function() {
  if(this.length === 0) return undefined;
  res = this[0];
  for(var i=1; i<this.length; ++i) if(res < this[i]) res = this[i];
  return res;
}
Array.prototype.min = function() {
  if(this.length === 0) return undefined;
  res = this[0];
  for(var i=1; i<this.length; ++i) if(this[i] < res) res = this[i];
  return res;
}
Array.prototype.sum = function() {
  if(this.length === 0) return undefined;
  res = this[0];
  for(var i=1; i<this.length; ++i) res += this[i];
  return res;
}

Number.prototype.times = function(cb) { res = []; for(var i=0; i<this; ++i) res.push(cb(i)); return res; }

Object.prototype.forEach = function(cb) { Object.keys(this).forEach(cb); }
Object.prototype.map = function(cb) { Object.keys(this).map(cb); }

var ss = (6).times(x => stdin.readline()).imap();
console.log(ss.sum() - ss.slice(0, 4).min() - ss.slice(4, 6).min())

Measured memory_bytes: 15196
s = gets.to_i
count = 1
arr = [s]
while true
if s % 2 == 0
    s = s / 2
    arr << s
    mezirusi = s
elsif s % 2 != 0
    s = s * 3 + 1
    arr << s
    mezirusi = s
end
ans = arr.count(mezirusi)
if ans == 2
    puts count + 1
    break
end
count += 1
end


Measured memory_bytes: 14256
#include <bits/stdc++.h>
#include <ext/numeric>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define oo 0x3f3f3f3f
#define OO 0x3f3f3f3f3f3f3f3f
#define popcount(n) __builtin_popcount(n)
#define popcountll(n) __builtin_popcountll(n)
#define long long long

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef pair<int, int> ii;
typedef pair<int, long> ill;
typedef pair<long, int> lli;
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<pair<long, long>> vll;
typedef vector<ii> vii;
typedef vector<pair<ii, int>> viii;

const double PI = acos(-1.0), EPS = 1e-9;
const int MAXN = 100005, MAXM = 102, Mod = 998244353, MAXLog = 20;


int main() {
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0), cout.precision(10), cout
            << fixed;

//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    int a, b;
    cin >> a >> b;
    cout << max(0, a - 2 * b) << '\n';

    return 0;
}

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

int main(){
    int m,n,i,j;
    string str;

    while(cin >> str){
        if(str=="-") break;
        cin >> m;
        for(i=0;i<m;i++){
            cin >> n;
            for(j=0;j<n;j++) str.insert(str.end(),str[j]);
            str.erase(0,n);
        }
        cout << str << endl;
    }
    return 0;
}



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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;
typedef long double ld;

const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

template<typename T>
T gcd(T a, T b) {
    if (b == 0) {
        return a;
    } else {
        return gcd(b, a % b);
    }
}

template<typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep (i, n) cin >> a[i];
    sort(a.begin(), a.end());
    if (k > a[n - 1]) {
        cout << "IMPOSSIBLE" << endl;
        return 0;
    }
    int g = a[0];
    rep (i, n) g = gcd(g, a[i]);
    if (k % g == 0) {
        cout << "POSSIBLE" << endl;
    } else {
        cout << "IMPOSSIBLE" << endl;
    }

    
    return 0;
}



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

using namespace std;
typedef pair<int,int> pii;
typedef long long int ll;

#define INF 1 << 30
#define REP(i,n) for(ll i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(ll i=(k);i<(int)(n);i++)

ll n,m;
int par[100001], ran[100001];
ll conn[100001] = {0};

/*
使い方
ノード数nの要素を持つint型配列par,ranを宣言し、init()を呼ぶ
*/


void init(int n,int par[],int ran[]){
  REP(i,n){
    par[i] = i;
    ran[i] = 0;
    conn[i] = 0;
  }
}

int find(int x,int par[]){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x], par);
  }
}

void unite(int x, int y, int par[], int ran[]){
  x = find(x,par);
  y = find(y,par);
  if(x == y) return;

  if(ran[x] < ran[y]){
    par[x] = y;
    conn[y] += conn[x]+1;
  }else{
    par[y] = x;
    conn[x] += conn[y]+1;
    if(ran[x] == ran[y]) ran[x]++;
  }
}

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

int main(){
  cin >> n >> m;
  init(n,par,ran);
  int a[100001], b[100001];
  REP(i,m){
    cin >> a[i] >> b[i];
  }
  ll cnt[100001];
  ll c = n*(n-1)/2;
  for(int i = m-1; i>=0; i--){
    cnt[i] = c;
    //cout << a[i]<<b[i]<<endl;
    if(!same(a[i],b[i],par)){
      ll k,l,m;
      k = conn[par[a[i]]];
      l = conn[par[b[i]]];
      unite(a[i],b[i],par,ran);
      m = max(conn[par[a[i]]],conn[par[b[i]]]);
      //cout  << m << endl;
      c += k*(k+1)/2+l*(l+1)/2-m*(m+1)/2;
    }
  }
  REP(i,m){
    cout << cnt[i] <<endl;
  }
}


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



int main() {
    int h, w, k;
    cin >> h >> w >> k;
    vector<string> s(h);
    for (int i = 0; i < h; i++) cin >> s[i];

    int ans = 0;

    for (int is = 0; is < 1<<h; is++) {
        for (int js = 0; js < 1<<w; js++) {
            int cnt = 0;
            for (int i = 0; i < h; i++) {
                for (int j = 0; j < w; j++) {
                    if (is>>i&1) continue;
                    if (js>>j&1) continue;
                    if (s[i][j] == '#') cnt++;
                }
            }
            if (cnt == k) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3540
def my_cal(N1,N2,PM):
    if PM == "+":
        return N1+N2
    else:
        return N1-N2
    
if __name__ == '__main__':
    I = list(map(int,input()))
    ANS = []
    for ele1 in ["+","-"]:
         for ele2 in ["+","-"]:
                for ele3 in ["+","-"]:
                     if my_cal(my_cal(my_cal(I[0],I[1],ele1),I[2],ele2),I[3],ele3) == 7:
                            ANS.append(str(I[0])+ele1+str(I[1])+ele2+str(I[2])+ele3+str(I[3])+"=7")
    print(ANS[0])

Measured memory_bytes: 3064
### 予め一筆書きルートを作る
H, W = map(int,input().split())
As = []
for i in range(H):
    As.append(list(map(int,input().split())))
routes = []
for i in range(H):
    for j in range(W):
        if i%2 == 0:
            routes.append((i+1,j+1))
        else:
            routes.append((i+1,W-j))
n = len(routes)
mvs = []
cnt = 0
for i in range(n-1):
    hi,wi = routes[i]
    hi2,wi2 = routes[i+1]
    if As[hi-1][wi-1] % 2 == 1:
        As[hi2-1][wi2-1] += 1
        mvs.append([hi,wi,hi2,wi2])
        cnt += 1

print(cnt)
for h1,w1,h2,w2 in mvs:
    print(h1,w1,h2,w2)

Measured memory_bytes: 48100
S = input()
answer = 'WA'
if S[0] == 'A':
    sKiridashi = S[2:-1]
    if sKiridashi.count('C') == 1:
        cIndex = sKiridashi.find('C') + 2
        otherStr = S[1:cIndex] + S[cIndex+1:]
        if otherStr.islower():
            answer = 'AC'
print(answer)

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

using namespace std;

#define ll long long
#define ini(arr, val) memset(arr, (val), sizeof(arr))
#define loop(i,n)  for(ll i=0; i<n; i++)
#define loop1(i,n)  for(ll i=1; i<=n; i++)

#define all(a)      (a).begin(),(a).end()
#define exist(s,e)  (s.find(e)!=s.end())
#define dbg(x)  cout << #x << " = " << x << endl
#define pt(x) cout<<x<<"\n"
#define pts(x) cout<<x<<" "

#define mp make_pair
#define pb push_back
#define F first
#define S second


#define inf (int)2e9
#define infll 1e18
#define eps 1e-9
#define PI 3.1415926535897932384626433832795
#define mod 1000000007


#define fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define test   int t; cin>>t; while(t--)

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef map<int,int> mii;
typedef set<int> si;

typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<pll> vpll;
typedef vector<vl> vvl;
typedef map<ll,ll> mll;
typedef set<ll> sl;


int dirx[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
int diry[] = { -1, 0, 1, -1, 1, -1, 0, 1 };



//===========================DEBUG======================//
#define XOX 1
vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

//================================================================//



//////////////////////////////////////////////////////////////////////////////////////////
//                      main starts
//////////////////////////////////////////////////////////////////////////////////////////
int const lmt=1e5+5;


int main(){
    #ifndef ONLINE_JUDGE
    freopen("../input.txt", "r", stdin);
    freopen("../output.txt", "w", stdout);
	#endif
    fast

    string a,b; cin>>a>>b;
    int n = a.length();
    int m = b.length();
    int dp[n+1][m+1];

    loop(i,n+1){
    	loop(j,m+1){
    		int &ret = dp[i][j];
    		if(i==0 || j==0) ret = 0;
    		else if(a[i-1]==b[j-1]){
    			ret = dp[i-1][j-1]+1;
    		}else{
    			ret = max(dp[i-1][j], dp[i][j-1]);
    		}
    	}
    }
    int ix=n,jx=m;
    string ans="";
    while(ix>=1 && jx>=1){
    	if(a[ix-1]==b[jx-1]){
    		ans += a[ix-1];
    		ix--; jx--; continue;
    	} 
    	if(dp[ix-1][jx]>dp[ix][jx-1])ix--;
    	else jx--;
    }
    reverse(all(ans));
    pt(ans);
}


/*


*/





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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int inf = 1LL<<60;
const int mod = 1e9 + 7;
const double eps = 1e-9;

/*{
}*/

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

  if(a < b) swap(a, b);
  int ans = a;
  a--;

  ans += max(a, b);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
<?php
fscanf(STDIN, '%d %d %d %d', $x, $y, $z, $k);
$a = array_map('intval', explode(' ', trim(fgets(STDIN))));
$b = array_map('intval', explode(' ', trim(fgets(STDIN))));
$c = array_map('intval', explode(' ', trim(fgets(STDIN))));

rsort($a);
rsort($b);
rsort($c);

$q = new SplPriorityQueue;
$q->insert([$a[0] + $b[0] +$c[0], 0 , 0, 0], $a[0] + $b[0] +$c[0]);
for ($i = 0; $i < $k; $i++) {
    list($max, $ai, $bi, $ci) = $q->extract();
    echo $max . PHP_EOL;
    addQueue($ai + 1, $bi, $ci);
    addQueue($ai, $bi + 1, $ci);
    addQueue($ai, $bi, $ci + 1);
}

function addQueue($ai, $bi, $ci) {
    global $a, $b, $c, $q;
    static $added;

    if (isset($added[$ai][$bi][$ci])) return;
    if (!isset($a[$ai]) || !isset($b[$bi]) || !isset($c[$ci])) return;

    $q->insert([$a[$ai] + $b[$bi] + $c[$ci], $ai, $bi, $ci], $a[$ai] + $b[$bi] + $c[$ci]);
    $added[$ai][$bi][$ci] = true;
}

Measured memory_bytes: 8696
#include <iostream>
#include <vector>
#include <numeric>
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    cout << accumulate(a.begin(), a.end(), 0)-n << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#define begin 17*60+30
#define end 19*60+30
int main(void){
  int x[8][8];

  x[1][2]=300;
  x[1][3]=500;
  x[1][4]=600;
  x[1][5]=700;
  x[1][6]=1350;
  x[1][7]=1650;
  x[2][1]=6;
  x[2][3]=350;
  x[2][4]=450;
  x[2][5]=600;
  x[2][6]=1150;  
  x[2][7]=1500;
  x[3][1]=13;
  x[3][2]=7;
  x[3][4]=250;
  x[3][5]=400;
  x[3][6]=1000;
  x[3][7]=1350;
  x[4][1]=18;
  x[4][2]=12;
  x[4][3]=5;
  x[4][5]=250;
  x[4][6]=850;
  x[4][7]=1300;
  x[5][1]=23;
  x[5][2]=17;
  x[5][3]=10;
  x[5][4]=5;
  x[5][6]=600;
  x[5][7]=1150;
  x[6][1]=43;
  x[6][2]=37;
  x[6][3]=30;
  x[6][4]=25;
  x[6][5]=20;
  x[6][7]=500;
  x[7][1]=58;
  x[7][2]=52;
  x[7][3]=45;
  x[7][4]=40;
  x[7][5]=35;
  x[7][6]=15;
  
  int v,y,a,b,h,m,val;

  while(1){
    scanf("%d",&v);
    if(v==0)break;
    scanf("%d %d %d %d %d",&a,&b,&y,&h,&m);

    if(((begin<=a*60+b && a*60+b<=end )||(begin<=h*60+m && h*60+m<=end))&&x[y][v]<=40){
      val=x[v][y]/2;
      if(val%100!=0){
	if(val%100<50){
	val=val/100;
	val=val*100+50;
	}
	else if(val%100>50){
	  val=val/100;
	  val=val*100+100;
	}
      }
      printf("%d\n",val);
	}
      else printf("%d\n",x[v][y]);
}

  return 0;
}

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

int N,M;
int G[20][20],U[110],V[110],W[110];
int Sum[(1<<15)+5],F[(1<<15)+5][20];

int main(){
	int i,j,k,s;
	scanf("%d%d",&N,&M);
	for(i=1;i<=M;i++){
		scanf("%d%d%d",&U[i],&V[i],&W[i]);
		U[i]--,V[i]--;
		G[U[i]][V[i]]=G[V[i]][U[i]]=W[i];
	}
	for(i=0;i<1<<N;i++)
		for(j=1;j<=M;j++)
			if(i>>U[j]&1&&i>>V[j]&1)
				Sum[i]+=W[j];
	memset(F,-0x3f,sizeof(F));
	F[1][0]=0;
	for(i=1;i<1<<N;i++)
		for(j=0;j<N;j++)
			if(F[i][j]>=0){
				s=(1<<N)-1-i;
				for(k=s;k;k=(k-1)&s)
					F[i|k][j]=max(F[i|k][j],F[i][j]+Sum[k|1<<j]);
				if(~i>>N-1&1)
					for(k=0;k<N;k++)
						if(~i>>k&1&&G[j][k])
							F[i|1<<k][k]=max(F[i|1<<k][k],F[i][j]+G[j][k]);
			}
	printf("%d\n",Sum[(1<<N)-1]-F[(1<<N)-1][N-1]);
	return 0;
}

Measured memory_bytes: 2944
s = input()
t = input()
ls, lt = len(s), len(t)
res = 5000
for i in range(ls - lt + 1):
  temp = 0
  for j in range(lt):
    if s[j + i] != t[j]:
      temp += 1
  res = min(res, temp)
print(res)

Measured memory_bytes: 9052
/* prime_table.cpp
    エラトステネスの篩で素数かどうかの情報を保存
*/
#include <bits/stdc++.h>
using namespace std;

/*  prime_table(n)
    入力：整数 n
    出力：nまでの数字が素数か判定したテーブル
    計算量：O(nloglogn)
*/
vector<bool> prime_table(int n) {
    vector<bool> prime(n + 1, true);
    if (n >= 0) prime[0] = false;
    if (n >= 1) prime[1] = false;
    for (int i = 2; i * i <= n; i++) {
        if (!prime[i]) continue;
        for (int j = i * i; j <= n; j += i) {
            prime[j] = false;
        }
    }
    return prime;
}

int main() {
    vector<bool> p_table = prime_table(2000000);
    int N;
    while (cin >> N) {
        if (N == 0) break;
        int pre = N, next = N;
        while (!p_table[pre]) pre--;
        while (!p_table[next]) next++;
        cout << next - pre << endl;
    }
}



Measured memory_bytes: 3020
loop do
	t = gets
	if t == nil
		break
	end
	c = t.split(",").map{|i| i.to_i}.sort()
	
	if (c[0] == c[1] or c[3] == c[4]) and c[1] == c[2] and c[2] == c[3]
		puts "four card"
	elsif c[0] == c[1] and c[1]==c[2] and c[3] == c[4]
		puts "full house"
	elsif c[0] == c[1] and c[2]==c[3] and c[3] == c[4]
		puts "full house"
	elsif c[0]+1==c[1] and c[1]+1==c[2] and c[2]+1==c[3] and c[3]+1==c[4]
		puts "straight"
	elsif c[0] == 1 and c[1] == 10 and c[2] == 11 and c[3] == 12 and c[4] == 13
		puts "straight"
	elsif (c[0] == c[1] and c[1] == c[2]) or (c[1] == c[2] and c[2] == c[3]) or (c[2] == c[3] and c[3] == c[4])
		puts "three card"
	elsif c.uniq.size == 3
		puts "two pair"
	elsif c.uniq.size == 4
		puts "one pair"
	else
		puts "null"
	end
end

Measured memory_bytes: 6132
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		 // ?¨??????\???????????????????????????????????????
		 Scanner sc = new Scanner(System.in);
		 int w = sc.nextInt();
		 int n = sc.nextInt();
		 int[] values = new int[w];
		 for (int i = 0; i < values.length; i++) {
			 values[i] = i + 1;
		 }
		 for (int i = 0; i < n; i++) {
			String str = sc.next();
		 	String[] ab = str.split(",");
		 	int a = Integer.parseInt(ab[0]) - 1;
		 	int b = Integer.parseInt(ab[1]) - 1;
		 // a??¨b????????£???values??????????????????
		 	int buffer;
		 	buffer=values[a];
		 	values[a]=values[b];
		 	values[b]=buffer;
		 }
		 // values??????????????????
		 for(int i=0;i<n;i++){
			 System.out.println(values[i]);
		 }
	}
}

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

#define MIN(x, y) ((x) < (y) ? (x) : (y))
#define MAX(x, y) ((x) > (y) ? (x) : (y))

#define DIVUP(x, y) (((x) + ((y) - 1)) / (y))
#define DIVOFF(x, y) (((x) + ((y) / 2)) / (y))
#define REMAINDER(x, y) ((x) % (y))

int E[300000]{};
int W[300000]{};

int main() {
  int N; cin >> N;
  string S; cin >> S;
  E[0] = S[0] != 'E' ? 1 : 0;
  W[N - 1] = S[N - 1] != 'W' ? 1 : 0;
  for (int i{1}; i < N; ++i) {
    E[i] = E[i - 1] + (S[i] != 'E' ? 1 : 0);
    W[N - 1 - i] = W[N - i] + (S[N - 1 - i] != 'W' ? 1 : 0);
  }
  int min{300000};
  for (int i{0}; i < N; ++i) {
    int temp = E[i] + W[i] - 1;
    if (min > temp) min = temp;
  }

  cout << min << "\n";
  return 0;
}


Measured memory_bytes: 2948
#include <iostream>
#include <vector>
#include <tuple>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <string>
#include <climits>
#include <map>
#include <set>
#include <queue>
using namespace std;
#define Rep(i, n) for (int i = 0; i < (n); ++i)
#define InitRep(i, begin, n) for (int i = (begin); i < (n); ++i)
#define RepItr(it, begin, end) for (auto it = (begin); it != (end); ++it)
using int64 = long long;
using vint = vector<int>;
using vint64 = vector<int64>;
const static double PI = ::acos(-1);


int main()
{
    string s;
    cin >> s;
    int n = s.size() + 1;
    queue<int> section;

    char prev = '<';
    int count = 0;
    Rep(i, n - 1)
    {
        if (s[i] == prev)
        {
            ++count;
        }
        else
        {
            section.push(count);
            prev = s[i];
            count = 1;
        }
    }
    section.push(count);

    int64 sum = 0;
    while (!section.empty())
    {
        int l = section.front();
        section.pop();
        int r;
        if (!section.empty())
        {
            r = section.front();
            section.pop();
        }
        else
        {
            r = 0;
        }
        for (int i = 1; i < l; ++i)
        {
            sum += i;
        }
        sum += max(l, r);
        for (int j = r - 1; j > 0; --j)
        {
            sum += j;
        }
    }
    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 1796
#include<stdio.h>
int main(void){
int x,a,b,da,db;
scanf("%d %d %d",&x,&a,&b);
da=x-a;
db=x-b;
if(da<0) da=-da;
if(db<0) db=-db;
if(da<db) printf("A");
else printf("B");
return 0;
}

Measured memory_bytes: 128
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

int main() {
    fastio();

    string s;
    cin >> s;

    int total = 0;
    for (auto c : s) {
        total += c - '0';
    }

    cout << (total % 9 ? "No" : "Yes") << endl;

    return 0;
}

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

N=int(input())
A = list(map(int, input().split()))

def bubbleSort(N):
    Flag=True
    count=0
    while Flag:
        Flag=False
        for j in reversed(range(1,N)):
            if A[j] < A[j-1]:
                A[j],A[j-1] = A[j-1],A[j]
                Flag=True
                count+=1
    print(*A)
    print(count)
bubbleSort(N)


Measured memory_bytes: 5616
#include <iostream>

using namespace std;

int main() {
    int64_t n, r_min, d_max = 1 - 1000000000;

    cin >> n >> r_min;

    for (int64_t i = 1; i < n; i++) {
        int64_t r;
        cin >> r;

        if (d_max < (r - r_min)) {
            d_max = r - r_min;
        }

        if (r < r_min) {
            r_min = r;
        }
    }

    cout << d_max << endl;

    return 0;
}

Measured memory_bytes: 3092
S = input()[::-1]

cnts = [0]*2019
cnts[0] = 1
num = 0
d = 1
ans = 0

for i in S:
    num += int(i) * d
    d *= 10
    num %= 2019
    d %= 2019
    cnts[num] += 1

for j in cnts:
    ans += j * (j-1) // 2 

print(ans)

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

pair<long long, long long> solve( int h, int w ) {
    if( h % 2 == 0 || w % 2 == 0 )
        return make_pair( 1LL * h * w / 2, 1LL * h * w / 2 );
    
    if( w < h )
        swap( w, h );
    
    return make_pair( 1LL * h * (w / 2), 1LL * h * (w / 2 + 1) );
}

int main( void ) {
    
    int h, w;
    cin >> h >> w;
    
    long long ans = 1e18;
    for( int i = 1; i < h; i ++ ) {
        pair<long long, long long> arr = solve( h - i, w );
        
        arr.first  = min( arr.first , 1LL * i * w );
        arr.second = max( arr.second, 1LL * i * w );
        
        ans = min( ans, arr.second - arr.first );
    }
    
    swap( h, w );
    
    for( int i = 1; i < h; i ++ ) {
        pair<long long, long long> arr = solve( h - i, w );
        
        arr.first  = min( arr.first , 1LL * i * w );
        arr.second = max( arr.second, 1LL * i * w );
        
        ans = min( ans, arr.second - arr.first );
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};
/**
 * snuke code
**/
fn main() {
    input! {
            h:usize,
            w:usize,
            k:usize,
        s:[Chars;h],
    }
    dbg!(&s);
    let mut ans = INF;
    // 横に切る方法を全探索
    for div in 0..(1usize << (h - 1)) {
        let mut g: usize = 0;
        let mut id = vec![0usize; h + 1];
        for i in 0..h {
            id[i] = g;
            if (((div >> i) & 1) == 1) {
                g += 1;
            }
        }
        g += 1;
        let mut c = vec![vec![0usize; w]; g];
        for i in 0..h {
            for j in 0..w {
                c[id[i]][j] += (s[i][j] as u8 - b'0') as usize;
            }
        }

        // dbg!(&c);
        let mut num: usize = g - 1;
        // 各グループで何個のホワイトチョコがあるか
        let mut now = vec![0usize; g];
        for j in 0..w {
            if !add(&mut now, j, g, k, &c) {
                num += 1;
                now = vec![0usize; g];
                if !add(&mut now, j, g, k, &c) {
                    num = INF;
                    break;
                }
            }
        }
        ans = min(ans, num);
    }
    println!("{}", ans);
}
// j列目をnowに加算
fn add(now: &mut Vec<usize>, j: usize, g: usize, k: usize, c: &Vec<Vec<usize>>) -> bool {
    for i in 0..g {
        now[i] += c[i][j];
    }
    for i in 0..g {
        if now[i] > k {
            return false;
        }
    }
    return true;
}
const INF: usize = 1 << 62;

pub fn charconv(c: char, base: char) -> usize {
    return (c as u8 - base as u8) as usize;
}


Measured memory_bytes: 2280
#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 << "Left" << endl;
  }
  if (a + b == c + d){
    cout << "Balanced" << endl;
  }
   
  if (a + b < c + d){
    cout << "Right" << endl;
  }
}

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


int main(){
int n;
cin >> n;
vector <int> w(n);
rep(i,n) cin >> w[i];
int count1=0, count2=0;
int cnt = 0;

rep(i,n) count1 += w[i]; 
int minimum = 10000;
rep(i,n-1){
    cnt += w[i];
    minimum = min(minimum, abs(count1-cnt*2));
}
cout << minimum <<endl; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define MOD 1000000007
typedef long long int ll;
using namespace std;
using Graph = vector<vector<int> >;

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int N;
cin>>N;
cout<<pow(N,3)<<endl;
//system("pause");
return 0;
}

Measured memory_bytes: 256
from collections import deque

n,q = map(int,input().split())
a = deque(list(input().split()) for _ in range(n))
total = 0

while a:
    b = a.popleft()
    b[1] = int(b[1])
    if b[1] > q:
        b[1] -= q
        a.append(b)
        total += q
    else:
        total += b[1]
        b[1] = total
        print(*b)
        





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

// repetition
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

// container util
#define all(x) (x).begin(), (x).end()

// typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

// const value
// const ll MOD = 1e9 + 7;
// const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
// const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

// conversion
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
inline ll toLL(string s) {
  ll v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T> inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {
  return a < b && (a = b, true);
}

template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {
  return a > b && (a = b, true);
}
ll h, w, k;
int check(VI &b, VI &v, VVI &cut) {
  VI vv(v.size(), 0);
  rep(i, cut.size()) {
    for(int x : cut[i]) {
      vv[i] += b[x];
    }
  }
  rep(i, v.size()) {
    if(vv[i] > k)
      return -1;
  }

  rep(i, cut.size()) {
    if(vv[i] + v[i] > k) {
      rep(j, v.size()) v[j] = vv[j];
      return 1;
    } else {
      v[i] += vv[i];
    }
  }
  return 0;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> h >> w >> k;
  string board[h];
  rep(i, h) cin >> board[i];

  VVI b(w, VI(h, 0));

  rep(j, w) rep(i, h) { b[j][i] = board[i][j] - '0'; }

  ll ans = 100000000;
  rep(bit, 1ll << (h - 1)) {
    int cnt = __builtin_popcount(bit);
    VI v(cnt + 1, 0);
    VVI cut(cnt + 1);
    int idx = 0;
    rep(i, h - 1) {
      cut[idx].push_back(i);
      if((bit >> i) & 1)
        idx++;
    }
    cut[idx].push_back(h - 1);
    ll sum = 0;
    ll tmp2 = check(b[0], v, cut);
    if(tmp2 == -1) {
      continue;
    }

    FOR(i, 1, w) {
      ll tmp = check(b[i], v, cut);
      if(tmp == -1) {
        sum = 10000000;
        break;
      }

      sum += tmp;
    }
    chmin(ans, sum + cnt);
  }

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


Measured memory_bytes: 384
s = list(input())

a = list("dream")
b = list("dreamer")
c = list("erase")
d = list("eraser")
flag = 0

while(flag == 0):
    if s[-7:] == b:
        del s[-7:]
    elif s[-6:] == d:
        del s[-6:]
    elif s[-5:] == a or s[-5:] == c:
        del s[-5:]
    elif s == []:
        print("YES")
        flag = 1
    else:
        print("NO")
        flag = 1

Measured memory_bytes: 9836
let rec make_list n f =
    if n = 0 then []
    else let e = f () in e :: make_list (n - 1) f

let () =
    let n, x =
        read_line ()
        |> (fun line -> Scanf.sscanf line "%d %d" (fun a b -> a, b))
    in
    let m = make_list n read_int in
    let min :: _ = List.sort compare m in
    let sum = List.fold_left (+) 0 m in
    Printf.printf "%d\n" (n + (x - sum) / min)


Measured memory_bytes: 384
//include,using,define等
#pragma region header
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
#include <cstring>

// ===============================================================
//using系
#pragma region header
using namespace std;
using ll = long long;
using lint = long long;
using vl = vector<long long>;
using vvl = vector<vector<long long>>;
using vvi = vector<vector<int>>;
using vs = vector<string>;
using vc = vector<char>;
using vcc = vector<vector<char>>;
using vm = vector<short>;
using vmm = vector<vector<short>>;
using pii = pair<int, int>;
using psi = pair<string, int>;
using ld = long double;
using ull = unsigned long long;
using ui = unsigned int;
using qul = queue<ll>;
using pql = priority_queue<ll>;
const int dx[] = { 1,0,-1,0 };
const int dy[] = { 0,1,0,-1 };
constexpr ll mod = 1e9 + 7;
constexpr long double pi = 3.141592653589793238462643383279;
#pragma endregion
// ========================================================================
//define
#pragma region header
//#define int long long
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i <= n; i++)
#define INF (ll)10000000000000000
#define mod (ll)1000000007
#define P pair<lint,lint>
template <class T>
bool chmax(T & a, const T & b) {
	if (a < b) {
		a = b;  // aをbで更新
		return true;
	}
	return false;
}
template <class T>
bool chmin(T& a, const T& b) {
	if (a > b) {
		a = b;  // aをbで更新
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion



int main(void) {
	string s; cin >> s;
	if (s.size() == 2)
		printf("%s", s.c_str());
	else
		for (int i = 2; i >= 0; i--)
			printf("%c", s[i]);
	printf("\n");

	return 0;
}

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

typedef long long int ll;
const ll MAX = 1e3+4;
const ll MOD = 1e9+7;
ll dp[MAX][MAX];
ll h,w;

int main()
{
    cin>>h>>w;
    
    for(int i=1;i<=h;i++)
    {
        string s;
        cin>>s;
        for(int j=1;j<=w;j++)
        {
            if(s[j-1] == '#')
                dp[i][j]=-1;
    
        }
    }
    dp[1][1]=1;
    for(int j=1;j<=w;j++)
    {
        if(dp[1][j]==-1)
            break;
        dp[1][j]=1;    
    }
    for(int j=1;j<=h;j++)
    {
        if(dp[j][1]==-1)
            break;
        dp[j][1]=1;    
    }
    for(int i=2;i<=h;i++)
    {
        for(int j=2;j<=w;j++)
        {
            if(dp[i][j]==-1)
                continue;
            if(dp[i-1][j]!=-1)
                dp[i][j]=((dp[i][j]%MOD)+(dp[i-1][j]%MOD))%MOD;
            if(dp[i][j-1]!=-1)
                dp[i][j]=((dp[i][j]%MOD)+(dp[i][j-1]%MOD))%MOD;
            dp[i][j]%=MOD;    
        }
    }
    cout<<dp[h][w]<<endl;
}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
#define int long long

using namespace std;

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  if (n == 1) {
    cout << 0 << '\n';
  } else {
    cout << (n % k == 0 ? 0 : 1) << '\n';
  }
  return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
g=[[] for _ in range(n)]
for _ in range(m):
    a,b,c=map(int,input().split())
    g[a-1].append([b-1,-c])

def bellman_ford(g,n):
    INF = 10**15
    res = [INF for _ in range(n)]
    res[0] = 0
    for _ in range(n-1):
        for i in range(n):
            for sa,sb in g[i]:
                res[sa] = min(res[sa],res[i]+sb)
    f = [False for _ in range(n)]
    for _ in range(n+1):
        for i in range(n):
            for sa,sb in g[i]:
                if res[sa] > res[i]+sb:
                    res[sa] = res[i]+sb
                    f[sa] = True
    if f[-1]: return "inf"
    else:return res[-1]*-1

print(bellman_ford(g,n))

Measured memory_bytes: 48216
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
#define MAX 1000
int lcs(string X, string Y) {
	int c[MAX + 1][MAX + 1];
	int m = X.size();
	int n = Y.size();
	int maxl = 0;
	X = ' ' + X;
	Y = ' ' + Y;
	for (int i = 0; i <= m; i++) c[i][0] = 0;
	for (int j = 1; j <= n; j++) c[0][j] = 0;
	for (int i = 1; i <= m; i++) {
		for (int j = 1; j <= n; j++) {
			if (X[i] == Y[j]) c[i][j] = c[i - 1][j - 1] + 1;
			else c[i][j] = max(c[i - 1][j], c[i][j - 1]);
			maxl = max(maxl, c[i][j]);
		}
	}
	return maxl;
}
int main() {
	int n;
	string a, b;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a >> b;
		cout << lcs(a, b) << endl;
	}
	return 0;
}


Measured memory_bytes: 7104
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 1LL << 60;

int main(){
    ll N, M, K; cin >> N >> M >> K;
    vector<ll> a(N), b(M);
    rep(i, N) cin >> a[i];
    rep(i, M) cin >> b[i];
    
    vector<ll> sumA(N + 1, 0), sumB(M + 1, 0);
    for(int i = 1; i <= N; i++){
        sumA[i] = sumA[i - 1] + a[i - 1];
    }
    for(int i = 1; i <= M; i++){
        sumB[i] = sumB[i - 1] + b[i - 1];
    }    
    ll ans = 0;
    rep(i, N + 1){
        if(sumA[i] > K) break;
        int last = K - sumA[i];
        auto itr = upper_bound(all(sumB), last);
        ans = max(ans, (ll)(i + itr - sumB.begin() - 1));
    }

    cout << ans << endl;
}

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

#define vi vector<int>
#define pb push_back

int main(){

    int a,b,c;
    cin >> a >> b >> c;
    vi m;
    string ans = "NO";
    REP(i,1,b + 1) if(i * a % b == c) ans = "YES";
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import kotlin.math.max
import kotlin.math.min

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

fun solve() {
    // いつかループする
    val (n, k) = readIntegerList()
    val pList = readIntegerList().map { it - 1 }
    val cList = readLongList()

    var ans = Long.MIN_VALUE
    for (i in pList.indices) {
        val loopPointList = mutableListOf<Long>()
        var loopScore = 0L
        var currentIndex = i
        while (true) {
            val next = pList[currentIndex]
            loopPointList.add(cList[next])
            loopScore += cList[next]
            currentIndex = next

            if (next == i) break
        }

        if (loopScore <= 0) {
            val loopCount = min(k, loopPointList.size)
            var score = 0L
            repeat(loopCount) {
                score += loopPointList[it]
                ans = max(ans, score)
            }
        } else {
            // できるだけsumを足す
            val loopCount = k / loopPointList.size - 1
            var score = loopScore * loopCount

            ans = max(ans, score)

            // 余った回数はシミュレート
            val remainLoopCount = k % loopPointList.size + loopPointList.size
            repeat(remainLoopCount) {
                score += loopPointList[it % loopPointList.size]
                ans = max(ans, score)
            }
        }
    }

    out.println(ans)
}

fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)


Measured memory_bytes: 57352
#include <bits/stdc++.h>
#include <vector>
#define ll long long
#define pb push_back
#define f first
#define s second
#define fast ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;


int main(){
    ll n, d; cin >> n >> d;
    pair<long long, long long> a[n];
    for(int i = 0; i < n; i++){
        cin >> a[i].first >> a[i].second;
    }
    int cnt = 0;
    for(int i = 0; i < n; i++){
        long long now = a[i].first * a[i].first + a[i].second * a[i].second;
        if(now <= d * d)cnt++;
    }
    cout << cnt << endl;
}


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


int main() {
    ll a;
    double b;
    cin >> a >> b;
    ll ib = b*100+0.5; //bを整数にしたいのだが誤差がでるため+0.5
    a *= ib;
    a /= 100;
    printf("%lld\n", a);
    return 0;
}

Measured memory_bytes: 3788
x1,y1,x2,y2 = list(map(int, input().split()))
dif = x2-x1
dif2 = y2-y1
l = [x2 - dif2, y2 + dif, x1 - dif2, y1 + dif]
ll = [str(i) for i in l]
print(" ".join(ll))

Measured memory_bytes: 3060
/// Rustで競技プログラミングの入力をスッキリ記述するマクロ
///
/// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[inline]
#[allow(dead_code)]
fn gcd(mut m: u64, mut n: u64) -> u64 {
    if m < n {
        std::mem::swap(&mut m, &mut n);
    }

    loop {
        let k = m % n;
        if k == 0 {
            return n;
        }

        m = n;
        n = k;
    }
}

#[inline]
#[allow(dead_code)]
fn lcm(m: u64, n: u64) -> u64 {
    m / gcd(m, n) * n
}

macro_rules! eprint(
    ($($arg:tt)*) => { {
        use std::io::Write;
        let r = write!(&mut ::std::io::stderr(), $($arg)*);
        r.expect("failed printing to stderr");
    } }
);

macro_rules! eprintln(
    ($($arg:tt)*) => { {
        use std::io::Write;
        let r = writeln!(&mut ::std::io::stderr(), $($arg)*);
        r.expect("failed printing to stderr");
    } }
);

macro_rules! dbg {
    ($val:expr) => {
        // Use of `match` here is intentional because it affects the lifetimes
        // of temporaries - https://stackoverflow.com/a/48732525/1063961
        match $val {
            tmp => {
                eprintln!(
                    "[{}:{}] {} = {:#?}",
                    file!(),
                    line!(),
                    stringify!($val),
                    &tmp
                );
                tmp
            }
        }
    };
}

fn main() {
    input! {
        x: i64,
        y: i64,
    }

    let answer = (x.abs() - y.abs()).abs()
        + if (x >= 0 && x <= y) || (y <= 0 && x <= y) {
            0
        } else if (x >= 0 && y <= 0) || (x < 0 && y > 0) {
            1
        } else {
            2
        };

    println!("{}", answer);
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <numeric>
#include <unordered_map>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <memory>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
long long MOD = 1e9 + 7;
constexpr ll INF = 1e17;
constexpr double PI = 3.141592653589793;


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

    int n;
    cin >> n;

    if (n == 1) {
        cout << 0 << endl;
        return 0;
    }

    if (n % 2 == 0) {
        cout << n / 2 - 1 << endl;
        return 0;
    }
    cout << (n + 1) / 2 - 1 << endl;

    return 0;
}

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

int main(){
  char a;
  char prev;
  int count = 1;
  int n; cin >> n;
  for (int i = 0; i < n; i++){
    cin >> a;
    // cout << "a: " << a <<endl;
    if (a == prev || i == 0){
      prev = a;
      continue;
    }else{
      // cout << i << endl;
      // cout << "a: " << a <<endl;
      // cout << "prev: " << prev <<endl;
      count += 1;
      prev = a;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int dfs(int x,int n,int s){
  
  if(n==0){
    return (s==0);
  }
    
  if(x==10)
    return 0;
  
  int res=0;
  
  for(int i=x;i<=9;++i){
    res+=dfs(i+1,n-1,s-i);
  }
  return res;
}

int main(){
  int n,s;

  while(cin>>n>>s,n!=0 || s!=0){
    cout<<dfs(0,n,s)<<endl;
  }
}

Measured memory_bytes: 2948