akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e8;
const ll INF = 1e16;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    int N, A;
    cin >> N >> A;
    int x[N];
    rep(i, N) cin >> x[i];
    sort(x, x+N, greater<int>());
    ll a[2501], b[2501], zero = 0;
    fill(a, a+2501, 0), fill(b, b+2501, 0);
    rep(i, N){
        int y = x[i]-A;
        if(y > 0){
            rep3(j, 2500, y){
                a[j] += a[j-y];
            }
            a[y]++;
        }
        elif(y == 0){
            zero++;
        }
        else{
            y *= -1;
            rep3(j, 2500, y){
                b[j] += b[j-y];
            }
            b[y]++;
        }
    }
    ll ans = 0;
    rep2(i, 1, 2500){
        ans += a[i]*b[i];
    }
    ans *= (1ll<<zero);
    ans += (1ll<<zero)-1;
    cout << ans << endl;
}

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

int main(){
    int a[3];
    for(int i=0;i<3;i++)cin>>a[i];
    int k;
    cin>>k;
    sort(a,a+3);
    while(k--)a[2]=a[2]*2;
    int sum=0;
    for(int i=0;i<3;i++)sum+=a[i];
    cout<<sum;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3") //コンパイラ最適化用

#define _GLIBCXX_DEBUG //配列に[]でアクセス時のエラー表示
#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>
#include <unordered_set>
#include <utility> //pair
#include <vector>  //可変長配列
using namespace std;
typedef long long ll;
typedef long double ld;

#define REP(i, n) for (int i = 0; i < ll(n); i++)
#define REPD(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < ll(b); i++)
#define FORD(i, a, b) for (int i = a; i > ll(b); i--)
// xにはvectorなどのコンテナ
#define ALL(x) x.begin(), x.end()
#define SIZE(x) ll(x.size()) // sizeをsize_tからllに直しておく
const long long INF = 1e12;
const int MOD = 1e9 + 7;
#define MAXR 100000 // 10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define Umap unordered_map
#define Uset unordered_set
#define int long long
const unsigned int BIT_FLAG_0 = (1 << 0); // 0000 0000 0000 0001
const unsigned int BIT_FLAG_1 = (1 << 1); // 0000 0000 0000 0010
const unsigned int BIT_FLAG_2 = (1 << 2); // 0000 0000 0000 0100
const unsigned int BIT_FLAG_3 = (1 << 3); // 0000 0000 0000 1000
const unsigned int BIT_FLAG_4 = (1 << 4); // 0000 0000 0001 0000
const unsigned int BIT_FLAG_5 = (1 << 5); // 0000 0000 0010 0000
const unsigned int BIT_FLAG_6 = (1 << 6); // 0000 0000 0100 0000
const unsigned int BIT_FLAG_7 = (1 << 7); // 0000 0000 1000 0000
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

// https://qiita.com/Lily0727K/items/06cb1d6da8a436369eed#c%E3%81%A7%E3%81%AE%E5%AE%9F%E8%A3%85
void print() { cout << endl; }

template <class Head, class... Tail> void print(Head &&head, Tail &&... tail) {
    cout << head;
    if (sizeof...(tail) != 0)
        cout << " ";
    print(forward<Tail>(tail)...);
}

template <class T> void print(vector<T> &vec) {
    for (auto &a : vec) {
        cout << a;
        if (&a != &vec.back())
            cout << " ";
    }
    cout << endl;
}

template <class T> void print(vector<vector<T>> &df) {
    for (auto &vec : df) {
        print(vec);
    }
}

void add(long long &a, long long b) {
    a += b;
    if (a >= MOD)
        a -= MOD;
}
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

signed main() {
    string n;
    cin >> n;
    int val = (int)n[n.size() - 1]-'0';

    if (val == 2 || val == 4 || val == 5 || val == 7 || val == 9) {
        print("hon");
    } else if (val == 3) {
        print("bon");
    } else {
        print("pon");
    }
}


Measured memory_bytes: 3636
#include "bits/stdc++.h"
using namespace std;
#define OUT(x)                cout << #x << " = " << x << endl; 
#define rep(i, n)             for (int (i) = 0; (i) < (int)(n); (i)++)
#define rer(i, l, r)          for (int (i) = (int)(l); (i) <= (int)(r); (i)++)
#define reu(i, l, r)          for (int (i) = (int)(l); (i) < (int)(r); (i)++)
#define each(i, v)            for (auto i : v)
#define all(x)                (x).begin(), (x).end()
#define rall(x)               (x).rbegin(), (x).rend()
#define pb(x)                 push_back(x)
#define bp(x)                 __builtin_popcount(x)
#define mp(x, y)              make_pair((x), (y))
#define fi                    first
#define se                    second
#define setp(x)               setprecision(x)
#define mset(m, v)            memset(m, v, sizeof(m))
#define sz(x)                 (int)(x.size())
static const int INF        = 0x3f3f3f3f;
static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
static const int MOD        = 1000000007;
static const double PI      = 3.141592653589793238462643383279;

//#define int                   long long

typedef vector<double>        vd;
typedef vector<string>        vs;
typedef vector<bool>          vb;
typedef vector<int>           vi;
typedef pair<int, int>        pii;
typedef vector<pii>           vpii;

template<typename T> void pv(T a, T b) { for (T i = a; i != b; i ++) cout << *i << " "; cout << endl; }
template<typename T, typename U> inline void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if (x < y) x = y; }
int in() { int _x; scanf("%d", &_x); return _x; }
long long lin() {long long _x; scanf("%lld", &_x); return _x; };

signed main() { 
        int h, w;
        cin >> h >> w;
        vs s(h);
        rep(i, h) cin >> s[i];
        rep(i, w + 2) cout << '#';
        cout << endl;
        rep(i, h) {
                cout << '#';
                cout << s[i];
                cout << '#';
                cout << endl;
        }
        rep(i, w + 2) cout << '#';
        cout << endl;
        return 0;
}               



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

#define IOS             ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define watch(x);       cout << "\n" <<  #x << " is: " << x << "\n";
#define ll              long long int
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define pb              push_back
#define nl              cout<<"\n"
#define gcd(a,b)        __gcd(a,b)
#define sq(a)           (a)*(a)
#define loop(i,a,b)     for (int i = a; i <= b; i++)
#define rloop(i,a,b)    for (int i = a; i >= b; i--)
#define sz(a)           a.size()
#define mod             1000000007
#define PI              2*acos(0.0)
ll b[100005];
int main()
{
    IOS
    int T=1;
    //cin>>T;
    while(T--)
    {
        ll n;
        cin>>n;
        ll a[n],sum=0;
        memset(b,0,sizeof b);
        loop(i,0,n-1)
        {
            cin>>a[i];
            b[a[i]]++;
            sum+=a[i];
        }
        int q;
        cin>>q;
        while(q--)
        {
            ll x,y;
            cin>>x>>y;
            sum=sum+b[x]*(y-x);
            cout<<sum;
            b[y]+=b[x];
            b[x]=0;
            nl;
        }

    }
    return 0;
}


Measured memory_bytes: 5204
import sys,queue,math,copy
LI = lambda : [int(x) for x in input().split()]

H,W,K = LI()
C = [[int(x) for x in input()] + [0] for _ in range(H)]

max_p = 0
for a in range(H):
    for b in range(W):
        c = copy.deepcopy(C)
        c[a][b] = 0
        p = 0
        for x in range(a,0,-1):
            c[x][b] = c[x-1][b]
        c[0][b] = 0


        update = True
        cnt = 0
        while update:
            update = False

            for i in range(H):
                n = c[i][0]
                nc = n > 0
                for j in range(1, W + 1):
                    if c[i][j] == n and n > 0:
                        nc += 1
                    else:
                        if nc >= K:
                            for k in range(nc):
                                c[i][j-k-1] = 0
                            p += nc * n * (2 **cnt)
                            update = True
                        n = c[i][j]
                        nc = n > 0

            for i in range(H-1, 0, -1):
                for j in range(W):
                    if c[i][j] > 0: continue
                    x = i
                    while x > 0:
                        x -= 1
                        if c[x][j] > 0:
                            c[i][j] = c[x][j]
                            c[x][j] = 0
                            break
            cnt += 1

        max_p = max(max_p,p)
print (max_p)


Measured memory_bytes: 61016
#import math
#=input()
#=int(input())
a,b=map(str,input().split())
#=list(map(int,input().split()))
#=[list(map(int,input().split())) for _ in range()]
a = int(a)
b = int(b[:1]+b[2:])
ans = (a * b) // 100
print(ans)

Measured memory_bytes: 9168
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

const int MOD = 1000000007;

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

    int A, B;
    cin >> A >> B;

    int ans = -1;
    for (int p = 0; (ans < 0) && (p < 13000); ++p) {
        if (p * 8 / 100 == A && p * 10 / 100 == B) {
            ans = p;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
int k;
int a,b;
cin>>k>>a>>b;
for(int i=a;i<=b;i++)
{
    if(i%k==0){
        cout<<"OK";
        return 0;
    }
}
cout<<"NG";

}


Measured memory_bytes: 3640
import numpy as np
N, M = map(int, input().split())
mat = np.zeros(N*M).reshape(M, N)

for i in range(M):
    k = list(map(int, input().split()))
    for j in k[1:]:
        mat[i, j-1] += 1
p = list(map(int, input().split()))

def two(x):
    a = np.zeros(N)
    for i in range(11):
        if x == 0:
            break
        elif x % 2 == 0:
            x = x // 2
        else:
            a[i] += 1
            x = x // 2
    return a

flag = 0
for i in range(2**N):
    a = two(i)
    mat2 = mat * a
    for j in range(M):
        if np.sum(mat2[j]) % 2 != p[j]:
            break
        if j == M-1:
            flag += 1

print(flag)


Measured memory_bytes: 14404
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static int[] dx = new int[] { 0, 0, 1, -1 };
    static int[] dy = new int[] { 1, -1, 0, 0 };

    static void Solve()
    {
        var n = sc.Int();

        var s = sc.Str(n);

        var cnt = s.OrderBy(x => x).Distinct().Count();

        if (cnt == 3)
            pr.WriteLine("Three");
        else
            pr.WriteLine("Four");
    }

    static int[,] Mul(int[,] a, int[,] b)
    {
        const int d = 2;
        var ret = new int[d, d];
        for (int i = 0; i < d; i++)
        {
            for (int j = 0; j < d; j++)
            {
                for (int k = 0; k < d; k++)
                {
                    ret[i, j] += a[i, k] * a[k, j];
                }
            }
        }

        return ret;
    }

    class Coord
    {
        public int x;
        public int y;
    }

    static void Main(string[] args)
    {
        // pr.AutoFlush = true;
        Solve();
        pr.Flush();
    }

    static Scanner sc = new Scanner();
    static Printer pr = new Printer();
}

#region IO
class Scanner
{
    private int _i = 0;
    private string[] line = new string[0];

    private T[] Enumerate<T>(int n, Func<T> f)
    {
        T[] ret = new T[n];
        for (int i = 0; i < n; i++)
            ret[i] = f();
        return ret;
    }

    public string Str()
    {
        if (line.Length <= _i)
        {
            line = Console.ReadLine().Split(' ');
            _i = 0;
        }

        return line[_i++];
    }

    public int Int() => int.Parse(Str());
    public long Long() => long.Parse(Str());
    public double Double() => double.Parse(Str());
    public int[] Int(int n) => Enumerate(n, Int);
    public long[] Long(int n) => Enumerate(n, Long);
    public double[] Double(int n) => Enumerate(n, Double);
    public string[] Str(int n) => Enumerate(n, Str);
}

class Printer : StreamWriter
{
    public Printer() : base(Console.OpenStandardOutput())
    {
        AutoFlush = false;
    }
}
#endregion

Measured memory_bytes: 13660
import fractions
A, B, C, D = map(int, input().split())
total = B - A + 1
Cdiv = B // C - (A-1) // C
Ddiv = B // D - (A-1) // D
cddiv = (C*D)//fractions.gcd(C,D)
CDdiv = B // (cddiv) - (A-1) // (cddiv)

print(total - Cdiv - Ddiv + CDdiv)


Measured memory_bytes: 5688
s = gets.chomp
m = gets.to_i

n = s.size

dp = Array.new(110) { Array.new(4) { Array.new(2, 0) } }

dp[0][0][0] = 1

n.times do |i|
  4.times do |j|
    2.times do |k|
      x = s[i].to_i
      10.times do |d|
        ni = i + 1
        nj = j
        nk = k
        nj += 1 if d != 0
        next if nj > m
        if k == 0
          next if d > x
          nk = 1 if d < x
        end
        dp[ni][nj][nk] += dp[i][j][k]
      end
    end
  end
end
p dp[n][m][0] + dp[n][m][1]

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

int main() {
    int ans = 1;
    int K;
    cin >> K;
    if(K % 2 == 0)
        cout << -1 << endl;
    else {
        vector<int> L(K, 0);
        int m = 7 % K;
        int n = m;
        L[n] = 1;
        while(n != 0) {
            m = (m * 10) % K;
            n = (n + m) % K;
            ans++;
            if(L[n] == 1) {
                cout << -1 << endl;
                return 0;
            } else
                L[n] = 1;
        }
        cout << ans << endl;
    }
}

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

int main() {
  int n,h,w,c = 0;
  cin >> n >> h >> w;
  rep(i,0,n){
    int a,b;
    cin >> a >> b;
    if(a >= h && b >= w) c++;
  }
  cout << c << endl;
}

Measured memory_bytes: 256
macro_rules! input {
    ($ttype:ty) => {
        {
            let mut input = String::new();
            let _= std::io::stdin().read_line(&mut input);
            input.trim().parse::<$ttype>().unwrap()
        }
    };

    ($($ttype:ty),*) => {
        {
            use std::io::BufRead;
            let mut input = String::new();
            let stdin = std::io::stdin();
            let _ = stdin.lock().read_line(&mut input);
            let mut iter = input.trim().split_whitespace();
            (
                $(iter.next().unwrap().parse::<$ttype>().unwrap(),)*
            )
        }
    };

    ($ttype:ty; $x:expr) => {
        {
            use std::io::BufRead;
            let mut input = String::new();
            let stdin = std::io::stdin();
            let _ = stdin.lock().read_line(&mut input);
            let v: Vec<$ttype> = input
                .trim()
                .split_whitespace()
                .map(|x| x.parse().unwrap())
                .collect();
            v
        }
    };

    ($ttype:ty; $x:expr; $y:expr) => {
        {
            use std::io::BufRead;
            let mut matrix = Vec::with_capacity($y);
            for _ in 0..$y {
                let mut input = String::new();
                let stdin = std::io::stdin();
                let _ = stdin.lock().read_line(&mut input);
                let v: Vec<$ttype> = input
                    .trim()
                    .split_whitespace()
                    .map(|x| x.parse().unwrap())
                    .collect();
                matrix.push(v);
            }
            matrix
        }
    };
}

fn gcd(x: i64, y: i64) -> i64 {
    if x % y == 0 {
        y
    } else {
        gcd(y % x, x)
    }
}

fn lcm(x: i64, y: i64) -> i64 {
    if x > y {
        (y / gcd(x, y)) * x
    } else {
        (y / gcd(y, x)) * x
    }
}

fn main() {
    let n = input!(usize);
    let mut t: Vec<i64> = Vec::with_capacity(n);
    for _ in 0..n {
        t.push(input!(i64));
    }
    t.sort();

    let mut answer = t.pop().unwrap();
    while let Some(x) = t.pop() {
        answer = lcm(answer, x);
    }
    println!("{}", answer);
}


Measured memory_bytes: 4352
#include<iostream>
#include<cstdlib>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
#include<set>
#define rep(i,n) for(int i(0);i<n;i++)
using namespace std;
typedef long long ll;

int main(){
	int n;
	cin >> n;
	vector<int> a;
	rep(i,n){
		int c;
		cin >> c;
		a.push_back(c);
	}	

	sort(a.begin(),a.end(),std::greater<int>());

	int ans(0);
	for(int i(0);i<n;i++){
		if(i%2 == 0) ans += a[i];
		else ans -= a[i];
	}
	cout << ans << endl;

    return 0;
}


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

vector<vector<int>> ki(100010);
bool ha[100010];
int kyori1[100010];
int kyori2[100010];
queue<int> q1;
queue<int> q2;
int main(void){
    int n,a,b,u,v;
    cin>>n>>u>>v;
    for(int i=0;i<n-1;i++){
        cin>>a>>b;
        ki[a].push_back(b);
        ki[b].push_back(a);
    }
    for(int i=1;i<=n;i++){
        if(ki[i].size()==1){
            ha[i]=true;
        }
        else ha[i]=false;
    }
    kyori1[u]=0;
    kyori2[v]=0;
    bool reached1[100010]={};
    bool reached2[100010]={};
    reached1[u]=true;
    reached2[v]=true;
    q1.push(u);
    q2.push(v);
    while(!q1.empty()){
        int x=q1.front();
        q1.pop();
        for(int i:ki[x]){
            if(reached1[i]) continue;
            reached1[i]=true;
            kyori1[i]=kyori1[x]+1;
            q1.push(i);
        }
    }
    while(!q2.empty()){
        int x=q2.front();
        q2.pop();
        for(int i:ki[x]){
            if(reached2[i]) continue;
            reached2[i]=true;
            kyori2[i]=kyori2[x]+1;
            q2.push(i);
        }
    }
    int KYORI=1;
    for(int i=1;i<=n;i++){
        if(ha[i]&&(kyori1[i]<kyori2[i])){
            KYORI=max(KYORI,kyori2[i]);
        }
    }
    cout<<KYORI-1;
}


Measured memory_bytes: 6912
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
using namespace std;
#define int long long
typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

bool query(int n) {
  assert(n >= 1 && n <= 1000000000000000000LL);
  cout << "? " << n << endl;
  char c;
  cin >> c;
  return c == 'Y';
}
void answer(int x) {
  assert(x >= 1 && x <= 1000000000);
  cout << "! "<<x<<endl;
  exit(0);
}
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int cur = 0;
  if (query(1000000000000LL)) {
    int lo = 0, hi = 11;
    while (hi - lo > 1) {
      int mid = (lo + hi )  / 2;
      int t = 0;
      rep(_, mid) t = 10*t+9;
      if (query(t)) hi = mid;
      else lo = mid;
    }
    cur = 1;
    rep(_, lo) cur *= 10;
  }
  else {
    for (int d=1; d<=12; d++) {
      int lo = 0, hi = 10;
      while (hi - lo > 1) {
        int mid = (lo + hi) / 2;
        int x = 10*cur + mid;
        while (x <= 1000000000000000LL) {
          x *= 10;
        }
        if (query(x)) hi = mid;
        else lo = mid;
      }
      cur = cur*10 + lo;
      /*
      int lo = 0, hi = 9;
      while (hi - lo > 1) {
        int mid = (lo + hi) / 2;
        int x = 10*cur + mid;
        while (x <= 1000000000000000LL) {
          x *= 10;
          x += 9;
        }
        if (query(x)) hi = mid;
        else lo = mid;
      }
      cur = cur*10LL + hi;
      int t = (cur-1);
      if (t != 0) {
        while (t <= 1000000000000000LL) t *= 10;
        if (query(t)) break;
      }
      */
    }
    cur+=1;
    while (cur%10==0) cur/=10;

    if (query((cur-1)*10)) {
      int lo = 0, hi = 10;
      while (hi - lo > 1) {
        int mid = (lo + hi) / 2;
        int t = cur;
        rep(_, mid) t *= 10;
        t += 1;
        if (query(t)) hi = mid;
        else lo = mid;
      }
      rep(_, hi) cur *= 10;
    }
  }
  answer(cur);
  return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> num(100005);
    ll sum = 0;
    rep(i,n){
        cin >> a[i];
        sum+=a[i];
        num[a[i]] ++;
    }
    int q;
    cin >> q;
    vector<int> b(q), c(q);
    rep(i,q) cin >> b[i] >> c[i];

    rep(i,q){
        sum += num[b[i]] * (c[i]-b[i]);
        num[c[i]] += num[b[i]];
        num[b[i]] = 0;
        cout << sum << endl;
    }
    return 0;
}

Measured memory_bytes: 4780
import java.util.Arrays;
import java.util.Collections;
import java.util.*;
class Main
{
	public static void main (String[] args)
	{
		Scanner sc=new Scanner(System.in); 
		int i;	
		char temp[]=sc.next().toCharArray();
		int a=temp.length; char s[]=new char[a+1];
		for(i=0;i<a;i++)
			s[i+1]=temp[i];
		temp=sc.next().toCharArray();
		int b=temp.length; char t[]=new char[b+1];
		for(i=0;i<b;i++)
			t[i+1]=temp[i];
		int dp[][]=new int[a+1][b+1];
		for(i=1;i<=a;i++)
		{
			for(int j=1;j<=b;j++)
			{
				if(s[i]==t[j])
					dp[i][j]=dp[i-1][j-1]+1;
				else
					dp[i][j]=Math.max(dp[i-1][j],dp[i][j-1]);
			}
		}
		int val=dp[a][b];
		String ans="";
		for(i=a;i>=1;i--)
		{
			for(int j=b;j>=1;j--)
			{
				if(dp[i][j]>dp[i-1][j]&&dp[i][j]>dp[i][j-1]&&dp[i][j]==val)
				{
					ans=s[i]+ans;
					val--;
					break;
				}
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 88756
#include<bits/stdc++.h>
#define int long long
using namespace std;
constexpr int mod=1e9+7;
int fact[2000001];
int mypow(int x,int n){
    if(n==0)
        return 1;
    if(n%2==1)
        return mypow(x,n-1)*x%mod;
    int tmp=mypow(x,n/2);
    return tmp*tmp%mod;
}
int inv(int n){
    return mypow(n,mod-2);
}
int comb(int n,int k){
    return fact[n]*inv(fact[k]*fact[n-k]%mod)%mod;
}
signed main(){
    int k;
    string s;
    cin>>k>>s;
    fact[0]=1;
    for(int i=1;i<=k+s.size();i++)
        fact[i]=fact[i-1]*i%mod;
    int ans=0;
    for(int i=0;i<=k;i++)
        ans=(ans+comb(k+s.size(),i)*mypow(25,i))%mod;
    cout<<ans<<endl;
}

Measured memory_bytes: 20016
n, m = map(int,input().split())
a = [int(i) for i in input().split()]
a.sort()
sa  = []
for i in range(len(a)):
    if i == 0:
        continue
    tmp = max(a[i],a[i-1]) - min(a[i],a[i-1])
    sa.append(tmp)
sa.sort()
sa.reverse()
tmp = 0
for i, num in enumerate(sa):
    if i < n - 1:
        continue
    tmp += num
print(tmp)

Measured memory_bytes: 13840
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-03-15 09:47:30
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <iomanip>
#include <random>
#include <utility>
#include <chrono>

using namespace std;

using int64 = long long;

template<class T> using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) { os << '{'; size_t n = vec.size(); for (size_t i = 0; i < n; ++i) { os << vec[i]; if (i != n - 1) os << ','; } os << '}'; return os; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) { os << '{'; for (auto it = mp.begin(); it != mp.end(); ++it) { os << '{' << it->first << ':' << it->second << '}'; if (it != --mp.end()) os << ','; } os << '}'; return os; }
template<class T> std::ostream& operator<<(std::ostream& os, const std::set<T>& st) { os << '{'; for (auto it = st.begin(); it != st.end(); ++it) { os << *it; if (it != --st.end()) os << ','; } os << '}'; return os; }
template<class T> std::istream& operator>>(std::istream& is, std::vector<T>& vec) { size_t n = vec.size(); for (size_t i = 0; i < n; ++i) is >> vec[i]; return is; }

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

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

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

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

  int n, p; cin >> n >> p;
  string s; cin >> s;
  map<int, int> mp;

  int64 ans = 0;

  mp[0] = 1;

  int t = 0;
  int cur = 1;

  if (p == 2) {
    for (int i = 0; i < n; ++i) {
      if (s[i] == '0' || s[i] == '2' || s[i] == '4' || s[i] == '6' || s[i] == '8') {
        ans += (1 + i);
      }
    }

  } else if (p == 5){
    for (int i = 0; i < n; ++i) {
      if (s[i] == '0' || s[i] == '5') {
        ans += (1 + i);
      }
    }
  } else {
    for (int i = n - 1; i >= 0; --i) {
      int d = s[i] - '0';
      t = (d * cur + t) % p;
      ans += mp[t];
      ++mp[t];
      (cur *= 10) %= p;
    }
  }

  cout << ans << endl;

  return 0;
}

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

int main() {
    int n;
    cin >> n;
    set<string> s;
    rep(i,n){
        string t;
        cin >> t;
        s.insert(t);
    }
    cout << s.size() << endl;
}


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

int main(){
    int N; cin >> N;
    string S; cin >> S;
    string T; cin >> T;
    ll ans=0;
    
    rep(i,N+1){
        if(S.substr(i,N-i)==T.substr(0,N-i)){ 
            ans=i+N;
            break;
        }
    }
    cout << ans;
}

Measured memory_bytes: 256
S = input()
ans = 0
c = 0
for i in range(len(S)):
  if S[i] == "A" or S[i] == "C" or S[i] == "G" or S[i] == "T":
    c += 1
    ans = max(ans, c)
  else:
    c = 0
print(ans)

Measured memory_bytes: 61924
#include <cassert>
#include <iostream>
#include <functional>
#include <iomanip>
#include <set>
#include <unordered_map>
#include <map>
#include <queue>
#include <vector>
#include <deque>
#include <algorithm>
#include  <cstring>
#include <string>
#include <cmath> 
 

#pragma warning(disable: 4996)

using namespace std;
using LL = long long;
const int MAX = 210000;
const LL base = LL( 1e9+7  );

using VI = vector<int>;
using VVI = vector< VI >;
using PII = pair<int, int>; 
template <typename T>
inline void maxs(T&a, const T&b) { a = max(a, b); }
struct Node {
	int x, y, w;
};
bool operator < (const Node & n0, const Node & n1) {
	return n0.x< n1.y;
}

LL za[20][20];
LL pre[1 << 17];
LL dp[1 << 17];
void solve() {

	LL result = 0;
	int n;

	cin >> n;
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) {
			cin >> za[i][j];
		}
	}
	int tall = (1 << n);

	for (int mask = 0; mask < tall; ++mask) {
		for (int i = 0; i < n; ++i) {
			for (int j = i + 1; j < n; ++j) {
				if (mask & (1 << i))
					if (mask &(1 << j))
						pre[mask] += za[i][j];
			}
		}
	}

	for (int mask = 2; mask < tall; ++mask) {
		int u = mask - 1;
		u = u&(mask);
		dp[mask] = pre[mask];
		while (u > 0) {
			maxs(dp[mask], dp[u] + dp[mask - u]);
			u = (u - 1)&mask;
		}
	}

	result = dp[tall - 1];
	cout << result << endl;

}

int main() {
	const int inId = 0;
	const int outId = 0;
	if (inId>0) {
		cerr << "redirect stdin to input " << inId << endl;
		string s = "input";
		s += to_string(inId);
		s += ".txt";
		auto r = freopen(s.c_str(), "r", stdin);	
		if (r == nullptr) {
			cerr<< "invalid input file "<< s;
		}
	}
	if (outId>0) {
		cerr << "redirect stdout to stdout " << outId << endl;
		string s = "stdout";
		s += to_string(outId);
		s += ".txt";
		auto r = freopen(s.c_str(), "w", stdout);
		if (r == nullptr) {
			cerr<< "invalid output file "<< s;
		}		
	}
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); // close sync between cout and printf
	cout.precision(10);
	solve();
}
 

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

#define ll long long
#define ld long double 
#define endl "\n"
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define fr(i,n) for(i=1;i<=n;i++)

typedef pair<int, int> II;
typedef vector< II > VII;
typedef vector<int> VI;

map<ll, ll> mp;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll n,m,i,cnt=0,x,ans=0;
    cin>>n>>m;
    fr(i,n)
    {
        mp[cnt]++;
        cin>>x;
        cnt=(cnt+x)%m;
        if(mp.find(cnt)!=mp.end())
            ans+=mp[cnt];
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 4224
k,n = map(int,input().split())
a = list(map(int,input().split()))

dif =[]

dif.append(a[0]+k-a[n-1])

for i in range(1,n):
    dif.append(a[i]-a[i-1])

dif.sort()
ans = 0
for i in range(n-1):
    ans += dif[i]

print(ans)


Measured memory_bytes: 26444
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
#define endl "\n";
using namespace std;

const long long INF = 100100100100100;
const int MOD = 1000000007;
const int inf = 1001001001;
typedef pair<int,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

int gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}



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

    int N,K;cin >> N >> K;
    vector<long long> retu(N);
    for(int i = 0;i<N;i++) cin >> retu.at(i);
    queue<long long> Q;
    for(int i = 0;i<K;i++){
        Q.push(retu.at(i));
    }    
    for(int i = K;i<N;i++){
        long long from = Q.front();
        long long to = retu.at(i);
        Q.push(to);
        Q.pop();
        if(from >= to){
            cout << "No" << endl;
        }
        else{
            cout << "Yes" << endl;
        }
    }
}

Measured memory_bytes: 6348
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
#define int long long
   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 int MAX =200005;
const int MOD =1000000007;

signed main(){
int n,q,a;
cin>>n>>q;
fenwick_tree<int> tr(n);
for(int i=0;i<n;i++){
  cin>>a;
  tr.add(i,a);
}
int p,l,r;
for(int i=0;i<q;i++){
  cin>>p>>l>>r;
  if(p){
    cout<<tr.sum(l,r)<<endl;
  }else tr.add(l,r);
}
}

Measured memory_bytes: 8216
package main

import ( 
		"fmt"
		"math"
)

var N, D int

func calcDis(arr1[10]int, arr2[10]int)float64 {
		dis := 0.0
		for j:=0; j<D; j++ {
				dis += (float64)((arr1[j] - arr2[j])*(arr1[j] - arr2[j]))
		}
		return math.Sqrt(dis)
}

func main() {
		fmt.Scan(&N, &D)
		var arr [10][10]int
		for i:=0; i<N; i++ {
				for j:=0; j<D; j++ {
						fmt.Scan(&arr[i][j])
				}
		}
		count := 0
		for i:=0; i<N; i++ {
				for j:=i; j<N; j++ { 
						if i != j {
								dis := calcDis(arr[i], arr[j])
								if math.Floor(dis) == dis {
										count++
								}
						}
						//fmt.Println(dis)
				}
		}
		fmt.Println(count)
}


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

#define ln                '\n'
#define all(dat)           dat.begin(), dat.end()
#define loop(i, to)        for (int i = 0; i < to; ++i)
#define cont(i, to)        for (int i = 1; i <= to; ++i)
#define circ(i, fm, to)    for (int i = fm; i <= to; ++i)
#define foreach(i, dat)    for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long          num;

using namespace std;

const int nsz = 12, msksz = 1 << 12, inf = 0x3f3f3f3f;
int n, m, k, lg[msksz + 5], a[nsz + 5][nsz + 5], c[nsz + 5], ans = inf;

void inline init() {
	loop (i, nsz) {
		lg[1 << i] = i + 1;
	}
}

int inline calc(int S) {
	int cur[nsz + 5], sum = 0;
	memset(cur, 0, sizeof(cur));
	for (int t = S, d = t & -t; t; t -= d, d = t & -t) {
		int i = lg[d];
		sum += c[i];
		cont (j, m) {
			cur[j] += a[i][j];
		}
	}
	cont (j, m) {
		if (cur[j] < k)  return inf;
	}
	return sum;
}

int main() {
	ios::sync_with_stdio(0);
	init();
	cin >> n >> m >> k;
	cont (i, n) {
		cin >> c[i];
		cont (j, m) {
			cin >> a[i][j];
		}
	}
	circ (S, 0, msksz) {
		ans = min(ans, calc(S));
	}
	ans = ans == inf ? -1 : ans;
	cout << ans << ln;
}

Measured memory_bytes: 3640
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const ll INF = 1e9 + 7;
const ll inf = 1LL << 50;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
///////////////////////////////////////

int main() {
	int H, W; cin >> H >> W;
	char A[110][110];
	map<char, int>cnt;//aからzが何個ずつあるか
	REP(i, H)REP(j, W)cin >> A[i][j];
	REP(i, H)REP(j, W)cnt[A[i][j]]++;
	bool ok = true;
	if (H % 2 == 0 && W % 2 == 0) {
		for (auto p : cnt) {
			if (p.second % 4)ok = false;
		}
	}
	if (H % 2 && W % 2) {
		map<int, int>c;//4で割って余る数の個数あるアルファベットが何個あるか
		for (auto p : cnt) {
			c[p.second % 4]++;
		}
		if (c[1])c[1]--;
		else {
			c[3]--; c[2]++;
		}
		if (c[1] != 0 || c[3] != 0)ok = false;
		int x = W + H - 1;
		x -= c[2] * 2;
		if (x < 0)ok = false;
	}
	else {
		if (W % 2)swap(H, W);
		map<int, int>c;
		for (auto p : cnt) {
			c[p.second % 4]++;
		}
		if (c[1] || c[3])ok = false;
		if (c[2] > W/ 2)ok = false;
	}
	if (ok)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
//#define NDEBUG
#include <cstddef>
#include <cstdint>
#include <vector>

using i8 = ::std::int_least8_t;
using i32 = ::std::int_least32_t;
using i64 = ::std::int_least64_t;
using u8 = ::std::uint_least8_t;
using u32 = ::std::uint_least32_t;
using u64 = ::std::uint_least64_t;
using isize = ::std::ptrdiff_t;
using usize = ::std::size_t;

template <class T = usize> class rep {
	const T f, l;

public:
	class itr {
		friend rep;
		T i;
		constexpr itr(T x) noexcept : i(x) {}

	public:
		void operator++() noexcept { ++i; }
		constexpr T operator*() const noexcept { return i; }
		constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
	};
	constexpr rep(const T first, const T last) noexcept : f(first), l(last) {}
	constexpr itr begin() const noexcept { return itr(f); }
	constexpr itr end() const noexcept { return itr(l); }
};
template <class T = usize> class revrep {
	const T f, l;

public:
	class itr {
		friend revrep;
		T i;
		constexpr itr(T x) noexcept : i(x) {}

	public:
		void operator++() noexcept { --i; }
		constexpr T operator*() const noexcept { return i; }
		constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
	};
	constexpr revrep(const T first, const T last) noexcept : f(first), l(last) {}
	constexpr itr begin() const noexcept { return itr(l - 1); }
	constexpr itr end() const noexcept { return itr(f - 1); }
};
template <class T> bool amax(T &a, const T &b) {
	return a <= b ? (a = b, 1) : 0;
}
template <class T> bool amin(T &a, const T &b) {
	return b <= a ? (a = b, 1) : 0;
}
template <class T> bool asmax(T &a, const T &b) {
	return b <= a ? 0 : (a = b, 1);
}
template <class T> bool asmin(T &a, const T &b) {
	return a <= b ? 0 : (a = b, 1);
}
template <class T> using vec_alias = ::std::vector<T>;
template <class T> auto md_vec(usize n, const T &value) {
	return ::std::vector<T>(n, value);
}
template <class... Args> auto md_vec(usize n, Args... args) {
	return ::std::vector<decltype(md_vec(args...))>(n, md_vec(args...));
}
template <class T> const T &as_const(const T &v) noexcept { return v; }
template <class T> constexpr T difference(const T &a, const T &b) {
	return a <= b ? b - a : a - b;
}

#include <algorithm>
#include <iostream>
#include <utility>
#include <numeric>

int main() {
	usize n, m;
	::std::cin >> n >> m;
	if (n >= m) {
		::std::cout << 0 << ::std::endl;
		return 0;
	}
	::std::vector<i32> x(m);
	for (auto &e : x) {
		::std::cin >> e;
	}
	::std::sort(x.rbegin(), x.rend());
	for (const auto i : rep<>(0, m - 1)) {
		x[i] -= x[i + 1];
	}
	x.pop_back();
	::std::sort(x.begin(), x.end());
	::std::cout
		<< ::std::accumulate(x.cbegin(), x.cbegin() + (m - n), 0)
		<< ::std::endl;
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;


int main(int argc, const char * argv[]) {

    string s;
    cin >> s;
    if(s.at(0) == s.at(2)){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main ()
{
	int i,n,count=0;
	string s,t;
	cin>>s;
	cin>>t;
	n=s.size();
	for(i=0;i<n;i++)
	{
		if(s[i]==t[i])
		{
			count++;
		}
	}
	cout<<count;
	return 0;
	
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

int main(){
    int N, K;
    cin >> N >> K;
    ll ans = 0;
    REP(i,N){
        int h;
        cin >> h;
        if(h >= K)
            ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <numeric>
#include <iostream>
#include <vector>
#include <set>
#include <cstring>
#include <string>
#include <map>
#include <cmath>
#include <ctime>
#include <algorithm>
#include <bitset>
#include <queue>
#include <sstream>
#include <deque>

using namespace std;

#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i = 0; i < (n); i++)
#define re return
#define fi first
#define se second
#define sz(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define sqrt(x) sqrt(abs(x))
#define y0 y3487465
#define y1 y8687969
#define fill(x,y) memset(x,y,sizeof(x))
#define prev PREV
#define next NEXT
                         
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef double D;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef vector<vi> vvi;

template<class T> T abs(T x) { re x > 0 ? x : -x; }
template<class T> inline T sqr (T x) { re x * x; }

#define filename ""

int n;
int m;
string s;

int main () {
	cin >> s;
	n = sz (s);
	for (int i = 0; i < n; i++)
		for (int j = i + 1; j < n; j++)
			if (s[i] == 'C' && s[j] == 'F') {
				printf ("Yes\n");
				re 0;
			}
	printf ("No\n");
	return 0;
}

Measured memory_bytes: 764
a=int(input())
b=int(input())
if a==1 and b==2:
  print(3)
elif a==2 and b==3:
  print(1)
elif a==3 and b==1:
  print(2)
elif a==1 and b==3:
  print(2)
elif a==2 and b==1:
  print(3)
elif a==3 and b==2:
  print(1)

Measured memory_bytes: 3060
import fractions

n,x = map(int,input().split())
xis = list(map(int,input().split()))

xsas = [abs(xi-x) for xi in xis]

if n == 1:
    print(xsas[0])
else:
    res = fractions.gcd(xsas[0],xsas[1])
    for xsa in xsas:
        res = fractions.gcd(res,xsa)
    print(res)

Measured memory_bytes: 16280
#!/usr/bin/env python3
(x, y, z, k), a, b, c = [[*map(int, o.split())] for o in open(0)]
a.sort(); b.sort(); c.sort()

p = a[-1] + b[-1] + c[-1]
s, h = {(p, -1, -1, -1)}, [(-p, -1, -1, -1)]

from heapq import*
def push(i, j, k):
    global s, h
    try:
        t = a[i] + b[j] + c[k]
    except IndexError:
        return
    if (t, i, j, k) not in s:
        heappush(h, (-t, i, j, k))
        s |= {(t, i, j, k)}

for _ in [0] * k:
    p, i, j, k = heappop(h)
    print(-p)
    push(i, j, k - 1)
    push(i, j - 1, k)
    push(i - 1, j, k)

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

 int main() {
 int N;
 cin >> N;
 vector<int> a(N);
 int sum = 0;

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

 int mini = sum;
 int prefix_sum = 0;
 for (int i = 0; i < N; ++i) {

 prefix_sum += a[i];
 mini = min(mini, abs(prefix_sum - (sum - prefix_sum)));
 }

 cout << mini << endl;
 return 0;
 }

Measured memory_bytes: 256
fn solve(src: &str) -> String {
    let mut sc = Scanner::from_str(src);

    let n: usize = sc.read();
    let test: Vec<Vec<(usize, bool)>> = (0..n)
        .map(|_| {
            (0..sc.read())
                .map(|_| (sc.read::<usize>() - 1, sc.read::<i32>() == 1))
                .collect()
        })
        .collect();

    let mut ans = 0;
    for bv in pow_bitvec(n) {
        let mut pc = 0;
        let ok = (0..n).filter(|&i| bv[i]).all(|i| {
            pc += 1;
            test[i].iter().all(|&(x, y)| bv[x] == y)
        });
        if ok && pc > ans {
            ans = pc;
        }
    }

    format!("{}", ans)
}

fn main() {
    let mut buf = String::new();
    use std::io;
    use std::io::{Read, Write};
    io::stdin().read_to_string(&mut buf).unwrap();
    io::stdout().write_all(solve(&buf).as_bytes()).unwrap();
}

struct Scanner<'a>(std::str::SplitWhitespace<'a>);
impl<'a> Scanner<'a> {
    fn from_str(src: &str) -> Scanner {
        Scanner(src.split_whitespace())
    }
    fn get(&mut self) -> &str {
        self.0.next().unwrap()
    }
    fn read<T: std::str::FromStr>(&mut self) -> T {
        self.get().parse().ok().unwrap()
    }
}

#[derive(Clone)]
pub struct TinyBitVec(u64);

impl TinyBitVec {
    pub fn new() -> Self {
        TinyBitVec(0)
    }

    pub fn count_ones(&self) -> usize {
        self.0.count_ones() as usize
    }

    pub fn set(&mut self, i: usize, x: bool) {
        if x {
            self.0 |= 1 << i
        } else {
            self.0 &= !(1 << i)
        }
    }
}

const TRUE: &'static bool = &true;
const FALSE: &'static bool = &false;
impl std::ops::Index<usize> for TinyBitVec {
    type Output = bool;
    fn index(&self, index: usize) -> &bool {
        if (self.0 >> index) & 1 == 1 {
            TRUE
        } else {
            FALSE
        }
    }
}

pub fn pow_bitvec(n: usize) -> PowBitVec {
    assert!(n < 64);
    PowBitVec { c: 0, m: 1 << n }
}

pub struct PowBitVec {
    c: u64,
    m: u64,
}

impl Iterator for PowBitVec {
    type Item = TinyBitVec;

    fn next(&mut self) -> Option<Self::Item> {
        if self.c < self.m {
            let ret = TinyBitVec(self.c);
            self.c += 1;
            Some(ret)
        } else {
            None
        }
    }
}


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

typedef long long ll;
char C[3][3];

int main(){
	for(int i=0;i<3;i++){
		for(int j=0;j<3;j++){
			cin >> C[i][j];
		}
	}
	cout << C[0][0] << C[1][1] << C[2][2] << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
@author: H_Hoshigi
"""
def main():
    K = int(input())
    S = input()
    answer = ""
    if len(S) <= K:
        answer = S
    else:
        answer = S[:K] + "..."
    print(answer)

if __name__ == "__main__":
    main()




Measured memory_bytes: 9168
import java.util.*;
public class Main {
public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	long N = sc.nextLong();
 	long A = sc.nextLong();
 	long B = sc.nextLong();
  	long amari = N%(A+B);
  	long ans=0;
     
  	ans = A * (N/(A+B));
  	if(amari<=A){
     ans += amari; 
    }else{
      ans += A;
    }
  
	System.out.print(ans);
	}
}

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

using namespace std;

int N;

int main(){
  int inp;
  int rate[9]={0,0,0,0,0,0,0,0,0};
  int min=0;
  
  cin >> N;
  for(int i =0;i<N;i++){
    cin >> inp;
    if((inp>=1)&&(inp<=399))rate[0]=1;
    else if((inp>=400)&&(inp<=799))rate[1]=1;
    else if((inp>=800)&&(inp<=1199))rate[2]=1;
    else if((inp>=1200)&&(inp<=1599))rate[3]=1;
    else if((inp>=1600)&&(inp<=1999))rate[4]=1;
    else if((inp>=2000)&&(inp<=2399))rate[5]=1;
    else if((inp>=2400)&&(inp<=2799))rate[6]=1;
    else if((inp>=2800)&&(inp<=3199))rate[7]=1;
    else rate[8]+=1;;
    
  }

  for(int i =0;i<8;i++){
    min+=rate[i];
  }
  if (min==0){cout << "1 " << min+rate[8]<<endl;}

  else{cout << min <<" "<<min+rate[8]<<endl;}
  
  return 0;
}


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

int main(void) {
    long long X;
    cin >> X;
    vector<bool> primes(100003, true);
    primes[0] = primes[1] = false;
    for (long long i = 2; i * i <= 100003; i++) {
        if (!primes[i]) continue;
        for (long long j = i * i; j <= 100003; j += i) {
            primes[j] = false;
        }
    }

    for (long long i = X; i <= 100003; i++) {
        if (primes[i]) {
            cout << i << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256