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

    #define all(v) v.begin(),v.end()
    #define rall(v) v.rbegin(),v.rend()
    #define trav(i,a) for(auto i: a)
    #define ff first
    #define ss second
    #define eb emplace_back
    #define tc(t) ll t; cin>>t; while(t--)
    #define prec(n) fixed<<setprecission(n)
    #define mst(arr,value) memset(arr,value,sizeof(arr))
    #define mod %MOD
    #define sz(a) a.size()
    
    const long long inf = (long long)1e18;
    const long long MOD = (long long)1e9+7;
    
    #define f(i,n)     for(ll i=0;   i<n;  i++)
    #define fab(i,a,b) for(ll i=a;   i<b;  i++)
    #define fr(i,n)    for(ll i=n-1; i>=0; i--)
    #define fba(i,b,a) for(ll i=b-1; i>=a; i--)

    ll bpw(ll a, ll b) {
        if(b == 0) return 1;
        if(b % 2 == 1) {
            return bpw(a, b - 1) * a mod;
        } else {
            ll b2 = bpw(a, b / 2) mod;
            return b2 * b2 mod;
        }
    }
    ll ncr(ll n, ll r) { 
        ll p = 1, k = 1, m; 
        if (n - r < r) 
            r = n - r; 
        if (r != 0) { 
            while (r) { 
                p *= n; 
                k *= r; 
                m = __gcd(p, k); 
                p /= m; 
                k /= m; 
                n--; 
                r--; 
            } 
        } 
        else
            p = 1;  
        return p; 
    } 

    int main() {
        ios_base::sync_with_stdio(0);
        cin.tie(NULL);
        cout.tie(NULL);
        string s;
        cin >> s;
        if(s[2] == s[3] and s[4] == s[5]) cout << "Yes";
        else cout << "No";
        return 0;
    }

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <map>

int main(){
    int n;
    std::cin >> n;
    
    std::map<int, int> mp;
    for (int i = 0; i < n; i++)
    {
        int a;
        std::cin >> a;
        mp[a]++;
    }
    
    int ans = 0;
    for (auto p: mp)
    {
        int num = p.first;
        int count = p.second;
        if (num < count)
        {
            ans += count - num;
        }
        else if (count < num)
        {
            ans += count;
        }
    }
    
    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 8120
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define LI list<int>
#define vct vector
#define vi vct<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vvi vct<vi>
#define vll vct<ll>
#define vvll vct<vll>
#define all(a) a.begin(),a.end()
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define ff first
#define ss second
#define bg begin()
#define ft cout<<"for test"<<endl;
#define read(v,a,n) for(int i=a; i<n; i++)cin>>v[i];
#define pi 2*acos(0.0)
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define t_c int test,cs=1;cin>>test;while(test--)
#define lcm(a,b) (a*b)/__gcd(a,b)
#define mod 1000000007
int main()
{
    FIO;
    int a,b;
    cin>>a>>b;
    cout<<a*b<<endl;
}



Measured memory_bytes: 3636
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <cstdarg>
#include <sys/time.h>
#include <fstream>
//#include "cout.h"

using namespace std;

#define SZ(x) ((int)x.size())
#define MSET(x,a) memset(x, a, (int)sizeof(x))
#define PB push_back
#define VI vector < int >
#define PII pair < int, int >
#define LL long long
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define FIT(it,v) for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define OUT(A) cout << #A << " = "<< (A) << endl
#define OUT2(A, B) cout << "(" << #A << ", " << #B << ") = (" << (A) << ", "<< (B) << ")" << endl
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }

#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(ALL(c), (e)) != (c).end())

int n;

void init() {

}

void input() {

}

vector<int> divisor(long long l){
    vector<int> res;
    for(long long i=1; i*i<=l; i++){
        if(l%i == 0){
            res.push_back(i);
            if(i != l/i) res.push_back(l/i);
        }
    }
    return res;
}

void solve() {
  cin >> n;
  int res = 0;
  for(int i=105; i<=n; i+=2) {
    VI v = divisor(i);
    if(v.size() == 8) res++;
  }
  cout << res <<endl;
}

int main() {
	init();
	input();
	solve();
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main(){
    int n, a, b;
    cin >> n >> a >> b;
    if ( a * n > b ) {
        cout << b << endl;
    }
    else {
        cout << a * n << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main() {
    int N, L;
    std::cin >> N >> L;

    const int R = L + N - 1;

    int eat = 0;
    if (R <= 0) {
        eat = R;
    } else if (L >= 0) {
        eat = L;
    } else {
        eat = 0;
    }

    const int total = N * L + N * (N - 1) / 2; 

    const int ret = total - eat;

    std::cout << ret << std::endl;
}


Measured memory_bytes: 256
import java.util.*;
class Main
{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s=sc.next();
		StringBuffer sb = new StringBuffer();
		int len=s.length();
		for(int i=0;i<len;i++)
		{
			if(s.charAt(i)=='1')
				sb.append('9');
			else if(s.charAt(i)=='9')
				sb.append('1');
			else
				sb.append(s.charAt(i));
		}
		System.out.println(sb);
	}
}

Measured memory_bytes: 21332
#include <bits/stdc++.h>
////////////////////////////////////////////////////////////
#define all(x) (x).begin(), (x).end()
const int inf = 1e9;
const long long INF=1e15;
#define endl '\n'
#define rep(i, n) for(int i=0;i<(n);++i)
#define repp(i, a, b) for(int i=(a);i<=(b);++i)
#define pb push_back
#define eb emplace_back
#define fastio ios::sync_with_stdio(false);cin.tie(0); //cout.tie(0);

using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ii> vii;

void solve() {
	string s; cin >> s;
	if(s[2] == s[3] && s[4] == s[5]) cout << "Yes";
	else cout << "No";
}
int main() {
	fastio;
	solve();
}

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

typedef long long ll;

int main(){
int N;  cin >> N;
  vector<string> S(N);
  
  for(int i = 0; i < N; i++){
    cin >> S[i]; sort(S[i].begin(),S[i].end());}
  
  
  
  sort(S.begin(),S.end());
  
  vector<ll> vec;
  
  int head = 0; int tail = 0;
  
  while( head < N){
    
    while( tail < N && S[tail] == S[head]){  tail++;}
    
    vec.push_back( tail - head);
    head = tail;}
  
  ll res = 0;
  
  for(int i = 0; i < (int) vec.size(); i++){
    res += (vec[i] * ( vec[i] - 1 )) / 2;}
  
  cout<< res <<endl; return 0;}
                 
  


Measured memory_bytes: 9344
N = int(input())
X, Y, H = [], [], []
X0, Y0, H0 = 0, 0, 0
for i in range(N):
    x, y, h = map(int, input().split())
    X.append(x)
    Y.append(y)
    H.append(h)
    if h >= 1:
        X0, Y0, H0 = x, y, h

M = 101
for i in range(M):
    for j in range(M):
        H1 = H0 + abs(X0 - i) + abs(Y0 - j)

        flag = True
        for k in range(N):
            if max(H1 - abs(i - X[k]) - abs(j - Y[k]), 0) != H[k]:
                flag = False

        if flag:
            print(i, j, H1)
            exit()





Measured memory_bytes: 3064
#include<stdio.h>
int main(){
  char s[258];
  int n,i,j,l,k,x,y,max;
  int X[]={1,1,0,-1};
  int Y[]={0,1,1, 1};
  while(1){
    scanf("%d",&n);
    if(n==0)break;
    scanf("\n");
    int m[257][257]={0};
    max=0;
    for(i=0;i<n;i++){
      fgets(s,257,stdin);
      for(j=0;j<n;j++){
	m[i+1][j+1]=s[j]-'0';
      }
    }
    for(i=0;i<n;i++){
      for(j=0;j<n;j++){
	if(m[i+1][j+1]==1){
	  for(k=0;k<4;k++){
	    x=j+1;
	    y=i+1;
	    l=0;
	    while(m[y][x]==1){
	      x+=X[k];
	      y+=Y[k];
	      l++;
	    }
	    if(max<l)max=l;
	  }
	}
      }
    }
    printf("%d\n",max);
  }
  return 0;
}

Measured memory_bytes: 872
import heapq

N = int(input())
Vn = list(map(int,input().split(' ')))
heapq.heapify(Vn)
init_val = heapq.heappop(Vn) 

for _ in range(N -1):
    init_val = (init_val + heapq.heappop(Vn))/2
print(init_val)

Measured memory_bytes: 3060
#include<stdio.h>
#include<string.h>
int max(int,int);
int LCSlength(char* ,char *);
int main(){
  int n,i;
  char X[1001],Y[1001];
  scanf("%d",&n);
  for(i = 0;i < n;i++){
    scanf("%s%s",X,Y);

    printf("%d\n",LCSlength(X,Y));
  }
  return 0;
}

int max(int a, int b){ return a < b ? b : a;}

int LCSlength(char *X,char *Y){
  int xlen,ylen,i,j;
  int Z[1001][1001];
  xlen = strlen(X);
  ylen = strlen(Y);
  for(i = 0; i < xlen+1;i++){
    Z[i][0] = 0;
  }
 for(i = 0; i < ylen+1;i++){
    Z[0][i] = 0;
  }



  for(i = 1;i <= xlen; i++){
    for(j = 1; j <= ylen; j++){
      if(X[i-1] == Y[j-1]) Z[i][j] = Z[i-1][j-1] + 1;
      else Z[i][j] = max(Z[i-1][j], Z[i][j-1]);
    }
  }

  

  return Z[xlen][ylen];
}

Measured memory_bytes: 4520
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;
int main() {
    string s, t;
    cin >> s >> t;
    t.pop_back();
    if(s == t) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define sz 10010
#define MOD 1000000007
#define ll long long

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	ll a, b, d; char c;
	cin >> a >> b >> c >> d;
	b = (b * 100) + d;
	cout << (a * b / 100);
	return 0;
}

Measured memory_bytes: 3612
N=int(input())
As=[int(e) for e in input().split(' ')]

d={}
for Ai in As:
    if Ai in d.keys():
        d[Ai] += 1
    else:
        d[Ai] = 1

sum=0
for k in d.keys():
    n=d[k]
    sum+=n*(n-1)//2

for Ai in As:
    n=d[Ai]
    print(sum-(n-1))

Measured memory_bytes: 26268
//コンパイラ最適化用
#pragma GCC optimize("Ofast")
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, int> pii;
typedef pair<ll, ld> pld;
typedef pair<pii, int> ppiii;
typedef pair<pii, ll> ppiill;
typedef pair<pll, ll> ppllll;
typedef pair<pli, int> pplii;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<int>> vvint;
typedef vector<vector<pll>> vvpll;

//マクロ
//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() 
#define SIZE(x) ll(x.size()) 
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define cin(x) cin >> x

vector<long long> solve(int N, vector<int> X, vector<int> Y, vector<int> P){
    const ll inf = 1LL <<62;
    int mul = 1;
    REP(i,N){mul*= 3;}
    vvint xsel(1<<N, vint(N));
    vvint ysel(1<<N, vint(N));
    for(int i =0; i <1 <<N; ++i){
        REP(j,N){
            xsel[i][j] = abs(X[j]);
            ysel[i][j] = abs(Y[j]);
            REP(k,N){
                if((i >> k) & 1){
                    xsel[i][j] = min(xsel[i][j],abs(X[j] - X[k]));
                    ysel[i][j] = min(ysel[i][j],abs(Y[j] - Y[k])); 
                }
            }
        }
    }
    vll ans(N+1, inf);
    for(int i =0; i < 1 << N; ++i){
        int cnt =0;
        REP(j,N){
            if((i >> j) & 1) ++cnt;
        }
        for(int j =i; j >= 0; --j){
            j &= i;
            ll cost = 0;
            REP(k,N){
                if(!((i >> k) & 1)){
                    cost += 1LL * min({xsel[j][k], ysel[i -j][k]}) *P[k];
                }
            }
            ans[cnt] = min(ans[cnt],cost);
        }
    }
    return ans;
}

signed main(){
    //入力の高速化用のコード
    //ios::sync_with_stdio(false);
    //cin.tie(nullptr);
    int N=0;
    cin(N);
    vint X(N), Y(N), P(N); 
    for(int i=0; i< N; i++){
        cin >> X[i] >> Y[i] >> P[i];
    }

    vll ans = solve(N, X ,Y , P);
    REP(i,N+1){
        cout << ans[i] << endl;
    }

  return 0;
}

Measured memory_bytes: 9792
N = int(input())
katsudou = [[0, 0, 0]]
for _ in range(N):
    katsudou.append(list(map(int, input().split())))

dp = [[0 for _ in range(3)] for _ in range(N + 1)]

for i in range(3):
    dp[1][i] = katsudou[1][i]

for i in range(2, N + 1):
    for j in range(3):
        if j == 0:
            dp[i][j] = max(dp[i - 1][1] + katsudou[i][j], 
            dp[i - 1][2] + katsudou[i][j])
        elif j == 1:
            dp[i][j] = max(dp[i - 1][0] + katsudou[i][j], 
            dp[i - 1][2] + katsudou[i][j])
        else:
            dp[i][j] = max(dp[i - 1][0] + katsudou[i][j], 
            dp[i - 1][1] + katsudou[i][j])

print(max(dp[N]))

Measured memory_bytes: 47300
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            String s = sc.nextLine();
            String answer = "";
            for (int i = 0; i < s.length(); i++) {
                char ch = s.charAt(i);
                if ('A' <= ch && ch <= 'Z') {
                    ch += 32;
                } else if ('a' <= ch && ch <= 'z') {
                    ch -= 32;
                }
                answer += ch;
            }
            System.out.println(answer);
        }
        sc.close();
    }
}


Measured memory_bytes: 31532
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <iostream>
#include <map>
#include <set>
#include <utility>
#include <vector>

using namespace std;

int main(){
  string s;
  cin >> s;
  for (int i = 0; i < 4; i++){
    cout << s[i];
  }  
  cout << ' ';
  for (int i = 4; i < s.length(); i++){
    cout << s[i];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
X = list(map(int,input().split()))
X.sort()
b = X[1]-X[0]
c = X[2]-X[0]
ans = 0
if b%2==1 and c%2==1:
  b += 1
  c += 1
  ans += 1
elif b%2==1 and c%2==0:
  b += -1
  ans += 1
elif b%2==0 and c%2==1:
  c += -1
  ans += 1
ans += (c + c - b)//2
print(ans)

Measured memory_bytes: 3064
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<functional>
#include <random>

using namespace std;

int main(void) {
	long long K, A, B, m;
	scanf("%lld %lld %lld", &K, &A, &B);
	m = (K + 1 - A) / 2;
	if (m < 0) { m = 0; }
	if (B - A < 2) { m = 0; }
	printf("%lld\n", 1 + (K - 2 * m) + m * (B - A));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
  
#define REP(i, s, n) for(int i = s; i < n; ++i)
#define rep(i, n)        REP(i, 0, n)
#define SORT(c)          sort((c).begin(), (c).end())
#define IINF    INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
  
typedef long long               ll;
typedef pair <int, int> ii;
  
/*
struct point{
    ll x;
    ll y;
    point(){x = 0;y = 0;}
    point(ll x, ll y):x(x), y(y){}
};
*/
 
int dw[] = {0, 1, 0 ,-1};
int dh[] = {1, 0 ,-1, 0};
 
int main() {
 
    int w, h;
    while(cin >> w >> h, w, h){
        vector<vector<int>> yoko(h ,vector<int>(w+1, 1));
        vector<vector<int>> tate(h+1 ,vector<int>(w, 1));
         
        rep(i, 2*h-1){
            if(i%2==0){
                rep(j, w-1) cin >> yoko[(int)(i/2)][j+1];
            }
            else{
                rep(j, w) cin >> tate[(int)(i/2)+1][j];
            }
        }
       
        queue<pair<ii, int>> qu;
        qu.push(make_pair(make_pair(0, 0), 0)); // h, w
         
        vector<vector<bool>> used(h, vector<bool>(w));
         
        int ans = 0;
         
        while(!qu.empty()){
            pair<ii, int> tmp = qu.front();
            qu.pop();
             
            int hh = tmp.first.first;
            int ww = tmp.first.second;
             
            if(used[hh][ww]) continue;
            used[hh][ww] = true;
            if(hh == h-1 && ww == w-1){
                ans = tmp.second + 1;
                break;
            }
             
            if(yoko[hh][ww] == 0) qu.push(make_pair(make_pair(hh, ww-1), tmp.second + 1));
            if(yoko[hh][ww+1] == 0) qu.push(make_pair(make_pair(hh, ww+1), tmp.second + 1));
            if(tate[hh][ww] == 0) qu.push(make_pair(make_pair(hh-1, ww), tmp.second + 1));
            if(tate[hh+1][ww] == 0) qu.push(make_pair(make_pair(hh+1, ww), tmp.second + 1));
        }
         
        cout << ans << endl;
 
    }
 
    return 0;
}

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

namespace abc125
{
    class Program
    {
        static void Main(string[] args)
        {
            var inputs = Console.ReadLine()
                .Split(' ')
                .Select(s => int.Parse(s))
                .ToArray();

            var a = inputs[0];
            var b = inputs[1];
            var t = inputs[2];

            var now = 0;
            var count = 0;

            while (true)
            {
                if (now + a > t)
                {
                    break;
                }

                count += b;
                now = now + a;
            }

            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 13268
-module('Main').
-export([main/1]).

rec(A, N) when A rem 2 =:= 0 -> rec(A div 2, N + 1);
rec(_, N) -> N.

solve() ->
    [N] = input("~d"),
    A = input(lists:flatten(["~d" || _ <- lists:seq(1, N)])),
    And = lists:foldl(fun (Elem, Acc) -> Elem bor Acc end, 0, A),
    io:format("~B~n", [rec(And, 0)]),
    ok.

main(_) ->
    solve(),
    halt().

input(Pat) ->
    {ok, L} = io:fread("", Pat),
    L.


Measured memory_bytes: 22084
#include <bits/stdc++.h>
using namespace std;
int s = 0;
string str;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cin >> str;
	for (char c : str) {
		if (c == '+') ++s;
		else if (c == '-') --s;
	}
	cout << s << '\n';
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define per(i, a, b) for (int i = (a); i >= (b); --i)
#define pb push_back
#define mp make_pair
#define pr pair<int, int>
#define x first
#define y second
using namespace std;

template<typename T>
void read(T& n){
	char ch; int sign = 1;
	while (!isdigit(ch = getchar())) if (ch == '-') sign = -1;
	n = ch - '0';
	while (isdigit(ch = getchar())) n = n * 10 + ch - '0';
	n *= sign;
}
typedef long long ll;
const int INF = 1e9 + 7;
const int N = 211111;
int n, x, mark(0);
int vis[N], mex[N];
struct edge{int to, nxt;} g[N];
int ghead[N], gtail(0);
vector<int> cir;
pr candidates[N];

void add(int l, int r){g[++gtail] = (edge){r, ghead[l]}, ghead[l] = gtail;}
void dfs(int x){
	vis[x] = mark;
	for (int p = ghead[x]; p; p = g[p].nxt){
		int v = g[p].to;
		if (vis[v] == mark){cir.pb(v), cir.pb(x); return ;}
		else if (!vis[v]){
			dfs(v);
			if (!cir.size()) continue;
			if (*cir.begin() == x) return;
			if (*(cir.end() - 1) == v){cir.pb(x); return;}
		}
	}
}
void grundy(int x, bool isrt, int nxt){
	for (int p = ghead[x]; p; p = g[p].nxt){
		int v = g[p].to; if (v == nxt) continue;
		grundy(v, 0, nxt);
	}
	mark++;
	for (int p = ghead[x]; p; p = g[p].nxt){
		int v = g[p].to; if (v == nxt) continue;
		vis[mex[v]] = mark;
	}
	int pos = 0;
	for (; vis[pos] == mark; pos++); mex[x] = pos;
	if (isrt){
		candidates[x].x = pos; 
		for (++pos; vis[pos] == mark; ++pos); 
		candidates[x].y = pos;
	}
}
bool verify(){
	for (int i = 0; i < (int)cir.size() - 1; ++i){
		int u = cir[i]; mark++;
		for (int p = ghead[u]; p; p = g[p].nxt)
			vis[mex[g[p].to]] = mark;
		int pos = 0; for (; vis[pos] == mark; pos++); mex[u] = pos;
	}
	int u = *(cir.end() - 1); mark++;
	for (int p = ghead[u]; p; p = g[p].nxt)
		vis[mex[g[p].to]] = mark;
	int pos = 0; for (; vis[pos] == mark; pos++); return pos == mex[u];
}

int main(){
	read(n);
	rep(i, 1, n) read(x), add(x, i);
	rep(i, 1, n) if (!vis[i]) mark++, dfs(i);
	if (!cir.size()) return 0 * puts("POSSIBLE");
	for (int i = 0; i < cir.size(); ++i)
		grundy(cir[i], 1, cir[(i+cir.size()-1)%cir.size()]);
	mex[*(cir.end() - 1)] = candidates[*(cir.end() - 1)].x;
	if (verify()) return 0 * puts("POSSIBLE");
	mex[*(cir.end() - 1)] = candidates[*(cir.end() - 1)].y;
	if (verify()) return 0 * puts("POSSIBLE");
	puts("IMPOSSIBLE");
	return 0;
}

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

int main()
{
    int n,i,sum,t;
    scanf("%d",&n);
    i=n;
    sum=0;
    while(i--){
        scanf("%d",&t);
        sum+=t;
    }
    printf("%d",sum-n);
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()) {
			double w = sc.nextDouble();
			System.out.println(rank(w));
		}
		sc.close();
	}
	static String rank(double w) {
		if(w <= 48) return "light fly";
		if(w <= 51) return "fly";
		if(w <= 54) return "bantam";
		if(w <= 57) return "feather";
		if(w <= 60) return "light";
		if(w <= 64) return "light welter";
		if(w <= 69) return "welter";
		if(w <= 75) return "light middle";
		if(w <= 81) return "middle";
		if(w <= 91) return "light heavy";
		return "heavy";
	}
}


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

int main() {
  int n, q, b, c, af;
  long sum=0;
  cin>>n;
  vector<int> a(n);
  vector<int> num(100001);
  rep(i,n){
  	cin>>a.at(i);
    af=a.at(i);
    sum+=a.at(i);
    num.at(af-1)=num.at(af-1)+1;
  }
  cin>>q;
  rep(i,q){
  	cin>>b >>c;
    sum=sum+(c-b)*num.at(b-1);
    cout<<sum<<endl;
    num.at(c-1)+=num.at(b-1);
    num.at(b-1)=0;
  }
}

Measured memory_bytes: 3920
n = int(input())
b = list(map(int, input().split()))

ans = []
for i in range(n):
    tmp = -1
    for j, k in enumerate(b):
        if j + 1 == k:
            tmp = j
    if tmp == -1:
        print(-1)
        exit()
    else:
        ans.append(b.pop(tmp))
print(*ans[::-1], sep="\n")

Measured memory_bytes: 3064
#include <cstdio>
#include <queue>

using namespace std;

char s[200001];

int main() {
    int n, k, c = 0, f = 0, i, j;
    deque <int> q;
    
    scanf("%d %d", &n, &k);
    scanf("%s", s);
    
    for (i = 0; i < n; i++) q.push_back(s[i] - 'A');
    
    for (i = 0; i < k; i++) {
        if ((q[0] + f) % 2 == 0) {
            q[0] = 1 - q[0];
        } else {
            f++;
            q.pop_front();
            q.push_back(f % 2);
            
            if (f == n) {
                if (n % 2 == 1 && (k - i - 1) % 2 == 1) q[0] = 1 - q[0];
                
                break;
            }
        }
    }
    
    for (i = 0; i < n; i++) putchar('A' + (q[i] + f) % 2);
    puts("");
    
    return 0;
}


Measured memory_bytes: 1536
mod = 998244353
n,m,k = map(int,input().split())

mm1 = []# m minus 1
div = [0]
conv = [1]
p = 1
d = 1
for i in range(n):
  mm1.append(p)
  p = (p*(m-1))%mod
  div.append(pow(i+1,mod-2, mod))
  conv.append((conv[-1] * (n-i-1) * div[-1])%mod)
  
ans = 0
for i in range(k+1):
  a = m * mm1[n-i-1] * conv[i]
  ans += a%mod
  ans %= mod
print(ans)

Measured memory_bytes: 100608
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,s;
    cin >> n >> s;
    vector<vector<mint> > dp(n+1, vector<mint>(s+1, mint(0)));
    vll a(n);
    REP(i,n) cin >> a[i];
    dp[0][0] = mint(1);
    for(ll i=1;i<=n;++i){
        REP(j,s+1){
            dp[i][j] = dp[i-1][j] * mint(2);
        }
        REP(j,s+1){
            if(j+a[i-1]>s) break;
            if(dp[i-1][j].x==0LL) continue;
            dp[i][j+a[i-1]] += dp[i-1][j];
        }
    }
    cout << dp[n][s].x << endl;
    return 0;
}

Measured memory_bytes: 73648
#include <iostream>
using namespace std;
int main()
{
  char s[201];
  char p[101];
  cin.getline(s,101);
  cin.getline(p,101);
  int ns=0,np=0;
  for(int i=0;s[i];i++)
    ns++;
  for(int i=0;p[i];i++)
    np++;
  for(int i=ns;i<2*ns;i++)
    s[i]=s[i-ns];
  s[2*ns]='\0';

  int i,j;
  for(i=0;i<2*ns-np;i++)
  {
    for(j=0;j<np;j++)
      if(s[i+j]!=p[j]) break;
    if(j==np)
    {
      cout<<"Yes"<<endl;
      break;
    }
  }
  if(i==2*ns-np)
    cout<<"No"<<endl;
}

Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

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

  ll n;
  cin >> n;
  vl a(n);
  rep(i, n) {
    cin >> a[i];
  }

  ll cnt = 0;
  rep(i, n) {
    if (a[i] == cnt+1) {
      cnt++;
    }
  }
  
  if (cnt == 0) cout << -1 << endl;
  else cout << n-cnt << endl;
}


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

int main() {
	int n;
	std::cin >> n;
	std::vector<int> a(n), b(n);
	auto f = [&] (int i) { return (a[i] == b[i]); };
	for (int i = 0; i < n; i++) std::cin >> a[i] >> b[i];
	
	bool ans = false;
	for (int i = 0; i + 2 < n; i++) {
		ans |= (f(i) and f(i + 1) and f(i + 2));
	}
	
	std::cout << (ans ? "Yes" : "No") << '\n';
	
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define numrep(i,p,n) for(int i=p;i<=n;i++)
#define ll int64_t
#define all(v) v.begin(), v.end()
#define bitrep(n) for(int bit=0;bit<(1<<n);bit++)

ll gcd(ll a, ll b)//最大公約数
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

ll lcm(ll a, ll b)//最小公倍数
{
   return a * b / gcd(a, b);
}

int main() {

  ll A,B; cin >> A >> B;

  ll ans=lcm(A,B);
  
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.math.*;
import java.security.*;
import java.text.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.function.*;
import java.util.regex.*;
import java.util.stream.*;
import static java.util.stream.Collectors.joining;
import static java.util.stream.Collectors.toList;

public class Main
{
    public static void main(String[] args)
    {
        Scanner in = new Scanner(System.in);
        int n=in.nextInt();
        long[] x=new long[n];
        long[] y=new long[n];
        TreeSet<Long> set1=new TreeSet<>();
        TreeSet<Long> set2=new TreeSet<>();
        for(int i=0;i<n;i++)
        {
            x[i]=in.nextLong();
            y[i]=in.nextLong();
            set1.add(x[i]+y[i]);
            set2.add(x[i]-y[i]);
        }
        System.out.println(Math.max(set1.last()-set1.first(), set2.last()-set2.first()));
        

    }
}

Measured memory_bytes: 88300
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int N;
    cin >> N;
    vector<pair<int, int>> query(N*N);
    REP(i, N*N) {
        int P;
        cin >> P;
        P--;
        query[i] = make_pair(P/N, P%N);
    }
    vector<vector<int>> dp(N, vector<int>(N));
    vector<vector<bool>> exist(N, vector<bool>(N, true));
    REP(i, N) REP(j, N) dp[i][j] = min(i, min(j, min(N-1-i, N-1-j)));
    int ans = 0;
    REP(i, N*N) {
        ans += dp[query[i].first][query[i].second];
        exist[query[i].first][query[i].second] = false;
        deque<tuple<int, int, int>> que;
        que.push_back(make_tuple(query[i].first, query[i].second, dp[query[i].first][query[i].second]));
        dp[query[i].first][query[i].second]++;
        while(!que.empty()) {
            tuple<int, int, int> tu = que.front();
            que.pop_front();
            if(get<2>(tu) + 1 == dp[get<0>(tu)][get<1>(tu)]) {
                dp[get<0>(tu)][get<1>(tu)] = get<2>(tu);
            } else {
                continue;
            }
            get<2>(tu) += exist[get<0>(tu)][get<1>(tu)] ? 1 : 0;
            //cout << get<0>(tu) << " " << get<1>(tu) << " " << get<2>(tu) << endl;
            if(get<0>(tu) != 0) que.push_back(make_tuple(get<0>(tu)-1, get<1>(tu), get<2>(tu)));
            if(get<0>(tu) != N-1) que.push_back(make_tuple(get<0>(tu)+1, get<1>(tu), get<2>(tu)));
            if(get<1>(tu) != 0) que.push_back(make_tuple(get<0>(tu), get<1>(tu)-1, get<2>(tu)));
            if(get<1>(tu) != N-1) que.push_back(make_tuple(get<0>(tu), get<1>(tu)+1, get<2>(tu)));
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 6268
#include<iostream>
#include<string>
using namespace std;
string str[10]; 
void ans(int i,int k){
	if(str[i][k+1] == '1' && str[i+1][k+1] == '1'&& str[i+1][k] == '1' ){
		cout << "A" << endl;  
		} else if(str[i+1][k] == '1' && str[i+2][k] == '1'&& str[i+3][k] == '1' ){
		cout << "B" << endl; 
		} else if(str[i][k+1] == '1' && str[i][k+2] == '1'&& str[i][k+3] == '1' ){
		cout << "C" << endl;  
		} else if(str[i+1][k] == '1' && str[i+1][k-1] == '1'&& str[i+2][k-1] == '1' ){
		cout << "D" << endl; 
		} else if(str[i][k+1] == '1' && str[i+1][k+1] == '1'&& str[i+1][k+2] == '1' ){
		cout << "E" << endl; 
		} else if(str[i+1][k] == '1' && str[i+1][k+1] == '1'&& str[i+2][k+1] == '1' ){
		cout << "F" << endl;  
		} else 	{cout << "G" << endl; }

}

int main(){
	
	while(1){
	for(int i=0;i<8;i++){
		for(int j=0;j<8;j++)str[i][j]=0;
	}
	for(int i =0;i<8;i++)
	if(!(cin>>str[i]))return 0;
	
	
	for(int i=0;i<64;i++)
	if(str[i/8][i%8] == '1'){
	ans(i/8,i%8);
	break;
	}

	
	}
	
}

Measured memory_bytes: 1180
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
ll mod = 1e9 + 7;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n, m;cin>>n>>m;
	set<int>s;
	for(int i = 0; i < n; ++i){
		int t;cin>>t;
		s.insert(t);
	}
	int dp[n+1];
	dp[0] = 1;
	dp[1] = (s.find(1)==s.end()?1:0);
	for(int i = 2; i<=n; ++i){
		dp[i] = dp[i-1] + dp[i-2];
		dp[i]%=mod;
		if(s.find(i)!=s.end()){
			dp[i] = 0;
		}
	}
	cout<<dp[n]<<endl;
	return 0;
}



Measured memory_bytes: 5376
a,b = gets.chomp.split
# A, B, C = gets.chomp.split.map(&:to_i)
a = a.to_i

bInt = b.split('.')[0].to_i
bFloat = b.split('.')[1].to_i

intN = a*bInt
floatN = (a*bFloat) / 100

p intN + floatN

Measured memory_bytes: 14324
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define showmap(is, js, x) {rep(i, is){rep(j, js){cout << x[i][j] << " ";}cout << endl;}}
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> llP;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}


int main()
{
    int n;
    cin >> n;
    vector<ll> a;
    ll xor_sum = 0;
    rep(i, n){ int tmp; cin >> tmp; a.push_back(tmp); xor_sum ^= tmp;}

    //cout << xor_sum << endl;

    rep(i, n){
        ll ans = xor_sum^a[i];
        cout << ans << " ";
    }
    cout << endl;
}


Measured memory_bytes: 5364
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define mod 1000000007
#define fi first
#define se second
#define pb push_back
#define IOS ios_base::sync_with_stdio(false);cout.tie(NULL);cin.tie(NULL);

using namespace std;

struct A{
    string s;
    int p;
    int id;
};

bool cmp(A a, A b)
{
    if(a.s==b.s) return a.p>=b.p;  
    return a.s<b.s;
}

int main()
{
    IOS;
    int n;
    cin>>n;
    A a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i].s>>a[i].p;
        a[i].id=i;
    }
    sort(a,a+n,cmp);
    for(int i=0;i<n;i++)
    {
        cout<<a[i].id+1<<endl;
    }
    return 0;
}


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

if a == b == c:
  if a%2 == 0:
    print(-1)
    exit()
  else:
    print(0)
    exit()
ans = 0
while(a%2 == b%2 == c%2 == 0):
  temp_a = (b+c)//2
  temp_b = (a+c)//2
  temp_c = (b+a)//2
  ans += 1
  a = temp_a
  b = temp_b
  c = temp_c
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<string>
#include<cmath>
#include<utility>
typedef long long ll;
int main() {
	int a[3] = {};
	int ans = 0;
	std::cin >> a[0] >> a[1] >> a[2];
	std::sort(a, a + 3);
	ans += a[1] - a[0];
	ans += a[2] - a[1];
	std::cout << ans << std::endl;
	return 0;

	
}

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

using namespace std;

# define REP(i, a, b) for(int i = a; i <= b; ++ i)
# define CLR(i, a) memset(i, a, sizeof(i))
# define REPD(i, a, b) for(int i = a; i >= b; -- i)

const int N = 2e5 + 3;

int a[N], n, len;

int chk(int x) {
	int l = n, r = n;
	bool tmp[N];
	REP(i, 1, len) tmp[i] = (a[i] > x);
	for(; l > 1 && tmp[l] != tmp[l - 1]; -- l); 
	for(; r < len && tmp[r] != tmp[r + 1] && r <= len; ++ r);
	return n - l < r - n ? tmp[l] : tmp[r];
}

int main() {
	scanf("%d", &n);
	len = (n << 1) - 1;
	REP(i, 1, len) scanf("%d", &a[i]);
	int l = 1, r = len;
	while(l < r) {
		int mid = l + r >> 1;
		if(chk(mid)) l = mid + 1; // mid < targ
		else r = mid;
	}
	printf("%d\n", l);
	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,L;
  cin >> N >> L;
  int sum = 0;
  for (int i = 0; i < N; i++) sum += L + i;
  if (L <= 0 && N + L > 0){
    cout << sum;
  } else {
    int First = L;
    int Last = L + N - 1;
    if (abs(First) < abs(Last)){
      cout << sum - First;
    } else {
      cout << sum - Last;
    }
  }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#define ll long long
using namespace std;
int a[15];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)  scanf("%d",&a[i]);
	sort(a,a+n);
	int sum=0;
	for(int j=0;j<n-1;j++)  sum+=a[j];
	if(sum>a[n-1])   printf("Yes\n");
	else if(sum<=a[n-1])   printf("No\n");    
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int a,b=1;
    cin>>a;
    while(b--)
    {
        long double c = sqrt(a);
        if(c-floor(c)==0)
            cout<<a<<endl;
        else
        {
            a--;
            b++;
        }
    }
    return 0;
}


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

int main() {
  char S[10];
  cin >> S;
  sort(S, S+4);
  if(S[0] == S[1] && S[2] == S[3] && S[1] != S[2] ) cout << "Yes" << endl;
  else cout << "No" << endl;
  
}

Measured memory_bytes: 256
a, b, c = map(int, raw_input().split())
 
if a > b:
 x = a
 a = b
 b = x
if b > c:
 x = b
 b = c
 c = x
if a > b:
 x = a
 a = b 
 b = x
 
print a, b, c
 

Measured memory_bytes: 6380
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <stack>
#include <vector>
#include <stdio.h>
#include <utility>
#include <map>
#include <set>
using namespace std;
#define LL long long;


int n, k;



int main() {

	cin >> n >> k;

	if (k != 1) cout << n - k << endl;
	else cout << "0" << endl;

	return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
n = int(input())
v = list(map(int, input().split()))
count1 = defaultdict(int)
count2 = defaultdict(int)
for i in range(0, n, 2):
    count1[v[i]] += 1
for i in range(1, n, 2):
    count2[v[i]] += 1
res = 0
max_count1 = max(count1.values())
max_count2 = max(count2.values())
max_key1 = 0
max_key2 = 0
for key, value in count1.items():
    res += value
    if value == max_count1:
        max_key1 = key
for key, value in count2.items():
    res += value
    if value == max_count2:
        max_key2 = key
res = res - max_count1 - max_count2
ans1 = 0
ans2 = 0
ans = 0
if max_key1 == max_key2:
    ans1 = res + max_count1
    count1[max_key1] = 0
    next_max_count1 = max(count1.values())
    ans1 -= next_max_count1

    ans2 = res + max_count2
    count2[max_key2] = 0
    next_max_count2 = max(count2.values())
    ans2 -= next_max_count2
    ans = min(ans1, ans2)
else:
    ans = res
print(ans)

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

int main(){
 int num = 0;
 cin >> num;
 int insSort[101];
 for(int i = 0; i < num; i++)
  cin >> insSort[i];

  for(int j = 0; j < num; j++)
   cout << insSort[j] << ( (j == num-1) ? '\n' : ' ');

 for(int i = 1; i < num; i++){ 
  int buf = insSort[i];
  int j = i-1; 
  while(0 <= j && insSort[j] > buf){
   insSort[j+1] = insSort[j];
   j--;
  }
  insSort[j+1] = buf;

  for(int j = 0; j < num; j++)
   cout << insSort[j] << ( (j == num-1) ? '\n' : ' ');
 }

 return 0;
} 

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
int main()
{
    
    int n,k,d,a;
    cin>>n>>k;
    set<int> s;
    for(int i=0;i<k;i++){
        cin>>d;
        for(int i=0;i<d;i++){
            cin>>a;
            s.insert(a);
        }
    }
    cout<<n-s.size()<<endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
 
#define ll          long long
#define ld          long double
#define pb          push_back
#define pf          push_front
#define mp          make_pair
#define pll         pair<ll,ll>
#define vl          vector<ll>
#define sl          set<ll> 
#define vll         vector<pll>
#define ml          map<ll,ll>
#define mll         map<pll,ll>
#define all(a)      a.begin(),a.end()
#define x           first
#define y           second
#define sz(x)       (ll)x.size()
#define dl          '\n'
#define mod         (ll)1000000007
#define lp(i,a,b)   for(ll i=a;i<b;++i)
#define lpr(i,a,b)  for(ll i=a;i>=b;i--)
#define lpd(i,x)    for(auto i:x)
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
ll inf = (ll)1e18;
ld pi = 3.141592653589;
using namespace std;

ll bpow(ll x, ll v) {   
    if (v == 0)
        return 1 % mod;
    if (v % 2 == 1)
        return (x * bpow(x, v - 1)) % mod;
    ll r = bpow(x, v / 2);
    return (r * r) % mod;   
}

ll solve(){ 
    ll n,ans=0; cin>>n;
    ml m;
    vl a(n); lp(i,0,n) cin>>a[i],m[a[i]]++;
    lpd(i,m)
    ans+=(i.y*(i.y-1))/2;
    ll p = ans;
    lp(i,0,n){
        ans-= (m[a[i]]*(m[a[i]]-1))/2;
        ans+= ((m[a[i]]-1)*(m[a[i]]-2))/2;
        cout<<ans<<dl;
        ans = p;
    }
}

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

Measured memory_bytes: 12800
/**
*    created: 06.07.2020 18:18:30
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
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;}
const long double pi = acos(-1.0);
const int INF = 1LL << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;

signed main() {

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

    int n; cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    rep(i,n) {
        if (i == 0) continue;
        a[i] += a[i-1];
    }
    int sum = a[n-1];
    int ans = INF;
    rep(i,n-1) chmin(ans,abs(sum-2*a[i]));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4660
// If you want something you've never had, you must be willing to do something you've never done

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef tree<pair<int,int>, null_type,less<pair<int, int> >,rb_tree_tag,tree_order_statistics_node_update > pbds;

#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;
#define debug4(x,y,z,w) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#w<<" :: "<<w<<endl;
#define ROUNDOFFINT(d) d = (int)((double)d + 0.5)

#define pb push_back
#define ft first
#define sd second
#define all(c)    (c).begin(),(c).end()
#define tr(c,i)   for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x)   ((c).find(x) != (c).end())
#define IOS ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

ll poww(ll a,ll b){ll res=1;while(b){if(b&1){res*=a;}a=a*a;b>>=1;}return res;}
ll poww(ll a,ll b,ll mod){ll res=1;while(b){if(b&1){res*=a;res%=mod;}a=a*a;a%=mod;b>>=1;}return res;}

const int INF = 2e9 ;
const int dx[] = {-1,0,0,1};
const int dy[] = {0,-1,1,0};
const int lg = 21;
const ll MOD = 1e9 + 7;
#define int ll
int n, m;
const int N = 1e5 + 5;


signed main() {
    int a;
  	string s;
  	cin >> a;
    cin >> s;
  	if(a >= 3200) cout << s << '\n';
  	else cout << "red\n";
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>

using namespace std;

int main() {
    long long a, b, k;
    cin >> a >> b >> k;

    if (a >= k) {
        cout << a - k << " " << b << endl;
    } else {
        cout << "0 " << max(b - (k - a), 0LL) << endl;
    }
}


Measured memory_bytes: 256
import math
H,W,K = map(int,input().split())
HW = [list(input()) for i in range(H)]
for i,h in enumerate(HW):
	if "S" in h:
		y = i
		x = h.index("S")
A = [(x,y)]
m = 800
def idou(a,b):
	X = []
	for i2 in range(4):
		if i2 == 0:
			t,k = a - 1, b
		elif i2 == 1:
			t,k = a, b - 1
		elif i2 == 2:
			t,k = a + 1, b
		elif i2 == 3:
			t,k = a, b + 1
		if 0 <= t < W and 0 <= k < H and HW[k][t] == ".":
			HW[k][t] = "o"
			X.append((t,k))
	return X
cnt = 0
while cnt < K:
	cnt += 1
	B = []
	for p in A:
		x,y = p
		b = idou(x,y)
		B.extend(b)
	A = B[:]
M = []
for i,w in enumerate(zip(*HW)):
	#print(w)
	if "o" in w or "S" in w:
		M.append(min(i,W - i - 1))
		
for i,h in enumerate(HW):
	if "S" in h or "o" in h:
		M.append(min(i, H - i - 1))
		#print(h)
m = min(M)
print((m + K - 1) // K + 1)

Measured memory_bytes: 11104
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        long d = in.nextLong(); in.nextLine();
        String[] tmp = in.nextLine().split(" ");
        long[] ary = new long[n];
        for( int i = 0; i < n; i++ ) ary[i] = Math.abs(Long.parseLong(tmp[i])-d);
        long ans = ary[0];
        for( long L : ary ) {
            ans = gcd(ans,L);
        }
        System.out.println(ans);
    }
    static long gcd(long a, long b) {
        if( b == 0 ) return a;
        return gcd(b,a%b);
    }
}

Measured memory_bytes: 63644
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;


void solve()
{
    int a, b, c, d, e, f;
    scanf("%d%d%d%d%d%d", &a, &b, &c, &d, &e, &f);
    int n = 30;
    int i, j;
    vector<int> flag(n + 1);
    for (i = 0; i <= n; i++) {
        for (j = 0; j <= n; j++) {
            int tmp=i*a + j * b;
            if (tmp <= n) flag[tmp] = 1;
        }
    }
    vector<int> flag2(e*n + 1);
    flag2[0] = 1;
    for (i = 0; i <= e*n; i++) {
        if (flag2[i]) {
            if (i + c <= e * n) {
                flag2[i + c] = 1;
            }
            if (i + d <= e * n) {
                flag2[i + d] = 1;
            }
        }
    }
    vector<int> z;
    for (i = 0; i <= e * n; i++) {
        if (flag2[i]) z.push_back(i);
    }

    long double ans = -1;
    const long double eps = 1e-10;
    int ians = 0, valans = 0;
    for (i = 0; i <= n; i++) {
        if (flag[i] == 0) continue;
        
        int mm=MIN(i*e, f-100 * i);

        int k=lower_bound(z.begin(), z.end(), mm + 1) - z.begin();
        k--;
        int val=z[k];
        long double tmp = (long double)val / ((long double)100*i + val);
        if (tmp > ans+eps) {
            ans = tmp;
            ians = i;
            valans = val;
        }
    }

    printf("%d %d\n", ians * 100 + valans, valans);


    return;
}

int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for(t=0; t<T; t++) {
        printf("Case #%d: ", t+1);
        solve();
    }
#endif
    return 0;
}



Measured memory_bytes: 256