akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const long double PI = acos(-1.0L);
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  ll num[10][10] = {};
  for (int i = 1; i <= n; i++) {
    int r = i%10, l = i;
    while (l > 9)
      l /= 10;
    num[l][r]++;
  }
  ll ans = 0;
  for (int i = 1; i <= n; i++) {
    int r = i%10, l = i;
    while (l > 9)
      l /= 10;
    ans += num[r][l];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	
	public static void main(String[] args) throws IOException {
		Main mainObj = new Main();
		mainObj.solve();
	}

	public void solve() throws IOException {
		FastScanner fs = new FastScanner();
		int n = fs.nextInt();
		
		System.out.println((n-2)*180);
	}

	

	public class FastScanner {

		BufferedReader reader;
		private StringTokenizer st;

		public FastScanner() {
			st = null;
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			if (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(reader.readLine());
			}
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			st = null;
			String readLine = null;
			readLine = reader.readLine();
			return readLine;
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		public int[] nextIntArr(int n) throws NumberFormatException, IOException {
			int[] retArr = new int[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextInt();
			}
			return retArr;
		}

		public long[] nextLongArr(int n) throws NumberFormatException, IOException {
			long[] retArr = new long[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextLong();
			}
			return retArr;
		}

		public void close() throws IOException {
			reader.close();
		}
	}


}


Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i, n) for(int i = 0; i<(int)(n); i++)
ll int n,m;
ll int x[1001],y[1001],z[1001];
int main(){
    cin >> n >> m;
    REP(i, n){
    	cin >> x[i] >> y[i] >> z[i];
    }
    ll int ans = 0;
    REP(t, 8){
    	int a = ((1 & (t >> 2)) == 1) ? 1 : -1;
    	int b = ((1 & (t >> 1)) == 1) ? 1 : -1;
    	int c = ((1 & t) == 1) ? 1 : -1;
        vector<ll int> data;
    	REP(i, n){
    		data.push_back(a*x[i]+b*y[i]+c*z[i]);
    	}
    	sort(data.begin(), data.end());
    	ll int tmpans = 0;
    	REP(i, m){
    		tmpans += data[n-i-1];
    	}
    	ans = max(ans, tmpans);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define unless(flg) if ( !(flg) )
#define read cin<<
#define echo cout<<
#define fin <<'\n'
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
#define cinf(n,x) for(int UNCH=0;UNCH<(n);UNCH++) cin >> x[UNCH];
#define fcin(n,x) for(int UNCH=1;UNCH<=(n);UNCH++) cin>> x[UNCH];
#define memmin(x) memset((x),-1,sizeof((x)))
#define memzer(x) memset((x), 0,sizeof((x)))
#define meminf(x) memset((x),0x3f,sizeof((x)))
#define int long long
typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 1000000009;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>T abs(T &x){return x<0 ? -x : x;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}



signed main(){
  string str;
  int ans =0,flag=0;
  cin >> str;
  FOR(i,str.length()){
    if(str[i]=='W')
      ans+=flag;
    else
      flag++;
  }
  cout << ans fin; 
    
  return 0;
}



struct xyz{ xyz(){ cin.tie(0), ios::sync_with_stdio(false); cout <<fixed<<setprecision(12);};}xyzzy;



Measured memory_bytes: 720
<?php

class Scanner
{
    private $arr = [];
    private $count = 0;
    private $pointer = 0;

    public function next()
    {
        if ($this->pointer >= $this->count) {
            $str = trim(fgets(STDIN));
            $this->arr = explode(" ", $str);
            $this->count = count($this->arr);
            $this->pointer = 0;
        }
        $result = $this->arr[$this->pointer];
        $this->pointer++;
        return $result;
    }

    public function hasNext()
    {
        return $this->pointer < $this->count;
    }

    public function nextInt()
    {
        return (int)$this->next();
    }

    public function nextDouble()
    {
        return (double)$this->next();
    }
}

class out
{
    public static function printIn($str = "")
    {
        echo $str . PHP_EOL;
    }
}

$sc = new Scanner;

$s = $sc->next();
$s_arr = str_split($s);

for ($i = 0; $i < count($s_arr); $i++) {
  if ($i === 0 || $i % 2 === 0){
      echo $s_arr[$i];
  }
}


Measured memory_bytes: 10872
/**
 *    author:  tourist
 *    created: 20.05.2018 15:45:51       
**/
#include <bits/stdc++.h>

using namespace std;

string to_string(string s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

void debug_out() { cerr << endl; }

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

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

int md;

inline void add(int &a, int b) {
  a += b;
  if (a >= md) a -= md;
}

inline void sub(int &a, int b) {
  a -= b;
  if (a < 0) a += md;
}

inline int mul(int a, int b) {
#if !defined(_WIN32) || defined(_WIN64)
  return (int) ((long long) a * b % md);
#endif
  unsigned long long x = (long long) a * b;
  unsigned xh = (unsigned) (x >> 32), xl = (unsigned) x, d, m;
  asm(
    "divl %4; \n\t"
    : "=a" (d), "=d" (m)
    : "d" (xh), "a" (xl), "r" (md)
  );
  return m;
}

inline int power(int a, long long b) {
  int res = 1;
  while (b > 0) {
    if (b & 1) {
      res = mul(res, a);
    }
    a = mul(a, a);
    b >>= 1;
  }
  return res;
}

inline int inv(int a) {
  a %= md;
  if (a < 0) a += md;
  int b = md, u = 0, v = 1;
  while (a) {
    int t = b / a;
    b -= t * a; swap(a, b);
    u -= t * v; swap(u, v);
  }
  assert(b == 1);
  if (u < 0) u += md;
  return u;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k >> md;
  const int MAX = 333;
  vector< vector<int> > c(MAX, vector<int>(MAX));
  for (int i = 0; i < MAX; i++) {
    for (int j = 0; j < MAX; j++) {
      if (j == 0) c[i][j] = 1; else
      if (i == 0) c[i][j] = 0;
      else c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % md;
    }
  }
  vector<int> f(n + 1, 1);
  for (int t = k - 1; t >= 1; t--) {
    vector<int> g(n);
    for (int i = 0; i < n; i++) {
      g[i] = f[i];
    }
    for (int i = 0; i < n; i++) {
      for (int j = i + 1; j < n; j++) {
        add(g[j], mul(g[i], mul(f[j - i - 1], c[j][i + 1])));
      }
    }
    for (int i = n; i >= 1; i--) {
      for (int j = 0; j < i; j++) {
        add(f[i], mul(g[j], mul(f[i - j - 1], c[i][j + 1])));
      }
    }
  }
  cout << f[n] << '\n';
  return 0;
}


Measured memory_bytes: 768
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main(void){
	unsigned int N;
	int cls=0;	
	int blicknum=0;
	int scBlicknum=1;
	scanf("%d",&N);
	for(int m=0;m<N;m++){
		scanf("%d",&blicknum);
		if(blicknum==scBlicknum){
			scBlicknum++;
		}else{
			cls++;
		}
	} 
	if(cls==N){
		cls=-1;
	}
	printf("%d",cls);
}

Measured memory_bytes: 128
#include "iostream"
#include "vector"
#include "string"
#include "algorithm"
#include "math.h"
#include "cstring"
#include "stack"
#include "queue"
#include "cmath"
#include "set"

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

int main()
{
  int n, p;
  cin >> n >> p;
  string s;
  cin >> s;
  if (p != 2 && p != 5)
  {
    int a[n + 1];
    a[0] = 0;
    int ind = 1;
    for (int i = 1; i <= n; i++)
    {
      int b = s[n - i] - '0';
      a[i] = (a[i - 1] + (b * ind)) % p;
      ind *= 10;
      ind %= p;
    }
    sort(a, a + n + 1);

    ll ans = 0;
    ll check = 1;
    for (int i = 1; i <= n; i++)
    {
      if (a[i] == a[i - 1])
      {
        check++;
      }
      else
      {
        ans += check * (check - 1) / 2;
        check = 1;
      }
    }
    ans += check * (check - 1) / 2;
    cout << ans << "\n";
  }
  else
  {
    ll ans = 0;
    for (ll i = 0; i < n; i++)
    {
      ll b = s[i] - '0';
      if (b % p == 0)
      {
        ans += i + 1;
      }
    }
    cout << ans << "\n";
  }
}

Measured memory_bytes: 1284
#include<iostream>
#include<map>
#include<vector>
#include<string>
#include<cmath>
#define rep(i, n) for(int i=0; i<n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define rFOR(i, a, b) for(int i=b-1; i>=a; i--)
#define MAX 100
using namespace std;
typedef long long ll;

int main(void){
  while(true){
    int n, m, p; cin >> n >> m >> p;
    if(n+m+p==0)  break;
    int x[MAX], sum=0;
    rep(i, n) {
      cin >> x[i];
      sum += x[i]*100;
    }
    sum = sum * (100-p) /100;
    if(x[m-1]==0) cout << 0 << endl;
    else   {
      sum /= x[m-1];
      cout << sum << endl;
    }
  }
  return 0;
}



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

int main() {
    int n, b, f, r, v;
    cin >> n;
    int count[4][3][10];
    for (int i = 0;i < 4;i++){
        for (int j = 0;j < 3;j++){
            for (int k = 0;k < 10;k++){
                count[i][j][k] = 0;
            }
        }
    }
    
    for (int i = 0;i < n;i++){
        cin >> b >> f >> r >> v;
        count [b-1][f-1][r-1] += v;
    }
    
    for (int i = 0;i < 4;i++){
        for (int j = 0;j < 3;j++){
            for (int k = 0;k < 10;k++){
                cout << " " << count[i][j][k];
            }
            cout << "\n";
        }
        if(i != 3){
            for(int l = 0;l < 20;l++){
                cout << "#";
            }
            cout << endl;
        }
    }
    
    return 0;
}

Measured memory_bytes: 1160
#include <iostream>

using namespace std;

int main()
{

    int r = 0, g = 0, b = 0;
    cin >> r >> g >> b;

    int com = 100 * r + 10 * g + b;
    if (com % 4 == 0)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
a, b, m = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
xyc = [list(map(int, input().split())) for _ in range(m)]

ans = float('inf')

for x, y, c in xyc:
    ans = min(ans, a[x-1] + b[y-1] - c)

print(min(min(a) + min(b), ans))


Measured memory_bytes: 38568
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>

#define For(i, j, k) for(int i = j; i <= k; i++)
#define Forr(i, j, k) for(itn i = j; i >= k; i--)

using namespace std;

const int N = 2010;
const int Mod = 924844033;

typedef long long LL;

int n, k, A[N];
bool flag[N];
LL dp[N][N][2][2];

int main(){
	scanf("%d%d", &n, &k);
	dp[0][0][0][0] = 1;
	int o = 0;
	For(i, 0, n) flag[i] = true;
	For(i, 1, n % k) flag[o += n / k + 1] = false;
	while(o < n) flag[o += n / k] = false;
	For(i, 0, n)
		For(j, 0, i) For(u, 0, 1) For(v, 0, 1){
			LL val = dp[i][j][u][v];
			if(j) (dp[i + 1][j - 1][0][0] += val * (j - flag[i] * u) * (j - flag[i] * v)) %= Mod;
			(dp[i + 1][j][0][0] += val) %= Mod;
			(dp[i + 1][j][0][1] += val * (j - flag[i] * u)) %= Mod;
			(dp[i + 1][j][1][0] += val * (j - flag[i] * v)) %= Mod;
			(dp[i + 1][j + 1][1][1] += val) %= Mod;
		}
	printf("%lld\n", dp[n][0][0][0]);
	return 0;
}

Measured memory_bytes: 124160
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int cut(int k, int *a, int n, int u){
    int res = 0;
    if(!k)return 0;
    for(int i=0; i<n; ++i){
        res += (a[i] + k - 1) / k - 1;
    }
    //cout<<k<<" "<<res<<endl;
    return (res <= u) ? 1 : 0;
}

signed main(){
    int n, k, a[200200] = {0};
    cin>>n>>k;
    for(int i=0; i<n; ++i){
        cin>>a[i];
    }

    int l=-1, r=1000000001, m;
    while(l < r - 1){
        m = l + (r - l) / 2;
        if(cut(m, a, n, k)){
            r = m;
        }
        else{
            l = m;
        }
    }

    cout<<r<<endl;

    return 0;
}

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

int main()
{
	int n;
	cin>>n;
	int arr[n];
	for(int i=0;i<n;i++)
		cin>>arr[i];
	ll res=0;
	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			res+=arr[i]*arr[j];
		}
	}
	cout<<res<<endl;

	return 0;
}

Measured memory_bytes: 256
N = int(input())
S = input()
count =0
flg = 0
for s in S:
    if s == "A":
        flg = 1
    elif s == "B" and flg == 1:
        flg =2
    elif s =="C" and flg ==2 :
        count +=1
        flg =0
    else:
        flg = 0
print(count)

Measured memory_bytes: 2940
import sys
input = sys.stdin.readline
n = int(input())

ss = list(input())
s = []
for i in range(n):
    s.append(1<<(ord(ss[i])-97))

#####segfunc######
def segfunc(x,y):
    #print(x|y)
    return x | y

def init(init_val):
    #set_val
    for i in range(n):
        seg[i+num-1]=init_val[i]
    #built
    for i in range(num-2,-1,-1) :
        seg[i]=segfunc(seg[2*i+1],seg[2*i+2]) 
    
def update(k,x):
    k += num-1
    seg[k] = x
    while k:
        k = (k-1)//2
        seg[k] = segfunc(seg[k*2+1],seg[k*2+2])
    
def query(p,q,k,l,r):
    if r<=p or q<=l:
        return ide_ele
    if p<=l and r<=q:
        return seg[k]
    else:
        vl = query(p,q,k*2+1,l,(r+l)//2)
        vr = query(p,q,k*2+2,(l+r)//2,r)
        return segfunc(vl,vr)

#####単位元######
ide_ele = 0

#num:n以上の最小の2のべき乗
num =2**(n-1).bit_length()
seg=[ide_ele]*2*num
init(s)


def popcnt(n):
    c = (n & 0x5555555555555555) + ((n>>1) & 0x5555555555555555)
    c = (c & 0x3333333333333333) + ((c>>2) & 0x3333333333333333)
    c = (c & 0x0f0f0f0f0f0f0f0f) + ((c>>4) & 0x0f0f0f0f0f0f0f0f)
    c = (c & 0x00ff00ff00ff00ff) + ((c>>8) & 0x00ff00ff00ff00ff)
    c = (c & 0x0000ffff0000ffff) + ((c>>16) & 0x0000ffff0000ffff)
    c = (c & 0x00000000ffffffff) + ((c>>32) & 0x00000000ffffffff)
    return c

q = int(input())

for i in range(q):
    qq,xx,yy = map(str,input().split())
    if qq == '1':
        xx = int(xx)
        update(xx-1,1<<(ord(yy)-97))
    else:
        xx,yy = int(xx),int(yy)
        res = query(xx-1,yy,0,0,num)
        print(popcnt(res))


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

long long n;
vector<long long> a, b;

int main() {
  cin >> n;
  a.resize(n);
  for(int i = 0; i < n; ++i) {
    cin >> a[i];
    b.push_back(a[i]);
  }
  sort(b.begin(), b.end(), greater<long long>());
  for(int i = 0; i < n; ++i)
    if(a[i] == b[0])
      cout << b[1] << endl;
    else
      cout << b[0] << endl;
  return 0;
}

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

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

  int d[300000];
  for(int i=0; i<N; i++){
    cin >> d[i];
  }

  int D = 0;
  for(int i=0; i<N-1; i++){
    D = max(D, d[i]);

    if(D<10){
      cout << "no" << endl;
      return 0;
    }
    D -=10;
  }
  D = 0;
  for(int i=N-1; i>0; i--){
    D = max(D, d[i]);

    if(D<10){
      cout << "no" << endl;
      return 0;
    }
    D -=10;
  }
  cout << "yes" << endl;
  return 0;
}



Measured memory_bytes: 4264
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define All(v) (v).begin(),(v).end()
typedef long long ll;

int main(){
    int A,B,C,D,P;
    cin >> A >> B >> C >> D >> P;

    cout << min(A*P,B+max(0,P-C)*D) << endl;
    return 0;
}


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

typedef long long lli;

int n;
lli a[10000];

int main() {
  while(cin >> n && n) {
    assert(1LL <= n && n <= 10000LL);
    for(int i = 0; i < n; ++i) {
      cin >> a[i];
      assert(0LL <= a[i] && a[i] <= 60LL);
    }
    sort(a, a+n);
    lli res = 0;
    for(int i = 0; i < n; ++i) {
      res += a[i] * (n-i-1);
    }
    cout << res << endl;
  }
  return 0;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vvd = vector<vd>;
using vvvi = vector<vvi>;
using vvvll = vector<vvll>;
using vvvd = vector<vvd>;

const double pi=acos(-1);
const ll MOD=1e9+7;
const ll INF=(1LL<<60);

int cost[101][101];
int mincost[101];
int used[101];
int v;

int prim(){
    for (int i=0;i<v;i++){
        mincost[i]=1e9;
        used[i]=0;
    }
    mincost[0]=0;
    int res=0;
    while(1){
        int v1=-1;
        for (int u=0;u<v;u++){
            if (!used[u] && (v1==-1||mincost[u]<mincost[v1]))v1=u;
        }
        if (v1==-1)break;
        used[v1]=1;
        res+=mincost[v1];
        for (int u=0;u<v;u++)mincost[u]=min(mincost[u],cost[v1][u]);
    }
    return res;
}

int main() {
    cin>>v;
    rep(i,v){
        rep(j,v){
            cin>>cost[i][j];
            if (cost[i][j]==-1)cost[i][j]=1e8;
        }
    }
    int ans=0;
    ans=prim();
    cout<<ans<<endl;
    

    return 0;
}


Measured memory_bytes: 3100
#include<iostream>
using namespace std;
 
#define rep(i, n) for(i = 0;i < n;++i)
 
int main(void){
  int i, j;
  int n, m, t;
  cin >> n >> m >> t;
  int a[n + 2];
  a[0] = -m;
  rep(i, n)cin >> a[i + 1];
  a[n + 1] = t + m;
 
  int res = 0;
  rep(i, n + 1)res += max(a[i + 1] - a[i] - m - m, 0);
  cout << res << endl;
 
  return 0;
}

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

#define int long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end())
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint=vector<int>;
using vvint=vector<vint>;
using pint=pair<int, int>;
using vpint=vector<pint>;
template<typename T> using priority_queue_rev=priority_queue<T, vector<T>, greater<T>>;
constexpr double pi = 3.1415926535897932384626433832795028L;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

signed N, X, D;
map<int, vpint> mp;
signed main() {
    cin >> N >> X >> D;
    if (D == 0) {
        if (X == 0) { fin(1); }
        fin(N + 1);
    }
    for (int i = 0; i <= N; i++) {
        int l = X * i + D * i * (i - 1) / 2;
        int r = l + D * (N - i) * i;
        if (l > r) { swap(l, r); }
        int m = abs(X) * i % abs(D);
        mp[m].push_back({l, r});
    }
    dump(mp.size());
    int ans = 0;
    for (auto p:mp) {
        vpint v = p.second;
        sort(all(v));
        dump(v);
        pint prev = {LLONG_MIN, LLONG_MIN};
        rep(j, v.size()) {
            pint cur = v[j];
            if (prev.second < cur.first) {
                ans += (cur.second - cur.first) / abs(D) + 1;
            } else {
                ans += max(0LL, (cur.second - prev.second) / abs(D));
            }
            if (prev.second <= cur.second) { prev = cur; }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 22144
def main():
  k, n = map(int, input().split())
  dis = tuple(map(int, input().split()))

  diff = [dis[i + 1] - dis[i] for i in range(n - 1)]
  diff.append(k - dis[-1] + dis[0])

  max_dis = 0
  max_idx = 0
  for i, d in enumerate(diff):
    if d > max_dis:
      max_dis = d
      max_idx = i

  diff[max_idx] = 0

  print(sum(diff))

main()


Measured memory_bytes: 25840
n=int(input())
x=[[0 for i in range(26)] for j in range(n)]
for i in range(n):
    s=input()
    for j in range(len(s)):
        x[i][ord(s[j])-97]+=1
ans=[0]*26
for i in range(26):
    ans[i]=min(x[j][i] for j in range(n))
a=[]
for i in range(26):
    for j in range(ans[i]):
        a.append(chr(97+i))
print("".join(a))



Measured memory_bytes: 66136
# coding: utf-8
"""this is python work script"""
def solve(N, A, B):
    LIST_RESULT = []
    for i in range(1, N + 1):
        str_i = str(i)
        l = len(str_i)

        sum_tmp = 0
        for x in range(l):
            sum_tmp += int(str_i[x])
        if A <= sum_tmp and sum_tmp <= B:
            LIST_RESULT.append(i)
    sum_result = sum(LIST_RESULT)
    return sum_result

def main():
    N, A, B = list(map(int, input().rstrip().split(' ')))
    answer = solve(N, A, B)
    print(answer)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3292
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(ll i = b; i <= e; i++)
#define Repr(e, b, i) for(ll i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define uniq(x) (x).erase(unique(all(x)),(x).end())

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef std::priority_queue<int> IntPrioQueue; //Z->A
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue; //A->Z

const int MAX = 200000;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<31-1;
const int MOD = 1000000007;

void solve(void){
    ll N, Y;
    cin >> N >> Y;
    rep(Y/10000LL+1LL, z) {
        rep((Y-10000LL*z)/5000LL+1LL, y) {
            ll x = N - y - z;
            if (x < 0LL) continue;
            if (x * 1000LL + y * 5000LL + z * 10000LL == Y) {
                cout << z << ' ' << y << ' ' << x << endl;
                return;
            }
        }
    }
    cout << -1 << ' ' << -1 << ' ' << -1 << endl;
}

int main(void){
  solve();
  //cout << "yui(*-v・)yui" << endl;
  return 0;
}


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

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    rep(i, n) cin >> p[i];
    sort(p.begin(), p.end());
    int ans = 0;
    rep(i, k) ans += p[i];
    cout << ans << endl;
}

Measured memory_bytes: 3636
#include<stdio.h>
#define swap(X,Y) {int Z; Z = Y; Y = X; X = Z;}

int main (void)
{
	int a, i = 1;
	
	while(1)
	{
		scanf("%d", &a);
		if(a == 0)
		{
			break;
		}
		
		printf("Case %d: %d\n", i++, a);
	}
	return 0;
}



Measured memory_bytes: 2032
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<iomanip>

using namespace std;
using ll = long long;
using P = pair<int, int>;

const int MOD = 1e9 + 7;
const int MAX = 1e9;
const ll LLMAX = 1e18;
const int INF = numeric_limits<int>::max();
const ll LLINF = numeric_limits<ll>::max();
const double PI = acos(-1.0);

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

int main() {
    int A, B; cin >> A >> B;

    int sum = A + B;

    if (sum >= 10) cout << "error" << endl;
    else cout << sum << endl;
    return 0;
}


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

/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}

int main() {
	long long int N,H;
	cin >> N >> H;
	vector<int> a1;
	vector<int> b1;
	long long int maxa = 0;
	long long int maxb = 0;
	long long int maxhitb = 0;
	long long int count = 0;
	for (int i = 0; i < N; i++) {
		int a, b;
		cin >> a >> b;
		if (a > maxa) {
			maxa = a;
			maxb = b;
		}
		else if (a == maxa) {
			if (b < maxb) {
				maxb = b;
			}
		}
		a1.push_back(a);
		b1.push_back(b);
	}
	sort(b1.begin(), b1.end(),greater<int>());
	sort(a1.begin(), a1.end());
	for (int i = 0; i < N; i++) {
		if (b1[i] >= maxa) {
			maxhitb = maxhitb + b1[i];
		}
	} 
	for (int i = 0; i < N; i++) {
		if (maxa <= b1[i]) {
			H = H - b1[i];
			count++;
		}
		if (H <= 0) {
			cout << i + 1;
			return 0;
		}
	}
	cout << count  +(H+(maxa-1))/ maxa;
}

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

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

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    int n;
    string s;
    cin >> s;
    REP(i,s.length()-1){
        if (s.substr(i,2) == "AC") {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
stdt = []
chpt = []
for _ in range(N):
    a, b = map(int, input().split())
    stdt.append((a, b))
for _ in range(M):
    a, b = map(int, input().split())
    chpt.append((a, b))

for s in stdt:
    a, b, = s[0], s[1]
    m = 100000000000000
    i = 0
    for j in range(M):
        d = abs(a - chpt[j][0]) + abs(b - chpt[j][1])
        if m > d:
            m = d
            i = j + 1
    print(i)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long 
#define ld long double
#define X first
#define Y second
#define pb push_back
#define max_el(x) max_element(x.begin(),x.end())-x.begin()
#define min_el(x) min_element(x.begin(),x.end())-x.begin()
#define mp make_pair
#define endl '\n'
#define fastread ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
// DONT USE MEMSET, USE VECTORS

int g[20][20]={0};

void solve(){
	int n,m;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int u,v;
		cin>>u>>v;
		g[u][v] = 1;
		g[v][u] = 1;
	}

	vector<int> a;
	for(int i=1;i<=n;i++){
		a.pb(i);
	}

	int ans = 0;
	do{
		bool fg = 0;
		for(int i=1;i<n;i++){
			if(!g[a[i]][a[i-1]]){
				// cout<<a[i]<<" "<<a[i-1]<<endl;
				fg = 1;
				break;
			}
		}
		if(!fg){
			ans += 1;
		}

	}while(next_permutation(a.begin()+1, a.end()));
	cout<<ans<<endl;
}

int main(){
	fastread;
	int t = 1;
	// cin>>t;
	for(int i=1;i<=t;i++){
		// cout<<"Case #"<<i<<": ";
		solve();
	}
	return 0;
}


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

int main(){
 int n, m, l;
    long long A[100][100], B[100][100], C[100][100];
    
    cin >> n >> m >> l;
    for ( int i = 0; i < n; i++ )
      for ( int j = 0; j < m; j++ ) cin >> A[i][j];
    for ( int i = 0; i < m; i++ )
      for ( int j = 0; j < l; j++ ) cin >> B[i][j];
        
        for ( int i = 0; i < n; i++){
        for ( int j = 0; j < l; j++){
          C[i][j] = 0;
            for ( int k = 0; k < m; k++ ){
              C[i][j] += A[i][k]*B[k][j];
            }
        }
    }
    
    for ( int i = 0; i < n; i++ ){
        for ( int j = 0; j < l; j++){
          if ( j ) cout << " ";
        cout << C[i][j];
        }
        cout << endl;
    }
    
    
    
    return 0;
}   

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP (i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back

using namespace std;

typedef long long ll;

// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const int MOD = 1000000007;

int main() {
  int ans = 0;
  int a, b, t;
  cin >> a >> b >> t;
  REP (i, 1, t + 1) if (i % a == 0) ans += b;
  cout << ans << endl;
}


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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1000000007;

int dx4[] = {0, 1, 0, -1}, dy4[] = {1, 0, -1, 0};

// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, q, x, K;
string s, t;
// <------------- Implement Functions Here ----------> //

struct comp {
	bool operator() (const ll &a, const ll &b) const {
		if (abs(a - x) == abs(b - x)) {
			return a < b;
		}
		return abs(a - x) < abs(b - x);
	}
};

// <------------- Start of main() -------------------> //

void MAIN() {
	ll a,b;
	cin >> a >> b;
	if(a > 8 || b > 8) {
		cout<<":(";
	}
	else {
		cout<<"Yay!";
	}
}


int main() {
	fastio; randomINT;
	//cin >> T;
	while (T--) {
		MAIN();
	}
	return 0;
}


Measured memory_bytes: 3644
<?php
list($A, $B, $Q) = explode(" ", trim(fgets(STDIN)));
for($i = 0; $i < $A; $i++){
    $aArray[] = trim(fgets(STDIN));
}
array_unshift($aArray, -10**12);
$aArray[] = 10**12;
for($i = 0; $i < $B; $i++){
    $bArray[] = trim(fgets(STDIN));
}
array_unshift($bArray, -10**12);
$bArray[] = 10**12;

for($i = 0; $i < $Q; $i++){
    $qArray[] = trim(fgets(STDIN));
}

foreach($qArray as $q){
    $min = 10**18;
    $a = bsl($aArray, $q);
    $b = bsl($bArray, $q);
    foreach([$aArray[$a], $aArray[$a+1]] as $a1){
        $p3 = $bArray[$b];
        $p4 = $bArray[$b+1];
        $min = min($min, abs($q - $a1) + abs($a1 - $p3));
        $min = min($min, abs($q - $a1) + abs($a1 - $p4));
    }
    foreach([$bArray[$b], $bArray[$b+1]] as $b1){
        $p3 = $aArray[$a];
        $p4 = $aArray[$a+1];
        $min = min($min, abs($q - $b1) + abs($b1 - $p3));
        $min = min($min, abs($q - $b1) + abs($b1 - $p4));
    }
    printf("%d\n", $min);
}

//二分探索　target以下で最大の値の場所を返す
function bsl($nums, $target) {
    $size = count($nums);
    $min = 0; 
    $max = $size - 1;
    while(true){
        $center = floor(($min + $max) / 2);
        $centerValue = $nums[$center];
        if($target == $centerValue){
            return $center;
        }elseif($target > $centerValue){
            $min = $center + 1;
        }else{
            $max = $center;
        }
        if($min == $max){
            $center = floor(($min + $max) / 2);
            $centerValue = $nums[$center];
            if($centerValue == $target){
                return $center;
            }elseif($centerValue < $target){
                return $center;
            }else{
                return $center-1;
            }
        }
    }
}


Measured memory_bytes: 30316
N, M = map(int, input().split())
A = [int(input()) for _ in range(M)]

j = 0
sum = []

for i in range(N+1):
    if j < M and i == A[j]:
        sum.append(0)
        if j < M-1:
            j += 1
    elif i == 0 or i == 1:
        sum.append(1)
    else:
        sum.append(sum[i-2] + sum[i-1])


print(sum[N]%1000000007)

Measured memory_bytes: 460020
#空港 A, B, C があり、それぞれの空港の間では、双方向に飛行機が運航しています。
#空港 A, B 間の飛行時間は片道 P 時間、空港 B, C 間の飛行時間は片道 Q 時間、空港 C, A 間の飛行時間は片道 R 時間です。
#いずれかの空港からスタートして他の空港に飛行機で移動し、さらにそのどちらでもない空港に飛行機で移動するような経路を考えます。
#飛行時間の和は最短で何時間になるでしょうか。

l = sorted(map(int, input().split()))
s = (l[:2])
print(sum(s))

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

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

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

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

    for(int i=0; i<n; i++){
        cout<<a[i].second+1<<" ";
    }

    cout<<endl;
}

Measured memory_bytes: 1664
import sys
input = sys.stdin.readline
sys.setrecursionlimit(100000)

def getN():
    return int(input())
def getList():
    return list(map(int, input().split()))
import math

n = getN()
nums = getList()
tmp = nums[-1]
for i in range(n-1):
    tgt = nums[n - i - 2]
    # print(tgt, tmp)
    if tgt <= tmp:
        tmp = tgt
    elif tgt == tmp + 1:
        tmp = tgt - 1
    else:
        print("No")
        sys.exit()

print("Yes")


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

int main() {
  int n; cin >>n;
  vector<int>a(n);
  long long sum=0;
  for(int i=0;i<n;i++){
    cin>>a[i];
    sum+=a[i];
  }
  long long mae=0;
  long long nokori=a[n-1];
  long long sa=LLONG_MAX;
  for(int i=0;i<n-1;i++){
    mae+=a[i];
    nokori=sum-mae;
    sa=min(sa,abs(nokori-mae));
  }
  cout<<sa<<endl;
  return 0;
}

Measured memory_bytes: 1024
def main():
    N, M = list(map(int, input().split()))
    cityList = {}
    for i in range(M):
        P, Y = list(map(int, input().split()))
        if not P in cityList:
            cityList[P] = [[i, Y]]
        else:
            cityList[P].append([i, Y])
    for value in cityList.values():
        value.sort(key=lambda city: city[1])
    cityNumList = []
    for key, value in cityList.items():
        for i in range(len(value)):
            cityNumList.append([value[i][0], "{:06d}{:06d}".format(key, i+1)])
    cityNumList.sort(key=lambda city: city[0])
    for cityNum in cityNumList:
        print(cityNum[1])

if __name__ == "__main__":
    main()

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

namespace AtCoder {
    class Program {
        static void Main() {
            int k = int.Parse(Console.ReadLine());
            int[] ab = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int a = ab[0], b = ab[1];
            int l = b / k * k;
            if(a <= l && l <= b) Console.WriteLine("OK");
            else Console.WriteLine("NG");
        }
    }
}

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

int main() {
  int A;
  int B;
  int C;
  int K;
  
  cin >> A >> B >> C >> K;
  
  if(A >=K){
     cout << K << endl;
  }
  
  else if(A+B >= K){
    cout << A << endl;
  }
  
  else{ 
    cout << 2 * A - K + B << endl;
  }
  
  
  
  
}

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

#include <boost/multiprecision/cpp_int.hpp>

// increment
#define rep_n(_1, _2, _3, NAME, ...) NAME
#define rep_2(i, n) for (int(i) = 0; (i) < (int)(n); ++(i))
#define rep_3(i, initial, n) \
  for (int(i) = (int)(initial); (i) < (int)(n); ++(i))
#define rep(...) rep_n(__VA_ARGS__, rep_3, rep_2, rep_1)(__VA_ARGS__)
// decrement
#define rep_r_n(_1, _2, _3, NAME, ...) NAME
#define rep_r_2(i, n) for (int(i) = (int)(n); (i) > 0; (i)--)
#define rep_r_3(i, initial, n) \
  for (int(i) = (int)(initial); (i) > (int)(n); (i)--)
#define rep_r(...) rep_r_n(__VA_ARGS__, rep_r_3, rep_r_2)(__VA_ARGS__)
// define type definition
using namespace std;
typedef long long ll;
using mpint = boost::multiprecision::cpp_int;  // 多倍長整数（任意精度）
typedef pair<int, int> P;

// define construct variable
const double EPS = numeric_limits<double>::epsilon();
// 10^9 + 7
const ll MOD = ll(1e9) + 7;
const ll INF = ll(1e10);
const string ALPHABET = "abcdefghijklmnopqrstuvwxyz";
const double PI = acos(-1);

// define methods
// 最大公約数
ll gcd(const ll a, const ll b) { return b ? gcd(b, a % b) : a; }
// 最小公倍数
ll lcm(const ll a, const ll b) { return a / gcd(a, b) * b; }
// char -> int
int ctoi(char c) { return (int)(c - '0'); }
// 素因数分解
vector<pair<ll, ll>> prime_factorize(ll n) {
  vector<pair<ll, ll>> p;
  for (ll i = 2; i * i <= n; i++) {
    if ((n % i) != 0) continue;
    pair<ll, ll> a = make_pair(i, 0);
    while ((n % i) == 0) {
      n /= i;
      a.second += 1;
    }
    p.push_back(a);
  }

  if (n != 1) p.push_back(make_pair(n, 1));
  return p;
}
// 組み合わせの整合性を保つ（後ほど解析する）
ll modinv(ll a) {
  ll b = MOD, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= MOD;
  if (u < 0) {
    u += MOD;
  }
  return u;
}
// 順列
ll permutation(const ll n, const ll m) {
  ll result = 1;
  for (ll i = n; i > n - m; i--) {
    result = (result * i) % MOD;
  }
  return result;
}

// 繰り返し n 乗法
ll repeat_square(const ll n, const ll x) {
  if (x == 0) return 1;
  ll res = repeat_square(n, x / 2);
  res = res * res % MOD;
  if ((x % 2) == 1) res = res * n % MOD;
  return res;
}
// 組み合わせ nCm
ll combination(ll n, ll m) {
  ll p = permutation(n, m);
  ll div = 1;
  for (ll i = 2; i <= m; i++) {
    div = (div * i) % MOD;
  }
  return (p * modinv(div)) % MOD;
}

// アルファベットの取得
string get_alphabet(ll n) {
  n--;
  return string(1, 'a' + (n % 26));
}

int main() {
  string S, T;
  cin >> S >> T;
  int ans = 0;
  rep(i, S.length()) {
    string s = S.substr(i, 1);
    string t = T.substr(i, 1);
    if (s != t) ans++;
  }

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


Measured memory_bytes: 3880
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long int
#define MOD 1000000007
#define oo 1000000000000000000
#define forr(i,n) for(ll i=0;i<n;i++)
#define fastio ios_base::sync_with_stdio(false); cin.tie(0) ; cout.tie(0);
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define pb push_back
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
 
using namespace __gnu_pbds; 
using namespace std;

ll valueOfIndex(ordered_set&s , ll i){ return *(s.find_by_order(i)); }
ll indexOfValue(ordered_set&s , ll x){ return s.order_of_key(x); }
ll add(ll a, ll b,ll p=MOD) { a%=p; b%=p; return (a+b + p)%p;}
ll mul(ll a, ll b,ll p=MOD) { a%=p; b%=p; return (a*b + p)%p;} // __int128
ll power(ll x,ll n,ll p=MOD){ if(x==0) return 0; if(n==0 || x==1) return 1LL;
    ll r = (power(x,n/2,p))%p; if(n&1) return mul(mul(r,r,p) , x,p); else return mul(r,r,p);
}
ll inv(ll x){return power(x,MOD-2);}


void __sol(){
    ll n,k; cin >> n >> k;
    int a[n+1];
    for(int i=1;i<=n;i++) cin >> a[i];
    vector<int> visit(n+2,0) , v,p;
 //   visit[1]=1;
   // v.eb(1);
    int start = a[1];
 //   cout << start << " ";

    while(1){
        if(!visit[start]){
        v.eb(start);
        visit[start] = 1;
        start = a[start];
        }
        else{
            if(start==a[1]){
                break;
            }
            else{
                int tt = start;
                p.eb(tt);
                tt = a[tt];
                while(tt!=start){
                    p.eb(tt);
                    tt = a[tt];
                }
                break;

            }
        }
    }
 //   for(auto &i: v) cout << i << " ";
    if(p.size()==0){
    if(k<=v.size()){
        cout << v[k-1];
    }
    else{
        ll sz = v.size();
        if(k%sz==0){
            cout << v[sz-1];
            return;
        }
        k = k%sz;
      //  cout << k << "**\n";
        k = (k-1+sz)%sz;
        cout << v[k];
    }
    }
    else{
        int tt = v.size() - p.size();
        if(k<=tt){
            cout << v[k-1];
        }
        else{
            k-=tt;
            tt = p.size();
            k = k%tt;
            k = (k-1+tt)%tt;
            cout << p[k];
        }
    }
}


int main(){
    fastio
    ll tc=1; //cin >> tc;
    while(tc--) __sol();
    return 0;
}

Measured memory_bytes: 7036
/*************************************************************************
  >         File: D.cc
  >       Author: lyyllyyl
  >         Mail: riho.yoshioka@yandex.com
  > Created Time: Mon 12 Sep 2016 11:27:41 PM CST
*************************************************************************/
#include <bits/stdc++.h>

int main() {
  std::ios::sync_with_stdio(0);
  std::set<std::pair<int, int>> rectangles[10];
  int H, W, n;
  std::cin >> H >> W >> n;
  std::set<std::pair<int, int>> points;
  for (int i = 0; i < n; ++i) {
    int x, y;
    std::cin >> x >> y;
    points.emplace(x, y);
  }
  for (auto &point: points) {
    int x, y;
    std::tie(x, y) = point;
    for (int dx = 0; dx < 3; ++dx) {
      for (int dy = 0; dy < 3; ++dy) {
        int tx = x - dx, ty = y - dy;
        if (tx < 1 || ty < 1) continue;
        if (tx + 2 > H || ty + 2 > W) continue;
        int cnt = 0;
        for (int a = 0; a < 3; ++a) {
          for (int b = 0; b < 3; ++b) {
            int bx = tx + a, by = ty + b;
            if (points.count({bx, by})) cnt++;
          }
        }
        rectangles[cnt].emplace(tx, ty);
      }
    }
  }
  using LL = long long;
  LL sum = 0;
  for_each(rectangles, rectangles + 10, [&sum] (auto rectangle) {
      sum += rectangle.size();
  });
  std::cout << 1LL * (H - 2) * (W - 2) - sum << std::endl;
  for (int i = 1; i < 10; ++i) std::cout << rectangles[i].size() << std::endl;

  return 0;
}


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


int main() {
long A,B,M;
cin>>A>>B>>M;
vector<long> a(A);
vector<long> b(B);
vector<long> x(M);
vector<long> y(M);
vector<long> c(M);

for(int i=0;i<A;i++) cin>>a[i];
for(int i=0;i<B;i++) cin>>b[i];
for(int i=0;i<M;i++) cin>>x[i]>>y[i]>>c[i];

long ans=1234567890;
for(int i=0;i<M;i++){
  int idx=x[i]-1;
  int idy=y[i]-1;
  long tmp=a[idx]+b[idy]-c[i];
  ans=min(tmp,ans);
}

sort(a.begin(),a.end());
sort(b.begin(),b.end());
long tmp=a[0]+b[0];
ans=min(tmp,ans);
cout<<ans<<endl;
}


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

vector<int>ans;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    long long n,m;
    cin>>n;
    m = n/100;
    int t=n%100;
    if(5*m>=t) cout<<1;
    else cout<<0;
    return 0;
}
 

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1000000000)
from itertools import count
from functools import lru_cache
from collections import defaultdict
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok
#

def main():
    N = ii()
    S, T = input().split()
    for s, t in zip(S, T):
        print(s, t, sep='', end='')


main()


Measured memory_bytes: 3956
n,k=map(int, input().split())
point = [int(i) for i in input().split()]
janken = input()

for i in range(k,n):
  if janken[i] == janken[i-k]:
    janken= janken[0:i]+'0'+janken[i+1:n]

count=0

for i in range(n):
  if janken[i] == 'r':
    count += point[2]
  elif janken[i] == 's':
    count += point[0]
  elif janken[i] == 'p':
    count += point[1]

print(count)

Measured memory_bytes: 3452