akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()

typedef long long ll;

using namespace std;
//using namespace boost::multiprecision;


int main(){

    string s;
    cin >> s;

    int ans = 0;

    for(int i = 0; i < s.size() / 2; i++){
        if(s[i] != s[s.size() - 1 - i]) ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main(int argc, const char * argv[]) {
    int k;
    int out = 0;
    int hit = 0;
    int numrun = 0;
    int pointa = 0;
    int pointb = 0;
    int ining = 0;
    
    std::cin >> ining;
    int i = 1;
    while(i < ining + 1){
        std::string judge;
        std::cin >> judge;
        
        if(judge == "HIT"){
            hit++;
            if(hit == 4){
                pointa++;
                hit = hit - 1;
            }
        }
        
        if(judge == "OUT"){
            out++;
            if(out >= 3){
                i++;
                std::cout << pointa << std::endl;
                hit = 0;
                out = 0;
                pointa = 0;
            }
        }
        
        if(judge == "HOMERUN"){
            pointa = pointa + hit + 1;
            hit = 0;
        }
  }
}

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


int main(){
    
    ll N,a[100010];
    ll cnt=0;
    ll M=1;
    
    cin>>N;
    rep(i,0,N)cin>>a[i];
    sort(a , a +N);
    /*if(a[0]==a[1])M=2;
    else{
        cnt++;
    }*/
    rep(i,0,N-1){
        if(a[i]==a[i+1])M++;
        else{
            cnt+=M%2;
            M=1;
        }
    }
    cnt+=M%2;
    
    cout<<cnt<<endl;
}




Measured memory_bytes: 1024
Scanf.scanf "%d %d %d" (fun n z w ->
    let a = Array.init n (fun _ -> Scanf.scanf " %d" (fun a -> a)) in
    let a1 = abs (w - a.(n - 1)) in
    let a2 = if n = 1 then a1 else abs (a.(n - 1) - a.(n - 2)) in
    Printf.printf "%d\n" @@ max a1 a2
)

Measured memory_bytes: 2944
use proconio::input;
use proconio::marker::Chars;
use std::collections::HashMap;
use std::vec::Vec;

fn main() {
	input! {
		n: usize,
		k: usize,
	}
	//   お菓子図鑑
	let mut map: HashMap<usize, usize> = HashMap::new();
	for i in 0..n {
		let _ = map.entry(i).or_insert(0);
	}

	// すぬけくんのポケットにあるお菓子を調べる
	for _ in 0..k {
		input! {
			d: usize,
			v: [usize; d],
		}
		// ポケットをチェック
		for a in v.iter() {
			let entry = map.entry(a - 1).or_insert(0);
			*entry += 1;
		}
	}

	// お菓子を持っていいないカウント
	let mut ans = 0;
	for (_, &v) in map.iter() {
		if v == 0 {
			ans += 1;
		} 
	}
	println!("{}", ans);
		
}

Measured memory_bytes: 2164
<?php
list($min,$max)=explode(" ",trim(fgets(STDIN)));
$count=0;

for($i=$min;$i<=$max;$i++){
   
     $judge=str_split($i);
     
     if($judge[0]==$judge[4]&&$judge[1]==$judge[3]){
      $count++;    
     }
 
}

echo $count;
?>

Measured memory_bytes: 3828
def main():
    s = input()
    t = input()
    ls = len(s)
    lt = len(t)
    dp = [[0] * (lt + 1) for _ in range(ls + 1)]
    for i in range(ls):
        for j in range(lt):
            if s[i] == t[j]:
                dp[i + 1][j + 1] = dp[i][j] + 1
            else:
                dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1])
    ans = ''
    while ls > 0 and lt > 0:
        if s[ls - 1] == t[lt - 1]:
            ls -= 1
            lt -= 1
            ans += s[ls]
            continue
        if dp[ls - 1][lt] > dp[ls][lt - 1]:
            ls -= 1
        else:
            lt -= 1
    print(ans[::-1])


main()


Measured memory_bytes: 112476
def is_pal(inp):
    start, end = 0, len(inp) - 1
    while start < end:
        if inp[start] != inp[end]:
            return False
        start += 1
        end -= 1
    return True

inp = input()
n = len(inp)
ret =  is_pal(inp) and is_pal(inp[:(n-1)//2]) and is_pal(inp[(n+3)//2 - 1:])
print('Yes' if ret else 'No')

Measured memory_bytes: 3060
#include <iostream>
#include <vector>

using namespace std;

int main(){
    double a, b, c, d, e, f;
    double p, q;
    while(cin >> a >> b >> c >> d >> e >> f){
        cin >> p >> q;
        vector<int> x(3), y(3);
        x[0] = a; x[1] = c; x[2] = e;
        y[0] = b; y[1] = d; y[2] = f;
        int ret = 0;
        bool is = false;
        double X1 = x[0], X2 = x[1], X3 = x[2];
        double Y1 = y[0], Y2 = y[1], Y3 = y[2];

        int ans = 0;
        if ((X2-X1)*(q-Y1)-(Y2-Y1)*(p-X1)>0.0) ans++;
        if ((X3-X2)*(q-Y2)-(Y3-Y2)*(p-X2)>0.0) ans++;
        if ((X1-X3)*(q-Y3)-(Y1-Y3)*(p-X3)>0.0) ans++;

        cout << (ans%3==0?"YES":"NO") << endl;
    }
}

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

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

typedef long long ll;

#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 FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//定数
#define INF 1000000000 //10^9:極めて大きい値,∞
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second　//pairの二つ目の要素

int main(){
    int x,y;
    cin>>x>>y;
    int t,k;
    if((y-2*k)%2==1){
        cout<<"No"<<endl;
        return 0;
    }
    k=(y-2*x)/2;
    if(k<0 || k>x){
        cout<<"No"<<endl;
        return 0;
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 3592
//*******************************************************************************
//       Exhaustive Search                 
//*******************************************************************************
//     < ???????????? >
//       Exhaustive Search ????????????????????¨??????????£??????????
//*******************************************************************************
#include <iostream>
#include <vector>
using namespace  std;

void fnInput(vector<int> &rvnElm, vector<int> &rvnTrg )
{
  int nElmCnt, nTrgCnt;
  cin >> nElmCnt;

  rvnElm.resize(nElmCnt);
  for (int i = 0; i < nElmCnt; i++)
    cin >> rvnElm[i];

  cin >> nTrgCnt;

  rvnTrg.resize(nTrgCnt);
  for (int i = 0; i < nTrgCnt; i++)
    cin >> rvnTrg[i];
}

void fnDPtblMake(vector<vector<int>> &rvvnDP, const vector<int> &cnrvnElm, int nMaxTrg)
{
  rvvnDP[cnrvnElm.size()][0] = 1;
  for (int j = 1; j <= nMaxTrg; j++)
    rvvnDP[cnrvnElm.size()][j] = 0;

  for (int i = cnrvnElm.size() - 1; i >= 0; i--)
    for (int j = 0; j <= nMaxTrg; j++)
      if (j < cnrvnElm[i])
        rvvnDP[i][j] = rvvnDP[i + 1][j];
      else
        rvvnDP[i][j] = rvvnDP[i + 1][j] || rvvnDP[i + 1][j - cnrvnElm[i]];
}

void fnExhSch(const vector<int> &cnrvnElm, const vector<int> &cnrvnTrg)
{
  vector<vector<int>> vvnDP(21, vector<int>(2001, -1));

  int nMaxTrg = cnrvnTrg[0]; 
  for (int i = 1; i < cnrvnTrg.size(); i++)
    nMaxTrg = max(nMaxTrg, cnrvnTrg[i]);

  fnDPtblMake(vvnDP, cnrvnElm, nMaxTrg);

  for (int i = 0; i < cnrvnTrg.size(); i++)
    if (vvnDP[0][cnrvnTrg[i]])
      cout << "yes" << endl;
    else
      cout << "no" << endl;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<int> vnElm, vnTrg;

  fnInput(vnElm, vnTrg);
  fnExhSch(vnElm, vnTrg);

  return 0;
}

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

int main() {
  string s;
  cin >> s;
  ll ans = 0, size = s.length();
  for (int i = 0; i < (1 << (size - 1)); i++) {
    bitset<10> b(i);
    ll m = 1;
    for (int j = 0; j < s.length(); j++) {
      ans += (s[s.length() - j - 1] - '0') * m;
      if (b.test(j) == 0)
        m *= 10;
      else
        m = 1;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long int MOD= 1e9+7;
int mp[500];
int main()
{
    int n;
    string s;
    cin>>n;
    cin>>s;
    for(int i=0;i<n;i++)
        mp[s[i]]++;
    long long val=1;
    for(int i='a';i<='z';i++)
        val*=(mp[i]+1),val%=MOD;
    cout<<val-1<<endl;
   return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 100010;

int n, m, q;
char s[2020][2020];
int a[2020][2020], b[2020][2020], c[2020][2020];

int main(){
    scanf("%d%d%d", &n, &m, &q);
    rep(i, n)rep(j, m) scanf(" %c", &s[i][j]);

    rep(i, n+1)rep(j, m+1) a[i][j] = b[i][j] = c[i][j] = 0;
    rep(i, n)rep(j, m) a[i+1][j+1] = (s[i][j] == '1');
    rep(i, n)For(j, 1, m) b[i+1][j+1] = (s[i][j] == '1' && s[i][j-1] == s[i][j]);
    rep(j, m)For(i, 1, n) c[i+1][j+1] = (s[i][j] == '1' && s[i-1][j] == s[i][j]);
    rep(i, n+1)rep(j, m){
        a[i][j+1] += a[i][j];
        b[i][j+1] += b[i][j];
        c[i][j+1] += c[i][j];
    }
    rep(j, m+1)rep(i, n){
        a[i+1][j] += a[i][j];
        b[i+1][j] += b[i][j];
        c[i+1][j] += c[i][j];
    }

    rep(_, q){
        int x, y, X, Y;
        scanf("%d%d%d%d", &x, &y, &X, &Y);
        --x; --y;
        int A = a[X][Y] - a[X][y] - a[x][Y] + a[x][y];
        int B = b[X][Y] - b[X][y+1] - b[x][Y] + b[x][y+1];
        int C = c[X][Y] - c[X][y] - c[x+1][Y] + c[x+1][y];
        printf("%d\n", A - B - C);
    }
}

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

using namespace std;
using ll = long long;

void solve(){
	string s;
	cin >> s;
	int z=0,o=0;
	for(int i=0;i<s.size();++i){
		if(s[i]=='1')
			o++;
		else
			z++;
	}
	cout << 2*min(o,z) << '\n';
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t = 1;
	//cin >> t;
	while(t--){ 
		solve();
	}
	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>

int main(void){
    char s[5];
    int i,flag = 1;
    scanf("%s", s);
    
    for(i = 0; i < 4; i++){
        if(s[i] == s[i+1]){
            flag = 0;
        }
    }
    
    if(flag){
        puts("Good");
    }else{
        puts("Bad");
    }
    
    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		execute();
	}

	private static void execute() {
		try (Scanner sc = new Scanner(System.in)) {
			long a = sc.nextLong();

			long x=0;
			long y=0;
			
			for(long i=(long)Math.sqrt(a); i>0;i--) {
				if(a%i==0) {
					x=i;
					y=a/i;
					break;
				}
			}
			
			System.out.println(x + y - 2);

		}
	}

}

Measured memory_bytes: 24020
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
int  d,n;

int main()
{
	scanf("%d%d",&d,&n);
	if(n==100)
	{
		if(d==0) printf("101");
		else if(d==1) printf("10100");
		else printf("1010000");
	}
	else
	{
		printf("%d",n);
		for(int i=1;i<=2*d;i++) printf("0");
	}
}

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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;

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

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n,m,s,t; cin>>n>>m>>s>>t;
  s--,t--;
  vector<vpll> G(2*n+5);
  rep(i,m){
    ll u,v,a,b; cin>>u>>v>>a>>b;
    u--,v--;
    G[u].emplace_back(v,a);
    G[v].emplace_back(u,a);
    G[u+n].emplace_back(v+n,b);
    G[v+n].emplace_back(u+n,b);
  }
  priority_queue<pll, vector<pll>, greater<pll>> q;
  q.emplace(0,s);
  q.emplace(0,t+n);
  vll dist(2*n+5,LINF);
  dist[s]=0;
  dist[t+n]=0;
  while(!q.empty()){
    auto p=q.top(); q.pop();
    ll v=p.second, c=p.first;
    if(dist[v]<c) continue;
    for(auto np: G[v]){
      ll nv=np.first, nc=np.second;
      if(chmin(dist[nv],dist[v]+nc)){
        q.emplace(dist[nv],nv);
      }
    }
  }
  ll base=1e15;
  vll ans(n);
  rrep(i,n){
    ans[i]=base-(dist[i]+dist[i+n]);
    if(i!=n-1) chmax(ans[i],ans[i+1]);
  }
  rep(i,n){
    cout<<ans[i]<<endl;
  }
}

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

int main() {
  string S;
  cin >> S;
  int count = 0;
  
  for (int i = 0; i < 3; i++) {
    if (S.at(i) == 'R') {
      count ++;
    }
  }
  
  if (count == 2) {
    if (S.at(1) == 'S') {
      count = 1;
    } 
  }
  cout << count << endl;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  int table[N][N-1][2];
  
  for(int i=0; i<N; i++){
    cin >> A.at(i);
    for(int j=0; j<A.at(i); j++){
      cin >> table[i][j][0] >> table[i][j][1];
      table[i][j][0]--;
    }
  }
  int ans=0;
  for(int i=0; i<pow(2, N); i++){
    int temp=i;
    vector<int> div(N);
    int honest=0;
    for(int j=0; j<N; j++){
      div.at(j)=temp%2;
      honest+=div.at(j);
      temp/=2;
    }
    int doubt=0;
    for(int j=0; j<N; j++){
      if(div.at(j)==0) continue;
      for(int k=0; k<A.at(j); k++){
        if(div.at(table[j][k][0])!=table[j][k][1]) doubt++;
      }
    }
    if(doubt==0) ans=max(ans, honest);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#pragma warning(disable:4996)
using namespace std;

const int my_inf=2147483647;
const long long int my_linf=9223372036854775807;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,1,0,-1 };
map<char, int>mp;
int main() {
	mp['N'] = 1;
	mp['E'] = 2;
	mp['S'] = 3;
	mp['W'] = 0;
	while (1) {
		int N; cin >> N;
		if (!N)break;
		vector<vector<bool>>fi(21, vector<bool>(21));
		while (N--) {
			int x, y; cin >> x >> y;
			fi[y][x] = true;
		}
		cin >> N;
		int nx = 10;
		int ny = 10;
		fi[ny][nx] = false;
		while (N--) {
			char a;
			int l; cin >> a >> l;
			for (int i = 0; i < l; ++i) {
				nx += dx[mp[a]];
				ny += dy[mp[a]];
				fi[ny][nx] = false;
			}
		}
		bool ok = true;
		for (int i = 0; i < 21; ++i) {
			for (int j = 0; j < 21; ++j) {
				if (fi[i][j]) {
					ok = false;
					break;
				}
			}
		}
		if (ok)cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 3100
from collections import deque, Counter as cnt
from collections import defaultdict as dd
from operator import itemgetter as ig
from bisect import bisect_right as bsr
from math import factorial, ceil, floor
import sys
sys.setrecursionlimit(1000000)

# お約束
args = None
INF = float("inf")
MOD = int(1e9 + 7)


def input(*ps):
    if type(ps[0]) is list:
        return [input(*ps[0][:-1]) for _ in range(ps[0][-1])]
    elif len(ps) == 1:
        return ps[0](next(args))
    else:
        return [p(next(args)) for p in ps]


def nlist(n, v):
    if not n:
        return [] if type(v) is list else v
    return [nlist(n[1:], v) for _ in range(n[0])]


def yesno(v, yes="Yes", no="No"):
    print([yes, no][not v])


def main():
    """エントリーポイント"""
    S = input(str)
    print("x" * len(S))


if __name__ == '__main__':
    args = iter(sys.stdin.read().split())
    main()


Measured memory_bytes: 3436
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
using namespace std;
typedef long long ll;
 
int main() {
	int n,m;
	cin >> n >> m;
	int a[m],b[m],c[n];
	for (int i=0;i<n;i++) c[i]=0;
	for (int i=0;i<m;i++) cin >> a[i] >> b[i];
	for (int i=0;i<m;i++) {
		c[a[i]-1]+=1;
		c[b[i]-1]+=1;
	}
	for (int i=0;i<n;i++) {
		cout << c[i] << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<queue>
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef pair<string,string> Pstring;
typedef pair<double,double> Pdouble;

#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define Precision13 cout << fixed << setprecision(13)
ll MOD = 1e9+7;
const double PI=3.14159265358979323846;


int main() {
  ll n;
  cin >> n;
  vector<ll> a(n+1);

  for(int i=2; i<=n; i++){
    cin >> a.at(i);
  }

  vector<ll> ca(n+1,0);
  for(int i=2; i<=n; i++){
    ca.at(a.at(i))++;
  }

  for(int i=1; i<=n; i++){
    cout << ca.at(i) << endl;
  }
}

Measured memory_bytes: 6428
n, m = [int(i) for i in input().split()]
table = [[int(i) for i in input().split()] for n in range(n)]

table.sort(key=lambda x: x[0])

ans = 0
for t in table:
  if m > t[1]:
    ans += t[1] * t[0]
    m -= t[1]
  else:
    ans += m * t[0]
    break
print(ans)

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

const int INF = 1 << 29;

int main() {
    int W, N, v[1000], w[1000];

    int n_case = 0;
    while (true) {
        ++n_case;
        cin >> W;
        if (W == 0) break;
        cin >> N;
        char ch;
        for (int j = 0; j < N; ++j) {
            cin >> v[j] >> ch >> w[j];
        }

        int dp[1001];
        fill(dp, dp+W+1, -INF);
        dp[0] = 0;

        for (int j = 0; j < N; ++j) {
            for (int k = W; k >= w[j]; --k) {
                if (dp[k - w[j]] != -INF) {
                    dp[k] = max(dp[k], dp[k - w[j]] + v[j]);
                }
            }
        }

        int max_v = -INF, ww;
        for (int j = 0; j <= W; ++j) {
            if (max_v < dp[j]) {
                max_v = dp[j];
                ww = j;
            }
        }
        cout << "Case " << n_case << ":" << endl;
        cout << max_v << endl;
        cout << ww << endl;
    }

    return 0;
}

Measured memory_bytes: 3072
#include <iostream>

using namespace std;

int gcd(int x, int y)
{
	if(x >= y)
	{
		if (x%y == 0)
		{
			return y;
		}
	  	else return gcd(y, x%y);
	}
	else if(y%x == 0)
	{
		return x;
	}else{
		return gcd(x,y%x);
	}
}

int main() {
	int a, b;
	cin >> a >> b;
	cout << gcd(a, b) << endl;
	return 0;
}


Measured memory_bytes: 3080
#include<bits/stdc++.h>
#define ll long long
#define dd double

using namespace std;


int main(){
    int N;
    int ans = 0;
    cin >> N;
    vector<int> B(N - 1);
    for(int i = 0; i < N - 1; i++){
        cin >> B[i];
    }
    ans += B[0] + B[N - 2];
    for(int i = 0; i < N - 2; i++){
        
        ans += min(B[i], B[i + 1]);
    }
    cout << ans << endl;
    
}

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

int main() {

  vector<int> x(5);
  
  for(int i=0; i<5; i++) {
    cin >> x.at(i);
  }
  
  for(int i=0; i<5; i++) {
    if(x.at(i)==0) cout << i+1 << endl;
  }
  
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define inf 100000000000000000LL
#define fast_io	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define mod 1000000007
using namespace std;

ll n,k;
bool check(ll *A,ll val,ll *dp)
{
	bool f=0;
	for(ll i=1;i<=n;i++)
	{
		if(val-A[i]<0)
		continue;
		if(dp[val-A[i]]==0)
		return 1;
	}
	return 0;
}
int main()
{
	
	cin>>n>>k;
	ll dp[k+1];
	ll A[n+1];
	
	for(ll i=1;i<=n;i++)
	{
		cin>>A[i];
	}
	
	memset(dp,0,sizeof(dp));
//	dp[0]=1;
	for(ll i=1;i<=k;i++)
	{
		dp[i]=check(A,i,dp);
	}
//	for(ll i=1;i<=k;i++)
//	{
//		cout<<dp[i]<<" ";
//	}
//	cout<<"\n";
	if(dp[k])
	cout<<"First\n";
	else cout<<"Second\n";
}

Measured memory_bytes: 4380
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define erep(i,a,n) for(int i = a;i<=n;i++)
typedef long long ll;
#define int long long
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 1101010101010101010
#define MOD 1000000007
#define P pair<int,int>
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; }

signed main(){
  int n,k;
  cin >> n >> k;
  vint A(n);
  rep(i,0,n) cin >> A[i];
  vint keta(60);
  rep(i,0,60){
    rep(j,0,n){
      if(A[j]>>i&1) keta[i]++;
    }
  }
  int ans = 0;
  rrep(i,60,-1){
    if(i != -1 && !((k>>i)&1)) continue;
    int tmp = 0;
    rrep(j,60,0){
      int mask = 1LL<<j;
      if(j > i){
        if(k&mask) tmp += mask*(n-keta[j]);
        else tmp += mask*keta[j];
      }
      else if(j == i){
        tmp += mask*keta[j];
      }
      else{
        tmp += mask*max(keta[j],n-keta[j]);
      }
    }
    ans = max(ans,tmp);
  }
  int tmp = 0;
  rep(i,0,n){
    int m = A[i]^k;
    tmp += m;
  }
  ans = max(ans,tmp);
  cout << ans << endl;
}

Measured memory_bytes: 1024
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        InputStreamScanner in = new InputStreamScanner(System.in);
        new Main().solve(in, out);
        out.flush();
    }

    private void solve(InputStreamScanner in, PrintWriter out) {
        String s = in.next();

        ArrayDeque<Character> stack = new ArrayDeque<>();
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            if (stack.isEmpty() || stack.peek() == c) {
                stack.push(c);
            } else {
                stack.pop();
            }
        }
        out.println(s.length() - stack.size());
    }

    static class InputStreamScanner {

        private InputStream in;

        private byte[] buf = new byte[1024];
        private int len = 0;
        private int off = 0;

        InputStreamScanner(InputStream in)	{
            this.in = in;
        }

        String next() {
            StringBuilder sb = new StringBuilder();
            for (int b = skip(); !isSpace(b);){
                sb.appendCodePoint(b);
                b = read();
            }
            return sb.toString();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        char nextChar() {
            return (char)skip();
        }

        int skip() {
            for (int b; (b = read()) != -1;) {
                if (!isSpace(b)) {
                    return b;
                }
            }
            return -1;
        }

        private boolean isSpace(int c) {
            return c < 33 || c > 126;
        }

        private int read() {
            if (len == -1) {
                throw new InputMismatchException("End of Input");
            }
            if (off >= len){
                off = 0;
                try {
                    len = in.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException(e.getMessage());
                }
                if (len <= 0) {
                    return -1;
                }
            }
            return buf[off++];
        }
    }
}


Measured memory_bytes: 23508
h,w = map(int,input().split())
g = [[0]*(w+2)]+[[0]+[(i == "#")*1 for i in list(input())]+[0] for _ in range(h)]+[[0]*(w+2)]

for i in range(1,h+1):
    for j in range(1,w+1):
        t = 0
        if g[i][j] == 0:
            continue
        if g[i-1][j] == 1:
            t += 1
        if g[i+1][j] == 1:
            t += 1
        if g[i][j-1] == 1:
            t += 1
        if g[i][j+1] == 1:
            t += 1
        if t == 0:
            print("No")
            quit()

print("Yes")


Measured memory_bytes: 9144
#include <bits/stdc++.h>
using namespace std;
typedef                 long long ll;
typedef                 unsigned long long ull;
#define mkp             make_pair
#define pii             pair<int,int>
#define piii            pair<pii,int>
#define vi              vector<int>
#define PI              acos(-1)
#define all(v)          v.begin(),v.end()
#define mmset(a,val)    memset(a,val,sizeof(a))
#define sc(a)           scanf("%d",&a)
#define sc2(a,b)        scanf("%d%d",&a,&b)
#define sc3(a,b,c)      scanf("%d%d%d",&a,&b,&c)
#define sc4(a,b,c,d)    scanf("%d%d%d%d",&a,&b,&c,&d)
#define sc5(a,b,c,d,e)  scanf("%d%d%d%d%d",&a,&b,&c,&d,&e)
#define scll(a)         scanf("%I64d",&a)
#define scll2(a,b)      scanf("%I64d%I64d",&a,&b)
#define scll3(a,b,c)    scanf("%lld%lld%lld",&a,&b,&c)
#define scll4(a,b,c,d)  scanf("%I64d%I64d%I64d%I64d",&a,&b,&c,&d)
#define Pr(a)           printf("%d\n",a)
#define Prll(a)         printf("%I64d\n",a)
#define pb(a)           push_back(a)
#define SZ              size()
#define tcs(t)          for(int tc=1;tc<=t;tc++)
#define INF             0x3f3f3f3f
#define hash_val        347
#define popcount        __builtin_popcount
#define MOD             1000000007
#define MX              2005
//int fx[]={-1,-1,0,1,1,1,0,-1};
//int fy[]={0,1,1, 1,0,-1,-1,-1};
int Set(int n,int pos){return n=n|(1<<pos);}
int reset(int n,int pos){return n=n& ~ (1<<pos);}
bool check(int n,int pos){return (bool) (n& (1<<pos));}
ll gcd(ll a,ll b){if(b==0)return a;else return gcd(b,a%b);};
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);};
ll l[105];
int main()
{
             //       freopen("input.txt","r",stdin);
            //  freopen("output.txt","w",stdout);

        int a,b,c,d,e;
        char s[5];
        sc(e);
        d=e%10;
        e/=10;
        c=e%10;
        e/=10;
        b=e%10;
        e/=10;
        a=e;
        if(a+b+c+d==7)
            printf("%d+%d+%d+%d=7\n",a,b,c,d);
        else if(a-b+c+d==7)
            printf("%d-%d+%d+%d=7\n",a,b,c,d);
        else if(a+b-c+d==7)
            printf("%d+%d-%d+%d=7\n",a,b,c,d);
        else if(a+b+c-d==7)
            printf("%d+%d+%d-%d=7\n",a,b,c,d);
            else if(a-b-c+d==7)
            printf("%d-%d-%d+%d=7\n",a,b,c,d);
            else if(a-b-c-d==7)
            printf("%d-%d-%d-%d=7\n",a,b,c,d);
            else if(a+b-c-d==7)
            printf("%d+%d-%d-%d=7\n",a,b,c,d);
            else if(a-b+c-d==7)
            printf("%d-%d+%d-%d=7\n",a,b,c,d);



}


Measured memory_bytes: 384
#include <iostream>
#include <map>
#include <algorithm>

using namespace std;

bool solve(const map<long long, long long> &w)
{
	long long t = 0;

	for (auto &e : w) {
		if (t + e.second > e.first) {
			return false;
		}
		t = min(t + e.second, e.first);
	}
	return true;
}

int main()
{
	int N;
	cin >> N;
	map<long long, long long> w;
	
	for (int i = 0; i < N; ++i) {
		long long A, B;
		cin >> A >> B;
		w[B] += A;
	}

	if (solve(w)) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


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

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#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 FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) ll(x.size()) //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB emplace_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define Umap unordered_map
#define Uset unordered_set

int main(){
    ll n;
    cin >> n;
    vector<ll> p(n);
    REP(i, n) cin >> p[i];
    bool ok = true;
    REP(i, n-1){
        if(p[i] > p[i+1]){
            ok = false;
            break;
        }
    }
    if(ok){
        cout << "YES";
        return 0;
    }
    REP(i, n-1){
        ll tmp = p[i];
        for(ll j = i+1; j < n; j++){
            p[i] = p[j];
            p[j] = tmp;
            ok = true;
            REP(i, n-1){
                if(p[i] > p[i+1]){
                    ok = false;
                    break;
                }
            }
            if(ok){
                cout << "YES";
                return 0;
            }
            else{
                p[j] = p[i];
                p[i] = tmp;
            }
        }
    }
    cout << "NO";
    return 0;
}

Measured memory_bytes: 3632
let () =
  let s = read_line () in
  try
    Array.init 26 (fun i -> Char.chr @@ Char.code 'a' + i)
    |> Array.to_list
    |> List.find (fun c ->
        Array.fold_left ( && ) true @@ 
        Array.init (String.length s) (fun i -> s.[i] <> c))
    |> Printf.printf "%c\n"
  with Not_found -> print_endline "None"


Measured memory_bytes: 9984
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int K,X;cin >> K >> X;
  rep(i,K)cout << X-K+1+i << endl;
  rep(i,K-1) cout << X+1+i << endl;
  return 0;
}


Measured memory_bytes: 256
require 'prime'

target = gets.to_i
num = 0
later_list = []

if target == 1
    puts 0
else
    prime_list = Prime.prime_division(target)
    prime_list.each do |prime|
        temp_num = prime[1]
        1.step(temp_num) do |i|
            break if i > temp_num
            i.times do |j|
                target = target / prime[0]
            end
            num = num + 1
            temp_num = temp_num - i
        end
    end
    puts num
end


Measured memory_bytes: 14496
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)

	x := nextInt()
	acount := x / 500
	bcount := x % 500 / 5
	fmt.Println(acount*1000 + bcount*5)

}

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


Measured memory_bytes: 1776
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1000000010
#define N 2010
#define S 0
#define T 2001
#define red(x) (x)
#define blue(x) (n+(x))
#define id(x) (2002+(x))
#define int long long
char getc(){char c=getchar();while ((c<'A'||c>'Z')&&(c<'a'||c>'z')&&(c<'0'||c>'9')) c=getchar();return c;}
int gcd(int n,int m){return m==0?n:gcd(m,n%m);}
int read()
{
    int x=0,f=1;char c=getchar();
    while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
    while (c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();
    return x*f;
}
int n,p[N],d[N],q[N],pre[N],t=-1,ans;
bool flag[N];
struct data{int x,y,c,v[4];
}a[N],b[N];
struct data2{int to,nxt,cap,flow,cost;
}edge[N<<5];
void addedge(int x,int y,int z,int cost)
{
    t++;edge[t].to=y,edge[t].nxt=p[x],edge[t].cap=z,edge[t].flow=0,edge[t].cost=cost,p[x]=t;
    t++;edge[t].to=x,edge[t].nxt=p[y],edge[t].cap=0,edge[t].flow=0,edge[t].cost=-cost,p[y]=t;
}
int inc(int &x){x++;if (x>2007) x-=2007;return x;}
bool spfa()
{
    memset(d,60,sizeof(d));d[S]=0;
    memset(flag,0,sizeof(flag));
    int head=0,tail=1;q[1]=S;
    do
    {
        int x=q[inc(head)];flag[x]=0;
        for (int i=p[x];~i;i=edge[i].nxt)
        if (edge[i].flow<edge[i].cap&&d[x]+edge[i].cost<d[edge[i].to])
        {
            d[edge[i].to]=d[x]+edge[i].cost;
            pre[edge[i].to]=i;
            if (!flag[edge[i].to]) q[inc(tail)]=edge[i].to,flag[edge[i].to]=1;
        }
    }while (head!=tail);
    return d[T]<10000000000000000ll;
}
void ekspfa()
{
    while (spfa())
    {
        int v=n;
        for (int i=T;i!=S;i=edge[pre[i]^1].to)
        v=min(v,edge[pre[i]].cap-edge[pre[i]].flow);
        for (int i=T;i!=S;i=edge[pre[i]^1].to)
        edge[pre[i]].flow+=v,edge[pre[i]^1].flow-=v,ans+=v*edge[pre[i]].cost;
    }
}
signed main()
{
    n=read();memset(p,255,sizeof(p));
    for (int i=1;i<=n;i++)
    {
        a[i].x=read(),a[i].y=read(),a[i].c=read();
        a[i].v[0]=a[i].x+a[i].y;
        a[i].v[1]=a[i].x-a[i].y;
        a[i].v[2]=-a[i].x+a[i].y;
        a[i].v[3]=-a[i].x-a[i].y;
    }
    for (int i=1;i<=n;i++)
    {
        b[i].x=read(),b[i].y=read(),b[i].c=read();
        b[i].v[0]=-b[i].x-b[i].y;
        b[i].v[1]=-b[i].x+b[i].y;
        b[i].v[2]=b[i].x-b[i].y;
        b[i].v[3]=b[i].x+b[i].y;
    }
    for (int i=1;i<=n;i++)
    {
        addedge(S,red(i),a[i].c,0),addedge(blue(i),T,b[i].c,0);
        for (int j=0;j<4;j++)
        addedge(red(i),id(j),a[i].c,-a[i].v[j]),addedge(id(j),blue(i),b[i].c,-b[i].v[j]);
    }
    ekspfa();
    cout<<-ans;
    return 0;
    //NOTICE LONG LONG!!!!!
}

Measured memory_bytes: 1280
using System;

namespace abc168_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string n = Console.ReadLine();
            int intN = int.Parse(n);

            int amariInt = intN % 10;

            switch (amariInt)
            {
                case 2:
                case 4:
                case 5:
                case 7:
                case 9:
                    Console.WriteLine("hon");
                    break;
                case 0:
                case 1:
                case 6:
                case 8:
                    Console.WriteLine("pon");
                    break;
                case 3:
                    Console.WriteLine("bon");
                    break;
                default:
                    break;
            }
        }
    }
}


Measured memory_bytes: 27332
import copy
import sys
n = int(input())
lst1 = list(map(int,input().split()))
lst2 = copy.copy(sorted(lst1))

c=0
for i in range(n):
    if lst1[i]==lst2[i]:
        pass
    else:
        c+=1
        if c > 2:
            print("NO")
            sys.exit()
            
print("YES")

Measured memory_bytes: 3444
function main(arg) {
  const array = arg.trim().split(" ");
  const A = parseInt(array[0]);
  const B = parseInt(array[1]);
  const H = parseInt(array[2]);
  const M = parseInt(array[3]);
  const PI = Math.PI;

  const th = ((H * 60 + M) / 720) * 2 * PI;
  const tm = (M / 60) * 2 * PI;

  let xh = A * Math.cos(th);
  let yh = A * Math.sin(th);
  let xm = B * Math.cos(tm);
  let ym = B * Math.sin(tm);
  let dx = xh - xm;
  let dy = yh - ym;

  let result = Math.sqrt(dx * dx + dy * dy);

  console.log(result);
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));
// main("3 4 10 40");


Measured memory_bytes: 29780
n,k = list(map(int, input().split()))
lst = list(map(int, input().split()))

checker = [None for i in range(n)]
checker[0] = 0
num = 0
count = 0
flag = 0

# 同じ地点に2度目に到着する or k回移動するまで移動する
while flag==0 and count!=k:
    if checker[lst[num]-1]==None:
        checker[lst[num]-1]=count+1
        count+=1
        num = lst[num]-1
    else:
        flag = 1
        count+=1

# 同じ地点に2度目に到着した場合、残移動回数をループ1回の移動回数で割った余りのみを再度移動すれば良い
if flag==1:
    remaining = (k-checker[lst[num]-1])%(count-checker[lst[num]-1])
    num = lst[num]-1
    for i in range(remaining):
        num = lst[num]-1

print(num+1)


Measured memory_bytes: 32228
n = int(input())
sp = [None]*n
for i in range(n):
    sp[i] = input().split(" ")
sp = list(map(lambda x: [x[0], int(x[1])], sp))
sl = list(map(lambda x: x[0], sp))
sp2 = []
for s in sorted(list(set(sl))):
    l = list(filter(lambda x: x[0] == s, sp))
    sp2.extend(sorted(l, key=lambda x:x[1], reverse=True))
for x in sp2:
    print(sp.index(x)+1)


Measured memory_bytes: 38512
#include <iostream>
#include <algorithm>
#include <math.h>

using namespace std;  

int main(){
  int N;
  int T, A;
  int H[1000] = {0};
  cin >> N;
  cin >> T >> A;
  for (int i = 0; i < N; i++){
    cin >> H[i];
  }
  float A_h = (T-A)/0.006;

  float h_min = fabs(A_h - (float)H[0]);
  int min_id = 1;
  for (int i = 1; i < N; i++)
  {
    float tmp_h = fabs(A_h -(float)H[i]);
    if (tmp_h < h_min){
      h_min = tmp_h;
      min_id = i + 1;
    }
    
  }
  cout << min_id << endl;

}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[][] A = new int[N][2];
		
		for(int i = 0; i < N; i++) {
			int temp = sc.nextInt();
			A[i][0] = temp - 1; 
			A[i][1] = i + 1; 
		}
		Arrays.sort(A, (a1, a2) -> Integer.compare(a1[0], a2[0]));
		for(int i = 0; i < N; i++) {
			System.out.print(A[i][1] + " ");
		}
	}
}


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

std::string replaceOtherStr(std::string &replacedStr, std::string from, std::string to) {
    const unsigned int pos = replacedStr.find(from);
    const int len = from.length();

    if (pos == std::string::npos || from.empty()) {
        return replacedStr;
    }

    return replacedStr.replace(pos, len, to);
}
int main() {
    string S; cin >> S;
    string T; cin >> T;
    reverse(S.begin(), S.end());
    reverse(T.begin(), T.end());
    string ans = S;
    bool isInsert = false;
    bool flag = true;
    int num = S.length() - T.length();
    if (num < 0) {
        cout << "UNRESTORABLE" << endl;
        return 0;
    } else {
    for(int i = 0; i < S.length() - T.length() + 1; i++) {
        flag = true;
        ans = S;
        for(int j = 0; j < T.length(); j++) {
            if(S[i+j] =='?' || S[i+j] == T[j]) {
                ans[i+j] = T[j];
            } else {
                flag = false;
            }
        }
        if (flag) {
            break;
        }
    }

    if(flag) {
        // replaceOtherStr(ans, "?", "a");
        reverse(ans.begin(), ans.end());
        for(auto c : ans) {
            if (c == '?') cout << 'a';
            else cout << c;
        }
        cout << endl;
    } else {
        cout << "UNRESTORABLE" << endl;
    }

    return 0;
    }
}


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

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

	int a[N];
	int sum_even = 0;
	int sum_odd = 0;
	for (i = 0; i < N; i++) {
		cin >> a[i];
		if (i % 2 == 0) {
			sum_even += a[i];
		} else {
			sum_odd += a[i];
		}
	}

	int temp = sum_even - sum_odd;

	cout << temp;
	for (i = 0; i < N - 1; i++) {
		temp = 2 * a[i] - temp;
		cout << " " << temp;
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 1664
#include <stdio.h>

int main(void)
{
	int price, quantity;
	int sum;
	float step;
	int ave;
	
	sum = step = ave = 0;
	while (scanf("%d%*c%d", &price, &quantity) != EOF){
		sum += price * quantity;
		ave += quantity;
		step++;
	}
	
	ave = ave / step + 0.5;
	
	printf("%d\n%d\n", sum, ave);
	
	return (0);
}

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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (int i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()

const int MOD = 1e9+7;

ll X, Y;

int pow_(ll n, ll k) {
    ll res = 1;
    while (k) {
        if (k&1) res = (res * n) % MOD;
        n = n * n % MOD;
        k >>= 1;
    }
    return res;
}

int inv(int n) {
    return pow_(n, MOD-2);
}

int solve(int x, int y) {
    if (x > y) swap (x, y);
    if ((x+y)%3) return 0;
    if (2*x < y) return 0;
    int z = (x+y)/3;
    x -= z; y -= z;
    ll res = 1, q = 1;
    FOR (i, 1, z+1) res = res * i % MOD;
    FOR (i, 1, x+1) q = q * i % MOD;
    FOR (i, 1, y+1) q = q * i % MOD;
    return res * inv(q) % MOD;
}

int main() {
    cin >> X >> Y;
    cout << solve(X, Y) << endl;
}

Measured memory_bytes: 384
while True:
    dataset = input().split(" ")

    H = int(dataset[0])
    W = int(dataset[1])

    if H==0 and W==0:
        break

    for i in range(H):
        for j in range(W):
            if i==0 or i==H-1 or j==0 or j==W-1:
                print("#", end="")
            else:
                print(".", end="")
        print()

    print()



Measured memory_bytes: 7000
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt(); in.nextLine();
        String[] tmp = in.nextLine().split(" ");
        int[] ary = new int[n+1];
        for( int i = 1; i <= n; i++ ) ary[i] = Integer.parseInt(tmp[i-1]);
        int ans = 0;
        for( int i = 1; i < n+1; i++ ) {
            if( ary[i]-ary[i-1]>0 ) ans += ary[i]-ary[i-1];
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 35612
N = int(input())
count = 0
s = []
mydict = {}
for i in range(N):
    s = "".join(sorted(list(input())))
    if (s in mydict.keys()):
        count += mydict[s]
        mydict[s] += 1
    else:
        mydict[s] = 1
print(count)

Measured memory_bytes: 17808
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons;

int[10^^5] NS;

void main()
{
    auto nm = readln.split.to!(int[]);
    auto N = nm[0];
    auto M = nm[1];

    foreach (_; 0..M) {
        auto ab = readln.split.to!(int[]);
        auto a = ab[0] - 1;
        auto b = ab[1] - 1;
        if (NS[a]) {
            NS[a] = min(NS[a], b);
        } else {
            NS[a] = b;
        }
    }

    int cnt, last = int.max;
    foreach (i, b; NS[0..N]) {
        if (i == last) {
            ++cnt;
            last = int.max;
        }
        if (b) {
            last = min(b, last);
        }
    }
    writeln(cnt);
}

Measured memory_bytes: 1660
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<queue>
#define null NULL
using namespace std;
/** 区间表示：[p->dl,p->dr]
 *  从0开始计数，[0,n-1]
 *  线段树RSQ
 *
 */

struct Node
{
    long long dl,dr,s,delta;
    Node *pl,*pr;
};
int n,q;

void build(Node *&p,int l,int r)
{
    p=(Node *)malloc(sizeof(Node));
    p->dl=l,p->dr=r,p->s=0,p->delta=0;
    p->pl=null,p->pr=null;
    int mid=(l+r)/2;
    if(r>l)
    {
        build(p->pl,l,mid);
        build(p->pr,mid+1,r);
    }
}

void preorder(Node *p)
{
    if(p!=null)
    {
        printf("%lld %lld %lld %lld\n",p->dl,p->dr,p->s,p->delta);
        preorder(p->pl);
        preorder(p->pr);
    }
}
///在其他节点更新和查询的过程中都要向下延迟修改
void pushdown(Node *&p,int delta)
{
    p->pl->s += p->delta;
    p->pr->s += p->delta;
    p->pl->delta += p->delta;
    p->pr->delta += p->delta;
    p->delta=0;
}
///当前区间的更新只更新到某些节点，下边节点的更新需要下次延迟修改
void update(Node *&p,int l,int r,int data)
{
    ///[l,r]必然位于[p->dl,p->dr]子区间
    ///当前节点的所有数据都是正确的！！
    ///延迟修改-lazy-tag技术
    ///此处下行的是之前的数据
    if(p->delta!=0 && p->dr>p->dl)
        pushdown(p,p->delta);

    if(p->dl==l &&p->dr==r)
    {
        p->s += data;
        p->delta=data;
        return ;
    }
    int mid=(p->dl+p->dr)/2;
    if(r<=mid)
        update(p->pl,l,r,data);
    else if(l>mid)
        update(p->pr,l,r,data);
    else
        update(p->pl,l,mid,data),update(p->pr,mid+1,r,data);
    p->s=min(p->pl->s,p->pr->s);
}
///当前节点的所有数据都是正确的！！
///即使不正确，在进入到这个之前也被pushdown过了,，所以一定是正确的
long long query(Node *&p,int l,int r)
{
    ///一个查询区间最终必然被分成若干个小的区间和，最后一个定会完全和区间贴合
    if(p->delta!=0 && p->dr>p->dl)
        pushdown(p,p->delta);

    if(p->dl==l &&p->dr==r)
        return p->s;
    int mid=(p->dl+p->dr)/2;
    ///判断查询区间与当前区间的位置关系
    //全部位于左侧
    if(r<=mid)
        return query(p->pl,l,r);
    //全部位于右侧
    else if(l>mid)
        return query(p->pr,l,r);
    //两个都有
    else
        return min(query(p->pl,l,mid),query(p->pr,mid+1,r));
}

int main()
{
    int i,type,tx,ty,x;
    Node *tree=null;
    scanf("%d%d",&n,&q);
    build(tree,0,n-1);
    for(i=0;i<q;i++)
    {
        scanf("%d",&type);
        if(type==0)
        {
            scanf("%d%d%d",&tx,&ty,&x);
            update(tree,tx,ty,x);
        }else
        {
            scanf("%d%d",&tx,&ty);
            long long ans=query(tree,tx,ty);
            printf("%lld\n",ans);
        }
    }
    return 0;
}



Measured memory_bytes: 15728
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <stdio.h>
using namespace std;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    for(int i = b; i <= c; i++){
        if(i % a == 0){
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
    return 0;
}


Measured memory_bytes: 3592