akhauriyash/Code-Regression huggingface dataset:
/*
...........__________    							 |										    ___  __
.............|       |     						     |											 |   /
.............|       |     						     |									  		 |  /
.............|       |                               |                         __                | /      _______
.............|_______|  _______            _______   |______   ________   /|  /  |               |/       |      |
.............| \               | |      | |          |      |          | / | /   |               |\       |
.............|  \       _______| |      | |_______   |      |   _______|   |/    |               | \      |
.............|   \      |      | |      |         |  |      |  |       |   |     |               |  \     |
.........  __|    \__|  |______| |______| ________|  |      |_ |_______|   |     |__|           _|   \__ _|        .

*/
#include<bits/stdc++.h>
using namespace std ;
#define int 				long long
#define ull 				unsigned long long int
#define ld 					long double
#define vi 					vector<int>
#define vii 				vector<pair<int,int>>
#define vvi 				vector<vector<int>>
#define pf 					push_front
#define popb 				pop_back
#define pb 					push_back
#define eb 					emplace_back
#define pii 				pair<int,int>
#define prec(x) 			fixed<<setprecision(15)<<x
#define all(x) 				x.begin(),x.end()
#define rall(x) 			x.rbegin(),x.rend()
#define mset(a,b) 			memset(a,b,sizeof(a))
#define mcpy(a,b) 			memcpy(a,b,sizeof(a))
#define fo0(i,n) 			for(int i=0,i##end=n;i<i##end;i++)
#define fo1(i,n) 			for(int i=1,i##end=n;i<=i##end;i++)
#define fo(i,a,b) 			for(int i=a,i##end=b;i<=i##end;i++)
#define foe(i,x)			for(__typeof((x).end())i=(x).begin();i!=(x).end();++i)
#define fre(i,x)			for(__typeof((x).rend())i=(x).rbegin();i!=(x).rend();++i)
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0)
#define inf 1e18
const int mod=1e9+7;
const int N=4e5+10;

vi printDivisors(int n) 
{ 
	vector<int> v; 
	for (int i=1; i<=sqrt(n); i++) 
	{ 
		if (n%i==0) 
		{ 
			if (n/i == i) 
				v.push_back(i); 
			else
			{ 
				v.push_back(i);
				v.push_back(n/i); 
			} 
		} 
	} 
	sort(all(v));
	return v;
}

bool prime(int n){
	if(n==1)
		return false;
	if(n==2)
		return true;
	for(int i=2;i*i<=n;i++){
		if(n%i==0)
			return false;
	}
	return true;
}

void raushan_kumar(){
	int a,b;cin>>a>>b;
	vi A,B;
	A=printDivisors(a);
	B=printDivisors(b);
	set<int> s1,s2;
	for(auto i: A)
		s1.insert(i);
	for(auto i: B)
		s2.insert(i);
	vi v;
	for(auto i: s1){
		if(s2.find(i)!=s2.end()){
			v.push_back(i);
		}
	}
	if(v.size()==1){
		cout<<1;
		return;
	}
	int cnt=0;
	for(int i=0;i<v.size();i++){
		if(prime(v[i]))
			cnt++;
	}
	cnt++;
	cout<<cnt;
}

int32_t main()
{
	fast;int t=1;
	//cin>>t;
	while(t--){
		raushan_kumar();
	}

}

Measured memory_bytes: 1152
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
using namespace std;

#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (int i=0; i < (int)(n); i++)  // 0 ~ n-1
#define REPN(i, n) for (int i=1; i <= (int)(n); i++)  // 1 ~ n
#define MIN(vec) min_element(ALL((vec)))  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
typedef long long ll;

const int MOD = 1000000007;  // 1 000 000 007


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

    // input
    int A;
    cin >> A;
    
    // calculation
    
    if (A >= 1200) {
        cout << "ARC" << "\n";
    } else {
        cout << "ABC" << "\n";
    }
    
    return 0;
}


Measured memory_bytes: 256
five = int(input())
one = int(input())
fifty = int(input())
x = int(input())
count = 0

for FIVE in range(five+1):
    for ONE in range(one+1):
        for FIFTY in range(fifty+1):
            if FIVE*500 + ONE*100 + FIFTY*50 == x:
                count += 1
print(count)


Measured memory_bytes: 3060
using System;
using System.IO;
using System.Linq;
using System.Runtime;
using System.Reflection;
using System.Diagnostics;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Text;
using System.Text.RegularExpressions;
using static System.Math;

class P
{
    static void Main()
    {
        var n = long.Parse(Console.ReadLine());
        for (int i = (int)Ceiling(Sqrt(n)); i >= 0; i--)
        {
            if(n % i == 0)
            {
                Console.WriteLine(Max((n / i).ToString().Length, (i).ToString().Length));
                return;
            }
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

vector<pair<int64_t, int64_t>> prime_factorize(int64_t n) {
    vector<pair<int64_t, int64_t>> ret;
    for (int64_t i = 2; i*i <= n; i++) {
        if (n % i != 0) continue;
        int64_t ex = 0;
        while (n % i == 0) {
            ex++;
            n /= i;
        }
        ret.push_back({i, ex});
    }
    if (n != 1) ret.push_back({n, 1});
    return ret;
}

int main() {
    Int n, p;
    cin >> n >> p;
    const auto &pf = prime_factorize(p);
    Int ans = 1;
    for (auto i : pf) {
        if (i.second >= n) ans *= pow(i.first, (i.second / n));
    }
    cout << ans << endl;
}

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



int N,M,P;
int X[110];
int g;

int main(){


  while(1){
    cin >> N >> M >> P;
    if(N == 0 && M == 0 && P == 0) break;

    g = 0;

    for(int i = 0 ; i < N ; i ++){
      cin >> X[i] ;
      g += X[i] * 100 - P*X[i];
    }
    if(X[M-1] == 0) cout << "0" << endl;
    else    cout << g/X[M-1] << endl;

  }


  return 0;

}

Measured memory_bytes: 1160
#include "bits/stdc++.h"
// #include "ext/pb_ds/assoc_container.hpp"
// #include "ext/pb_ds/tree_policy.hpp"
// #define ordered_set tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
//using namespace __gnu_pbds;
#define int long long int
#define pb push_back
#define vec vector<int>
#define fo(i, n) for (int i = 0; i < n; i++)
#define foo(i, a, b) for (int i = a; i < b; i++)
#define mp make_pair
#define deb(x) cout << #x << " --> " << x << endl;
#define deb1a(v) cout << #v << "--->" << endl; for (auto it : v)  cout << it << " "; cout << endl;
#define deb2a(v) cout << #v << "--->" << endl;for (auto it:v){for(auto it1 : it){cout << it1 << " ";}cout<< endl;}
#define deb3a(v) cout << #v << "-->" << endl; for(auto it:v){cout << it.fi << " " << it.se << endl;}
#define mod 29996224275833
#define so(v) sort(v.begin(),v.end())
#define fi first
#define se second
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
int power(int x, unsigned int y, int p){ int res = 1;x = x % p;while (y > 0)  { if (y & 1)res = (res*x) % p;y = y>>1;  x = (x*x)% p;} return res;}
int mI(int a, int m)  {return power(a, m - 2, m);}

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    vec v(n);
    fo(i,n)
    cin >> v[i];
    vec v1(n), v2(n);
    fo(i, n)
        v1[i] = i + v[i],v2[i]=i-v[i];
    int ans = 0;
    map<int, int> m;
    for(int i=n-1;i>=0;i--){
        ans += m[v1[i]];
        m[v2[i]]++;
    }
    cout<< ans;
}
    


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

    def f(x):
        return (A*x)//B - A*(x//B)
    if(x<0):
        print(f(N))
    else:
        print(f(x))
    # print(max(f(x),f(N),f(N-1)))
if __name__ == '__main__':
    main()

Measured memory_bytes: 78044
N = int(input())
S = input()

p = 0
c = 0
for i in range(N):
    if S[i] == 'A':
        p = 1
    elif p == 1 and S[i] == 'B':
        p = 2
    elif p == 2 and S[i] == 'C':
        c += 1
        p = 0
    else:
        p = 0

print(c)

Measured memory_bytes: 2940
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <queue>
#include <algorithm>
#define ULL unsigned long long
#define INF 0x3f3f3f3f
using namespace std;
int main() {
    int n;
    cin>>n;
    int res=1,flag=1,tmp;
    for(int i=1;i<=n;i++){
        scanf("%d",&tmp);
        if(res-tmp>1){
            printf("No");
            return 0;
        }
        if(res<tmp){
            res=tmp;
        }
    }
    printf("Yes");
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#define loop(i, N) for(int i = 0; i < N; i++)

using namespace std;

int main() {
	int n;
	cin >> n;

	vector<int> t1, t2;
	vector<double> v;
	t1.push_back(0); t2.push_back(0);
	v.push_back(0);
	int tmp, last_t = 0;
	loop(i, n) { cin >> tmp; t1.push_back(last_t); last_t += tmp; t2.push_back(last_t); }
	loop(i, n) { cin >> tmp; v.push_back(tmp); }
	t1.push_back(last_t);
	t2.push_back(last_t);
	v.push_back(0);

	double prev_v = 0.0;
	double dist = 0.0;
	loop(t, last_t * 2) {
		double min_v = 100000.0;
		double _t = t / 2.0 + 0.5;
		loop(i, n + 2) {
			//printf(" v: %f, lim_v: %f\n", prev_v, v[i]);
			if (_t < t1[i]) {
				min_v = min(min_v, v[i] + t1[i] - _t);
			}
			else if (t2[i] < _t) {
				min_v = min(min_v, v[i] + _t - t2[i]);
			}
			else {
				min_v = min(min_v, v[i]);
			}
		}
		//printf("t: %f, v: %f\n", _t, min_v);
		dist += (prev_v + min_v) / 2 * 0.5;
		prev_v = min_v;
	}
	printf("%.10lf\n", dist);

	return 0;
}

Measured memory_bytes: 256
n = int(input())
lst1 = list(map(int,input().split()))
mod = 10**9+7
def pow(n, p):
    res = 1
    while p > 0:
        if p % 2 == 0:
            n = n ** 2 % mod
            p //= 2
        else:
            res = res * n % mod
            p -= 1
    return res % mod
fac = [1]

for i in range(n-1):
    fac.append(fac[-1]*(i+1)%mod)

f = 1
ans = 0
for i in range(n-1):
    ans += ((lst1[-1]-lst1[i])*fac[-1]*pow(i+1,mod-2))%mod
print(ans%mod)

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

int main() {
        string S;
        cin >> S;

        rep(s, S.size()) {
                if (S[s] < 'D') {
                        S[s] += ('X' - 'A');
                } else {
                        S[s] -= 3;
                }
        }
        cout << S << endl;
        return 0;
}



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

int main(){

  char c[3];
  for(int i=0;i<3;i++){
    cin >> c[i];
  }

  if(c[0]!=c[1] &&c[1]!=c[2] &&c[0]!=c[2]){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

}



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

typedef long long ll;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define debug(x) cerr << #x << ": " << x << '\n'

int main()
{
    ll M, N;
    cin >> N >> M;
    ll sum = 0;
    vector<ll> A;
    ll i = 0;
    for (i = 0; i < N; ++i)
    {
        ll temp;
        cin >> temp;
        sum += temp;
        A.push_back(temp);
    }
    sort(A.begin(), A.end());
    reverse(A.begin(), A.end());
    i = 0;
    double thr = ((double)sum / (4.0 * (double)M));

    while (A[i] >= thr)
    {
        ++i;

        bool B = (i >= M);

        if (B)
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}


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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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


map< ll, int > prime_factor(ll n) {
  map< ll, int > ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

void solve() {
    ll N; cin >> N;
    vec v(1000, 1);
    per1(i, N){
        map<ll, int> tmp = prime_factor(i);
        for(auto a : tmp){
            v[a.first] += a.second;
        }
    }

    modint ans = {1};
    Rep(i, 2, v.size()){
        if(v[i] != 1) ans.n = modint(ans.n * v[i]);
    }

    cout << ans.n << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


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

int main(){
  string s;
  cin>>s;
  int count=0;
  for(int i=0;i<4;i++){
    for(int a=i+1;a<4;a++){
      if(s[i]==s[a]){
        count++;
      }
    }
  }
  if(count==2){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	string U,N;
	int A,B;
	string S;
	cin >> U >> N >> A >> B >> S;
	if(U==S){
		cout << A-1 << " " << B << endl;
	}
	else{
		cout << A << " " << B-1 << endl;
	}


}

Measured memory_bytes: 256
import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
 
   int N = sc.nextInt();
   int K = sc.nextInt();
   
   int sum = 0 ;
   int tmp = 0 ;
   for(int i=0;i<N;i++)
   {
     tmp = sc.nextInt();
     if(K-tmp<tmp) sum+=K-tmp;
     else sum+=tmp;
   }
   System.out.println(2*sum);
 }
}

Measured memory_bytes: 21844
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,j,n) for(int i=(j);i<=((int)n);++i)
#define rev(i,n,j) for(int i=(n);i>=((int)j);--i)
typedef long long int ll;
#define int long long int
const ll INFL=0x3f3f3f3f3f3f3f3fLL;
const int INF=0x3f3f3f3f;
const int mod=998244353;
#define endl "\n"
#define mem(a,val) memset(a,val,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define present(container, element) (container.find(element) != container.end())
#define pb push_back
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define readmat(a, n, m) int a[n + 5][m + 5] = {}; rep(i, 1, n) {rep(j, 1, m) cin >> a[i][j];}
#define printmat(a, n, m) rep (i, 1, n) {rep (j, 1, m) cout << a[i][j] << " "; cout << endl;} cout << endl;
#define printarr(a, n) rep(i, 1, n) cout << a[i] << " "; cout << endl;
typedef std::map< int,int> mii;
typedef std::vector< int > vi;
typedef std::vector< vi > vvi;
typedef std::pair< int,int > ii;
using namespace std;
#define cerr cout
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);}
const int N = 1e6+5, M = N;
vector <int>g[N];

ll power(ll a, ll b)	//a is base, b is exponent
{
	if(b==0)
		return 1;
	if(b==1)
		return a;
	if(b%2 == 1)
		return (power(a,b-1)*a)%mod;
	ll q = power(a,b/2);
	return (q*q)%mod;
}

void solve()
{
	int n,s;
	cin>>n>>s;
	int a[n+5];
	for(int i = 1; i <=n; ++i) 
	{
		cin>>a[i];
	}

	int dp[n+5][s+5];
	mem(dp,0);
	dp[0][0]=power(2,n);

	int inv=power(2,mod-2);

	for(int i = 1; i <=n; ++i) 
	{
		for(int j =0; j <=s; ++j) 
		{
			if (j<a[i])
			{
				dp[i][j]=dp[i-1][j];
				continue;
			}
			dp[i][j]=(dp[i][j]+dp[i-1][j]+(dp[i-1][j-a[i]]*inv)%mod)%mod;
		}
	}


	cout<<dp[n][s]<<endl;
  

}

signed main()
{
  FAST;
#ifdef LOCAL
    freopen("C:\\Users\\hp\\Documents\\input.txt", "r", stdin);
    freopen("C:\\Users\\hp\\Documents\\output.txt", "w", stdout);
    std::chrono::time_point<std::chrono::high_resolution_clock> start, end;
    start = std::chrono::high_resolution_clock::now();
#endif

solve();

#ifdef LOCAL
    end = std::chrono::high_resolution_clock::now();
    ll elapsed_time = std::chrono::duration_cast<std::chrono::milliseconds>(end-start).count();
    cout<<endl;
    cout << "\nElapsed Time: " << elapsed_time << "ms\n";
#endif

return 0;

}

Measured memory_bytes: 97652
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Author: z0marlin
Title: B.cpp
Time: 24-08-2019T17:29:52+0530 
I suck at CP T_T
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
#include <bits/stdc++.h>
#if DEBUG
#define dprintf(...) printf(__VA_ARGS__)
#else
#define dprintf(...)
#endif
#define FOR(i, a, n) for(int i = a; i < n; ++i)
#define FORE(a, v) for(auto a:v)
#define MAX(a, b) ((a>b)?a:b)
#define MIN(a, b) ((a<b)?a:b)
#define mp(i, j) make_pair(i, j)
#define pb push_back
#define ppb pop_back
#define all(a) a.begin(), a.end()

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pii_t;
typedef pair<ll,ll> pll_t;
typedef vector<int> vi_t;
typedef vector<ll> vll_t;
typedef vector<ull> vull_t;

const int MAX_SZ=1e6+2;
const int MOD=1e9+7;
ll t = 1, n, m, q, ql,k, qr;
char ch;
vll_t inp, fq(2001);

ll numInv(){
    ll inv=0;
    FOR(i,0,n){
        FOR(j,i+1,n){
            if(inp[i]>inp[j]) inv++;
        }
    }
    return inv;
}

ll fillfq(){
    FOR(i,0,n){
        fq[inp[i]]++;
    }
    FORE(e,fq) dprintf("%lld ", e);
    dprintf("\n");
    ll sum=0;
    FOR(i,0,2001){
        swap(sum,fq[i]);
        sum+=fq[i];
    }
    sum=0;
    FOR(i,0,n){
        sum+=fq[inp[i]];
    }
    return sum;
}

int solve(){
    ll inv = numInv();
    ll s = fillfq();
    dprintf("{inv:%lld, s:%lld}\n",inv,s);
    ll ans = ((k*(k-1))/2)%MOD;
    ans = (ans*s)%MOD + (k*inv)%MOD;
    printf("%lld\n", ans%MOD);
}

int main(){
    // scanf("%d", &t);
    while(t--){
        scanf("%lld%lld",&n,&k);
        inp.reserve(n);
        FOR(i,0,n){
            scanf("%lld", &inp[i]);
        }
        solve();
    }
}

Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    n = I()
    s = int(math.sqrt(n))+1
    t = n
    for i in range(s,0,-1):
        if n % i == 0:
            t = max(n//i,i)
            break
    ti = 0
    while t > 0:
        ti += 1
        t //= 10
    return ti



print(main())


Measured memory_bytes: 7748
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int n;
  cin >> n;
  string s;
  cin >> s;
  int cnt[26] = {};
  for (char c : s) cnt[c - 'a']++;
  long long ans = 1;
  for (int i = 0; i < 26; i++) {
    ans *= 1LL * (cnt[i] + 1);
    ans %= 1000000007;
  }
  ans -= 1;
  if (ans < 0) ans += 1000000007; 
  cout << ans << endl;
  return 0;	
}

Measured memory_bytes: 512
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
class Simple {
    int N;
    int[] A;
    void Solve() {
        //input
        N = io.Int;
        A = new int[N];
        for (int i = 0; i < N; ++i)
            A[i] = io.Int;
        //cal
        var map = new Dictionary<int, int>();
        for(int i = 0; i < N; ++i) {
            if (!map.ContainsKey(A[i])) map[A[i]] = 0;
            map[A[i]]++;
        }
        var ans = map.Values.Count(value => value % 2 != 0);       
        //ret
        Console.WriteLine(ans);
    }

    SimpleIO io = new SimpleIO();
    public static void Main(string[] args) { new Simple().Stream(); }
    void Stream() {
        Solve();
        io.writeFlush();
    }
}
class SimpleIO {
    SimpleIO(bool isAutoFlush = false) { this.isAutoFlush = isAutoFlush; }
    string[] nextBuffer;
    int BufferCnt;
    char[] cs = new char[] { ' ' };
    public bool isAutoFlush;
    StreamWriter sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
    public SimpleIO() {
        nextBuffer = new string[0];
        BufferCnt = 0;
        if(!isAutoFlush)
            Console.SetOut(sw);
    }
    public string Next() {
        if (BufferCnt < nextBuffer.Length)
            return nextBuffer[BufferCnt++];

        string st = Console.ReadLine();
        while (st == "")
            st = Console.ReadLine();
        nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        BufferCnt = 0;
        return nextBuffer[BufferCnt++];
    }
    public string String => Next();
    public char Char => char.Parse(String);
    public int Int => int.Parse(String);
    public long Long => long.Parse(String);
    public double Double => double.Parse(String);
    public void writeFlush() { Console.Out.Flush(); }
}


Measured memory_bytes: 18644
#include <iostream>
#include <vector>
using namespace std;
const int di[8] = {-1, 0, 1, 0, -1, -1, 1, 1};
const int dj[8] = {0, 1, 0, -1, -1, 1, 1, -1};
bool ongrid(int h, int w, vector< vector<int> >& g)
{
    if (h >= 0 && h < g.size() && w >= 0 && w < g[0].size()) return true;
    return false;
}

bool dfs(int h, int w, vector< vector<int> >& g, vector< vector<bool> >& seen)
{
    seen[h][w] = true;
    if (g[h][w] == 0) return false;
    for (int i = 0; i < 8; i++)
    {
        if (ongrid(h+di[i], w+dj[i], g) && seen[h+di[i]][w+dj[i]] == false)
            dfs(h+di[i], w+dj[i], g, seen);
    }
    return true;
}

int main()
{
    while (true)
    {
        int w, h; cin >> w >> h;
        if (w == 0 && h == 0) break;
        vector< vector<int> > g(h, vector<int>(w));
        for (int i = 0; i < h; i++)
            for (int j = 0; j < w; j++)
                { int c; cin >> c; g[i][j] = c;}
        vector< vector<bool> > seen(h, vector<bool>(w, false));
        int cnt = 0;
        for (int i = 0; i < h; i++)
            for (int j = 0; j < w; j++)
                if (seen[i][j] == false)
                    if (dfs(i, j, g, seen) == true) cnt++;
        cout << cnt << endl;
    }
}


Measured memory_bytes: 3252
import java.util.ArrayList;
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		ArrayList<Integer> list = new ArrayList<Integer>();
		
		while(true){
			list.clear();
			int n = sc.nextInt();
			if(n == 0)break;
			for(int i = 0; i < n; i++)
				list.add(sc.nextInt());
			
			int sum = 0; 
			int max = -100000;
			for(int i = 0; i < n; i++){
				for(int j = i; j < n; j++){
					sum += list.get(j);
					max = Math.max(max, sum);
				}
				sum = 0;
			}
			System.out.println(max);
		}
		sc.close();
	}
}

Measured memory_bytes: 26604
#include<stdio.h>
#include<stdlib.h>
#define size 100000
main()
{
	long int n,i,flag=0;
	scanf("%ld",&n);
	long int a[size];
	for(i=0;i<n;++i)
	{
		scanf("%ld",&a[i]);
	}
a[0]=a[0]-1;
for(i=0;i<n-1;++i)
{
	if((a[i+1]-a[i])>0)
	{
		a[i+1]=a[i+1]-1;
	}
	else if((a[i+1]-a[i])<0)
	{
		printf("No");
		flag=1;
		break;
	}
}
if(flag==0)
printf("Yes");
}


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

int main() {

    int A, B, C;
    cin >> A >> B >> C;
    
    cout << max(0, B+C-A) << endl;

    return 0;
}

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

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

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

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

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

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

ll ngcd(vector<ll> a) {
  ll res = a[0];
  for(ll i=1; i<a.size() && res!=1; i++) res = gcd(a[i], res);
  return res;
}
ll nlcm(vector<ll> a){
  ll res = a[0];
  for(ll i=1; i<a.size(); i++) res = lcm(a[i], res);
  return res;
}
bool is_prime(ll n) {
  if(n < 2) return false;
  for (ll i = 2; i * i <= n; i++) if (n % i == 0) return false;
  return true;
}
ll digsum(ll n) {
  ll res=0;
  while(n) res += n%10, n /= 10;
  return res;
}
ll digcnt(ll n){
  ll res=0;
  while(n) res++, n /= 10;
  return res;
}
vector<ll> divisor(ll n) {
  vector<ll> res;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      res.push_back(i);
      if (i != n / i) res.push_back(n / i);
    }
  }
  sort(res.begin(), res.end());
  return res;
}
map<ll, ll> prime_factor(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) ++res[i], n /= i;
  }
  if (n != 1) res[n] = 1;
  return res;
}

ll f(ll a){
  ll res=0;
  while(a%2==0){
    res++;
    a/=2;
  }
  return res;
}

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n,m; cin>>n>>m;
  vll a(n);
  rep(i,n){
    cin>>a[i];
    a[i]/=2;
  }
  
  ll cnt=f(a[0]);
  rep(i,n){
    if(cnt!=f(a[i])){
      cout<<0<<endl;
      return 0;
    }
    a[i]>>=cnt;
  }
  m>>=cnt;
  
  ll l=1;
  rep(i,n){
    l=lcm(l,a[i]);
    if(l>m){
      cout<<0<<endl;
      return 0;
    }
  }
  
  ll ans=m/l;
  ans=(ans+1)/2;
  cout<<ans<<endl;
  
}

Measured memory_bytes: 1024
from collections import Counter
n,k,l=map(int,input().split())
#union-find
par1=[-1]*(n+1)
par2=[-1]*(n+1)

def find1(x):
    if par1[x]<0:
        return x
    else:
        par1[x]=find1(par1[x])
        return par1[x]
def find2(x):
    if par2[x]<0:
        return x
    else:
        par2[x]=find2(par2[x])
        return par2[x]
def size1(x):
    return -par1[find1(x)]
def size2(x):
    return -par2[find2(x)]
def unite1(x,y):
    if find1(x)==find1(y):
        return False
    else:
        if size1(x)<size1(y):
            x,y=y,x
        X=find1(x)
        Y=find1(y)
        par1[X]-=size1(Y)
        par1[Y]=X
        return True
def unite2(x,y):
    if find2(x)==find2(y):
        return False
    else:
        if size2(x)<size2(y):
            x,y=y,x
        X=find2(x)
        Y=find2(y)
        par2[X]-=size2(Y)
        par2[Y]=X
        return True
def is_same1(x,y):
    return find1(x)==find1(y)
def is_same2(x,y):
    return find2(x)==find2(y)

for _ in range(k):
    p,q=map(int,input().split())
    unite1(p,q)
for _ in range(l):
    r,s=map(int,input().split())
    unite2(r,s)
L=[]
for i in range(1,n+1):
    L.append((find1(i),find2(i)))
kazu=Counter(L)
ans=[0]*(n)
for i in range(n):
    ans[i]=kazu[L[i]]
print(*ans, sep=' ')

Measured memory_bytes: 44384
#include <bits/stdc++.h>
        #include<iostream>
        #include<cstdio>
        #include<vector>
        #include<queue>
        #include<map>
        #include<cstring>
        #include<string>
        #include <math.h>
        #include<algorithm>
    //    #include <boost/multiprecision/cpp_int.hpp>
        #include<functional>
      #define int long long
        #define inf  1000000007
        #define pa pair<int,int>
#define ll long long
        #define pal pair<ll,ll>
        #define ppa pair<int,pa>
        #define EPS (1e-10)
        #define equals(a,b) (fabs((a)-(b))<EPS)

        using namespace std;

        class Point{
        	public:
        	double x,y;
        	Point(double x=0,double y=0):x(x),y(y) {}
        	Point operator + (Point p) {return Point(x+p.x,y+p.y);}
        	Point operator - (Point p) {return Point(x-p.x,y-p.y);}
        	Point operator * (double a) {return Point(x*a,y*a);}
        	Point operator / (double a) {return Point(x/a,y/a);}
        	double absv() {return sqrt(norm());}
        	double norm() {return x*x+y*y;}
        	bool operator < (const Point &p) const{
        		return x != p.x ? x<p.x: y<p.y;
        	}
        	bool operator == (const Point &p) const{
        		return fabs(x-p.x)<EPS && fabs(y-p.y)<EPS;
        	}
        };
        typedef Point Vector;

        struct Segment{
        Point p1,p2;
        };

    double hen(Vector a){
    if(fabs(a.x)<EPS && a.y>0) return acos(0);
    else if(fabs(a.x)<EPS && a.y<0) return 3*acos(0);
    else if(fabs(a.y)<EPS && a.x<0) return 2*acos(0);
    else if(fabs(a.y)<EPS && a.x>0) return 0.0;
    else if(a.y>0) return acos(a.x/a.absv());
    else return 2*acos(0)+acos(-a.x/a.absv());

    }

        double dot(Vector a,Vector b){
        	return a.x*b.x+a.y*b.y;
        }
        double cross(Vector a,Vector b){
        	return a.x*b.y-a.y*b.x;
        }
        int dx[4] = {1, 0, -1, 0};
        int dy[4] = {0, 1, 0, -1};
        //----------------kokomade temple------------
int beki[20];



int ha(string s,int a,int b){
int y=0;
	for(int i=a;i<=b;i++){
		y *=10;
		y += (s[i]-'0');
	}
	return y;
}

signed main(){
beki[0]=1;
	for(int i=1;i<=12;i++) beki[i] = 2*beki[i-1];
	
	
	string s;
	cin>>s;
	int n=s.length();
	s="s"+s;
	int ans=0;
	for(int i=1;i<=n;i++){
		for(int j=i;j<=n;j++){
			int z=ha(s,i,j);
	//		cout<<i<<" "<<j<<" "<<z;
			int d=i-2;
			if(d<0) d=0;
			int dd=n-j-1;
			if(dd<0) dd=0;
			z *= beki[d];
			z *= beki[dd];
	//		cout<<" "<<z<<endl;
			ans +=z;
		}
	}
	cout<<ans<<endl;
	return 0;
        }
        
//printf("%.10f\n",ans);


Measured memory_bytes: 256
while True:
    n = int(input())
    if n == 0:
        break
    k = 1
    for i in range(1,n+1):
        k *= i

    c = 0
    for i in str(k)[::-1]:
        if i == "0":
            c += 1
        else:
            break
    print(c)



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

int n, m, a, b;

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main() {
  cin >> n >> m;
  UnionFind tree(n);
  rep (i, m) {
    cin >> a >> b;
    a--;b--;
    tree.unite(a, b);
  }
  vector<int> v(n, 0);
  rep (i, n) {
    v[tree.root(i)]++;
  }
  sort(v.rbegin(), v.rend());
  cout << v[0] << endl;
  return 0;
}


Measured memory_bytes: 10956
#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>
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
 
using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

ll dp[100010][110][2];
 
int main(){
	string K; cin >> K;
	int D; cin >> D;
	int N = K.size();
	dp[0][0][0] = 1;
	rep(i,N)rep(j,D)rep(k,2){
		int d = K[i]-'0';
		rep(l,10){
			if(l < d){
				dp[i+1][(j+l)%D][1] += dp[i][j][k];
				dp[i+1][(j+l)%D][1] %= MOD;
			}
			else if(l == d){
				dp[i+1][(j+l)%D][k] += dp[i][j][k];
				dp[i+1][(j+l)%D][k] %= MOD;
			}
			else{
				if(k == 1){
					dp[i+1][(j+l)%D][k] += dp[i][j][k];
					dp[i+1][(j+l)%D][k] %= MOD;
				}
			}
		}
	}
	ll ans = (dp[N][0][0] + dp[N][0][1]-1) % MOD;
	if(ans < 0) ans += MOD;
	cout << ans << endl;
}


Measured memory_bytes: 18688
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, vector<ll>> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int t;
    cin >> t;
    rep(ti,t){
        int n;
        cin >> n;
        vector<ll> a(n);
        rep(i,n) cin >> a[i];
        string s;
        cin >> s;
        if(s.back() == 1){
            cout << 1 << endl;
            continue;
        }
        vector<P> v;
        v.push_back(P(0, {}));
        for(int i = n-1; i >= 0; --i){
            if(v.back().first == (s[i] - '0')){
                v.back().second.push_back(a[i]);
            }
            else{
                int nex = 1 - v.back().first;
                v.push_back(P(nex, {a[i]}));
            }
        }
        for(auto &p : v){
            sort(p.second.begin(), p.second.end());
        }
        int sz = v.size();
        vector<ll> buf;
        bool f = true;
        rep(i,sz){
            if(v[i].first == 0){
                for(ll x : v[i].second) buf.push_back(x);
            }
            else{
                auto memo = buf;
                int sz2 = memo.size();
                int rank = 0;
                for(int j = 59; j >= 0; --j){
                    int pivot = -1;
                    for(int k = rank; k < sz2; ++k){
                        if(memo[k] >> j & 1){
                            pivot = k;
                            break;
                        }
                    }
                    if(pivot == -1) continue;
                    swap(memo[pivot], memo[rank]);
                    for(int k = 0; k < sz2; ++k){
                        if(k != rank && (memo[k] >> j & 1)) memo[k] ^= memo[rank];
                    }
                    for(ll &x : v[i].second){
                        if(x >> j & 1) x ^= memo[rank];
                    }
                    ++rank;
                }
                for(ll x : v[i].second){
                    if(x != 0){
                        f = false;
                        break;
                    }
                }
                if(!f) break;
            }
        }
        cout << !f << endl;
    }
    return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<strings.h>
using namespace std;
int main(){
	int a;
	cin>>a;
	int b[100];
	for(int i=0;i<a;i++){
		cin>>b[i];
	}
	sort(b,b+a);
	cout<<b[a-1]-b[0]<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)    for(long long i = 0; i < (n) ; ++i)
#define orep(i,n)   for(long long i = 1; i <= (n); ++i)   // one rep
#define drep(i,n)   for(long long i = (n)-1; i >= 0; --i) // down rep
#define srep(i,s,t) for(long long i = (s); i < (t); ++i)  // set rep
#define rng(x)  (x).begin(),(x).end()

  // range
#define rrng(a) (a).rbegin(),(a).rend() // reverse range
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define ru(x,y) (((x)+(y)-1)/(y)) // round up
#define fi first
#define se second
#define eb emplace_back
#define fcout cout << fixed << setprecision(15)


using namespace std;
using ll  = long long;
using P   = pair<int,int>;
using vi  = vector<int>;
using vvi = vector<vi>;
using vp  = vector<P>;
using vl  = vector<ll>;

template<typename T> void Yes(T flag) {
  cout << (flag ? "Yes" : "No") << endl;
}

template<typename T> void pv(vector<T> vec) {
  cout << "[";
  for(auto& v : vec) { cout << v << ","; }
  cout << "]" << endl;
}

template<>
void pv(vector<P> vec) {
  cout << "[";
  for(auto& v : vec) {
    cout << "<" << v.fi << ","<< v.se << ">" << ",";
  }
  cout << "]" << endl;
}

template<typename T> void pv2(vector<vector<T>> vec) {
  for(auto& v : vec) pv(v);
}

int main() {
  ll x,k,d;cin >> x >> k >> d;


  if(x == 0) {
    if(k % 2 == 0) cout << 0 << endl;
    else cout << d << endl;
    return 0;
  }
  x = abs(x);
  ll ido = x / d;
  ll two = k % 2;

  if(ido <= k + 1 and ido % 2== two) cout << x % d << endl;
  else if(ido <= k + 1 and ido %2 != two) cout << abs(x%d-d) << endl;
  else if (ido == k) cout << x % d << endl;
  else cout << x - k * d << endl;


  return 0;
}


Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s = scan.next();
		if(s.length() != 6) {
			System.out.println("No");
			return;
		}
		if(s.charAt(2) != s.charAt(3)) {
			System.out.println("No");
			return; 
		}
		if(s.charAt(4) != s.charAt(5)) {
			System.out.println("No");
			return;
		}
		
		System.out.println("Yes");
	}

}

Measured memory_bytes: 23892
import java.util.Scanner;

/**
 * Created by kazuki on 2014/07/05.
 */
public class Main {
    static Scanner s = new Scanner(System.in);

    static class Team {
        public int solveNum;
        public int time;
        public int teamNum;
        public int[] penalty = new int[11];

        Team(int num) {
            solveNum = 0;
            time = 0;
            teamNum = num;
        }

        void addPenalty(int num) {
            penalty[num]++;
        }

    }

    static void sort(Team[] team, int T) {
        Team tmp;

        for(int j=T;j>1;j--){
            for(int i=1;i<j;i++){
                if (team[i].solveNum < team[i+1].solveNum) {
                    tmp = team[i];
                    team[i] = team[i+1];
                    team[i+1] = tmp;
                } else if (team[i].solveNum == team[i+1].solveNum) {

                    if (team[i].time > team[i+1].time) {
                        tmp = team[i];
                        team[i] = team[i+1];
                        team[i+1] = tmp;
                    } else if (team[i].time == team[i+1].time && team[i].teamNum > team[i+1].teamNum) {
                        tmp = team[i];
                        team[i] = team[i+1]                        ;
                        team[i+1] = tmp;
                    }
                }
            }
        }



    }

    public static void main(String[] args) {
        int T, P, R;
        int tID, pID, time;
        String message;
        Team[] team;

        while (true) {
            T = s.nextInt();
            P = s.nextInt();
            R = s.nextInt();

            if(T==0 && P==0 && R==0) break;

            team = new Team[T + 1];
            for (int i = 1; i < T + 1; i++)
                team[i] = new Team(i);

            for (int i = 0; i < R; i++) {
                tID = s.nextInt();
                pID = s.nextInt();
                time = s.nextInt();
                message = s.next();

                if (message.equals("WRONG")) {
                    team[tID].addPenalty(pID);
                } else if (message.equals("CORRECT")) {
                    team[tID].solveNum += 1;
                    team[tID].time += time + team[tID].penalty[pID] * 1200;
                }
            }

            sort(team, T);

            for (int i = 1; i < T + 1; i++)
                System.out.println(team[i].teamNum + " " + team[i].solveNum + " " + team[i].time);
        }
    }
}

Measured memory_bytes: 64088
#C

n,m = (int(x) for x in input().split())
a = []
for i in range(m):
    x = int(input())
    a.append(x)

p = 0
num = [1]
if p>=m:
    num.append(1)
elif a[p] == 1:
    num.append(0)
    p += 1
else:
    num.append(1)

for i in range(2,n+1):
    if p>=m:
        temp = num[-2]+num[-1]
        num.append(temp)
    elif a[p] == i:
        num.append(0)
        p += 1
    else:
        temp = num[-2]+num[-1]
        num.append(temp)

print(num[-1]%1000000007)
    
    
    

Measured memory_bytes: 460020
#include"stdio.h"
#include"stdlib.h"
#include"string.h"
#include"ctype.h"
#include"math.h"
//??????a????????????????????????
void listSort(int length,int* a){
	int* temp=(int*)malloc(sizeof(int)*length);//???????????\????????´???
	int big=9;     //?????¨?????????????????°???
	int i;         //???????????¨?????°
	int index=0;   //temp????????§????¬??????\????????´???
	while(big>=0){
		for(i=0;i<length;i++){
			if(a[i]==big)temp[index++]=big;
		}
		big--;
	}
	for(i=0;i<length;i++){
		a[i]=temp[i];
	}
	free(temp);
}
//????????????list[0]????????????????????¨????????°??????????????????
int makeValue(int length,int* a){
	int i,j;
	int ans=0;
	j=1;
	for(i=length-1;i>-1;i--){
		ans+=a[i]*j;
		j*=10;
	}
	return ans;
}
//??°???????°??????????????????????????????????????????????
void makeList(int length,int data,int* a){
	int i=0;
	while(data>0){
		a[i++]=data%10;
		data/=10;
	}
	for(;i<length;i++){
		a[i]=0;
	}
}
//???????????°????????????????????????????????£???int????????????????????????
void printList(int length,int* a){
	int i;
	for(i=0;i<length;i++){
		printf("%d",a[i]);
	}
	printf("\n");
}

int main(void){
	int a,L;    //??´??°a0??¨?????°L
	int* list;  //??´??°a0?????°???????????°????????????????????\????????????
	int* temp;  //list???????£??????????????????????
	int ans[100000];//a0~ai?????°?????????????????????
	int i,j,k;    //???????????¨?????°
	
	while(1){
re_roop:         //??????????????????printf?????????????????????????????????????????¶??????????????§??????????????\????????§?????????
		//??\???
		scanf("%d %d",&a,&L);
		if(a==0 && L==0)break;    //??????????????????????????????????????¶
		ans[0]=a;
		i=1;
		list=(int*)malloc(sizeof(int)*L);
		temp=(int*)malloc(sizeof(int)*L);
		while(1){
			makeList(L,ans[i-1],list);
			//??????????????????
			listSort(L,list);
			//??????????????????
			for(j=0;j<L;j++){
				temp[L-j-1]=list[j];
			}
			//?????????????????????????????????????????????????????????ai????????????
			int temp1=makeValue(L,list);
			int temp2=makeValue(L,temp);
			ans[i]=temp1-temp2;
			//ai??¨????????????????????§?????????????????£??????????????????.
			for(j=0;j<i;j++){
				if(ans[j]==ans[i]){
					printf("%d %d %d\n",j,ans[j],i-j);
					free(list);
					free(temp);
					goto re_roop;
				}
			}
			i++;
		}
	}
	//free(list);
	//free(temp);
	
	return 0;
}

Measured memory_bytes: 608
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main{
    public static final int M = 1000000007;

    public static void main(String[] args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] t = br.readLine().split(" ");
        int m = Integer.parseInt(t[0]);
        int n = Integer.parseInt(t[1]);
        System.out.println(power(m, n));
    }

    public static long power(int x, int n){
        long res = 1;
        if(n > 0){
            res = power(x, n / 2);
            if(n % 2 == 0) res = (res * res) % M;
            else res = (((res * res) % M) * x) % M;
        }
        return res;
    }

}

Measured memory_bytes: 24312
#include<bits/stdc++.h>
#include<tr1/unordered_map>
#define pb push_back
#define pii pair<int,int>
#define SZ(x) (int)x.size()
#define mem(a,b) memset(a,b,sizeof(a))
#define  For(i,a,b) for(int i=a,i##E=b;i<=i##E;++i)
#define rFor(i,a,b) for(int i=a,i##E=b;i>=i##E;--i)
typedef long long LL;
using namespace std;
const int N=100010;
template<typename T>inline bool chkmin(T &a,const T &b){return a>b?a=b,1:0;}
template<typename T>inline bool chkmax(T &a,const T &b){return a<b?a=b,1:0;}
template<typename T>inline void read(T &x)
{
	x=0;int _f(0);char ch=getchar();
	while(!isdigit(ch))_f|=(ch=='-'),ch=getchar();
	while( isdigit(ch))x=x*10+ch-'0',ch=getchar();
	x=_f?-x:x;
}
inline void file()
{
#ifdef ztzshiwo
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
#endif
}
int S[N],n,ans;
int main()
{
	int x;
	file();
	read(n);
	For(i,1,n)read(x),S[x]++;
	For(i,1,N-10)chkmax(ans,S[i-1]+S[i]+S[i+1]);
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 640