akhauriyash/Code-Regression huggingface dataset:
import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15

from itertools import permutations,product,combinations_with_replacement,groupby,accumulate,combinations
class BinaryIndexedTree():
    def __init__(self,N):
        self.N = N
        self.tree = [0] * (N + 1)
    
    def add(self,i,x):
        while i <= self.N:
            self.tree[i] += x
            i += (i & -i)
    
    def sum(self,i):
        ret = 0
        while i > 0:
            ret += self.tree[i]
            i -= (i & -i)
        return ret
    
    def lower_bound(self,x):#初めて和がx以上となるindex(0indexed)
        if x <= 0:
            return 0
        i = 0
        K = 1 << self.N.bit_length()
        while K > 0:
            if i + K <= self.N and self.tree[i + K] < x:
                x -= self.tree[i + K]
                i += K
            K >>= 1
        return i + 1
    
    def __str__(self):
        return ' '.join(map(str,self.tree))

def main():
    N,K = map(int,input().split())
    A = [int(input()) for _ in range(N)]
    A = [0] + [a - K for a in A]
    A = list(accumulate(A))

    compress = list(sorted(set(A)))
    dic = {c:i for i,c in enumerate(compress,1)}
    bit = BinaryIndexedTree(len(compress))
    ans = N*(N + 1)//2
    for i,a in enumerate(A):
        j = dic[a]
        ans -= i - bit.sum(j)
        bit.add(j,1)
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 48212
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;
using System.IO;
using System.Diagnostics;

class Scanner
{
    private readonly char Separator = ' ';
    private int Index = 0;
    private string[] Line = new string[0];
    public string Next()
    {
        if (Index >= Line.Length)
        {
            Line = Console.ReadLine().Split(Separator);
            Index = 0;
        }
        var ret = Line[Index];
        Index++;
        return ret;
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    private long NextLong()
    {
        return long.Parse(Next());
    }
}

class Magatro
{
    private int N, M;
    private List<int>[] R;
    private int[] Col;
    private void Scan()
    {
        var sc = new Scanner();
        N = sc.NextInt();
        M = sc.NextInt();
        R = new List<int>[N];
        for (int i = 0; i < N; i++)
        {
            R[i] = new List<int>();
        }
        for (int i = 0; i < M; i++)
        {
            var a = sc.NextInt() - 1;
            var b = sc.NextInt() - 1;
            R[a].Add(b);
            R[b].Add(a);
        }
    }

    private bool F(int num, int col)
    {
        if (Col[num] == col)
        {
            return true;
        }
        else if (Col[num] == 0)
        {
            Col[num] = col;
            bool c = true;
            foreach (var i in R[num])
            {
                c &= F(i, col * -1);
            }
            return c;
        }
        else
        {
            return false;
        }
    }

    public void Solve()
    {
        Scan();
        Col = new int[N];
        if (F(0, 1))
        {
            int a = 0;
            int b = 0;
            foreach (var i in Col)
            {
                if (i == 1) a++;
                else b++;

            }
            Console.WriteLine((long)a * b - M);
        }
        else
        {
            Console.WriteLine((long)N * (N - 1) / 2 - M);
        }
    }

    static public void Main()
    {
        new Magatro().Solve();

    }
}


Measured memory_bytes: 29068
from fractions import gcd


N = int(input())
A = list(map(int, input().split()))

# l[i] := [0, i]の数のGCDメモ
l = [None for _ in range(N)]
l[0] = A[0]
for i in range(1, N):
    l[i] = gcd(l[i - 1], A[i])

# r[i] := [i, N - 1]の数のGCDメモ
r = [None for _ in range(N)]
r[N - 1] = A[N - 1]
for i in reversed(range(N - 1)):
    r[i] = gcd(r[i + 1], A[i])

ans = 0
for i in range(N):
    if i == 0:
        ans = max(ans, r[1])
    elif i == N - 1:
        ans = max(ans, l[N - 2])
    else:
        ans = max(ans, gcd(l[i - 1], r[i + 1]))
print(ans)

Measured memory_bytes: 16152
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <numeric>
#define rep(i, m, n) for(int i = m;i < n;i++)
#define repr(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define INF 999999999
using namespace std;

int main(){
    char T[3];
    rep(i, 0, 3)cin >> T[i];
    SORT(T, 3);

    char A=T[0];
    char B=T[1];
    char C=T[2];


    if(A == 'a' && B == 'b' && C == 'c') cout << "Yes"<< endl;
    else cout << "No" << endl;

    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define contains(v, t) (find(v.begin(), v.end(), t) != v.end())
#define MOD 1000000007
typedef long long ll;
typedef unsigned long long ull;

int main() {
  string s;
  cin >> s;
  set<char> se;
  rep(i, s.length()) {
    auto res = se.insert(s[i]);
    if (!res.second) {
      cout << "no";
      return 0;
    }
  }
  cout << "yes";
}


Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, char const *argv[])
{
	char s[4],c = 0;
	scanf("%s",s);
	for (int i = 0; i < 4; ++i)
	{
		if(s[i] == '2')	++c;
	}
	printf("%d\n", c);
	return 0;
}

Measured memory_bytes: 128
l,r=map(int,input().split())
mod=2019
a=l%mod
b=l//mod
c=r%mod
d=r//mod
if d-b!=0:
  print(0)
else:
  ans=float('inf')
  for i in range(l,r):
    for j in range(i+1,r+1):
      ans=min(ans,(i*j)%mod)
  print(ans)

Measured memory_bytes: 65504
#include <bits/stdc++.h>
int from_roman(const std::string &s){
    static const std::map<char, int> m = {
        { 'I', 1 },
        { 'V', 5 },
        { 'X', 10 },
        { 'L', 50 },
        { 'C', 100 },
        { 'D', 500 },
        { 'M', 1000 }
    };
    static const auto get = [&](char c) {
        return m.find(c)->second;
    };
    int n=0;
    for(int i = 0; i < (int)s.size(); ++i){
        if(i + 1 == (int)s.size() || get(s[i]) >= get(s[i+1])) n += get(s[i]);
        else n -= get(s[i]);
    }
    return n;
}

// int to_roman(int n){
//     std::vector<std::pair<std::string, std::string>> res;
//     while(n){
//         int d = n % 10;

//     }
// }

using namespace std;
int main(){
    string n;
    while(cin >> n){
        cout << from_roman(n) << endl;
    }
}

Measured memory_bytes: 3080
using System;
using System.IO;

class Program
{
    static void Main(string[] args)
    {
        new Program().Solve();
    }

    public void Solve()
    {
        var sc = new Scanner();

        int r = sc.NextInt();
        Console.WriteLine(3 * r * r);
    }
}


class Scanner
{
    public Scanner()
    {
        _stream = new StreamReader(Console.OpenStandardInput());
        _pos = 0;
        _line = new string[0];
    }

    const char Separator = ' ';
    private readonly StreamReader _stream;
    private int _pos;
    private string[] _line;

    #region スペース区切りで取得

    public string Next()
    {
        if (_pos >= _line.Length)
        {
            _line = _stream.ReadLine().Split(Separator);
            _pos = 0;
        }

        return _line[_pos++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }

    #endregion

    #region 型変換

    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }

        return result;
    }

    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }

        return result;
    }

    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }

        return result;
    }

    #endregion

    #region 配列取得

    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = _stream.ReadLine().Split(Separator);

        _pos = _line.Length;
        return _line;
    }

    public int[] IntArray()
    {
        return ToIntArray(Array());
    }

    public long[] LongArray()
    {
        return ToLongArray(Array());
    }

    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }

    #endregion
}


Measured memory_bytes: 13140
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>

using namespace std;

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


    int x[3] = {a+b, a-b, a*b};

    cout << max(max(x[0],x[1]),x[2]) << endl;


    return 0;
}


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


int main() {
	int N, M, X;
	cin >>  N >> M >> X;
	int sum = 0;
	vector<int> A(N+1, 0);

	for (int i = 0; i < M; i++) {
		int temp;
		cin >> temp;
		A[temp] = 1;
	}

	for (int i = X; i < N + 1; i++) {
		sum += A[i];
	}
	int sum2 = 0;
	for (int i = X; i > -1; i--) {
		sum2 += A[i];
	}
	if (sum < sum2)cout << sum << endl;
	else cout << sum2 << endl;


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;

#define dump(x)  cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define possible(n) cout << ((n) ? "possible" : "impossible"  ) << endl

#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) for(ll i=0;i<(n);++i)
#define REPR(i,n) for(ll i=n;i>=0;i--)

#define FOREACH(x,a) for(auto&& (x) : (a) )

#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j])

#define SCOUT(x) cout<<(x)<<" "
#define ENDL cout<<endl

#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i]
#define VECCOUT(x) if(1){for(auto tt=x.begin();tt!=x.end();tt++){if(tt!=x.begin())cout<<" ";cout<<(*tt);}cout<<endl;}

#define ALL(obj) (obj).begin(),(obj).end()

#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())
#define EN(x) if(1){cout<<#x<<endl;return 0;}
#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

template <class T = ll>
T IN(){T x;cin>>x;return (x);}

template <class Head>
void VT(Head head){}
template <class Head,class Seco,class... Tail>
void VT(Head&& head,Seco&& seco,Tail&&... tail){
    seco.resize(head);
    VT(head,move(tail)...);
}
void VT2(){}
template <class Head,class... Tail>
void VT2(Head&& head,Tail&&... tail){
  VECCIN(head);
  VT2(move(tail)...);
}

template <class Head>
void VT3(Head&& head){}
template <class Head,class Seco,class... Tail>
void VT3(Head&& head,Seco&& seco,Tail&&... tail){
  seco[head]=IN();
  VT3(head,move(tail)...);
}

#define VC1(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);VT2(__VA_ARGS__); //aaabbbccc
#define VC2(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);REP(i,n)VT3(i,__VA_ARGS__); //abcabcabc

// #include <boost/multiprecision/cpp_ll.hpp>
// using namespace boost::multiprecision; // cpp_ll

#define P pair<ll,ll>
#define V vector<ll>
#define M map<ll,ll>
#define S set<ll>

#define pb(a) push_back(a)
#define mp make_pair

signed main(){
    CIN(n,t,a);VC1(n,h);
    double diffmin = 1e9;
    int ind = 0;
    REP(i,n){
        double diff = abs(t - h[i] * 0.006 - a);
        if(diff < diffmin){
            diffmin = diff;
            ind = i;
        }
    }
    COUT(ind + 1);

}


Measured memory_bytes: 256
import sys
import math

def solve(K: int, A: int, B: int):
    a = math.ceil(A / K)
    b = math.floor(B / K)

    if b >= a:
        print("OK")
    else:
        print("NG")
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(K, A, B)

if __name__ == '__main__':
    main()

Measured memory_bytes: 62052
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ll long long
#define ll_MAX LONG_LONG_MAX
#define ll_MIN LONG_LONG_MIN
#define pi pair<ll,ll>
#define endl "\n"
#define MAXN 100005
#define mod 1000000007
using namespace std;

void solve()
{
    
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	cout.tie(NULL);
    solve();
    ll n;
    cin>>n;
    ll maxi = 0, maxi1 = 0;
    ll mini = 1e10, mini1 = 1e10;
    for(ll i=0; i<n; i++)
    {
        ll x,y;
        cin>>x>>y;
        maxi = max(x + y, maxi);
        maxi1 = max(maxi1, y - x);
        mini1 = min(mini1, y - x);
        mini = min(x + y, mini);
    }
    cout<<max(maxi1 - mini1, maxi - mini)<<'\n';
}

Measured memory_bytes: 3584
#include "bits/stdc++.h"
using namespace std;
#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define PI 3.1415926535
typedef long long ll;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<Pll> vPll;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<double>> vvd;
typedef vector<vector<Pi>> vvPi;
typedef priority_queue<int, vector<int>, greater<int>> pqli;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi>> pqlP;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
int main(void)
{
	int a, b, ans=0;

	string s;

	cin>>a>>b;

	repr(i, a, b+1){
		s=to_string(i);
		if(s[0]==s[4]&&s[1]==s[3]) ans++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#18:45
n = int(input())
a = list(map(int,input().split()))
b = [0 for _ in range(n)]
for i in range(n,0,-1):
  tmp = 0
  here = i
  while True:
    try:
      tmp ^= b[here-1]
      here += i
    except:
      tmp ^= a[i-1]
      break
  if tmp == 1:
    b[i-1] = 1
print(sum(b))
c = []
for i in range(n):
  if b[i] == 1:
    c.append(i+1)
print(' '.join(list(map(str,c))))

Measured memory_bytes: 19900
#include <stdio.h>
int main()
{
 int x,y,r,W,H;
 scanf("%d%d%d%d%d",&W,&H,&x,&y,&r);
 W-=r;H-=r;
 if(r<=x && r<=y && x<=W && y<=H)
  printf("Yes\n");
 else
  printf("No\n");
 return 0;
}


Measured memory_bytes: 2104
h, w = map(int, input().split())
a=[list(input()) for i in range(h)]
def vert(a):
    res=[]
    for i in range(len(a)):
        if all(x=="." for x in a[i]):
            res.append(i)
    return res
def hori(a):
    res=[]
    for i in range(len(a[0])):
        if all(a[j][i]=='.' for j in range(len(a))):
            res.append(i)
    return res

while True:
    v_res=vert(a)
    if not(len(v_res)==0):
        a= [a[i] for i in range(len(a)) if not i in v_res]
            
    h_res=hori(a)
    if not(len(h_res)==0):
        a=[[a[j][i] for i in range(len(a[0])) if not i in h_res] for j in range(len(a))]
    if len(h_res+v_res)==0:
        break
for ai in a:
    print(''.join(ai))
    
    

Measured memory_bytes: 3188
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    A = sorted(list(map(int, input().split())))
    if n % 2 == 0:
        num = 1
        for i in range(0, n - 1, 2):
            if A[i] != num or A[i + 1] != num:
                print(0)
                exit()
            num += 2
    else:
        if A[0] != 0:
            print(0)
            exit()
        num = 2
        for i in range(1, n - 1, 2):
            if A[i] != num or A[i + 1] != num:
                print(0)
                exit()
            num += 2

    res = pow(2, n // 2, mod)
    print(res % mod)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 20332
C=[0,0]
A=[0,0]
C[0]=list(input())
C[1]=list(input())
A[1]=[C[0][-1],C[0][-2],C[0][-3]]
A[0]=[C[1][-1],C[1][-2],C[1][-3]]
print('YES' if A==C else 'NO')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP2(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(v) (v).begin(),(v).end()
#define INF 2e9
typedef long long ll;

int main()
{
  int n,a,b;
  cin>>n>>a>>b;
  vector<int> p1,p2,p3;
  REP(i,n){
    int p;
    cin>>p;
    if(p<=a) p1.emplace_back(p);
    else if(p<=b) p2.emplace_back(p);
    else p3.emplace_back(p);
  }
  cout<<min(min(p1.size(),p2.size()),p3.size())<<endl;
  
	return 0;
}

Measured memory_bytes: 256
function main(input) {
  var inputs = input.split('\n');

  var nums = inputs[0].split(' ');
  var n = parseInt(nums[0], 10);
  var m = parseInt(nums[1], 10);
  var hs = inputs[1].split(' ').map((n) => parseInt(n, 10));

  var bridges = [];
  for (var i = 0; i < m; i++) {
    var nums = inputs[i + 2].split(' ').map((n) => parseInt(n, 10));
    bridges.push(nums);
  }

  // true: good, false: bad
  var evaluates = [];
  for (var i = 0; i < hs.length; i++) {
    evaluates.push(true);
  }

  bridges.forEach((item, i) => {
    var peak1 = item[0] - 1;
    var peak2 = item[1] - 1;
    var isHeigherPeak1 = hs[peak1] > hs[peak2];
    var isHeigherPeak2 = hs[peak2] > hs[peak1];

    if (evaluates[peak1]) {
      evaluates[peak1] = isHeigherPeak1;
    }

    if (evaluates[peak2]) {
      evaluates[peak2] = isHeigherPeak2;
    }
  });

  var goodPeakCount = 0;
  evaluates.forEach((item, i) => {
    if (item) goodPeakCount += 1;
  });

  console.log(goodPeakCount);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


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

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		long sum=0;
		for(int i=0;i<N;i++){
			var d=rla();
			sum+=d[0]*d[1];
		}
		if(sum==0){
			Console.WriteLine(0);
		}else{
			Console.WriteLine(1);
			Console.WriteLine("{0} {1}",sum>0?-1:1,sum>0?sum:-sum);
		}
		
	}
	int N;
	
	public Sol(){
		//L=ri();
		rs();
		N=ri();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}

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

li = list(range(n + 1))
li3 = [i * 3 for i in list(range(n // 3+1))]
li5 = [i * 5 for i in list(range(n // 5+1))]

li = set(li)
li3 = set(li3)
li5 = set(li5)
print(sum(li.difference(li3, li5)))

Measured memory_bytes: 181944
N,M = map(int,input().split())
S = input()
T = input()
def gcd(a,b):
  if a%b == 0:
    return b
  else:
    return gcd(b,a%b)
p = gcd(M,N)
q = M*N//p
flag = True
for j in range(p):
  if S[N*j//p] != T[M*j//p]:
    flag = False
    break
if flag:
  print(q)
else:
  print(-1)

Measured memory_bytes: 3316
#include<iostream>
#include<stdio.h>
using namespace std;

int main(){
  char ch;
  int count[26];
  // 初期化
  for(int i=0;i<26;i++){
    count[i]=0;
  }
  while(cin>>ch){
    for(int i=0;i<26;i++){
      if((ch=='a'+i)||(ch=='A'+i))count[i]++;
    }
    if(ch=='@')break;
  }
  for(int i=0;i<26;i++){
    printf("%c : %d\n",'a'+i,count[i]);
  }
  return 0;
}



Measured memory_bytes: 3160
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define divceil(A, B) ((A + (B - 1)) / B)
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define CERR if(false) cerr

using namespace std;

int main(){

    int n,m;
    cin >> n >> m;

    vector<int> dp(n + 1, 0);
    vector<int> k(n + 1, 1);

    rep(i,m){
        int tmp;
        cin >> tmp;

        k[tmp] = 0;
    }

    dp[0] = 1;
    dp[1] = dp[0] * k[1];

    for(int i = 2; i <= n; i++){
        dp[i] = ((dp[i - 1] + dp[i - 2]) * k[i]) % MODN;
    }

    cout << dp[n] << endl;


}


Measured memory_bytes: 1024
from math import log

N, K = map(int, input().split())
A = list(map(int, input().split()))

x = 0
if K != 0:
    for i in range(int(log(K, 2)), -1, -1):
        cnt_zero = 0
        cnt_one = 0
        for a in A:
            digit = (a >> i) & 1
            if digit == 0:
                cnt_zero += 1
            else:
                cnt_one += 1

        x += 2**i if cnt_zero > cnt_one else 0
        if x > K:
            x -= 2**i

ans = 0
for a in A:
    ans += x ^ a
print(ans)

Measured memory_bytes: 14620
#include<bits/stdc++.h>
using namespace std;
signed main(){
  int n;
  cin>>n;
  int a[100];
  for(int i=0;i<n;i++)cin>>a[i];
  sort(a,a+n);
  int ans=0;
  for(int i=0;i<n;i++){
    ans+=(i%2?-a[n-1-i]:a[n-1-i]);
  }
  cout<<ans<<endl;
  return 0;
}


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

typedef long long ll;
typedef long double ld;
#define blue ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define mod 1000000007;


int main() {
  blue;
  int n,w;
  cin>>n>>w;
  ll value[n+1],weight[n+1];
  for(int i=1;i<=n;i++) cin>>weight[i]>>value[i];
  ll dp[n+1][w+1];
  // max( dp(i,now+a[i][1]), dp(i+1,now) )
  for(int i=0;i<=n;i++) {
    for(int j=0;j<=w;j++) {
      if(i==0 || j==0) dp[i][j]=0;
      else if(j<weight[i]) dp[i][j]=dp[i-1][j];
      else {
        // cout<<dp[i-1][j]<<" "<<value[i]+dp[i-1][j-weight[i]]<<endl;
        // cout<<dp[i-1][j-weight[i]]<<endl;
        dp[i][j]=max(dp[i-1][j], value[i] + dp[i-1][j-weight[i]]);
      }

      // cout<<dp[i][j]<<" ";
    }
    // cout<<"\n";
  }

  cout<<dp[n][w];

}

/*
  
*/

Measured memory_bytes: 79104
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<stack>
#include<queue>

using namespace std;

bool ans(vector<string> &refe, string &S) {
    int pos = 0;

    while(pos < S.length()){
        for(int i = 0; i < refe.size(); i++){
            if(S.length() < pos + refe[i].length()) continue;
            if(refe[i] == S.substr(pos, refe[i].length())){
                pos += refe[i].length();
                goto next;
            }
        }
        return false;
        next:;
    }

	return true;
}

int main(void) {
    string S;
    vector<string> refe;

	// refe.push_back("dreameraser");
	// refe.push_back("dreamerase");
	refe.push_back("dreamer");
	refe.push_back("dream");
	refe.push_back("eraser");
	refe.push_back("erase");
    
	cin >> S;

    for(int i = 0; i < refe.size(); i++) reverse(refe[i].begin(), refe[i].end());
    reverse(S.begin(), S.end());

	if (ans(refe, S)) cout << "YES" << endl;
	else cout << "NO" << endl;

	//system("pause");
	return 0;
}


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

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

using namespace std;

int main() {
  int n,K;
  cin>>n>>K;
  vector<vector<tuple<int,int,int>>> p(n);
  vector<int> sx,sy,sz;
  REP(i,n){
    REP(j,2){
      int x,y,z;
      cin>>x>>y>>z;
      p[i].emplace_back(x,y,z);
      sx.push_back(x);
      sy.push_back(y);
      sz.push_back(z);
    }
  }
  sort(begin(sx),end(sx));
  sort(begin(sy),end(sy));
  sort(begin(sz),end(sz));
  sx.erase(unique(begin(sx),end(sx)),end(sx));
  sy.erase(unique(begin(sy),end(sy)),end(sy));
  sz.erase(unique(begin(sz),end(sz)),end(sz));
  int h=sx.size(),w=sy.size(),d=sz.size();
  int bx[h][w][d];
  REP(i,h)REP(j,w)REP(k,d)bx[i][j][k] = 0;
  REP(i,n){
    vector<tuple<int,int,int>> p2;
    REP(j,2){
      int x,y,z;
      tie(x,y,z)=p[i][j];
      int xc=lower_bound(begin(sx),end(sx),x)-begin(sx);
      int yc=lower_bound(begin(sy),end(sy),y)-begin(sy);
      int zc=lower_bound(begin(sz),end(sz),z)-begin(sz);
      p2.emplace_back(xc,yc,zc);
    }
    REP(j,2)REP(k,2)REP(l,2){
      int x,y,z;
      x=get<0>(p2[j]);
      y=get<1>(p2[k]);
      z=get<2>(p2[l]);
      int sg=1;
      if((j+k+l)%2)sg*=-1;
      bx[x][y][z] += sg;
    }
  }
  REP(i,h)REP(j,w)REP(k,d-1) bx[i][j][k+1] += bx[i][j][k];
  REP(i,h)REP(j,w-1)REP(k,d) bx[i][j+1][k] += bx[i][j][k];
  REP(i,h-1)REP(j,w)REP(k,d) bx[i+1][j][k] += bx[i][j][k];
  int64_t cnt = 0;
  REP(i,h)REP(j,w)REP(k,d) {
    if(bx[i][j][k] >= K) {
      int64_t v = 1;
      v *= sx[i+1]-sx[i];
      v *= sy[j+1]-sy[j];
      v *= sz[k+1]-sz[k];
      cnt += v;
    }
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 5128
/*
    飲んだ魔剤で家が建つ。
    created at: 2020-04-18 11:06:49
*/

#include <bits/stdc++.h>
using namespace std;

#define all(x) (x).begin(),(x).end()
#define rev(x) greater<x>()
#define MOD 1000000007
#define INF 1000000000

typedef long long LL;
typedef long double LD;

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

LL modpower(LL n, LL m, LL mod)
{
    if (m == 0) {
        return 1;
    } else if (m % 2 == 0) {
        LL p = modpower(n, m/2, mod);
        return p*p % mod;
    } else {
        return n*modpower(n, m-1, mod) % mod;
    }
}

LL modinv(LL n, LL mod)
{
    return modpower(n, mod-2, mod);
}

LL modcombination(LL n, LL r, LL mod)
{
    LL ret = 1;

    for (int i = 0; i < r; i++) {
        ret *= (n-i);
        ret %= mod;
        ret *= modinv(i+1, mod);
        ret % mod;
    }

    return ret % mod;
}

int gcd(int k, int l)
{
    if (l > 0) return gcd(l, k%l);
    else return k;
}

struct UnionFind
{
    vector<int> par;

    UnionFind(int n) : par(n) {
        for (int i = 0; i < n; i++) par[i] = i;
    }

    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main()
{
    int a, b, c;
    cin >> a >> b >> c;

    int ans = a + b + c - max({a, b, c});
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
a = list(map(int,input().split(" ")))
N = a[0]
M = a[1]
X = a[2]
Y = a[3]
x = list(map(int,input().split(" ")))
y = list(map(int,input().split(" ")))

max_x = max(x)
min_y = min(y)
Z = X + 1
done = False
while not done:
    if Z > Y:
        done = True
        s = "War"

    elif max_x < Z <= min_y:
        done = True
        s = "No War"

    Z += 1

print(s)


Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
typedef long long ll;

int main(){
    int a, b, r;
    while(cin >> a >> b >> r, a+b){
        vector<double> ax[10050];
        for(int i = 0; i < a; i++){
            int x, y;
            cin >> x >> y;
            ax[x].push_back(y);
        }
        for(int i = 0; i < 10050; i++){
            if(ax[i].size())    sort(ax[i].begin(),ax[i].end());
        }
        ll ans = 0;
        for(int i = 0; i < b; i++){
            int x, y;
            cin >> x >> y;
            for(int j = -4*r; j <= 4*r; j++){
                if(x+j < 0) continue; 
                double rr = sqrt(4*r*4*r-j*j);
                ans += upper_bound(ax[x+j].begin(), ax[x+j].end(), y+rr)-lower_bound(ax[x+j].begin(),ax[x+j].end(),y-rr);
            }
        }
        cout << ans << endl;
    }
    return 0;
}


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

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

    int ans;
    for (int i = M / N; i > 0; --i) {
        if (!((M % i) % i)) {
            ans = i;
            break;
        }
    }

    cout << ans << endl;
    
    return 0;
}

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

using namespace std;
bool FLAG = true;
#define debug(x) if(FLAG){cout<< #x << " = " << x << endl;}
#define debug_vec(x) if(FLAG){cout << #x << " = {"; for(auto a : x) cout << a << ","; cout << "}" << endl; }
#define debug_pair(x) ...
int n, cnt[4];
double p[301][301][301], ev[301][301][301];
int main(){
    cin >> n;
    for(int i = 1; i <= n; i++){
        int a;
        cin >> a;
        cnt[a]++;
    }
    p[cnt[3]][cnt[2]][cnt[1]] = 1;
    for(int i = cnt[3]; i >= 0; i--){
        for(int j = cnt[2] + (cnt[3] - i); j >= 0; j--){
            for(int t = cnt[1] + (cnt[2] + (cnt[3] - i) - j); t >= 0; t--){
                if(i == 0 && j == 0 && t == 0){
                    continue;
                }
                double p_w = (double)(n - i - j - t) / n;
                double ev_w = p_w / (1 - p_w) + 1;
                ev[i][j][t] += (p[i][j][t] * ev_w);
                if(t - 1 >= 0){
                    double p_go = (double) t / (i + j + t);
                    p[i][j][t - 1] += p[i][j][t] * p_go;
                    ev[i][j][t - 1] += ev[i][j][t] * p_go;
                }
                if(j - 1 >= 0){
                    double p_go = (double) j / (i + j + t);
                    p[i][j - 1][t + 1] += p[i][j][t] * p_go;
                    ev[i][j - 1][t + 1] += ev[i][j][t] * p_go;
                }
                if(i - 1 >= 0){
                    double p_go = (double)i / (i + j + t);
                    p[i - 1][j + 1][t] += p[i][j][t] * p_go;
                    ev[i - 1][j + 1][t] += ev[i][j][t] * p_go;
                }
            }
        }
    }
    cout << fixed << setprecision(9) << ev[0][0][0];
}


Measured memory_bytes: 426240
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1 << 30;
const double EPS = 1e-10;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

int a, b, c;

int main()
{
	cin >> a >> b >> c;
	cout << min(a + b, min(a + c, b + c));
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include <iomanip> 
#include<vector>
#define fo(i,n) for(int i=0;i<n;i++)
#define f(i,n) for(int i=2;i<=n;i++)
#define ll long long
/*Elegizip, elegizip otken sol bir shaktar-ai
 Elendeter zamanymnyn otip bara zhatkanny-ai
Umytylmas-Umytylmas Kairan esil shaktar-ai
Zamanymnyn kolyn bulgap otip bara jatkany-ai
 kairan esil , kairan esil shaktar-ai
kolyn bulgap zamanymnyn otip bara jatkany-ai;*/
using namespace std;

int main()
{ios::sync_with_stdio(0);
ll n,k, r=0;
cin>>n>>k;
cout<<min(n%k,k-(n%k));

}





Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::ops::Bound::*;
use itertools::Itertools;
use num_traits::clamp;
use ordered_float::OrderedFloat;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout]
fn main() {
    input! {
        n: usize, t: usize,
        ab: [(usize, i64); n],
    }

    let mut dp1 = vec![vec![0; t+1]; n+1];
    for i in 0..n {
        for j in 0..=t {
            dp1[i+1][j] = dp1[i][j];
            if j >= ab[i].0 {
                dp1[i+1][j] = max(dp1[i+1][j], dp1[i][j-ab[i].0] + ab[i].1);
            }
        }
    }

    let mut dp2 = vec![vec![0; t+1]; n+2];
    for i in (0..n).rev() {
        for j in 0..=t {
            dp2[i+1][j] = dp2[i+2][j];
            if j >= ab[i].0 {
                dp2[i+1][j] = max(dp2[i+1][j], dp2[i+2][j-ab[i].0] + ab[i].1);
            }
        }
    }

    let mut ans = 0;
    for i in 0..n {
        for j in 0..t {
            ans = max(ans, dp1[i][j] + dp2[i+2][t-1-j] + ab[i].1);
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 142968
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int INF = 0x3f3f3f3f;
const double pi = acos(-1);
namespace {
  template <typename T> inline void read(T &x) {
    x = 0; T f = 1;char s = getchar();
    for(; !isdigit(s); s = getchar()) if(s == '-') f = -1;
    for(;  isdigit(s); s = getchar()) x = (x << 3) + (x << 1) + (s ^ 48);
    x *= f;
  }
}
#define fio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define _for(n,m,i) for (register int i = (n); i < (m); ++i)
#define _rep(n,m,i) for (register int i = (n); i <= (m); ++i)
#define lson rt << 1, l, mid
#define rson rt << 1 | 1, mid + 1, r
#define lowbit(x) x & (-x)
#define pii pair<int,int>
#define fi first
#define se second
const int N = 1e5+5;
int sum[N], prime[N];
bool vis[N];
void init() {
  for(int i = 2; i < N; i++) {
    if(!vis[i]) prime[++prime[0]] = i;
    for(int j = 1; j <= prime[0] && prime[j]*i < N; j++) {
      vis[i*prime[j]] = 1;
      if(i % prime[j]==0) break;
    }
  }
  for(int i = 3;i < N; i++) if(!vis[i] && !vis[i+1>>1]) sum[i] = 1;
  for(int i = 3;i < N; i++) sum[i] += sum[i-1]; 
}
int main() {
  init();
  int q; read(q);
  for(int i = 0, l, r; i < q; i++) {
    read(l); read(r);
    printf("%d\n", sum[r]-sum[l-1]);
  }
}

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

int main() {
  int n;
  cin >> n;
  bool judge = false;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    if (s == "Y") {
      judge = true;
    }
  }
  if (judge) {
    cout << "Four" << endl;
  }else {
    cout << "Three" << endl;
  }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define arep(a,i,n) for(int i=(a);i<(n);i++)
#define rep(i,n) for(int i=0;i<(n);i++)
#define cinf(x,n) for(int i=0;i<(n);i++)cin>>x[i];
#define coutf(x,n) for(int i=0;i<(n);i++)cout<<x[i]<<endl;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using namespace std;

int main(){
	ull n,a,b;
	cin >> n >> a >> b;
	if((b-a)%2==0)
		cout << (b-a)/2 << endl;
	else
		cout << min((a+b-1)/2,n-(a+b-1)/2) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define all(x) x.begin(),x.end()
#define br cout << "\n";
using namespace std;
const long long INF = 1e10;
const long long MOD = 1e9+7;
using Graph = vector<vector<ll>>;
using pll = pair<ll, ll>;
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;}

// 0 false, 1 true 
// string to int : -48
// a to A : -32
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp

ll tmp = 1000000000000001;

vector<ll> vec;
vector<ll> vec2;

int main() {
    std::cout << std::fixed << std::setprecision(15);
    ll n; cin >> n;

    vector<char> res;
    while(n != 0){
        n--;
        res.push_back((char)('a' + (n % 26)));
        n /= 26;
    }

    rep(i, res.size()){
        cout << res[res.size() - 1 - i];
    }
    br;




}

Measured memory_bytes: 3632
MOD=10**9+7
cnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def desc(ar) ar.sort!{|x,y|y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+) end

def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2<b;(a-b+1..a).inject(:*)/(1..b).inject(:*)) end

def puts_yesno(can) puts(can ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def debug(k,v) puts "#{k}:#{v}" end
########### ( ˘ω˘ )ｽﾔｧ… ###########
s,t=gets.chomp.split
puts t+s

Measured memory_bytes: 1788
x,y,z,k = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
num = []
for a in A:
    for b in B:
        num.append(a+b)
num.sort(reverse = True)
num2 = []
for i in range(min(len(num),k)):
    for j in C:
        num2.append(num[i]+j)
num2.sort(reverse = True)
for i in range(k):
    print(num2[i])


Measured memory_bytes: 148144
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}

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

    string inp;
    cin >> inp;

    ll ans = 0;
    rep(i, inp.size()){
      if(inp[i] == '-') ans --;
      else ans ++;
    }

    cout<< ans << endl;
    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}






Measured memory_bytes: 256
N = int(input())
import itertools

def divisor_pl(num):
    l = []
    i = 2
    while num > 1:
        if num%i == 0:
            l.append(i)
            num = int(num/i)
            i = 2
        else:
            i += 1
    if num != 1:
        l.append(num)
    return l

l = []
for i in range(2,N+1):
    l.append(divisor_pl(i))
l = sum(l,[])
l.sort()

fac_dict = {}
fac_list = []
for key, value in itertools.groupby(l):
    fac_dict[str(key)] = len(list(value))
    fac_list.append(key)

count = 0
#(4,4,2)型のカウント
for l in itertools.combinations(fac_list,3):
    for i in range(3):
        if fac_dict[str(l[i%3])] >= 4 and fac_dict[str(l[(i+1)%3])] >= 4 and fac_dict[str(l[(i+2)%3])] >= 2:
            count+=1

#(14,4)型のカウント
for l in itertools.combinations(fac_list,2):
    for i in range(2):
        if fac_dict[str(l[i%2])] >= 14 and fac_dict[str(l[(i+1)%2])] >= 4:
            count+=1

#(24,2)型のカウント
for l in itertools.combinations(fac_list,2):
    for i in range(2):
        if fac_dict[str(l[i%2])] >= 24 and fac_dict[str(l[(i+1)%2])] >= 2:
            count+=1

#(74)型のカウント
for l in fac_list:
    if fac_dict[str(l)] >= 74:
        count += 1

print(count)

Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <vector>
#include <tuple>
using namespace std;
using P=pair<int64_t,int64_t>;

int main(){
    int N,M;
    cin>>N>>M;
    vector<P> V;
    for(int i=0;i<N;i++){
        int64_t A,B;
        cin>>A>>B;
        V.emplace_back(A,B);
    }
    sort(V.begin(), V.end());
    int64_t ans=0;
    for(auto v:V){
        int64_t A,B;
        tie(A,B)=v;
        if(B<=M){
            M-=B;
            ans+=A*B;
        }else{
            ans+=A*M;
            M=0;
        }
        if(!M){
            cout<<ans<<endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 3444
/*
我的心脏怦怦跳，监管者就在附近
name:
Algorithm:
writer:Lxs(cdx)
place:
nothing is impossible
*/
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
#include<string>
#include<iostream>
#include<cmath>
#include<set>
#include<stack>
#include<queue>
#include<unistd.h>
#include<stdio.h>
#include<cstring>
#define random(a,b) (rand()%(b-a+1)+a)
using namespace std;
bool prime(int x){
	 int i;
	 if(x<2) return 0;
	 for(i=2;i*i<=x;i++){
		if(x%i==0){return 0;}
	 }
	 return 1;
}
map<long long,bool> c;
int main()
{
	long long a,b,minn=12121200001;
	cin>>a>>b;
	a%=b;
	c[a]=1;
	minn=a;
	while(1){
		if(abs(a-b)<=minn){
			minn=abs(a-b);
		}
		a-=b;
		a=abs(a);
		//cout<<minn<<endl;
		if(c[a]==1){
			cout<<minn<<endl;
			break;
		}
		else{
			c[a]=1;
		}
	}
	return 0;
}


Measured memory_bytes: 256
<?php
list($R, $C, $K) = ints();
for ($i = 0; $i < $K; ++$i) {
    list($r, $c, $v) = ints();
    $val[$r][$c] = $v;
}
// dp[i][j][k] := (i, j)までで、i行上でk個以下のアイテムを選んだ時の価値の合計の最大値
$dp = array_fill(0, $C + 1, array_fill(0, 4, 0));
for ($i = 1; $i <= $R; ++$i) {
    for ($j = 1; $j <= $C; ++$j) {
        for ($k = 0; $k < 4; ++$k) {
            if ($dp[$j - 1][$k] > $dp[$j][3]) {
                $dp[$j][$k] = $dp[$j - 1][$k];
            } else {
                $dp[$j][$k] = $dp[$j][3];
            }
        }
        if (!isset($val[$i][$j])) continue;
        for ($k = 3; $k >= 1; --$k) {
            if ($dp[$j][$k - 1] + $val[$i][$j] > $dp[$j][$k]) {
                $dp[$j][$k] = $dp[$j][$k - 1] + $val[$i][$j];
            }
        }
    }
}
echo $dp[$C][3], PHP_EOL;
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


Measured memory_bytes: 36696
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define f first
#define s second
using namespace std;
	
int main(){
	string s;
	cin >> s;
	if(s[0] == 'R' && s[1] == 'R' && s[2] == 'R')cout << 3 << endl;
	else if(s[0] == 'R' && s[1] == 'R')cout << 2 << endl;
	else if(s[1] == 'R' && s[2] == 'R')cout << 2 << endl;
	else if(s[0] == 'R')cout << 1 << endl;
	else if(s[1] == 'R')cout << 1 << endl;
	else if(s[2] == 'R')cout << 1 << endl;
	else cout << 0 << endl;
	return 0;
}
















Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll N=3e5+10;
int n,m,k,ans;
int num[N],temp[N];
map<int,int>mp;
ll read() {
    ll y=0,flag=1;
    char ch=getchar();
    while( (ch>'9' || ch<'0') && ch!='-' ) ch=getchar();
    if(ch=='-') flag=-1,ch=getchar();
    while(ch>='0' && ch<='9') y=y*10+ch-'0',ch=getchar();
    return y*flag;
}
int main(){
    n=read();
    for(int i=1;i<=9;i++){
        for(int j=1;j<=9;j++){
            mp[i*j]=1;
        }
    }
    if(mp.count(n)!=1)cout<<"No";
    else cout<<"Yes";
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<cstdio>
#include<cstdlib>
#include<queue>
#include<list>
#include<deque>
#include<cmath>
#include<unordered_map>
#include<unordered_set>
#include<numeric>

using namespace std;

using ll = int64_t;

/// <summary>
/// 単純なcoutの時に使う
/// </summary>
#define co(a) cout<<a<<"\n"


/// <summary>
/// [beg, end)の範囲を，添え字indexでループするfor文に置換します
/// </summary>
#define rep(i,a) for(ll i=0; i<a; ++i)
#define reps(i, a, b) for(ll i = a; i < b; ++i)

/// <summary>
/// 迷路等で使う方向のベクトル
/// </summary>
const vector<ll> dx = { 0, 1, 0, -1 }, dy = { 1, 0, -1, 0 };

/// <summary>
/// デバッグ時に使う
/// </summary>
#define DEBUG(x)     std::cout << #x << " : " << x << "\n"

///////////////////////////////////////////////////////////////////////////

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

    cout << N * N * N << endl;
}



Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
typedef pair<int,int> PI;
typedef vector<int> vi;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#define pb push_back
#define F first
#define S second


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

int ans,w,h,sx,sy;
int ling[20][20];

void dfs(int x,int y,int te){
  if(te>9)return;
  te++;
  rep(i,4){
    int nx=x+dx[i],ny=y+dy[i];
    if(nx<0 || nx>=w || ny<0 || ny>=h || ling[nx][ny]==1)continue;
    while(nx>=0 && nx<w && ny>=0 && ny<h && ling[nx][ny]==0)nx+=dx[i],ny+=dy[i];
    if(nx<0 || nx>=w || ny<0 || ny>=h)continue;
    if(ling[nx][ny]==3){
      if(ans==-1)ans=te;
      else ans=min(te,ans);
    }else{
      ling[nx][ny]=0;
      dfs(nx-dx[i],ny-dy[i],te);
      ling[nx][ny]=1;
    }
  }
}

main(){
  while(cin>>w>>h,w|h){
    ans=-1;
    rep(i,h)rep(j,w){
      cin>>ling[j][i];
      if(ling[j][i]==2)sx=j,sy=i;
    }
    ling[sx][sy]=0;
    dfs(sx,sy,0);
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 864
import java.util.Scanner;

public class Main {

	/** 入力数字桁数 */
	private static final int N = 3;

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			char[] n = scanner.next().toCharArray();
			System.out.println((n[0] == n[N - 1]) ? "Yes" : "No");
		}
	}
}


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

int main() {
    int a, b;
    cin >> a >> b;
    double mean = (a+b) * 0.5;
    if(mean != int(mean)) {
        mean += 1.0;
    }
    int res = int(mean);
    cout << res << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
using namespace std;
 
#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592
 
const double EPS = 1e-10;
 
using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

int main(){
    int n; cin >> n;
    vector<int> P(n),Q(n);
    rep(i,n) cin >> P[i];
    rep(i,n) cin >> Q[i];
    vector<int> a(n);
    rep(i,n){
        a[i] = i+1;
    }
    int now = 1;
    int ans1 = 0;
    int ans2 = 0;
    do{
        if(a == P) ans1 = now;
        if(a == Q) ans2 = now;
        now++;
    }while(next_permutation(a.begin(),a.end()));

    cout << abs(ans1-ans2) << endl;
}


Measured memory_bytes: 256
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.Scanner;

public class Main {
	static Scanner sc;

	public static void main(String[] args) throws Exception {
		InputStream in = System.in;
		//PrintStream out = new PrintStream("src/output.txt");

		//System.setOut(out);

		sc = new Scanner(in);

		String S = sc.next();
		int answer = 700;

		for(int i = 0; i < 3; i++){
			if(S.charAt(i) == 'o'){
				answer += 100;
			}
		}
		System.out.println(answer);

		//out.close();
	}
}

Measured memory_bytes: 20552
#include<iostream>
#include<cstdio>
#include<limits.h>
#include<algorithm>
using namespace std;

int main(){
  double xmax=0,xmin=INT_MAX,ans,n[100000];

  int i=0;
  while(cin >> n[i]){
    xmax=max(xmax,n[i]);
    xmin=min(xmin,n[i]);
    i++;
}

  cout << xmax-xmin << endl;





}

Measured memory_bytes: 0