akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;
 
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
 
template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}
 
// ------------------------------------------------------------------------------------------

map<vector<int>, int> mp;

int init() {
   vector<int> v(8);
   iota(all(v), 0);
   mp[v] = 0;
   queue<vector<int>> que;
   que.push(v); // 最終状態をpush

   while (que.size()) {
      vector<int> cur = que.front(); que.pop();
      int idx = find(all(cur), 0) - cur.begin(); // 0の場所
      int y = idx / 4, x = idx % 4; // idxを2次元座標に変換
      rep (i, 4) {
         int ny = y + dy[i], nx = x + dx[i];
         if (ny < 0 || ny >= 2 || nx < 0 || nx >= 4) continue;
         int nc = 4 * ny + nx; // 2次元座標を1次元座標に変換
         vector<int> next = cur;
         swap(next[idx], next[nc]);
         if (mp.count(next)) continue;
         mp[next] = mp[cur] + 1;
         que.push(next);
      }
   }
}

int main() {
   init();
   vector<int> vs(8);
   while (cin >> vs[0]) {
      repp (i, 1, 8) cin >> vs[i];
      cout << mp[vs] << endl;
   }

   return 0;
}


Measured memory_bytes: 5648
n = int(input())
l = [[int(i) for i in input().split()] for _ in range(n)]
memo = [[ 0 for _ in range(3)] for _ in range(n)]

def dp(n,l,memo):
    memo[0] = l[0]
    for i in range(1,n):
        memo[i][0] = max(memo[i-1][1],memo[i-1][2]) + l[i][0]
        memo[i][1] = max(memo[i-1][0],memo[i-1][2]) + l[i][1]
        memo[i][2] = max(memo[i-1][0],memo[i-1][1]) + l[i][2]
        
    return memo

ans = dp(n,l,memo)
print(max(ans[n-1]))


Measured memory_bytes: 45684
#include<iostream>

using namespace std;

int main() {
	int Mt[10];

	for (int i = 0; i < 10; i++)
		cin >> Mt[i];

	int cnt;
	do{
		cnt = 0;
		for (int j = 0; j < 9; j++) {
			if (Mt[j] < Mt[j + 1]) {
				int tmp = Mt[j];
				Mt[j] = Mt[j + 1];
				Mt[j + 1] = tmp;
				cnt++;
			}
		}
	} while (cnt != 0);

	for (int k = 0; k < 3; k++)
		cout << Mt[k] << endl;

	return 0;
}

Measured memory_bytes: 1160
n,q = [int(i) for i in input().split()]
s = input()

r_cnt = [0]
for i in range(1,n):
  if s[i-1:i+1] == 'AC':
    r_cnt.append(r_cnt[i-1]+1)
  else:
    r_cnt.append(r_cnt[i-1])

for i in range(q):
  l, r = [int(j) for j in input().split()]
  ans = r_cnt[r-1] - r_cnt[l-1]
  print(ans)

Measured memory_bytes: 6156
n = int(input())
l = list(map(int, input().split()))
ans = 0
count = {}
for i in range(0, 10**5+1):
  count[i] = 0

for i in l:
  count[i] = count[i] + 1

for i in range(0, 10**5+1):
  if i == 0:
    temp = count[i] + count[i+1]
  elif i == 10**5:
    temp = count[i] + count[i-1]
  else:
    temp = count[i] + count[i+1] + count[i-1]

  if temp > ans:
    ans = temp

print(ans)

Measured memory_bytes: 20704
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repf(i,a,b) for (int i = (a); i < (b); i++)
#define repi(i,a,b) for (int i = (a); i <= (b); i++)
#define repr(i,a,b) for (int i = (a); i >= (b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(all(x));
#define RSORT(x) sort(rall(x));
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vd = vector<double>;
using vb = vector<bool>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;
using tiii = tuple<int, int, int>;
const ll inf = 1ll<<29;
const ll mod = 1000000007;
const double eps = 1e-9;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int N, A, B, C;
vi l(N+10);

int dfs(int cur, int a, int b, int c) {
  if(cur==N) {
    if(min({a,b,c})>0) {
      return abs(a-A)+abs(b-B)+abs(c-C)-30;
    }
    else {
      return inf;
    }
  }
  
  int ret0 = dfs(cur+1, a, b, c);
  int ret1 = dfs(cur+1, a+l[cur], b, c)+10;
  int ret2 = dfs(cur+1, a, b+l[cur], c)+10;
  int ret3 = dfs(cur+1, a, b, c+l[cur])+10;
  return min({ret0, ret1, ret2 ,ret3});
}

int main() {
  cin >> N >> A >> B >> C;
  rep(i,N) cin >> l.at(i);
  
  cout << dfs(0,0,0,0) << endl; 
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AOJ
{
	class Program
	{
		static void Main(string[] args)
		{
			bool[] p = Enumerable.Repeat(true, 50000).ToArray();
			p[0] = p[1] = false;
			for (int i = 2; i < Math.Sqrt(p.Length); i++)
				if (p[i])
					for (int j = i * 2; j < p.Length; j++)
						if (j % i == 0)
							p[j] = false;
			var n = 0;
			while ((n = int.Parse(Console.ReadLine())) != 0)
			{
				var r = 0;
				for (int i = 2; i <= n / 2; i++)
					if (p[i] && p[n - i]) r++;
				Console.WriteLine(r);
			}
		}
	}
}

Measured memory_bytes: 6144
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <cmath>
 
using namespace std;
 
// typedef
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<string> vs;
 
// container util
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for (typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
// repetition
#define FOR(i,m,n) for (ll (i) = ((ll) m); (i) < ((ll) n); ++(i))
#define RFOR(i,m,n) for (ll (i) = ((ll) (m)-1); (i) >= ((ll) n); --(i))
#define REP(i,n) FOR(i,0,n)
 
// i/o
#define TFOUT(b,t,f) cout << ((b)? (t) : (f)) << endl
 
//constant
const double    EPS     = 1e-10;
const double    PI      = acos(-1.0);
const int       INFTY   = (1<<21);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

int main() {
    int n; cin >> n;
    unordered_map<int, vector< pair<int, ll> > > edges;
    REP(i, n-1) {
        int a, b; ll c; cin >> a >> b >> c;
        a--; b--;
        edges[a].emplace_back(b, c);
        edges[b].emplace_back(a, c);
    }
    int q, k; cin >> q >> k;
    k--;
    vector<ll> costs(n, -1); costs[k] = 0;
    unordered_set<int> open_set{k};
    while (!open_set.empty()) {
        unordered_set<int> new_open_set;
        for (const int node : open_set) {
            for (const pair<int, ll> neighborhood : edges[node]) {
                if (costs[neighborhood.first] != -1) continue;
                new_open_set.insert(neighborhood.first);
                costs[neighborhood.first] = neighborhood.second + costs[node];
            }
        }
        open_set = new_open_set;
    }
    REP(i, q) {
        ll x, y; cin >> x >> y;
        x--; y--;
        cout << (costs[x] + costs[y]) << endl;
    }
}


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

int main() {
  int n, m;
  cin >> n >> m;
  int a[m];
  map<int, bool> ma;
  for (int i =0; i<m; ++i) {
    cin >> a[i];
    ma[a[i]] = true;
    if (i > 0) {
      if (a[i-1]+1 == a[i]) {
        cout << 0 << endl;
        return 0;
      }
    }
  }

  long long int d[n+20];
  fill_n(d, n+20, 0);

  d[1] = 1;
  for (int i = 0; i < m; ++i) {
    if (1 == a[i]) {
      d[1] = 0;
      break;
    }
  }

  d[2] = 2;
  if (d[1] == 0) {
    d[2] = 1;
  }
  for (int i = 0; i < m; ++i) {
    if (2 == a[i]) {
      d[2] = 0;
      break;
    }
  }

  for (int i = 3; i <= n; ++i) {
    bool b = false;
    if (ma.find(i) != ma.end()) {
      b = true;
    }
    //for (int j = 0; j < m; ++j) {
    //  if (i == a[j]) {
    //    b = true;
    //    break;
    //  }
    //}

    if (b) {
      d[i] = 0;
    } else {
      d[i] = (d[i-1] + d[i-2]) % 1000000007;
    }
  }

  cout << d[n] << endl;

  return 0;
}

Measured memory_bytes: 3584
import java.io.*;
  
class Main {
    public static void main(String[] args) {
        BufferedReader kb = new BufferedReader( new InputStreamReader( System.in ) );
        try {
            int n = Integer.parseInt( kb.readLine() );
             
            int num;
			int cnt = n;
            int i, j;
            for( i=0; i<n; i++ ) {
                num = Integer.parseInt( kb.readLine() );
				if( 2 == num ) { continue; }
				if( 0 == num%2 ) {
					cnt--;
					continue;
				}
                for( j=3; j*j<=num; j+=2 ) {
                    if( 0 == num%j ) {
                        cnt--;
						break;
                    }
                }
            }
             
            System.out.println( cnt  );
              
            kb.close();
        } catch( IOException e ) {
            System.err.println( e );
        }
    }
}

Measured memory_bytes: 22932
def exp(n):
    if n == 0:
        return 1
    elif n == 1:
        return 2
    if n % 2 == 0:
        tmp = exp(n // 2) % 1000000007
        return (tmp * tmp) % 1000000007
    else:
        tmp = exp(n // 2) % 1000000007
        return (2 * tmp * tmp) % 1000000007
n = int(input())
ar = list(map(int, input().split()))
ar.sort()
if n % 2 == 0:
    curr = 1
    valid = True
    for i in range(1, n, 2):
        if ar[i] == ar[i - 1] == curr:
            curr += 2
            continue
        else:
            valid = False
            break
    if valid:
        print(exp(n // 2))
    else:
        print(0)
else:
    curr = 2
    valid = True
    if ar[0] != 0:
        valid = False
    else:
        for i in range(2, n, 2):
            if ar[i] == ar[i-1] == curr:
                curr += 2
                continue
            else:
                valid = False
                break
    if valid:
        print(exp(n // 2))
    else:
        print(0)


Measured memory_bytes: 14008
// In the name of God

#include <bits/stdc++.h>

using namespace std;

bool f;
string s;

int solve(int l, int r) {
	if(l>=r) return 0;
	if(s[l] == s[r]) {
		return solve(l+1, r-1);
	}
	if(s[l] == 'x') return solve(l+1, r) + 1;
	if(s[r] == 'x') return solve(l, r-1) + 1;
	f = true;
	return 1e9;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> s;
	int ans = solve(0, (int)s.length() - 1);	
	if(f) cout << -1;
	else cout << ans;

	return 0;
}


Measured memory_bytes: 512
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<set>
#include<map>

using namespace std;
long long MOD = 1000000007LL;
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define endl "\n"
const double PI = 3.14159265358979323846;

int main() {
	double a, b, h, m;
	cin >> a >> b >> h >> m;

	double degA, degB;
	degA = (h / 12.0) * 2 * PI + 2 * PI * (m / 60.0) * (1.0 / 12.0);
	degB = (m / 60.0) * 2 * PI;


	double deg = min(degA - degB, degB - degA);
	double ans = sqrt(pow(a, 2) + pow(b, 2) - 2 * a * b * cos(deg));

	printf("%0.12lf\r\n", ans);

	return 0;
}



Measured memory_bytes: 4256
#include "bits/stdc++.h"
using namespace std;
 
////////////// Prewritten code follows. Look down for solution. ////////////////

#define fs first
#define sc second
#define pb push_back
#define len(x) ((int)(x).size())
#define fastio ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef long long ll;

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

/// command for char arrays with spaces -> scanf(" %[^\n]", text);
 
////////////////////////// Solution starts below. //////////////////////////////

int main(){
	fastio;
	int h, a;
	cin >> h >> a;
	int ans = h/a;
	if(h%a) ans++;
	cout << ans << endl;
	return 0;
}

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

using ll=long long;
using namespace std;

#define rep_i(i, n) for (int i = 0; i < (n); ++i)
#define rep_ll(i, n) for (long long i = 0; i < (n); ++i)
#define r_rep_i(i, start, end) for (int i = (start); i < (end); ++i)
#define r_rep_ll(i, start, end) for (long long i = (start); i < (end); ++i)
#define debug_vi(v) copy((v).begin(), (v).end(), ostream_iterator<int>(cout, " "));
#define debug_vll(v) copy((v).begin(), (v).end(), ostream_iterator<long long>(cout, " "));
#define debug_vd(v) copy((v).begin(), (v).end(), ostream_iterator<double>(cout, " "));
#define sort_v(v) sort((v).begin(), (v).end()); //昇順
#define d_sort_vi(v) sort((v).begin(), (v).end(), greater<int>()); //降
#define d_sort_vll(v) sort((v).begin(), (v).end(), greater<long long>()); //降
#define d_sort_vd(v) sort((v).begin(), (v).end(), greater<double>()); //昇順
#define say(t) cout << (t) << endl;
#define sum_vi(v) accumulate((v).begin(), (v).end(), 0);
#define sum_vll(v)accumulate((v).begin(), (v).end(), 0LL);

ll gcd(ll a, ll b) { return b?gcd(b, a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a, b)*b;}

const int IINF=(1<<30);
const ll LLINF = 1LL<<60;

char BigAlphaToSmall(char a){
    if (a >= 65 && a <= 90){
        return a + 32;
    }
    return a;
}

char SmallAlphaToBig(char a){
    if (a >= 97 && a <= 122){
        return a - 32;
    }
    return a;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    string s;cin >> s;
    int n; cin >> n;
    string cmd;
    string p;
    int a, b;
    for (int i = 0; i < n; i++){
        // cout << "#" << endl;
        cin >> cmd >> a >> b;
        if (cmd == "replace"){
            cin >> p;
            s.replace(a, (b - a + 1), p);
            // cout << s << endl;
        }

        if(cmd == "reverse"){
            reverse(s.begin() + a, s.begin() + (b + 1));
            // cout << s << endl;
        }

        if(cmd == "print"){
            // cout << s << endl;
            cout << s.substr(a, (b - a + 1)) << endl;
        }
    }
    
}


Measured memory_bytes: 3216
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// AtCoder_C
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		long A[] = new long[N];

		long ans = 0;
		for(int i=0; i<N; i++) {
			A[i] = sc.nextLong();
		}

		long HNow = A[0];

		for(int i=1; i<N; i++) {
			if(A[i] < HNow) {
				ans += HNow - A[i];
			} else {
				HNow = A[i];
			}
		}

		System.out.println(ans);

	    // Scannerクラスのインスタンスをクローズ
		sc.close();
	}
}

Measured memory_bytes: 61532
from math import factorial

n,p = map(int,input().split())
a_input = list(map(int,input().split()))

#p==0:奇数が偶数個になるまで食べる
#p==1:奇数が奇数個になるまで食べる
def calc_comb(n,r):
    return factorial(n) / factorial(r) / factorial(n - r)

odd_len = 0
even_len = 0
for i in range(n):
    if a_input[i]%2==0:
        even_len+=1
    else:
        odd_len+=1

ans=0
even_comb = 2**even_len
if p==0:
    if odd_len%2==0:
        for i in range(0,odd_len+1,2):
            ans+=calc_comb(odd_len,i)*even_comb
    if odd_len%2==1:
        for i in range(1,odd_len+1,2):
            ans+=calc_comb(odd_len,i)*even_comb
else:
    if odd_len%2==0:
        for i in range(1,odd_len+1,2):
            ans+=calc_comb(odd_len,i)*even_comb
    if odd_len%2==1:
        for i in range(0,odd_len+1,2):
            ans+=calc_comb(odd_len,i)*even_comb
print(int(ans))


Measured memory_bytes: 3064
def gcd(a,b):
    x = max(a,b)
    y = min(a,b)
    if x%y == 0:
        return y
    else:
        while x%y != 0:
            z = x%y
            x = y
            y = z
        else:
            return z



def lcm(m,n):
    return int(m * n/gcd(m,n))

a,b = map(int,input().split())
print(lcm(a,b))


Measured memory_bytes: 3060
using System;

namespace SmallLargeorEqual
{
	class MainClass
	{
		public static void Main (string[] args)
		{
			//??\??????
			string[] ab = Console.ReadLine().Split(' ');

			//??´??°a
			int a = int.Parse (ab[0]);
			//??´??°b
			int b = int.Parse (ab[1]);

			//a ?????? b ???????????§???????????°
			if (a < b) {
				Console.WriteLine ("a < b");
			} 
			//a ?????? b ??????????°????????????°
			else if (a > b) {
				Console.WriteLine ("a > b");
			} 
			//a ??¨ b ?????????????????°
			else {
				Console.WriteLine ("a == b");
			}
		}
	}
}

Measured memory_bytes: 5284
#ifdef LOCAL
  #define debug_echo(expr) cout << expr;
#else
  #define debug_echo(expr)
#endif

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

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

#include <vector>
template<class T>
ostream &operator<<(ostream &o, const vector<T> &v)
{
    o<<"{";
    bool f = false;
    for (const T &a: v)
        o<<(f?", ":"")<<a,
        f = true;
    o<<"}";
    return o;
}

enum Reach {
    Unreachable,
    Reachable,
};

int N;
int M;
vector<pair<int, int> > ab;
Reach canReachIsland[200000];

bool solve(int curri, int nexti) {
    if (canReachIsland[nexti] == Reachable) {
        return true;
    } else if (canReachIsland[nexti] == Unreachable) {
        return false;
    }

    // bool canReach = false;
    // for (int i = curri; i < M; i++) {
    //     if (ab[i].first == nexti && ab[i].second == N) {
    //         return true;
    //     } else if (ab[i].second == nexti && ab[i].first == N) {
    //         return true;
    //     } else if (ab[i].first == N || ab[i].second == N) {
    //         canReachIsland = true;
    //     }
    // }
    // if (canReach) {
    //     canReachIsland[nexti] = Reachable;
    // } else {
    //     canReachIsland[nexti] = Unreachable;
    // }
    // return false;
}

int main() {
    cin >> N >> M;
    rep(i, M) {
        int a;
        int b;
        cin >> a >> b;
        ab.push_back(make_pair(a, b));
    }
    sort(ab.begin(), ab.end());
    rep(i, N) {
        canReachIsland[i] = Unreachable;
    }
    rep(i, M) {
        if (ab[i].first == N) {
            canReachIsland[ab[i].second] = Reachable;
        } else if(ab[i].second == N) {
            canReachIsland[ab[i].first] = Reachable;
        }
    }
    
    bool possible = false;
    rep(i, M) {
        if (ab[i].first == 1) {
            if (solve(i, ab[i].second)) {
                possible = true;
                break;
            }
        } else if (ab[i].second == 1) {
            if (solve(i, ab[i].first)) {
                possible = true;
                break;
            }
        }
    }
    if (possible) {
        cout << "POSSIBLE" << endl;
    } else {
        cout << "IMPOSSIBLE" << endl;
    }
}


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

using namespace std;

int Molecule, Denominator;
string InputInfo;


void getDataWithoutBrackets() {
	int pos, cnt, acc;
	int num, num1;
	stringstream ss;

	pos = InputInfo.find('.');
	cnt = InputInfo.size() - 1 - pos;
	ss << InputInfo.substr(pos + 1, cnt);
	ss >> num;
	//cout << "num=" << num << endl;
	acc = 1;
	if (num != 0) {
		acc = pow(10, cnt);
	}
	//cout << "acc=" << acc << endl;
	ss.clear();
	ss << InputInfo.substr(0, pos);
	ss >> num1;
	num += num1*acc;
	//cout << "num_=" << num << endl;
	Molecule = num;
	Denominator = acc;
}

void getDataWithBrackets(int pos) {
	int posPoint, cnt, cntInter;
	int num, num1;
	string tmp, tmpInter;
	stringstream ss;

	posPoint = InputInfo.find('.');
	cntInter = pos - posPoint - 1;
	//cout << cntInter << endl;
	cnt = InputInfo.size() - 1 - posPoint - 2;
	//cout << cnt << endl;

	tmpInter = InputInfo.substr(0, pos);
	tmpInter.erase(tmpInter.find('.'), 1);
	//cout << tmpInter << endl;
	ss << tmpInter;
	ss >> num;
	//cout << num << endl;

	tmp = tmpInter + InputInfo.substr(pos + 1, InputInfo.size() - 1 - pos - 1);
	//cout << tmp << endl;
	ss.clear();
	ss << tmp;
	ss >> num1;
	//cout << num1 << endl;
	Molecule = num1 - num;
	Denominator = pow(10, cnt) - pow(10, cntInter);
}

int getGcd(int a, int b) {
	if (b == 0) {
		return a;
	}
	return getGcd(b, a%b);
}

int main() {
	int gcd, pos;

	cin >> InputInfo;
	pos = InputInfo.find('(');
	if (pos == string::npos) {
		getDataWithoutBrackets();
	}
	else {
		getDataWithBrackets(pos);
	}
	//cout << Molecule << " : " << Denominator << endl;
	gcd = getGcd(Molecule, Denominator);
	//cout << "gcd=" << gcd << endl;
	cout << Molecule / gcd << "/" << Denominator / gcd << endl;

	return 0;
}



Measured memory_bytes: 3356
#include <bits/stdc++.h>
#define ALL(A) (A).begin(),(A).end()
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int k;
	cin >> k;
	vector<ll> a(k);
	rep(i,k)cin >> a[i];
	reverse(ALL(a));
	ll l  = 2, r = 3;
	for(int i=0;i<k;i++){
		l = (l + a[i] - 1 )/a[i] * a[i];
		r = (r + a[i] - 1 )/a[i] * a[i];
	}
	if(l==r){
		cout << -1 << endl;
	}else{
		cout << l << " " << r-1 << endl;
	}
}

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

constexpr int MAX_N = 100 + 7;
constexpr int MAX_W = 1e5 + 7;

int w[MAX_N], v[MAX_N];
long dp[MAX_N][MAX_W];

int main() {
  int N, W;
  cin >> N >> W;
  for (int i{1}; i <= N; ++i) {
    cin >> w[i] >> v[i];
  }

  for (int i{1}; i <= N; ++i) {
    for (int j{}; j <= W; ++j) {
      if (j < w[i]) {
        dp[i][j] = dp[i - 1][j];
      } else {
        dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w[i]] + v[i]);
      }
    }
  }
  cout << dp[N][W] << endl;
  return 0;
}


Measured memory_bytes: 79360
#include <iostream>
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
using namespace __gnu_pbds; 
using  namespace std;

#define endl '\n'
#define ll long long
#define re register
#define pb(x) push_back(x)
#define ce(x) cout << x << endl;

using db = long double;
using pii = pair < int, int >;
using pll = pair < ll, ll >;
#define scl1(a)             scanf(“%I64d", &a)
#define scl2(a, b)          scanf("%lld %lld", &a, &b)

#define rep(i,x,n,inc) for(i=x ; i<n ; i+=inc)
#define repr(i,x,n,inc) for( i=x ; i>n ; i+=inc)
#define all(a)      (a).begin(),(a).end()
#define rall(x) (x).rbegin(), (x).rend()
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))

#define mp(a,b) make_pair(a,b)
#define ff first
#define ss second
#define hell 1000000007
const db pi = acos(-1);
const long long infl = LLONG_MAX;
const int inf = 0x3f3f3f3f;

#define Foxen(i,s) for (i=s.begin(); i!=s.end(); i++)
#define Fill(s,v) memset(s,v,sizeof(s))
#define cout_p(x, p) cout << fixed << setprecision((p)) << x << endl     //print with precision

#define tc(tt) \
    ll tt;    \
    cin >> tt; \
    for (ll _tt = 0; _tt < tt; _tt++) // testcase 

int32_t main(){

	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

ll t,i,x,j,y,z,k=infl,n;
cin>>n;
	for(i=1;i*i<=n;i++){
		if(n%i)	continue;
		x=i,y=n/i;
		k=min(k,x+y-2);
	}
	ce(k)
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] ss = Console.ReadLine().Split(' ');
            int AB = int.Parse(ss[0]);
            int BC = int.Parse(ss[1]);
            Console.WriteLine(AB * BC / 2);
        }
    }
}


Measured memory_bytes: 13140
#include <set>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <map>
#include <bitset>
#define ll long long
#define inf 0x3f3f3f3f
#define ms(a, b) memset(a, b, sizeof a)
using namespace std;
int a, b, c, d;
int main(void) {
    cin >> a >> b >> c >> d;
    if(c > b || d < a) cout << "0";
    else {
        if(c > a) {
            if(d > b) {
                cout << b - c;
            }
            else {
                cout << d - c;
            }
        }
        else {
            if(d > b) {
                cout << b - a;
            }
            else {
                cout << d - a;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define sz(x) ((int)x.size())
#define pb push_back
#define ii pair<int,int>
#define orta ((bas+son)/2)
#define st first
#define nd second
#define ll long long
#define N 100005
#define inf 1000000000
#define MOD 1000000007
using namespace std;

int n,q;
ll m;
int dad[N],dad2[N],sz[N];

int find2(int x) {return dad2[x]=(x==dad2[x]?x:find2(dad2[x]));}

int find(int x) {return dad[x]=(x==dad[x]?x:find(dad[x]));}

void fail() {cout<<"No";exit(0);}

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);

	cin>>n>>m>>q;

	for(int i=1;i<=n;i++) dad[i]=i;

	int cnt=n;

	vector<ii> ch;

	for(int i=1;i<=q;i++) {

		int a,b,c;

		cin>>a>>b>>c;

		a++;b++;

		if(c==0) {

			if(find(a)!=find(b)) {

				dad[find(a)]=find(b);
				cnt--;

			}

		}
		else {

			ch.pb({a,b});

		}
 
	}

	for(auto x:ch) {

		if(find(x.st)==find(x.nd)) fail();

	}

	if(sz(ch) && cnt<3) fail();

	if((ll)cnt*(cnt-1)/2+n-cnt<m) fail();

	ll mn=n-cnt;

	for(int i=1;i<=n;i++) if(find(i)==i) dad2[i]=i,sz[i]=1;

	for(auto x:ch) {

	//	cerr<<x.st<<" "<<x.nd<<" "<<find(x.st)<<" "<<find(x.nd)<<"\n";

		if(find2(find(x.st))!=find2(find(x.nd))) {

			sz[find2(find(x.nd))]+=sz[find2(find(x.st))];
			dad2[find2(find(x.st))]=find2(find(x.nd));

//			cerr<<sz[find2(find(x.nd))]<<find(x.nd)<<"\n";	

		}

	}

	bool no=0;
	bool y=0;

	for(int i=1;i<=n;i++) {

		if(find2(i)==i) {

			if(sz[find2(i)]==2) {

				mn+=2;
				if(y==0) y=1;
				else y=-1;

			}
			else if(sz[find2(i)]!=1) {

				no=1;
				mn+=sz[find2(i)];

			}

		}

	}

	if(!no && y==1) mn++;

//	cerr<<mn<<"\n";

	if(mn>m) fail();

	cout<<"Yes";

}

Measured memory_bytes: 2292
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    x,y = MI()
    if y==0:
        if(x<0):
            ans = abs(x)
        else:
            ans = abs(x)+1
    else:
        if(x<0):
            if(y>=0):
                if(abs(x)<=abs(y)):
                    ans = abs(y)-abs(x)+1
                else:
                    ans = abs(x) - abs(y) + 1
            else:
                if(y<x):
                    ans = abs(abs(y) - abs(x)) + 2
                else:
                    ans = y - x
        else:
            if(y>=0):
                if(x<=y):
                    ans = y-x
                else:
                    ans = abs(y-x)+2
            else:
                if(abs(x)<=abs(y)):
                    ans = abs(y)-abs(x)+1
                else:
                    ans = 1+x-abs(y)

    print(ans)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 63468
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;

#define rep(i,n)  for(int i = 0; i < (int)(n);    i++)
#define sz(x)     ((int)(x).size())
#define all(x)    (x).begin(),(x).end()

using ll = long long;

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); }

int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  int N, K; std::cin >> N >> K;
  std::vector<int> A(N, 0);
  rep(i, K) {
    int d; std::cin >> d;
    rep(j,d) {
      int a; std::cin >> a; a--;
      A[a]++;
    }
  }

  int ans = 0;
  rep(i,N) if ( A[i] == 0 ) ans++;
  std::cout << ans << std::endl;
  return 0;
}



Measured memory_bytes: 3644
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef deque<ll> di;
typedef pair<ll,ll> pi;
#define pb push_back
#define mp make_pair
#define mh make_heap
#define pf push_front
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define INF 1000000000
#define FOR(i,a,b) for(ll i=a;i<b;i++)


int main()
{
    //freopen("contest.txt","r",stdin);
    //freopen("contest.txt","w",stdout);
    IOS
    ll n;
    cin>>n;
    ll flag=0;
    ll count_=0;
    while(n--)
    {
        ll d1,d2;
        cin>>d1>>d2;
        if(d1==d2)
            count_++;
        else
            count_=0;
        if(count_==3)
        {
            flag=1;
        }
    }
    if(flag==1)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;

    return 0;
}


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

int main() {
  int count = 0;
  string s, t;
  cin >> s >> t;
  if (s == t) {
    cout << 0 << endl;
    return 0;
  }
  for (int n = 0; n < s.size(); n++){
    if (s.at(n) != t.at(n)) {
      s.at(n) = t.at(n);
      count++;
    }
  }
  cout << count << endl;
}


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

using namespace std;

//using namespace __gnu_cxx;
//using namespace __gnu_pbds;
//template<typename T>
//using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
//struct mul {
//    long operator()(const long &n1, const long &n2) const {
//        return (n1 * n2) % Mod;
//    }
//};
//
//long identity_element(const mul &m) {
//    return 1LL;
//}

//long rand_int(long l, long r) { //[l, r]
//    static mt19937_64 gen(chrono::steady_clock::now().time_since_epoch().count());
//    return uniform_int_distribution<long>(l, r)(gen);
//}

const double PI = acos(-1.0);


int main() {
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "rt", stdin);
    //    freopen("friday.out", "w", stdout);
#endif
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0), cout.precision(10), cout << fixed;

    string str;
    cin >> str;
    for (int i = 0; i < (int) str.size() - 1; ++i) {
        if (str[i] == str[i + 1]) {
            cout << i + 1 << ' ' <<  i + 2 << '\n';
            return 0;
        }
        if (i < (int)str.size() - 2 && str[i] == str[i + 2]) {
            cout << i + 1 << ' ' <<  i + 3 << '\n';
            return 0;
        }
    }

    cout << -1 << ' ' << -1 << '\n';


    return 0;
}

Measured memory_bytes: 512
def f(X):
  if all(X[i] == X[(-1)*(i+1)] for i in range(len(X))) == True:
    return 1
  else:
    return 0

s = list(input())
n = len(s)
A = s[0:int((n-1)/2)]
B = s[int((n+3)/2)-1:n]
if f(s) * f(A)*f(B) == 1:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b) { return *(int *)a - *(int *)b; }                            /* 1,2,3,4.. */
int des(const void *a, const void *b) { return *(int *)b - *(int *)a; }                            /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { return *(char *)a - *(char *)b; }                     /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) { return strcmp(*(const char **)a, *(const char **)b); } /* aaa,aab.. */
#define min(a, b) (a < b ? a : b)
#define max(a, b) (a > b ? a : b)

int main(void)
{
  int a, b;
  scanf("%d %d", &a, &b);

  int ans;
  if (a >= 13)
    ans = b;
  else if (a >= 6)
    ans = b / 2;
  else
    ans = 0;
  printf("%d\n", ans);
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e18+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

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 (b<a) { a=b; return true; } return false; }

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);

    ll n;
    cin>>n;
    ll ans=0;
//    Vec p(n);
//    Vec q(n);
    string x;
    REP(i,1,n+1){
        x += std::to_string(i);
    }
    string p;
    string q;
    rep(i,n){
        ll tmp;
        cin>>tmp;
        p += std::to_string(tmp);
    }
    rep(i,n){
        ll tmp;
        cin>>tmp;
        q += std::to_string(tmp);
    }
//    dbg(x)
//    dbg(p)
//    dbg(q)
    ll cnt = 0;
    ll a=0;
    ll b=0;

    do {
        cnt++;
       if(x==p){
           a=cnt;
       }
        if(x==q){
            b=cnt;
        }
    }while (std::next_permutation(ALL(x)));
    cout<<abs(a-b)<<endl;
    return  0;
}


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

int main(){
    int A, B, C;
    cin >> A >> B >> C;
    int ans;
    ans = C - (A - B);
    if(ans > 0){
        cout << ans << endl;
    }
    else{
        cout << 0 << endl;
    }
}

Measured memory_bytes: 384
import java.util.Scanner;

class Main
{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int x;
    for(int i = 1 ; (x = sc.nextInt()) != 0 ; i++)
    {
      System.out.println("Case "+ i +": "+ x);
    }
  }
}

Measured memory_bytes: 42176
//
//  AOJ0593.c
//  
//
//  Created by 中野 優 on 2014/02/15.
//
//

#include <stdio.h>
int main(void){
    int n,m,i,j,max;
    scanf("%d %d",&n,&m);
    int a[n],b[m],count[n];
    for(i=0;i<n;i++) count[i]=0;
    for(i=0;i<n;i++) scanf("%d",&a[i]);
    for(i=0;i<m;i++) scanf("%d",&b[i]);

    for(i=0;i<m;i++){
        for(j=0;;j++){
            if (b[i]>=a[j]) {
                count[j]++;
                break;
            }
        }
    }
    max=1;
    for(i=0;i<n-1;i++){
        if (count[max-1]<count[i+1]) max=i+2;
    }
    printf("%d\n",max);
    return 0;
}

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

int main()
{
    int n;
    cin >> n;
    int a = 2999999;
    cin >> a;
    int ans = 1;
    for( int i = 1; i < n; i++ ){
        int b;
        cin >> b;
        if( b <= a ){
            ans = ans+1;
            a = b;
        }
    }
    cout << ans << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
double pi = acos(-1);

int main() {
    double r;
    cin >> r;
    double ans = 2.0*pi*r;
    exout(ans);
    re0;
}

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

int main()
{
	int n;
	double s[1000];
	while (true)
	{
		double sum1 = 0, m, sum2 = 0, q, a;
		cin >> n;
		if (n == 0) break;
		for (int i = 0; i < n; i++)
		{
			cin >> s[i];
			sum1 += s[i];
		}
		m = sum1 / n;
		for (int i = 0; i < n; i++)
		{
			sum2 += pow(s[i] - m, 2);
		}
		q = sum2 / n;
		a = sqrt(q);
		cout << setprecision(8) << fixed << a << endl;
	}

}
	



Measured memory_bytes: 3236
#include <stdio.h>
#include <stdlib.h>

int main(void) {
  
  int n, m;
  long sum = 0;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < m; i++)
  {
    int a;
    scanf("%d", &a);
    sum += a;
  }
  m = n - sum >= 0 ? n - sum : -1;
  printf("%d\n", m);

  return 0;
}

Measured memory_bytes: 2148
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <deque>
#include <numeric>
using lint = long long;

int main()
{
    lint n;
    scanf("%lld", &n);

    std::vector<lint> v1(100001, 0);
    std::vector<lint> v2(100001, 0);

    for (lint i = 0; i < n; ++i)
    {
        lint v;
        scanf("%lld", &v);
        if (i % 2 == 0)
        {
            v1[v - 1]++;
        }
        else
        {
            v2[v - 1]++;
        }
    }

    std::pair<lint, lint> v1_1, v1_2, v2_1, v2_2;
    v1_1 = std::make_pair(-1, 0);
    v1_2 = std::make_pair(-1, 0);
    v2_1 = std::make_pair(-1, 0);
    v2_2 = std::make_pair(-1, 0);

    for (lint i = 0; i < 100001; ++i)
    {

        if (v1_1.second <= v1[i])
        {
            v1_2 = v1_1;
            v1_1 = std::make_pair(i, v1[i]);
        }
        else if (v1_2.second <= v1[i] && v1[i] < v1_1.second)
        {
            v1_2 = std::make_pair(i, v1[i]);
        }
        if (v2_1.second <= v2[i])
        {
            v2_2 = v2_1;
            v2_1 = std::make_pair(i, v2[i]);
        }
        else if (v2_2.second <= v2[i] && v2[i] < v2_1.second)
        {
            v2_2 = std::make_pair(i, v2[i]);
        }
    }

    lint ans = 0;

    if (v1_1.first != v2_1.first)
    {
        ans = n - v1_1.second - v2_1.second;
    }
    else
    {
        ans = std::min(n - v1_1.second - v2_2.second, n - v1_2.second - v2_1.second);
    }

    printf("%lld", ans);

    return 0;
}


Measured memory_bytes: 1792
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn make_divisors(n: usize) -> Vec<usize> {
    let mut res = Vec::new();
    for i in 1.. {
        if i*i > n {
            break;
        }
        if i*i == n {
            res.push(i);
        } else if n%i == 0 {
            res.push(i);
            res.push(n/i);
        }
    }
    res
}

fn solve() {
    let n = get!(usize);

    let mut count = 0usize;
    for e in make_divisors(n).into_iter().skip(1) {
        let mut n = n;
        while n % e == 0 {
            n /= e;
        }
        if n%e ==1 {
            count += 1;
        }
    }
    count += make_divisors(n-1).len()-1;
    println!("{}", count);
}


Measured memory_bytes: 8572
import java.util.*;
import java.math.*;
public class Main{
        public static void main(String args[])
        {

            Scanner sc = new Scanner(System.in);
            int k = sc.nextInt();
            String s = sc.next();

            char c [] =new char[s.length()];
            for(int i=0; i<s.length();i++){
              int temp = (int)s.charAt(i);
              if(s.charAt(i)+k<=90)
                c[i] = (char)(temp+k);
                else
                c[i] =(char)(temp+(k-26));
            }
            for(char cc : c)
            System.out.print(cc);


        }
}


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

int main() {

    int N, M;
    cin >> N >> M;
    if (N == M)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> H(N);
  for(int i=0;i<N;i++){
    cin >> H.at(i);
  }
  vector<long long> dp(N,1000000000);
  dp.at(0)=0;
  for(int i=0;i<N-1;i++){
    if(i==N-2){
      dp.at(i+1)=min(dp.at(i+1),dp.at(i)+abs(H.at(i)-H.at(i+1)));
    }
    else{
      dp.at(i+1)=min(dp.at(i+1),dp.at(i)+abs(H.at(i)-H.at(i+1)));
      dp.at(i+2)=min(dp.at(i+2),dp.at(i)+abs(H.at(i)-H.at(i+2)));
    }
  }
  cout << dp.at(N-1) << endl;
} 

Measured memory_bytes: 4560
#include<stdio.h>

int _, a, b, c, o;
char s[2];
int main(void)
{
  while(~scanf("%d,%s", &_, s))
  {
    if(s[1] == 'B')
      c++;
    else if(s[0] == 'A')
      a++;
    else if(s[0] == 'B')
      b++;
    else
      o++;
  }
  printf("%d\n%d\n%d\n%d\n", a, b, c, o);
  return 0;
}

Measured memory_bytes: 596
#include<iostream>
#include<stdio.h>

using namespace std;

int main(){

    int N, K;
    cin>> N>> K;
    for(int i=0; i<K; i++){
        int a, b;
        scanf("%d %d", &a, &b);
        a--; b--;
        a=min(a, N-a-1); b=min(b, N-b-1);
        cout<< (min(a, b)%3+1)<< endl;
    }

    return 0;
}

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

const int MAX_N = 2005;
int N, vals[MAX_N];

int main() {
  scanf("%d", &N);
  int sum = 0;
  for (int i = 0; i < N; ++i) {
    scanf("%d", vals + i);
    sum += vals[i];
  }
  std::bitset<MAX_N * MAX_N> s{1};
  for (int i = 0; i < N; ++i) {
    s |= s << vals[i];
  }
  int last = 0;
  for (int k = s.size() - 1; k >= sum / 2 + sum % 2; --k)
    if (s[k]) last = k;
  printf("%d\n", last);
}


Measured memory_bytes: 1664
R = 2**15+1
dp = [[0]*R for i in range(5)]
dp[0][0] = dp[1][0] = dp[2][0] = dp[3][0] = 1
for i in range(1,182):
	for k in range(1,5):
		for j in range(i*i,R):
			dp[k][j] += dp[k-1][j-i*i]

while 1:
	n = input()
	if n == 0: break
	print dp[4][n]

Measured memory_bytes: 6312
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <tuple>
#include <vector>
#include <set>
#include <map>
#include <iterator>
#include <random>
#include <cmath>

using namespace std;
using lint = long long int;

int main() {
	int n;
	string s;
	cin >> n >> s;
	if (n % 2 == 1) {
		cout << "No" << endl;
		return 0;
	}
		
	int n2 = n / 2;

	string s1 = s.substr(0, n2);
	string s2 = s.substr(n2, n2);
	if (s1 == s2)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;

}


Measured memory_bytes: 256
import std.stdio, std.string, std.range, std.algorithm;

void main() {
    string s = strip(readln());
    size_t n = s.length;
    auto odd = filter!(a => a%2 == 0)(iota(n));
    foreach (c; map!(i => s[i])(odd)) {
        write(c);
    }
    writeln();
}



Measured memory_bytes: 508
n = int(input())

primes = set(range(2, n+1))
for i in range(2, int(n**0.5+1)):
    primes.difference_update(range(i*2, n+1, i))
primes=list(primes)

ans=0
for i in range(1,n):
    ans+=(n-1)//i
print(ans)

Measured memory_bytes: 172720