akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;

int main() {
  string s, t;
  cin >> s >> t;

  int a, b;
  cin >> a >> b;

  string u;
  cin >> u;

  if(u == s) {
  	cout << a - 1 << " " << b << endl;
  } else {
  	cout << a << " " << b - 1 << endl;
  }

  return 0;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
#define ll long long 
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define pr pair<int,int>
#define endl "\n"
#define MOD 1000000007 // 10^9 + 7
#define sz(x) (int)(x).size()
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl;
#define all(c) (c).begin(), (c).end()

#define FOR(i,b) for (int i = 0; i < (b); i++)
#define FORR(i,a,b) for (int i = a; i < (b); i++)
#define FORB(i,b) for (int i = (b); i >= (0); i--)
#define FORRB(i,a,b) for (int i = (a);i>= (b); i--)

using namespace std;

int n , arr[100010][3];
ll dp[100010][3];

ll solve(int i,int j){
	if(i >= n) return 0;
	if(dp[i][j] != -1) return dp[i][j];
	if(j == 0){
		dp[i][j] = arr[i][j] + max(solve(i+1,j+1),solve(i+1,j+2));
	}
	else if(j == 1){
		dp[i][j] = arr[i][j] + max(solve(i+1,j-1),solve(i+1,j+1));
	}
	else if(j == 2) dp[i][j] = arr[i][j] + max(solve(i+1,j-1),solve(i+1,j-2));

	return dp[i][j];
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	//freopen("addin.txt","r",stdin);
	//freopen("addout.txt","w",stdout);
	cin >> n;
	for(int i = 0;i < n;i++){
		for(int j = 0;j <= 2;j++){
			cin >> arr[i][j];
		}
	}
	memset(dp,-1,sizeof(dp));
	ll max1 = INT_MIN;
	for(int i=0;i<=2;i++){
		max1 = max(max1,solve(0,i));
	}
	cout<<max1<<endl;
	return 0;
}

Measured memory_bytes: 9984
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		boolean ok = false;
		for(int i = 1; i <= 9; i++) {
			for(int j = 1; j <= 9; j++) {
				if(i*j == N)
					ok = true;
			}
		}
		System.out.println(ok ? "Yes" : "No");

	}

}


Measured memory_bytes: 21844
def main():
    n , k = map(int,input().split())
    r, s, p = map(int,input().split())
    t = list(input())
    score = 0
    te = []

    for count, i in enumerate(t):
        if count < k :
            if i == 'r' :
                score += p
                te.append('p')
            elif i == 's' :
                score += r
                te.append('r')
            elif i == 'p' :
                score += s
                te.append('s')
        else:
            if i == 'r' and  te[-k] != 'p':
                score += p
                te.append('p')
            elif i == 's' and te[-k] != 'r':
                score += r
                te.append('r')
            elif i == 'p' and te[-k] != 's':
                score += s
                te.append('s')
            else:
                te.append('0')
    print(score)

if __name__ == '__main__':
    main()

Measured memory_bytes: 4792
import sys
import math
import heapq
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())
def FLIST(n):
    res = [1]
    for i in range(1, n+1): res.append(res[i-1]*i%DVSR)
    return res
def gcd(x, y):
    if x < y: x, y = y, x
    div = x % y
    while div != 0:
        x, y = y, div
        div = x % y
    return y

A,B,C=LI()

print(C - min(A-B, C))


Measured memory_bytes: 3064
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
count=0
for i in range(n):
  sum=0
  a=list(map(int,input().split()))
  for j in range(m):
    sum+=a[j]*b[j]
  if sum>-c:
    count+=1
print(count)

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>

using namespace std;
using ll = long long;

#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
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 dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
/*----------------------------------------------------------------------------------*/


int main() {
    int n; cin >> n;
    vector<int> a(n), b(n);
    ll asum = 0, bsum = 0;
    rep(i,n) cin >> a[i], asum += a[i];
    rep(i,n) cin >> b[i], bsum += b[i];

    if (bsum < asum) {
        cout << "No" << endl;
        return 0; 
    }

    ll cnt = bsum - asum;

    ll acnt = 0, bcnt = 0;
    rep(i,n) {
        if (a[i] < b[i]) {
            acnt += (b[i]-a[i]+1)/2;
            if ((b[i]-a[i])%2==1) bcnt++;
        } else if (a[i] > b[i]) {
            bcnt += a[i]-b[i];
        }
    }

    if (acnt < bcnt || acnt+(acnt-bcnt)!=cnt) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
#define MOD 1000000007
#define INF 1000000000
typedef pair<int64_t, int64_t> PII;
typedef vector<int64_t> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

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

string S; cin >> S;

// 101010 または 01010101
int cnt10 = 0, cnt01 = 0, b = 1;
rep(i, 0, S.size()){
    if (S[i] - '0' == b) ++cnt10;
    b = 1 - b;
    if (S[i] - '0' == b) ++cnt01;
}
cout << min(cnt10, cnt01) << endl;


}

// 書いて考える
// 境界，出力文字列 チェック
// 可読性優先．高速化次点．
// まずは全探索，分割統治，次にDP
// 制限を見る．境界に注意．求めたい量の変域．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性，二分探索
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり



Measured memory_bytes: 512
#pragma GCC optimize ("O3")
#pragma GCC optimize("unroll-loops")
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll

int32_t main()
{
	#ifdef ONLINE_JUDGE
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	#endif
	int n;
	cin>>n;
	int ans=0;
	ans+=(n/500)*1000;
	ans+=((n%500)/5)*5;
	cout<<ans;
	
}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int res = 0;
        for(int i = 1; i <= K; i++) {
            for(int j = 1; j <= K; j++) {
                for(int k = 1; k <= K; k++) {
                    res += gcd(j,gcd(i,k));
                }
            }
        }
        System.out.println(res);
    }
    public static int gcd(int a, int b) {
        if(b == 0) {
            return a;
        } else {
            return gcd(b, a % b);
        }
    }
}


Measured memory_bytes: 35880
from collections import deque
N,M=map(int,input().split())

AB = [list(map(int, input().split())) for i in range(M)]

links=[[] for _ in range(N+1)]
for a, b in AB:
    links[a].append(b)
    links[b].append(a)

results=[-1]*(N+1)#番号をそのまま使いたいからプラス１
#このresults[i]のiが各部屋となり、そのresults[i]の値が繋がる別の部屋番号となる

q=deque([1])#1からスタートさせるために

while q:
    pos=q.popleft()#1からスタート
    for i in links[pos]:#部屋posにつながる部屋iを探索
        if results[i]==-1:#部屋iを未探索なら、そこに行くべき場所posを記入 すでに値が入っている場合では、この場合部屋探索は１からスタートしているため先に入っている値（部屋番号）が１に近い数値となっている。なので値が入っている場合はスルーする。
            results[i]=pos
            q.append(i)#捜索した部屋iを次の出発地として追記
print('Yes')
print('\n'.join(str(i) for i in results[2:]))

Measured memory_bytes: 65536
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  int count=0;
  string S;
  cin>>N>>S;
  for(int i=0;i<N-2;i++){
    if(S.substr(i,3)=="ABC"){
      count++;
    }
  }
  cout<<count<<endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int  n = sc.nextInt();
		int[] arr =new int[n];
		for(int i=0;i<n;i++){
			arr[i]=sc.nextInt();
		}
		if(n==1){
			System.out.println(0);
			return;
		}
		Arrays.sort(arr);
		long ans = arr[arr.length-1];
        int ct=1;
		for(int i=arr.length-2;i>=0;i--){
			if(ct>=(n-1)){
				break;
			}
			ans=ans+arr[i];
			ct++;
			if(ct>=n-1){
				break;
			}
			ans=ans+arr[i];
			ct++;
		}
		System.out.println(ans);
		//System.out.println(ans-arr[idx]);
	}
}

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

int main(){
    int A[46];
    int n;
    scanf("%d",&n);
    A[0] = A[1] = 1;
    for(int i=2;i<=n;++i){
        A[i] = A[i-1] + A[i-2];
    }
    printf("%d\n",A[n]);
    return 0;
}




Measured memory_bytes: 3216
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;

#define rep(i, n) for (ll i = 0; i < ll(n); i++)
#define repd(i, n) for (ll i = n - 1; i >= 0; i--)
#define all(x) x.begin(), x.end()

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

    int n;
    cin >> n;

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

    cout << 1000 - n % 1000 << endl;
}


Measured memory_bytes: 3652
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<map>
#include<algorithm>
#include<set>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
int main(void){
    int n,k;
    cin>>n>>k;
    vector<int> v(n,0);
    rep(i,n) cin>>v[i];
    sort(v.begin(),v.end());
    reverse(v.begin(),v.end());
    int a=0;
    rep(i,k) a+=v[i];
    cout<<a<<endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

lst =[]
count = sum(b)

for i in range(n - 1):
  if a[i + 1] == a[i] + 1:
    lst.append(a[i] - 1)
  
for i in lst:
  count += c[i]
  
print(count)

Measured memory_bytes: 3064
x,y=map(int,input().split())
ans=abs(abs(x)-abs(y))

if (x<0 and y<0) or (x>0 and y>0):
    if x>y :ans+=2
elif x!=0 and y!=0:
    ans+=1
else:
    if y<=0 and x>y:
        ans+=1

print(ans)


Measured memory_bytes: 3060
/*
ID: Barry Wang
LANG: C++11
TASK: 
*/
#include <bits/stdc++.h>
using namespace std;
/*---define tricks---*/
#define ALL(v) v.begin(),v.end()
#define UN(v) sort(ALL(v)),v.erase(unique(ALL(v)),v.end())
#define FILL(x,y) memset(x,y,sizeof(x))
#define EACH(v,it) for(__typeof(v.begin()) it=v.begin();it!=v.end();it++)
#define FIO ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define revsort(b,e) sort(b,e),reverse(b,e)
#define X first
#define Y second
#define Chtolly return 0
/*---define types---*/
typedef long long ll;
typedef list<int> li;
typedef queue<int> qi;
typedef deque<int> dqi;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vii;
typedef pair<ll,ll> pll;
typedef pair<ll,int> pli;
typedef unsigned int uint;
/*---define variables---*/
const int inf=(1<<29);
ll n,k;
ll ans;
ll a[200005];
ll s[200005];
map<ll,int> cnt;
/*---define function---*/

/*---main code---*/
int main(){
	FIO;
	cin>>n>>k;
	for(int i=1;i<=n;++i){
		cin>>a[i];
		a[i]--;
	}
	for(int i=1;i<=n;++i){
		s[i]=(a[i]+s[i-1])%k;
	}
	for(int i=0;i<=n;++i){
		if(i>=k){
			cnt[s[i-k]]--;
		}
		ans+=cnt[s[i]];
		cnt[s[i]]++;
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 15872
N, K, Q = map(int,input().split())
As = []
for i in range(Q):
    As.append(int(input()))

points = [K - Q] * N
for a in As:
    points[a - 1] += 1

for p in points:
    if p > 0:
        print("Yes")
    else:
        print("No")




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

int calc( int s , int n , int f ){
	if( f == 0 ) return s+n ;
	if( f == 1 ) return s-n ;
	if( f == 2 ) return s*n ;
	if( f == 3 ) return s/n ;
}

int calc2( string a ){
	int p=1,num = 0;
	for( int i=a.size()-1 ; i>=0 ; i-- ){
		num += (a[i]-'0') * p ;
		p *= 10 ;
	}
	return num;
}

int main(){
	
	string str;
	int ans=0,f=0;
	
	while( cin >> str ){
		if( str == "=" ) break ;
		
		if( str == "+" )      f = 0;
		else if( str == "-" ) f = 1;
		else if( str == "*" ) f = 2;
		else if( str == "/" ) f = 3;
		else ans = calc( ans , calc2(str) , f );
	}
	
	cout << ans << endl;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
#define ll long long
const int N=200050;
using namespace std;
inline int gi(){
  char ch=getchar();int x=0,q=0;
  while(ch<'0' || ch>'9') ch=='-'?q=1:0,ch=getchar();
  while(ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();
  return q?(-x):x;
}
struct date{
  ll s; int l,r,siz,p;
}tr[N];
ll sum,ans;
int rt;
int getrk(int x,ll s){
  if (!x) return 0;
  if (tr[x].s<=s)
    return getrk(tr[x].r,s)+tr[tr[x].l].siz+1;
  return getrk(tr[x].l,s);
}
void update(int x){
  tr[x].siz=tr[tr[x].l].siz+tr[tr[x].r].siz+1;
  return;
}
date split(int x,int k){
  if (!x) return (date){0,0};
  date p;
  if (tr[tr[x].l].siz+1<=k){
    p=split(tr[x].r,k-tr[tr[x].l].siz-1);
    tr[x].r=p.l,p.l=x;
  }
  else{
    p=split(tr[x].l,k);
    tr[x].l=p.r,p.r=x;
  }
  return update(x),p;
}
int merge(int x,int y){
  if (!x||!y) return x+y;
  if (tr[x].p<tr[y].p){
    tr[x].r=merge(tr[x].r,y);
    return update(x),x;
  }
  else{
    tr[y].l=merge(x,tr[y].l);
    return update(y),y;
  }
}
int main(){
  srand(19260817);
  int n=gi(),k=gi(),r,h;
  date g;
  rt=1;
  for (int i=2; i<=n+1; ++i){
    sum+=(h=gi()-k);
    tr[i]=(date){sum,0,0,1,rand()};
    r=getrk(rt,sum);
    ans+=getrk(rt,sum);
    g=split(rt,r);
    rt=merge(g.l,merge(i,g.r));
  }
  cout<<ans;
  return 0;
}


Measured memory_bytes: 4992
n = int(input())
d = [list(map(str, input().split())) for i in range(n)]
for i in range(1, n+1):
    d[i-1].append(i)
    d[i-1][1] = int(d[i-1][1])
d.sort()
ans = []
tmp = []
now_city = d[0][0]
for i in range(n):
    if now_city == d[i][0]:
        tmp.append(d[i])
    else:
        tmp.sort(key=lambda x: x[1], reverse=True)
        for j in range(len(tmp)):
            ans.append(tmp[j][2])
        tmp = []
        tmp.append(d[i])
        now_city = d[i][0]
tmp.sort(key=lambda x: x[1], reverse=True)
for j in range(len(tmp)):
    ans.append(tmp[j][2])
for i in ans:
    print(i)

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

class UnionFind {
public:
    vector <ll> par; // 各元の親を表す配列
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_): par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};


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

  int N, K, L;
  cin >> N >> K >> L;

  UnionFind ufp(N);
  UnionFind ufr(N);

  int p, q;
  for(int i = 0; i < K; i++){
    cin >> p >> q;
    p--;
    q--;
    ufp.merge(p, q);
  }

  for(int i = 0; i < L; i++){
    cin >> p >> q;
    p--;
    q--;
    ufr.merge(p, q);
  }

  map<pair<int, int>, int> mp;

  for(int i = 0; i < N; i++){
    mp[make_pair(ufp.root(i), ufr.root(i))]++;
  }

  for(int i = 0; i < N; i++){
    cout << mp[make_pair(ufp.root(i), ufr.root(i))] << " ";
  }

  cout << endl;

  return 0;
}


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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U> void chmax(T &a, U b) {
  if (a < b)
    a = b;
}

template <class T, class U> void chmin(T &a, U b) {
  if (b < a)
    a = b;
}

template <class T> T Sq(const T &t) { return t * t; }

const int mod = 1e9 + 7;

signed main() {
  vi abc(3);
  REP(i, 3) abc[i] = read();
  sort(ALL(abc));
  print(abc[0] + abc[1]);
}


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

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

    int cnt=0;

    for(int i = 1; i <= N; i++){
        if(i / 10 == 0) cnt++;          //1 ~ 9
        else if(i / 100 == 0){          //10 ~ 99
            if(i / 10 == i % 10){   //11,22,33,...,99
                //i=11のとき (1, 11), (11, 1)
                cnt += 2;
                //(i, i)
                cnt++;
            }
            else if(i / 10 > i % 10 && i % 10 != 0){   //21,31,32,41,42,43,51,...,97,98
                //i=21のとき (12, 21), (21, 12)
                cnt += 2;
            }
        }
        else if(i / 1000 == 0){     //100 ~ 999
            if(i / 100 == i % 10){
                //i=292のとき (2, 292), (22, 292), (202, 292), (212, 292), ..., (282, 292) * 2!
                cnt += (2 + (i / 10 % 10)) * 2;
                cnt++;
            }
            else if(i / 100 < i % 10 && i % 10 != 0){
                //i=385のとき (53, 385), (385, 53)
                cnt += 2;
            }
            else if(i / 100 > i % 10 && i % 10 != 0){
                cnt += 11 * 2;
            }
        }
        else if(i / 10000 == 0){    //1000 ~ 9999
            if(i / 1000 == i % 10){
                cnt += (12 + (i / 10 % 100)) * 2;
                cnt++;
            }
            else if(i / 1000 < i % 10 && i % 10 != 0){
                cnt += 11 * 2;
            }
            else if(i / 1000 > i % 10 && i % 10 != 0){
                cnt += 111 * 2;
            }
        }
        else if(i / 100000 == 0){   //10000 ~ 99999
            if(i / 10000 == i % 10){
                cnt += (112 + (i / 10 % 1000)) * 2;
                cnt++;
            }
            else if(i / 10000 < i % 10 && i % 10 != 0){
                cnt += 111 * 2;
            }
            else if(i / 10000 > i % 10 && i % 10 != 0){
                cnt += 1111 * 2;
            }            
        }
        else{                       //100000 ~ 200000
            if(i / 100000 == i % 10){
                cnt += (1112 + (i / 10 % 10000)) * 2;
                cnt++;
            }
            else if(i / 100000 < i % 10 && i % 10 != 0){
                cnt += 1111 * 2;
            }
            else if(i / 100000 > i % 10 && i % 10 != 0){
                cnt += 11111 * 2;
            }             
        }
    }

        cout << cnt << endl;
}


Measured memory_bytes: 3596
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
using namespace std;
const int INF= 1e9+5;
typedef long long ll;

int main(){
  int n,m,c;
  int count=0;
  cin>>n>>m>>c;
  int b[30];
  int a[30][30];
  for(int i=0;i<m;i++)cin>>b[i];
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++)cin>>a[i][j];
  }
  for(int i=0;i<n;i++){
    int sum=0;
    for(int j=0;j<m;j++){
      sum+=a[i][j]*b[j];
    }
    sum+=c;
    if(sum>0)count++;
  }
  cout<<count<<endl;
}


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

string revstr(const string &s){
	string a=s;
	reverse(a.begin(),a.end());
	return a;
}

int main(void){
  int m;cin>>m;
  while(m--){
    string s;cin>>s;
    set<string> pattern;
    for(int i=1;i<s.size();++i){
      string a=s.substr(0,i),b=s.substr(i,s.size()-i);
      //cerr<<a<<":"<<b<<endl;
      pattern.insert(a+b);
      pattern.insert(revstr(a)+b);
      pattern.insert(a+revstr(b));
      pattern.insert(revstr(a)+revstr(b));
      swap(a,b);
      pattern.insert(a+b);
      pattern.insert(revstr(a)+b);
      pattern.insert(a+revstr(b));
      pattern.insert(revstr(a)+revstr(b));
    }
    cout<<pattern.size()<<endl;
  }
  return 0;
}

Measured memory_bytes: 1296
#include<cstdio>
#include<algorithm>
#include<climits>

#define max_n (1<<18)

using namespace std;

int dat[max_n],n;

void update(int k,int a){
  for(k+=n,dat[k]=a;k>1;k>>=1)
    dat[k>>1]=min(dat[k],dat[k^1]);
}

int rmq(int a,int b){
  int res=INT_MAX;
  for(a+=n,b+=n;a<=b;a=(a+1)>>1,b=(b-1)>>1){
    if(a&1)res=min(res,dat[a]);
    if(!(b&1))res=min(res,dat[b]);
  }
    return res;
}

int main(void){
 
  fill(dat,dat+max_n,INT_MAX);
  int q;
  scanf("%d %d",&n,&q);
 
  while(q--){
    int com,x,y;
    scanf("%d %d %d",&com,&x,&y);
    if(com)printf("%d\n",rmq(x,y));
    else update(x,y);
  }
  return 0;
}

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

int main(){
#ifdef _DEBUG
	freopen("in" , "r", stdin );
	freopen("out", "w", stdout);
#endif
	ios::sync_with_stdio(0); cin.tie(0);
	string s; cin >> s;
	int ans = 0;
	for(int i = 1; i < s.size(); i++)
		if(s[i] != s[i - 1]) ans++;
	cout << ans << '\n';
}


Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define sz size
#define re return
#define gl getline
#define ll long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rept(i,a,b) for(int i=a;i<=b;i++)
#define all(a) (a).begin(),(a).end()
#define inf 1<<30
int main(){
	ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	int n,x,t;
	cin>>n>>x>>t;
	if(n%x==0)cout<<(n/x*t)<<endl;
	else cout<<((n/x+1)*t)<<endl;
	return 0;
}

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

int main(){
	int N, M;
	cin >> N >> M;
	int log[30+1] = {0};
	int K, A;
	for(int n = 1; n <= N; n++){
		cin >> K;
		for(int i = 1; i <= K; i++){
			cin >> A;
			log[A]++;
		}
	}
	int res = 0;
	for(int i = 1; i <= M; i++){
		if(log[i] == N) res++;
	}
	cout << res << endl;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args) {
        Scanner sc = new  Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        String S = sc.next();

        String[] str = S.split("", -1);
        for (int i=0;i<N;i++){
            if(i==K-1){
                if(str[i].equals("A")){
                    System.out.print("a");
                } else if (str[i].equals("B")){
                    System.out.print("b");
                } else if (str[i].equals("C")){
                    System.out.print("c");
                }
            }else{
                System.out.print(str[i]);
            }
        }
        sc.close();
    }
}

Measured memory_bytes: 23636
import math
import sys
from collections import deque, defaultdict

N, M = map(int, input().split())
AB = [tuple(map(int, input().split())) for _ in range(M)]
g = [set() for _ in range(N)]
for a, b in AB:
    g[a - 1].add(b - 1)


def find_loop(s, subnode):
    q = deque([(s, {s})])
    visited = defaultdict(lambda: math.inf)
    while len(q) > 0:
        node, p = q.popleft()
        for to_node in g[node] & subnode:
            if to_node == s:
                return p
            if visited[to_node] > len(p):
                visited[to_node] = len(p)
                q.append((to_node, p | {to_node}))
    return -1


V = set(range(N))
for i in range(N):
    subnode = find_loop(i, V)
    if subnode != -1:
        break
if subnode == -1:
    print(-1)
    sys.exit()


while True:
    # 条件判定
    flg = True
    for i in subnode:
        if len(g[i] & subnode) != 1:
            flg = False
            s = i
            break
    if flg:
        break
    subnode = find_loop(s, subnode)

print(len(subnode))
for node in subnode:
    print(node+1)


Measured memory_bytes: 75484
awk 'BEGIN{FS=RS;RS=""}
function abs(x){return x<0?-x:x}
{
    ans = "Yay!"
    for(i=1;i<6;++i)for(j=1;j<i;++j)if(abs($i-$j)>$6)
        ans = ":("
    print ans
}'


Measured memory_bytes: 552
#include <bits/stdc++.h>
#define int long long
#define gcd            __gcd
#define setbits(x)     __builtin_popcountll(x)
#define zrobits(x)     __builtin_ctzll(x)
#define mod            1000000007
#define mod2           998244353
#define maxe           *max_element
#define mine           *min_element
#define inf            1e18
#define deci(x,y)      fixed<<setprecision(y)<<x
#define w(t)           int t; cin>>t; while(t--)
#define nitin          ios_base::sync_with_stdio(false); cin.tie(NULL)
#define PI             3.141592653589793238
using namespace std;

int power(int x, int y, int p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
int modi(int a, int m)
{
    return power(a, m - 2, m);
}
int32_t main()
{
    nitin;
    int n,k;
    cin>>n>>k;
    vector<int>v(n+1);
    for(int i=0;i<n;i++){
        cin>>v[i+1];
    }
    int idx=-1;
    for(int i=2;i<=n;i++)
    {
        if(v[i]+v[i-1]>=k)
        {
            idx=i;
            break;
        }
    }
    if(idx==-1)
    {
        cout<<"Impossible"<<endl;
    }
    else{
        cout<<"Possible"<<endl;
        for(int i=1;i<=idx-2;i++)
            cout<<i<<endl;
        for(int i=n-1;i>=idx;i--)
            cout<<i<<endl;
        cout<<idx-1<<endl;
    }
    return 0;
}

Measured memory_bytes: 3952
#include<bits/stdc++.h>
using namespace std;
long long f[90],n;
int main(){
	ios::sync_with_stdio(false);
	cin>>n;f[0]=2;f[1]=1;
	for(int i=2;i<=n;i++)f[i]=f[i-1]+f[i-2];
	cout<<f[n];
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long int
#define pb push_back
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pii pair<int,int>
#define vvi vector<vector<int>>
#define vi vector<int>
#define f first 
#define s second 
using namespace std;
const int mod=1e9+7;
int logi(int n){int p=0;while(n/2){n=n/2;p++;}return p;}
int poww(int x,int y){int pro=1;while(y){if(y&1)pro=((pro%mod)*(x%mod)%mod);y=y>>1;x=((x%mod)*(x%mod)%mod);}return pro;}
int poww2(int x,int y){int pro=1;while(y){if(y&1)pro=pro*x;y=y>>1;x=x*x;}return pro;}
bool isprime(int n){ if(n==1) return false; for(int i=2;i<=sqrt(n);i++)	if(n%i==0) return false; return true;}

/*

*/



void solve()
{
	int n;
	cin>>n;
	vi v(n);
	int x=0;
	for(int i=0;i<n;i++) 
	{
		cin>>v[i];
		x^=v[i];
	}
	for(int i=0;i<n;i++)
	{
		int temp=v[i]^x;
		cout<<temp<<" ";
	}
}

int32_t main()																																	
{
	fast;
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
}


Measured memory_bytes: 4732
#8:47
MOD=10**9+7
INT_MAX=10**20+7
def INPUT():return list(int(i) for i in input().split())
def LIST_1D_ARRAY(n):return [False for _ in range(n)]
def LIST_2D_ARRAY(m,n):return [[0 for _ in range(n)]for _ in range(m)]
#################################################################################
n=int(input())
A=INPUT()
C=LIST_1D_ARRAY(10**6+1)
count=[0]*(10**6+1)
for i in range(n):
    C[A[i]]=True
    count[A[i]]+=1
for i in range(1,10**6+1):
    if C[i]==True:
        for j in range(2*i,10**6+1,i):
            C[j]=False
ans=0
for i in range(1,10**6+1):
    if C[i]==True and count[i]==1:
        ans+=1
print(ans)


Measured memory_bytes: 167252
import java.util.stream.Collectors;

public class Main {

    public static void main(String... args) throws Exception {
        var inputText = AtCoderReader.readInputText();
        var inputLines = inputText.lines().collect(Collectors.toList());
        var d = Long.parseLong(inputLines.get(0).split(" ")[1]);
        var pointList = inputLines.subList(1, inputLines.size()).parallelStream().map(t -> t.split(" "))
                .map(a -> new Point(Integer.parseInt(a[0]), Integer.parseInt(a[1]))).collect(Collectors.toList());
        long squaredDistance = d * d;
        var count = pointList.parallelStream().filter(p -> p.squaredDistanceFromOrigin() <= squaredDistance).count();
        System.out.println(count);
    }

    public static class Point {
        private final long x;
        private final long y;

        public Point(int x, int y) {
            this.x = x;
            this.y = y;
        }

        public long squaredDistanceFromOrigin() {
            return x * x + y * y;
        }
    }

    public static class AtCoderReader {
        public static String readInputText() {
            try (var input = System.in) {
                return new String(System.in.readAllBytes()).trim();
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
    }
}

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

using namespace std;
#define DBG(x)                         \
    (void)(cout << "L" << __LINE__     \
                << ": " << #x << " = " \
                << (x) << '\n')
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
typedef long long ll;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;
const int INF = 0x3f3f3f3f;
const int maxn = 110000;
int ans[maxn];
vector<int> G[maxn];
void bfs()
{
    queue<int> q;
    q.push(1);
    ans[1] = 1;
    while (!q.empty())
    {
        int u = q.front();
        q.pop();
        for (int v : G[u])
        {
            if (ans[v] == 0)
            {
                ans[v] = u;
                q.push(v);
            }
        }
    }
}
void run_case()
{
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= m; i++)
    {
        int u, v;
        cin >> u >> v;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    bfs();
    for (int i = 2; i <= n; i++)
    {
        if (ans[i] == 0)
        {
            cout << "No\n";
            return;
        }
    }
    cout << "Yes\n";
    for (int i = 2; i <= n; i++)
    {
        cout << ans[i] << "\n";
    }
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    run_case();
    cout.flush();
    return 0;
}

Measured memory_bytes: 10764
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=4e5+10,p=1e9+7;
int inc(int x,int y){x+=y;return x>=p?x-p:x;}
int dec(int x,int y){x-=y;return x<0?x+p:x;}
int mul(int x,int y){return (ll)x*y%p;}
struct edge{int f,t,l;}w[N];
int n,m,S,T,head[N],nxt[N];
void add(int f,int t,int l){
	static int cnt=0;
	w[++cnt]=(edge){f,t,l};
	nxt[cnt]=head[f];
	head[f]=cnt;
}
ll disS[N],disT[N];
int dpS[N],dpT[N];
bool vis[N];
typedef pair<ll,int> pii;
priority_queue<pii,vector<pii>,greater<pii> > Q;
int q[N];ll *val;
bool cmp(int x,int y){return val[x]<val[y];}
void dijsktra(int S,ll *dis,int *dp){
	for (int i=1;i<=n;i++) dis[i]=1e18,vis[i]=0;
	Q.push(pii(dis[S]=0,S));
	while (!Q.empty()){
		int v=Q.top().second;Q.pop();
		if (vis[v]) continue;vis[v]=1;
		for (int i=head[v];i;i=nxt[i]){
			int u=w[i].t;
			if (dis[u]>dis[v]+w[i].l) Q.push(pii(dis[u]=dis[v]+w[i].l,u));
		}
	}
	dp[S]=1;
	for (int i=1;i<=n;i++) q[i]=i;
	val=dis;sort(q+1,q+n+1,cmp);
	for (int i=1;i<=n;i++){
		int v=q[i];
		for (int i=head[v];i;i=nxt[i]){
			int u=w[i].t;
			if (dis[u]==dis[v]+w[i].l) dp[u]=inc(dp[u],dp[v]);
		}
	}
}
int main()
{
	scanf("%d%d",&n,&m);
	scanf("%d%d",&S,&T);
	for (int i=1;i<=m;i++){
		int u,v,l;
		scanf("%d%d%d",&u,&v,&l);
		add(u,v,l);add(v,u,l);
	}
	dijsktra(S,disS,dpS);dijsktra(T,disT,dpT);
	ll len=disS[T];
	int ans=mul(dpS[T],dpS[T]);
	for (int i=1;i<=n;i++){
		int k=mul(dpS[i],dpT[i]);k=mul(k,k);
		if (disS[i]*2==len) ans=dec(ans,k);
	}
	for (int v=1;v<=n;v++)
	for (int i=head[v];i;i=nxt[i]){
		int u=w[i].t;
		if (disS[v]+w[i].l!=disS[u]||len!=disS[v]+w[i].l+disT[u]) continue;
		int k=mul(dpS[v],dpT[u]);k=mul(k,k);
		if (disS[v]*2<len&&disS[u]*2>len) ans=dec(ans,k);
	}
	cout<<ans<<endl;
	return 0;
}

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

int main(){
    int N, T, A;
    cin >> N >> T >> A;
    vector<int> H(N);
    for(int i = 0; i < N; i ++){
        cin >> H.at(i);
    }
    int res = -1;
    int cc = 10000000000;
    for(int i = 0; i < N; i ++){
        int d = (T * 1000 - H.at(i) * 6) - A * 1000;
        if (d < 0) d = -d;
        if (cc > d){
            cc = d;
            res = i;
        }
    }
    
    cout << res + 1 << endl;
}


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

int main(){

int b,c,d;
cin>>b>>c;
  d=1;
  for(int i=0;i<b;i++){
d*=100;
  }
  if(c!=100){

      cout<<d*c<<endl;
  }
  else{
  cout<<d*(c+1)<<endl;
  }


}

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

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define _dec(i,N,j) for(int i = (N-1);i >= (j);i--)
#define _rec(i,N,j) for(int i = (N);i >=(j);i--)
#define ALL(x) x.begin(),x.end()
#define MEM(a,n) memset(a,n,sizeof(a))
#define fst first
#define scd second
#define PB push_back
#define MP make_pair

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

int get_int(){int x;scanf("%d",&x);return x;}
LL get_ll(){LL x;scanf("%lld",&x);return x;}
double get_db(){double x;scanf("%lf",&x);return x;}

template<typename T> int chmin(T &a,T &b){if(a > b){a = b;return 1;}else return 0;}
template<typename T> int chmax(T &a,T &b){if(a < b){a = b;return 1;}else return 0;}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {_for(i,0,v.size()) os << v[i] << " ";return os;}
template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){for(auto a:v) os << a <<" ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& v){os << v.fst <<" "<<v.scd << " ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const map<T1,T2>& v){for(auto a:v) cout << a << endl;return os;}

static const int dx[8] = { 1,  0, -1,  0,  1, -1,  1, -1};
static const int dy[8] = { 0,  1,  0, -1,  1, -1, -1,  1};
const double pi  = acos(-1.0);
const double eps = 1e-8;
const LL  INF  = 0x3f3f3f3f3f3f3f3f;
const int inf  = 0x3f3f3f3f;


int get_input(){
    return 1;
}
void output(){;}
const int maxn = 1e3+5;
LL A[maxn];
LL sum[maxn];
int N,K;


int        main()
{   
    cin >> N >> K;
    _rep(i,1,N){
        cin >> A[i];
        sum[i] = sum[i-1] + A[i];
    }

    vector<LL> vi;

    _rep(i,0,N){
        _rep(j,i+1,N){
            vi.PB(sum[j] - sum[i]);
        }
    }
    sort(ALL(vi),greater<LL>());
    int r = vi.size();
    for(int digit = 45;digit >=0 ;digit--){
        LL k = (1LL << digit);
        int cnt = 0;
        _for(j,0,vi.size()){
            if(vi[j]>=0 && vi[j]&k) cnt++;
        }
        if(cnt >= K){
            _for(j,0,vi.size()){
                if(vi[j]>=0 && !(vi[j]&k)) vi[j] = -1;
            }
        }
    }

    //cout << vi << endl;

    LL ans = -1;
    _for(i,0,vi.size()){
        if(vi[i] > 0) ans &= vi[i]; 
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 6384
#include <stdio.h>

struct a{
   char mark;
   int value;
};

int main() {
   int n, i, j, t1, minj;
   char t2;
   struct a b[36];
   struct a s[36];

   scanf("%d", &n);

   for (i = 0; i < n; ++i){
        scanf("%c",&t2);
        scanf("%c%d", &b[i].mark, &b[i].value);
        s[i].value = b[i].value;
        s[i].mark = b[i].mark;
   }

   for (i = 0; i < n; ++i){
        for (j = n-1; j >= i+1; --j) {
             if(b[j].value < b[j-1].value) {
                  t1 = b[j].value;
                  b[j].value = b[j-1].value;
                  b[j-1].value = t1;
                  t2 = b[j].mark;
                  b[j].mark = b[j-1].mark;
                  b[j-1].mark = t2;
             }
        }
   }

   for (i = 0; i < n; ++i){
        printf("%c%d", b[i].mark, b[i].value);
        if (i != n-1) {
            putchar(' ');
        }
        else{
            putchar('\n');
        }
    }

   printf("Stable\n");

   for (i = 0; i < n; ++i){
        minj = i;
        for (j = i; j < n; ++j) {
             if (s[j].value < s[minj].value) minj = j;
         }   
        t1 = s[i].value;
        s[i].value = s[minj].value;
        s[minj].value = t1;
        t2 = s[i].mark;
        s[i].mark = s[minj].mark;
        s[minj].mark = t2;
   }
   for (i = 0; i < n; ++i){
        printf("%c%d", s[i].mark, s[i].value);
        if (i != n-1) {
            putchar(' ');
        }
        else{
            putchar('\n');
        }
    }

   t1 = 0;
   for (i = 0; i < n; ++i) {
        if (b[i].mark != s[i].mark) {
            t1 = 1;
            break;
        }
   }

   if(t1 == 0){
        printf("Stable\n");
   }else{
        printf("Not stable\n");
   }

   return 0;
}

Measured memory_bytes: 1852
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int n, l;
  cin >> n >> l;
  vector<string> v(n);
  rep(i, 0, n) cin >> v[i];
  sort(v.begin(), v.end());

  rep(i, 0, n) cout << v[i];
  cout << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

unsigned long long int ZET(unsigned long long int N, unsigned long long int K)
{
    if (N > K)
    {
        return N-K;
    }

    if (N <= K)
    {
        return K-N;
    }
    
    
}
 
int main(void)
{
    unsigned long long int N, K;
    scanf("%llu %llu", &N, &K);

    if (N > K)
    {
        N = (N%K) + K;
    }
    

    while (ZET(N,K) < N)
    {
        N = ZET(N,K);
    }

    printf("%llu", N);
    
    


    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#define NMAX 100005

using namespace std;

int n, a[NMAX], s;
int main() {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i <= n; i++) {
		s += abs(a[i] - a[i + 1]);
	}
	for (int i = 1; i <= n; i++) {
		cout << s - abs(a[i - 1] - a[i]) - abs(a[i]-a[i+1]) + abs(a[i - 1] - a[i + 1]) << '\n';
	}
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  string s;
  cin >> s;
  int n = s.size();

  vector<int> v(2);
  rep(i, 0, n) { v[s[i] - '0']++; }

  cout << n - (abs(v[0] - v[1])) << endl;
}


Measured memory_bytes: 3732
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i=0; i<n; i++)
    cin >> a[i];
  
  vector<int> b(n);
  for (int i=0; i<n; i++)
    b[a[i]-1] = i + 1;
  
  for (int i=0; i<n; i++)
    cout << b[i] << ' ';
  
  cout << endl;

}

Measured memory_bytes: 3984
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EDPCE2
{
    class Program
    {
        struct wv
        {
            public int weight;
            public int value;
        }
        static void Main(string[] args)
        {
            // スペース区切りの整数の入力
            string[] inputNW = Console.ReadLine().Split(' ');
            int N = int.Parse(inputNW[0]);
            long W = long.Parse(inputNW[1]);
            List<wv> Stock = new List<wv>();
            wv article = new wv();
            int row = 0;
            article.weight = 0;
            article.value = 0;
            Stock.Add(article);//0番目の品物
            for (int i = 1; i <= N; i++)
            {
                string[] inputWV = Console.ReadLine().Split(' ');
                article.weight = int.Parse(inputWV[0]);
                article.value = int.Parse(inputWV[1]);
                Stock.Add(article);
                row += article.value;//DPの列の大きさ
            }
            if (N == 1)
            {
                if (Stock[1].weight <= W)
                {
                    Console.WriteLine(Stock[1].value);
                }
                else
                {
                    Console.WriteLine(0);
                }
            }
            else
            {
                //同じ重さならvalueの大きい方を使いたい
                Stock.Sort((a, b) => b.value - a.value);
                Stock.Sort((a, b) => a.weight - b.weight);
                /*
                            foreach (var item in Stock)
                            {
                                Console.WriteLine(item.weight+" "+item.value);
                            }
                */
                int ans = 0;
                int max =int.MaxValue ;//大きな数字
                
                long[,] DP = new long[N + 1, row + 1];
                for (int i = 1; i <= row; i++)
                {
                    DP[0, i] = max;
                }
                for (int i = 1; i <= N; i++)//各品物を表す行
                {
                    for (int j = 1; j <= row; j++)//選んだ品物の価値の合計を表す列
                    {
                        if (Stock[i].value >= j)//選んだ品物の価値がＶより大きいなら
                        {
                            DP[i, j] = Math.Min(DP[i - 1, j], Stock[i].weight);
                        }
                        else//選んだ品物の価値ではＶに足りないなら
                        {
                            DP[i, j] = Math.Min(DP[i - 1, j], DP[i - 1, j - Stock[i].value] + Stock[i].weight);
                        }
                        //Console.Write(DP[i, j] + " ");
                    }
                    //Console.WriteLine();
                }
                for (int k = 1; k <= row; k++)
                {
                    if(W>=DP[N,k])
                    {
                        ans = k;
                    }
                }
                Console.WriteLine(ans);
            }
        }
    }
}


Measured memory_bytes: 90052
n = int(input())
a = list(map(int, input().split()))
c = 0
flag = 0
for i in range(n):
    minv = i
    for j in range(i+1, n):
        if a[j]<a[minv]:
            minv = j
            flag = 1
    c += flag
    flag = 0
    a[i], a[minv] = a[minv], a[i]
print(*a)
print(c)



Measured memory_bytes: 5608
#include <iostream>
#include <vector>
using namespace std;
long long const mod = 1e9+7;
int len;
string s;
vector< vector< long long > > dp;
long long mod_pow(long long a, long long b, long long m){
    long long res = 1;
    a %= m;
    while(b > 0){
        if(b%2 == 1) res = (res * a) % m;
        a = (a * a) % m;
        b /= 2;
    }
    return res;
}
long long f(int x, int y){
    if(x == len){
        if(y == 0)return 1;
        return 0;
    }
    if(dp[x][y] != -1)return dp[x][y];
    long long res = 0;
    for(int j=0;j<10;j++){
        if(s[x] != '?' && (s[x] - '0') != j)continue;
        long long t = ( j * mod_pow(10, len-1-x, 13) ) % 13;
        res += f(x+1, (y-t+13)%13);
        res %= mod;
    }
    return dp[x][y] = res;
}
int main(void){
    cin >> s;
    len = s.length();
    dp.assign(len, vector<long long>());
    for(int i=0;i<len;i++){
        dp[i].assign(13, -1);
    }
    cout << f(0, 5) << endl;
}


Measured memory_bytes: 23424
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define _FOR(i, a, b) for(int i = a; i >= b; i--)
using namespace std;
int n, k, a[100], sum = 0;
int main() {
    cin >> n >> k;
    FOR(i, 1, n) {
        cin >> a[i];
    }
    sort(a + 1, a + 1 + n);
    _FOR(i, n, n - k + 1) {
        sum += a[i];
    }
    cout << sum;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
//#define ARRAY(type,n) (type *)malloc(sizeof(type)*n)
template<typename T>
T* ARRAY(int n){
	(T*)malloc(sizeof(T)*n);
}
template<typename T>
T** ARRAY2(int m,int n){
	T** type = (T**)malloc(sizeof(T*)*m);
	for(int i=0;i<m;i++){
		type[i]=(T*)malloc(sizeof(T)*n);
	}
	return type;
}

bool cmp(pair<ll,ll> l, pair<ll,ll> r){
	return l.first<r.first;
}

 
int main(void){
	ll n,m;
	cin>>n>>m;
	vector<pair<ll,ll> > v;
	rep(i,n){
		pair<ll,ll> p;
		cin>>p.first>>p.second;
		v.push_back(p);
	}
	sort(v.begin(),v.end(),cmp);
	ll ans=0;
	rep(i,n){
		while(m > 0 && v[i].second > 0){
			m--;
			ans += v[i].first;
			v[i].second--;
		}
		if(m==0){
			break;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2420
public class Main {

	public static void main(String[] x_args) {
		for (int i = 1; i <= 9; i++) {
			kuku_keisan(i);			
		}
	}
	
	public static void kuku_keisan(int kuku_dan) {
		
		for (int i = 1; i <= 9; i++) {
			System.out.println(kuku_dan + "x" + i + "=" + i * kuku_dan);
		}

	}
}

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

using namespace std;
using ll = long long;
#define int ll
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll INF = (1LL<<60);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

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

  int n;
  cin >> n;

  VI a, b;
  for(int i=0; i<=100; i+=4) a.PB(i);
  for(int i=0; i<=100; i+=7) b.PB(i);

  for(auto i: a) {
    for(auto j: b) {
      if(i+j == n) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256