akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <type_traits>
using namespace std;

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

struct mint {
  ll x;
  mint(ll x=0) : x(x%mod) {}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x -= a.x) < 0) x += mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) {
    mint res(*this);
    return res*=a;
  }
};

inline ll mypow(ll x, ll n) {
  if (n == 0) return 1;
  if (n % 2 == 0)
    return mypow(x * x % mod, n / 2);
  else
    return x * mypow(x, n - 1) % mod;
}

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

  ll n, k; std::cin >> n >> k;
  mint ans = 0;
  vector<mint> div(k+1);
  ddrep(i, k) {
    mint cnt = mypow(k/i, n);
    cnt -= div[i];
    ans += cnt * i;
    for (ll x = 1; x*x <= i; x++) if (i % x == 0) {
      div[x] += cnt;
      if (x * x != i) div[i/x] += cnt;
    }
  }
  std::cout << ans.x << "\n";
}


Measured memory_bytes: 3996
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define l first
#define r second

int main(){
	int n,w,h,p;
	cin>>n>>w>>h;
	p=w*2+h*2;
	deque<pii> rng(n);
	rep(i,n){
		int x,y,v; char c;
		cin>>x>>y>>c;
		rng[i].l=[=]{return (int[]){x-h+y,x+h-y,w*2+h+y-x,w*2+h-y-x}["NEWS"s.find(c)];}();
		rng[i].r=[=]{return (int[]){x+h-y,w*2+h-y-x,w*2+h+y+x,w*2+h+y-x}["NEWS"s.find(c)];}();
	}
	sort(all(rng),[](pii a,pii b){return a.r<b.r;});
	//for(auto i:rng)cout<<i.l<<","<<i.r<<endl;
	
	int ans=1e8;
	rep(i,n) {
		for(auto&j:rng) if(j.r<rng[0].r) j.l+=p, j.r+=p;
		sort(all(rng),[](pii a,pii b){return a.r<b.r;});
		int a=1,b=rng[0].r;
		//cout<<i<<":"<<b<<"====="<<endl;
		range(j,1,n){
			if(rng[j].l>b){
				a++;
				b=rng[j].r;
				//cout<<j<<":"<<b<<endl;;
			}
		}
		ans=min(ans,a);
		rng.emplace_back(rng[0].l+p,rng[0].r+p);
		rng.pop_front();
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 3220
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
using Double = long double;

template<typename T1,typename T2> void chmin(T1 &a,T2 b){if(a>b) a=b;};
template<typename T1,typename T2> void chmax(T1 &a,T2 b){if(a<b) a=b;};

signed main(){
  Int n;
  const Double EPS = 1e-8;
  Int cnt=0;
  while(cin>>n,n){
    ++cnt;
    vector<Double> vx(n),vy(n);
    for(Int i=0;i<n;i++) cin>>vx[i]>>vy[i];

    const Double g=9.8;
    auto calc=[&](Int i,Double x){    
      Double t=x/vx[i];
      return vy[i]*t-g/2.0*t*t;    
    };

    Double x,y;
    cin>>x>>y;
  
    Double lb=calc(0,x);
    for(Int i=0;i<n;i++) chmin(lb,calc(i,x));
    if(y+EPS<lb){
      cout<<"No"<<endl;
      continue;
    }
    
    auto check=[&](Double m)->Double{
      Double res=0;
      for(Int i=0;i<n;i++){
	if(vy[i]<m*vx[i]) continue;
	res+=vx[i]*(vy[i]-m*vx[i])/9.8;
      }
      return res+EPS;
    };
    auto check2=[&](Double m)->Double{
      Double res=0;
      for(Int i=0;i<n;i++){
	if(vy[i]<m*vx[i]) continue;
	res+=calc(i,vx[i]*(vy[i]-m*vx[i])/9.8);
      }
      return res;
    };
    Double l=-1e9,r=1e9;
    for(Int k=0;k<100;k++){
      Double m=(l+r)/2;
      if(x<=check(m)) l=m;
      else r=m;
    }
    //cout<<l<<":"<<check(l)<<":"<<check2(l)<<endl;
    cout<<(y<=check2(l)?"Yes":"No")<<endl; 
  }
  
  return 0;
}



Measured memory_bytes: 3204
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class MainClass : Scanner
{
    static void Main()
    {
        string s = RString();
        string t = RString();
        s = string.Join("", s.OrderBy(_ => _));
        t = string.Join("", t.OrderByDescending(_ => _));
        if (s == t)
        {
            WriteLine("No");return;
        }
        string[] words = new string[2] { s, t };
        Array.Sort(words);
        if (words[0] == s) WriteLine("Yes");
        else WriteLine("No");
    }
}



class Scanner
{
    public static string RString() => Console.ReadLine();
    public static int RInt() => ReadTuple<int>();
    public static long RLong() => ReadTuple<long>();
    public static double RDouble() => ReadTuple<double>();

    public static string[] RStrings() => Console.ReadLine().Split();
    public static int[] RInts() => Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
    public static long[] RLongs() => Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
    public static double[] RDoubles() => Array.ConvertAll(Console.ReadLine().Split(), double.Parse);
    public static int[] RInts(Func<string, int> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static long[] RLongs(Func<string, long> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static double[] RDoubles(Func<string, double> func) => Console.ReadLine().Split().Select(func).ToArray();
    //public static string[] RStrings(Func<string, string> func) => Console.ReadLine().Split().Select(func).ToArray();

    public static T1 ReadTuple<T1>()
    {
        var r = RString();
        var r1 = (T1)Convert.ChangeType(r, typeof(T1));
        return r1;
    }
    public static (T1, T2) ReadTuple<T1, T2>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        return (r1, r2);
    }
    public static (T1, T2, T3) ReadTuple<T1, T2, T3>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        var r3 = (T3)Convert.ChangeType(r[2], typeof(T3));
        return (r1, r2, r3);
    }
    public static (T1, T2, T3, T4) ReadTuple<T1, T2, T3, T4>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        var r3 = (T3)Convert.ChangeType(r[2], typeof(T3));
        var r4 = (T4)Convert.ChangeType(r[3], typeof(T4));
        return (r1, r2, r3, r4);
    }
}


Measured memory_bytes: 27064
from sys import stdin
import math
import itertools


def makeIntMatrix(lines):
    intMatrix = []
    for a in makeStringMatrix(lines):
        intMatrix.append([int(b) for b in a])
    return intMatrix
 
 
def makeStringMatrix(lines):
    stringMatrix = [line.split() for line in lines]
    return stringMatrix
 
 
def makeInt(line):
    return int(line.rstrip())
 
 
def makeMultiInteger(line):
    return [int(x) for x in line.rstrip().split()]


def solve():
    a = makeInt(input())
    b = makeInt(input())
    c = makeInt(input())
    d = makeInt(input())
    e = makeInt(input())
    l = [0, a, b, c, d, e]
    m = 9
    m_i = 1
    for i in range(len(l)):
        if m > l[i] % 10 and l[i] % 10 > 0:
            m = l[i] % 10
            m_i = i
    if m != 0:
        temp = l[-1]
        l[-1] = l[m_i]
        l[m_i] = temp

    #ls = sorted(l)
    #print(ls)
    lst = 0
    alst = 0
    i = 1
    # 10ずつ足されるのがベスト
    at = 0
    while(i < 6):
        if at >= l[i-1]:
            #print(at, ls[i-1])
            if i != 5:
                #print(at)
                alst += at
                #print(ls[i])
            else:
                #print(at)
                alst += at
                alst += l[i]
                return alst
            at = 0
            i += 1
            #print(alst)
        else:
            at += 10


def main():
    answer = solve()
    print(answer)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};
//左　上　右　下

int main(){
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i, h) cin >> s[i];

    int max = 0;

    rep(si, h)rep(sj, w){
        if(s[si][sj]=='#') continue;
        vvi dist(h, vi(w, INF));
        queue<P> q;
        auto update = [&](int i, int j, int x){
            if(dist[i][j] != INF) return;
            dist[i][j] = x;
            q.push(P(i, j));    
        };
        update(si, sj, 0);
        while(!q.empty()){
            int i = q.front().fi;
            int j = q.front().se; q.pop();
            rep(dir, 4){
                int ni = i+di[dir];
                int nj = j+dj[dir];
                if(ni<0||ni>=h||nj<0||nj>=w) continue;
                if(s[ni][nj]=='#') continue;
                update(ni, nj, dist[i][j]+1);
            }
        }
        rep(i, h)rep(j, w){
            if(dist[i][j] == INF) continue;
            if(max < dist[i][j]) max = dist[i][j];
        }
    }
    cout << max << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
odds_or_even = N%2+2
inf = -float("inf")
dp = [[inf for _ in range(N+1)] for _ in range(odds_or_even)]
dp[0][0] = 0
for i in range(N):
    dp[0][i+1] = dp[0][i]+A[i]*((i+1)%2)
for j in range(1,odds_or_even):
    for i in range(N):
        dp[j][i+1] = max(dp[j-1][i],dp[j][i]+A[i]*((i+j+1)%2))

print(dp[odds_or_even-1][N])

Measured memory_bytes: 49848
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <random>
#include <chrono>
#include <utility>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <sstream>
#include <assert.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <unordered_map>
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(bool x) {cerr << (x ? "true" : "false");}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}

template<typename T, typename V> void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";} void _print() {cerr << "]\n";}
template <typename T, typename... V>void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef HOME
#warning CHECK int:ll::INT_MAX:LLONG_MAX
#define maxn 20
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define maxn 2000006
#define gcd __gcd
#define debug(x...)
#endif

#define ff first
#define endl '\n'
#define ss second
#define inf 0x3f3f3f3f
#define MOD 1000000007
#define PI 3.14159265358979323846264338327950L
#define f(i,x,n) for(int i=x;i<=n;i++)
#define fr(i,x,n) for(int i=x;i>=n;i--)
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

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


int main() {

	int n; cin >> n;
	vector<int> p(n), q(n);
	for (int i = 0; i <= n - 1; i++) cin >> p[i];
	for (int i = 0; i <= n - 1; i++) cin >> q[i];

	map<vector<int>, int> ind;

	vector<int> perm(n); for (int i = 0; i <= n - 1; i++) perm[i] = i + 1;
	int i = 1;
	do {
		ind[perm] = i++;
	} while (next_permutation(perm.begin(), perm.end()));

	cout << abs(ind[p] - ind[q]);

	return 0;
}

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

using namespace std;

int main(){
int k,s;
cin >> k >> s;
int count = 0;

for(int x = 0;x <= k;x++){
	for(int y = 0;y <= k;y++){
    int z = s-x-y;

    if(z >= 0&&z <= k)count++;
	}
}
cout << count <<endl;
}

Measured memory_bytes: 256
h,n=map(int,input().split())
ans=0
magic=[]
al=[]
bl=[]
for i in range(n):
  a,b=map(int,input().split())
  magic.append([a,b])
  al.append(a)
  bl.append(b)
amx=max(al)
bmn=min(bl)
dp=[-1]*(h+amx+1)
dp[0]=0
for i in range(1,h+amx+1):
  mn=float("inf")
  for j in magic:
    mp=j[1]
    at=j[0]
    if at>i:
      cst=mp
    else:
      cst=dp[i-at]+mp
    if cst<mn:
      mn=cst
  dp[i]=mn
  
print(min(dp[h:]))


Measured memory_bytes: 74180
#include <iostream>
#include <math.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <stack>

using namespace std;
typedef long long ll;

ll min(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll max(ll a,ll b){
    if(a>b)return a;
    else return b;
}

int main(){
    ll n;cin>>n;
    ll a[n],b[n],c[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
        cin>>b[i];
        cin>>c[i];
    }
    ll A[n],B[n],C[n];
    A[0]=a[0];
    B[0]=b[0];
    C[0]=c[0];
    for(int i=1;i<n;i++){
        A[i]=max(B[i-1]+a[i],C[i-1]+a[i]);
        B[i]=max(A[i-1]+b[i],C[i-1]+b[i]);
        C[i]=max(A[i-1]+c[i],B[i-1]+c[i]);
    }
    cout<<max(max(A[n-1],B[n-1]),C[n-1])<<endl;
    
    return 0;
}



Measured memory_bytes: 4992
//Catchharsh
#include<bits/stdc++.h>
#define ll long long int 
#define ld long double
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define F first
#define S second
#define sz(x) x.size()
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define see(x) cout<<#x<<" = "<<x<<endl
const ll MOD = 1e9+7;
const ll INF = 1011111111;
const ll LLINF = 1000111000111000111LL;
const ld EPS = 1e-10;
const ld PI = 3.14159265358979323;
using namespace std;
ll power (ll base,ll exponent)
{
    ll ans=1;
    //base%=MOD;
    //exponent%=(MOD-1);
    while(exponent!=0)
    {
      if(exponent&1) ans=(1LL*ans*base);
      base=(1LL*base*base);
      exponent>>=1;
    }
    return ans;
}

int32_t main()
{   
     IOS;
     
     ll x,y,z;
     cin>>x>>y>>z;
     swap(x,y);
     swap(x,z);
     cout<<x<<" "<<y<<" "<<z;
     
     cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';             
}

Measured memory_bytes: 256
def get(text,n):
    ans = [""]*n
    i = 0
    for x in text:
        if x==" ":
            i = i + 1
        ans[i] = ans[i]+x
    return ans

nk = input()
N = int(get(nk,2)[0])
K = int(get(nk,2)[1])

H = get(input(),N)
for i in range(N):
    H[i]= int(H[i])

H.sort()

s = 0
for i in range(N-K):
    s = s + H[i]

print(s)

Measured memory_bytes: 19700
import java.util.*;

public class Main {
	
	public static boolean isPrime(int n){
        if(n == 2){
            return true;
        }else if(n < 2 || n % 2 == 0){
            return false;
        }else{
            int x = 3;
            while(x <= Math.sqrt((double)n)){
                if(n%x == 0)    return false;
                x += 2;
            }
            return true;
        }
	}
	
	public static void main(String[] args){
        Scanner in = new Scanner(System.in);

        int a = in.nextInt();
        int count = 0;

        for(int i = 0; i < a; i++){
            if(isPrime(in.nextInt())) count++;
        }

        System.out.println(count);
    }
}


Measured memory_bytes: 42236
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=a;i<int(b);i++)
using namespace std;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n;
    map<int, int> m;
    REP(i, 0, n) {
        cin >> k;
        m[k]++;
    }
    long long ans = 0;
    for (auto p: m) {
        if (p.first < p.second) {
            ans += p.second - p.first;
        } else if (p.first > p.second) {
            ans += p.second;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 4736
# 解説

def main():
    s = input()
    n = len(s)

    parity = (n & 1)  # 初期長の偶奇=1->奇数,0->偶数
    same_chars = int(s[0] == s[-1])  # 最終長の偶奇=1->奇数,0->偶数

    cond = parity ^ same_chars  # 取り除ける個数の偶奇=1->奇数,0->偶数

    print('First' if cond else 'Second')


if __name__ == '__main__':
    main()

# 最終状態は複数考えられるが
# 共通する性質がある
# ababa
# ababab
# 交互に並ぶ
# 両端の文字が一致するかで、最終長の偶奇が定まる
# 元の長さの偶奇と比較すると、取れる個数の偶奇がわかる


Measured memory_bytes: 3316
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
#include<math.h>
#include<bitset>
#include<random>
 
using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
 
#define shosu setprecision(17)
 
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<char,P> Q;
//ll longinf=1ll<<60;
int inf=1<<29;
ll longinf=(1ll<<60);

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

ll string_ll(string s){
    ll ret=0;
    rep0(i,s.size()){
        ret*=10;
        ll a = s[i] - '0';
        ret+=a;
    }
    return ret;
}


int main(){
    ll n;
    cin>>n;
    vector<string> ans;
  int aa=1<<20;
    rep0(i,aa){
        ll j=i;
        string s={};
        bool t=false;
        bool f=false;
        bool se=false;
        while(j>0){
            if((j&3)==1){
                s+='3';
                t=true;
                }
            if((j&3)==2){
                s+='5';
                f=true;
            }
            if((j&3)==3){
                s+='7';
                se=true;
            }
            j>>=2;
        }
        if(t&&f&&se) ans.push_back(s);
    }
  std::sort(ans.begin(), ans.end());
  ans.erase(std::unique(ans.begin(), ans.end()), ans.end());
    int cnt=0;
    rep0(i,ans.size()){
        ll saa;
      saa=string_ll(ans[i]);
        if(saa<=n) cnt++;
    }
    cout<<cnt<<endl;
  

    return 0;
}


Measured memory_bytes: 53864
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  
  int e, f;
  
  if ( a >= b){
    e = b;
  }
  
  if ( b > a){
    e = a;
  }
  
  if ( c >= d){
    f = d;
  }
  
  if ( d > c){
    f = c;
  }
  
  cout << e + f << endl;

}

Measured memory_bytes: 256
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

K = int(input())
output = 0
for i1 in range(1,K+1):
    for i2 in range(1,K+1):
        for i3 in range(1,K+1):
            output += gcd(i1,i2,i3)
print(output)

Measured memory_bytes: 74932
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
#define INF 1001001001
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define repX(i, n ,x) for (int i = x; i < (int)(n); ++i)
#define repBack(i, n) for (int i = n; i >= 0; --i)
#define dup(x,y) (((x)+(y)-1)/(y))

int main() {
    int A,B;
    cin >> A >> B;
    if(A>=13)cout << B << endl;
    else if(A>=6)cout << B/2 << endl;
    else cout << 0 << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<bits/stdc++.h>
#include<stack>
#include<queue>
#include<list>
#include<vector>
#include<bitset>
#include<unordered_map> 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
// #include "boost/algorithm/string.hpp"
#define fio ios_base::sync_with_stdio(false)
#define mod 1000000007
#define mod1 mod
#define mod2 1000000007
#define li long long int
#define ll li
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define readi(x) scanf("%d",&x)
#define  reads(x)  scanf("%s", x)
#define readl(x) scanf("%I64d",&x)
#define rep(i,n) for(i=0;i<n;i++)
#define revp(i,n) for(i=(n-1);i>=0;i--)
#define myrep1(i,a,b) for(i=a;i<=b;i++)
#define myrep2(i,a,b) for(i=b;i>=a;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define MAXN 1000000000000000005
#define MINN -1000000000000000000
#define INTMAX 1000001000
#define pii pair<ll,ll> 
#define pdd pair<double,double>
#define pic pair<int,char>
#define N 105 
#define lgn 20
#define ddouble long double
#define minus minu
#define PI 3.1415926535
#define lgn 20
 
 
// #define INTMAX 200000000 
 
// using namespace boost;
// #define si short int
 
using namespace std;
using namespace __gnu_pbds;             
typedef priority_queue<ll, vector<ll > > max_pq;
typedef priority_queue<ll, vector<ll> , greater<ll >  > min_pq;
ll toint(const string &s) {stringstream ss; ss << s; ll x; ss >> x; return x;}
string tostring ( ll number ){stringstream ss; ss<< number; return ss.str();}
 
using namespace __gnu_pbds;         
// typedef priority_queue<pair<ll,char> , vector<pair<ll , char> > > max_pq;
// typedef priority_queue<pii , vector<pii > ,greater<pii > > min_pq;
// typedef tree<pii , null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> OST;
// typedef priority_queue<pair < ll , pair < pii , ll > >  , vector<pair < ll , pair < pii , ll > >  > ,greater<pair < ll , pair < pii , ll > >  > > min_pq;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << std::endl;
        //use cerr if u want to display at the bottom
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif
#define nn 2000005
typedef long double ld;
ll n;
string s;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> s;
    ll las = s.size()-1;
    ll ans = 0;
    bool flg = 0;
    for ( ll i = s.size()-1; i >= 0 ; i --)
    {
        if ( flg and s[i] == 'B' )
            ans += ( las - i ),las--;
        if ( flg == 0 and s[i] == 'W' )
            las = i;
        flg |= (s[i]=='W');
    }
    cout << ans;
}

Measured memory_bytes: 720
def f(m,l):
    tmpm=set()
    for x in m:
        tmpm.add(x+l);tmpm.add(x-l)
    return tmpm

s=input()+"T"
x,y=map(int,input().split())

while s and s[0]=="F":
    x-=1
    s=s[1:]
ss=[{0},{0}]
mode=0
l=0
for i in range(len(s)):
    if s[i]=="F": l+=1
    else:
        ss[mode]=f(ss[mode],l)    
        mode^=1
        l=0

print("Yes" if x in ss[0] and y in ss[1] else "No")

Measured memory_bytes: 48860
n = gets.to_i
a = gets.split.map(&:to_i)

sum = a.sum
h = a.tally

q = gets.to_i
q.times do
  b,c = gets.split.map(&:to_i)
  b_count = h[b].to_i
  sum += b_count * (c - b)
  h[b] = 0
  h[c] = h[c].to_i + b_count
  puts sum
end



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

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin >> n;
	long long r;
	cin >> r;
	for (int i = 1; i < n; i++)
	{
		long long t;
		cin >> t;
		r = t/__gcd(r, t) * r;
	}
	cout << r << endl;
	return 0;
}


Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};


int main() {
    int N, A;
    cin >> N >> A;
    if (N % 500 <= A) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

typedef pair<int,int> P;

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

int main(){
  int H,W;
  cin >> H >> W;
  char a[H][W];
  int cost[H][W];
  queue<P> que;

  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin >> a[i][j];
      if(a[i][j] == '#'){
        cost[i][j] = 0;
        que.push(P(i,j));
      }
      else cost[i][j] = inf;
    }
  }

  //bfs
  while(que.size()){
    P p = que.front();
    que.pop();

    for(int i=0;i<4;i++){
      int nx = p.first + dx[i];
      int ny = p.second + dy[i];
      if(0 <= nx && nx < H && 0 <= ny && ny < W && cost[nx][ny] == inf){
        cost[nx][ny] = cost[p.first][p.second] + 1;
        que.push(P(nx,ny));
      }
    }
  }

  int ans = 0;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      ans = max(ans, cost[i][j]);
    }
  }

  cout << ans << endl;
  return 0;




}

Measured memory_bytes: 13328
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<string>
#include<cstdlib>
#include<algorithm>
using namespace std;
int st[4];
string st1;
int shu;
int main()
{
cin>>st1;
for(int i=0; i<4; i++)st[i]=int(st1[i])-48;
shu=st[0];
for(int i=1; i<=2; i++)
{
	if(i==1)shu+=st[1];
	else shu-=st[1];
	for(int j=1; j<=2; j++)
	{
		if(j==1)shu+=st[2];
		else shu-=st[2];
		for(int k=1; k<=2; k++)
		{
			if(k==1)shu+=st[3];
	    	else shu-=st[3];
			if(shu==7)
			{
				cout<<st[0];
				if(i==1)cout<<'+';
				else cout<<'-';
				cout<<st[1];
		        if(j==1)cout<<'+';
		        else cout<<'-';
		        cout<<st[2];
		        if(k==1)cout<<'+';
		        else cout<<'-';
		        cout<<st[3];
		        cout<<"=7";
		        cout<<endl;
		        return 0;
			}
			if(k==1)shu-=st[3];
	    	else shu+=st[3];
		}
		if(j==1)shu-=st[2];
		else shu+=st[2];
	}
	if(i==1)shu-=st[1];
	else shu+=st[1];
}
return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
const int N=100005;
using namespace std;
ll c[2010],n,z,w;
int main(){
    cin>>n>>z>>w;
    for(int i=0;i<n;i++) cin>>c[i];
    ll ans=abs(c[n-1]-w);
    if(n>1) ans=max(ans,abs(c[n-1]-c[n-2]));
    cout<<ans;
    return 0;
}

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();
		sc.nextLine();
		int sum = 0;
		String s=sc.nextLine()+'Z';
		for(int i=0;i<s.length()-1;i++){
			if(s.charAt(i)!=s.charAt(i+1))
				sum++;
		}
		System.out.println(sum);
	}
}

Measured memory_bytes: 28220
#include <bits/stdc++.h>
using namespace std;
string s;
int main(){
	ios::sync_with_stdio(0), cin.tie(0);
	cin>>s;
	bool flag = true;
	for(int a = 0; a < s.length(); a++){
        if(a % 2 == 1){
            if(!(s[a] == 'L' || s[a]=='U' ||s[a]=='D')){
                flag = false;
                break;
            }
        }else{
            if(!(s[a] == 'R' || s[a]=='U' ||s[a]=='D')){
                flag = false;
                break;
            }
        }
	}
	if(flag)cout<<"Yes\n";
	else cout<<"No\n";
}


Measured memory_bytes: 256
from collections import defaultdict
def solve(x, y, z):
    return x*x + y*y + z*z + x*y + y*z + z*x
d = defaultdict(int)
ans = 0
n = int(input())
for i in range(1, n + 1):
    if solve(i, i, i) > n:
        break
    for j in range(i, n + 1):
        if solve(i, j, j) > n:
            break
        for k in range(j, n + 1):
            if solve(i, j, k) > n:
                break
            
            l = len({i,j,k})
            if l==3:
                res = 6
            elif l==2:
                res = 3
            else:
                res = 1
            d[solve(i, j, k)]+=res
ans = [d[i] for i in range(1,n+1)]
print(*ans, sep='\n')

Measured memory_bytes: 69820
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <limits.h>
#include <assert.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string>
#include <bitset>
#include <vector>
using namespace std;

#define LL long long

#define fi first
#define se second
#define lson l,mid,id<<1
#define rson mid+1,r,id<<1|1
#define ls id<<1
#define rs id<<1|1
#define MID(a,b) (((a)+(b))>>1)
#define maxx(a,b) ((a)<(b)?(b):(a))
#define minx(a,b) ((a)<(b)?(a):(b))
#define absx(a) ((a)<0?-(a):(a))
#define mk(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define itr iterator
#define lowbit(x) ((x)&-(x))

typedef unsigned LL ULL;
typedef unsigned uint;
typedef map<int,int> mii;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef pair<LL,LL> pLL;

template< typename T > inline void read(T &x) {
    static bool fr_f; static char fr_ch;
    fr_f=0; x=0; fr_ch=getchar();
    while(fr_ch<'0' || '9'<fr_ch) {if(fr_ch=='-') fr_f=1; fr_ch=getchar();}
    while('0'<=fr_ch && fr_ch<='9') {x=(x<<1)+(x<<3)+fr_ch-'0'; fr_ch=getchar();}
    if(fr_f) x=-x;
}

template< typename T > inline void Max (T &a, T b) {if(a<b) a=b;}
template< typename T > inline void Min (T &a, T b) {if(b<a) a=b;}
template< typename T > inline void Swap(T &a, T &b) {T c=a;a=b;b=c;}
template< typename T > inline T Abs(T a) {if(a<0) return -a; else return a;}

const double   pi = acos(-1.0) ;
const int     MOD = (int)1e9+7 ;
const int     INF = (int)0x3f3f3f3f ;
const LL     LINF = (LL)INF<<32|INF ;
const int    SINF = (uint)(-1)>>1 ;
const LL    SLINF = (ULL)(-1)>>1 ;
const double DINF = 1e50 ;
const double  eps = 1e-5 ;
const int    maxn = (int) 2e5+20 ;
const int    maxm = (int) 1e6+20 ;
const int    maxk = (int) 1000+20 ;

inline int sig(double x) {return x<-eps?-1:x>eps;}
inline LL fp(LL a,LL n,LL p) {LL res=1; for(;n;n>>=1,a=a*a%p) if(n&1) res=res*a%p; return res;}
template<typename T>inline T gcd(T a,T b) {for(T c;b;c=a%b,a=b,b=c); return a;}

//--------------------start--------------------

int n;
int a[maxn];
int x[maxn];

void work()
{
    read(n);
    for(int i=1;i<=n;i++) read(a[i]);

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

    int now = 1, ans = 1;
    for(int i=2;i<=n;i++)
    {
        if(x[i] > x[i - 1])
        {
            now++;
            Max(ans, now);
        }
        else
        {
            now = 1;
        }
    }

    cout <<n - ans <<endl;
}

//---------------------end---------------------

int main()
{
#ifdef yukihana0416
freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);
#endif // yukihana0416
    work();
    return 0;
}


Measured memory_bytes: 1792
// --------------
// Tejas Pandey  |
// 18 - 08 - 19  |
// ABC #138      |
// --------------

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

#define mod 1000000007
#define vi vector<int>
typedef long long int ll;


int main (void)
{
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t = 1;
	//cin >> t;
	while(t--)
	{
		//cout << "Case #" << c-t << ": ";
		string s,t;
		cin >> s >> t;
		vector<int> pos[26];
		for(int i = 0;i < s.size();i++){
			pos[s[i] - 'a'].push_back(i+1);
		}
		ll prev = 0, ans = 0;
		for(int i = 0;i < t.size();i++){
			int sc = t[i] - 'a';
			int position = (lower_bound(pos[sc].begin(),pos[sc].end(),prev+1)) - pos[sc].begin();
			if(position == pos[sc].size()){
				if(pos[sc].size() == 0){
					cout << "-1";
					return 0;
				}
				ans += s.size() - prev;
				prev = 0;
				i--;
			}
			else{
				ans += pos[sc][position] - prev;
				prev = pos[sc][position];
			}
		}
		cout << ans;
	}
	return 0;
}

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

using namespace std;


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

	vector<int> counter(26, 0);

	int n = s.size();

	for (int i = 0; i < n; i++) {
		counter[s[i] - 'a']++;
	}

	for (int i = 0; i < 26; i++) {
		if (counter[i] % 2 == 1) {
			cout << "No";
			return 0;
		}
	}

	cout << "Yes";
}


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

int main() {
  int A, B, C, X;
  cin >> A >> B >> C >> X;
  int res = 0;
  for (int a = 0; a <= A; ++a) {
    for (int b = 0; b <= B; ++b) {
      for (int c = 0; c <= C; ++c) {
        int total = 500*a + 100*b + 50*c; //変数totoalのみ変化させる
        if (total == X) ++res; 
      }
    }
  }
  cout << res << endl;
}


Measured memory_bytes: 256
/**
 * @Author:      G_bg
 * @DateTime:    2019-07-27 20:03:58
 * @Description: 
 */
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const double PI = 3.1415926535898;
const double E = 2.718281828459;
const int INF = 0x7fffffff;
const int mod = 1e9+7;
const int maxn = 50+10;
int a[maxn];
int main(int argc, char const *argv[]) {
    ios::sync_with_stdio(0);cin.tie(0);
    int n;cin >> n;
    int sum = 0;
    for(int i = 1;i <= n;i++){
        cin >> a[i];
        if(a[i] != i) sum++;
    }
    if(sum == 2 || sum == 0) cout << "YES" << endl;
    else cout << "NO" << endl;
    //system("pause");
    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0LL)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;}
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);}
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;}
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;}


bool isOk(ll key,ll value){
  return key >= value;
}

ll binary_search(vector<ll> a,ll key){
  ll ok = a.size()-1;
  ll ng = 0;

  while(abs(ok - ng) > 1){
    ll mid = (ok + ng) / 2;
    if(isOk(key,a[mid]))ok = mid;
    else ng = mid;
  }
  return ok;
}

bool isPrime(ll n) {
	for (int i = 2; n >= i * i; ++i) {
		if(!(n % i))return false;
	}
  return true;
}
vector<ll> primes(ll n){
  vector<ll> v(1,1);
  for (ll i = 2; n >= i * i; ++i) {
		if(!(n % i)){
      v.pb(i);
	  }
  }
  if(v.size()==1)v.pb(n);
  return v;
}

int main() {
  cin.tie(0); ios::sync_with_stdio(0);
  int n,k;cin>>n>>k;
  string s;cin>>s;

  int ans = 0;
  rep(i,n){
    if(i != 0 && s[i] == 'L' && s[i] == s[i-1])ans++;
    if(i!=n-1 && s[i] == 'R' && s[i] == s[i+1])ans++;
  }

  UNIQUE(s);

  int cnt = (s.size())/2 - !(s.size()%2);
  ans += max(min(cnt,k)*2,0);
  k -= cnt;
  ans += max(min((int)!(s.size()%2),k),0);  
  
  print(ans);
  return 0;
} 

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();

		long[] small = new long[n + 10];
		long[] big = new long[n + 10];
		for (int i = 1; i <= n + 1; ++i) {
			small[i] = small[i - 1] + (i - 1);
			big[i] = big[i - 1] + n - (i - 1);
		}

		final long mod = 1000000007;
		long ans = 0;
		for (int i = k; i <= n + 1; ++i) {
			ans += big[i] - small[i] + 1;
			ans %= mod;
		}

		System.out.println(ans);
	}

}


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

using namespace std;

static const int MAX = 100;

void trace(int A[], int N){
    int i;
    for (int i = 0; i < N; i++){
        if (i) cout << " ";
        cout << A[i];
    }
    cout << endl;
}

int main(){
    int num;
    int A[MAX];

    cin >> num;
    for (int i = 0; i < num; i++) cin >> A[i];

    trace(A, num);
    for (int i = 1; i < num; i++){
        int tmp = A[i];
        int j = i - 1;
        while (j >= 0 && A[j] > tmp){
            A[j + 1] = A[j];
            j--;
        }
        A[j + 1] = tmp;
        trace(A, num);
    }

    return 0;
}

Measured memory_bytes: 3080
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[6] = {1, 0, -1, 0,1,1};
const int dy[6] = {0, 1, 0, -1,1,-1};
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(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    vector<int> r(4);
    int sum = 0;
    for(int i=0; i<4; i++) cin >> r[i],sum += r[i];
    int a,b;
    cin >> a >> b;
    sort(r.begin(),r.end());
    cout << sum - r[0] + max(a,b) << endl;
    return 0;
}


Measured memory_bytes: 3208
//============================================================================
// Name        : AOJ0042.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;

#define MAX_N 1000
#define MAX_M 10000

int n, W;
int w[MAX_N] = { 0 }, v[MAX_N] = { 0 };

short dp[MAX_N + 1][MAX_M + 1] = { { 0 } };

void solve() {

  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= W; j++) {
      if (j < w[i]) {
        dp[i + 1][j] = dp[i][j];
      } else {
        dp[i + 1][j] = (short)max((int)dp[i][j], dp[i][j - w[i]] + v[i]);
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= W; j++) {
      //printf("%5d", dp[i][j]);
    }
    //cout << endl;
  }
  //cout << endl;
  cout << dp[n][W] << endl;
  int i;
  for (i = W; i >= 0; i--) {
    if (dp[n][W] != dp[n][i]) break;
  }
  cout << i + 1 << endl;

}

int main() {

  int kase = 1;
  char str[11];
  cin >> W;

  while (W != 0) {
    cin >> n;

    for (int i = 0; i < n; i++) {
      cin >> str;

      int j = 0;

      v[i] = 0;
      w[i] = 0;

      while (str[j] != ',') {
        v[i] = v[i] * 10;
        v[i] = v[i] + (str[j] - '0');
        j++;
      }

      j++;

      while (str[j] != '\0') {
        w[i] = w[i] * 10;
        w[i] = w[i] + (str[j] - '0');
        j++;
      }
    }
    /*
     for (int i = 0; i < n; i++) {
     cout << v[i] << endl;
     cout << w[i] << endl;
     }
     */
    cout << "Case " << kase << ":" << endl;
    solve();

    kase++;
    cin >> W;
  }

  return 0;
}

Measured memory_bytes: 18516
#include<stdio.h>
#include<math.h>

short is_prime_number(unsigned long x)
{
    unsigned long max, i;
    max = (unsigned long)sqrt((double)x);

    if(x == 1)return 0;
    if(x == 2)return 1;
    if(x % 2 == 0) return 0;
    for(i=3; i<=max; i+=2)
        if(x % i == 0)
            return 0;
    return 1;
}

int main(void)
{
    unsigned int n, n_prime = 0, i;
    unsigned long x;

    scanf("%u", &n);
    for(i=0; i<n; ++i){
        scanf("%lu", &x);
        if(is_prime_number(x))
            ++n_prime;
    }
    printf("%u\n", n_prime);

    return 0;
}

Measured memory_bytes: 1824
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
     long long a,b,c,d,e;
    while(cin>>a>>b>>c){
     d=c-(a+b);
     e=4*a*b;
    if(d<=0) puts("No");
	else if(4*a*b<d*d)
     	puts("Yes");
  else puts("No");
	}
  return 0;
}

Measured memory_bytes: 256
N = int(input())
K = int(input())
x = [int(x) for x in input().split()]

moveSum = 0
for x2 in x:
    move = x2 * 2
    if move > (K - x2) * 2:
        move = (K - x2) * 2
    moveSum += move

print(moveSum)

Measured memory_bytes: 2940
using System;
using System.Collections.Generic;
using System.Linq;
class b{
  public static void Main(){
    String str1 = Console.ReadLine();
    String str2 = Console.ReadLine();
    int ans = 0;
    for(int i=0; i<str1.Length; i++){
      if(str1[i] != str2[i]) ans++;
    }
    Console.WriteLine(ans);
  }
}


Measured memory_bytes: 18188
n, p = map(int, input().split())
A = list(map(int, input().split()))  

for a in A:
  if a % 2 != 0:
    break 
else:
  if p == 1: 
    print(0)
    exit()
  if p == 0: 
    print(2**n)
    exit()
  
ans = 2**(n-1)
print(ans)


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

struct Query {
  int node, dist, color;
  Query(){}
  Query(int _n, int _d, int _c){
    node = _n;
    dist = _d;
    color = _c;
  }
};
Query query[100005];
vector<int> adj[100005];
int color[100005][15];

void dfs(int u, int d, int col){
  if(d >= 0 && color[u][d] == 0){
    color[u][d] = col;
    for(int v : adj[u]){
      dfs(v, d-1, col);
    }
  }
}

int main(){
  ios_base :: sync_with_stdio(false);
  int V, E;
  cin >> V >> E;
  for(int i=1; i<=E; i++){
    int u, v;
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }

  int Q;
  cin >> Q;
  for(int i=1; i<=Q; i++){
    cin >> query[i].node >> query[i].dist >> query[i].color;
  }

  for(int i=Q; i>=1; i--){
    for(int d=query[i].dist; d>=0; d--){
      dfs(query[i].node, d, query[i].color);
    }
  }

  for(int i=1; i<=V; i++) cout << color[i][0] << endl;


  return 0;
} 

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

int n,ans[100010],cnt,ji,a[100010],k;
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;++i)
	scanf("%d",&a[i]);
	ji=1;	
	for(int i=2;i<=n-1;++i)
	{
		if(a[i]+a[i+1]>a[ji]+a[ji+1])
		ji=i;
	}
	if(a[ji]+a[ji+1]<k)
	printf("Impossible\n");
	else
	{
		printf("Possible\n");
		for(int i=1;i<=ji-1;++i)
		printf("%d\n",i);
		for(int i=n-1;i>=ji;--i)
		printf("%d\n",i);
	}
	return 0;
}

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

using namespace std;

int main()
{
  int n,x;
  
  while(1){
    cin>>n>>x;
    if(n==0 && x==0) break;
    int count=0;
    for(int i=1;i<n-1;i++){
      for(int j=i+1;j<n;j++){
	for(int k=j+1;k<n+1;k++){
	  if(i+j+k==x){
	    count++;
	}
      }
    }
    }
    cout<<count<<endl;
  }
  return 0;
}



Measured memory_bytes: 3096
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
    
int main() {
  ll N;
  cin >> N;
  
  if (N%2 == 1) {
    cout << 0 << endl;
  }
  
  else {
    vector<ll> M(27, 0);
    ll div = 2;
    for (int i=0; i<27; i++) {
      div *= 5;
      M.at(i) = N/div;
    }
  
    ll ans = 0; 
    for (int i=0; i<27; i++) {
      ans += M.at(i);
    }
  
    cout << ans << endl;
  }
}

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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(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) int(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>;

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 int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n,q; cin>>n>>q;
  string S; cin>>S;
  vll l(q), r(q);
  rep(i,q) cin>>l[i]>>r[i];
  vll s(n+1);
  irep(i,1,n){
    if(S[i-1]=='A'&&S[i]=='C') s[i+1]=s[i]+1;
    else s[i+1]=s[i];
  }
  rep(i,q){
    cout<<s[r[i]]-s[l[i]]<<endl;
  }
}

Measured memory_bytes: 3408
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
int main() {
	// your code goes here
	ll a,b,c;
	cin>>a>>b>>c;
	ll rem=a-b;
	if(rem==c || c<rem){
		cout<<0<<endl;
	}
	else if(c>rem){
		cout<<c-rem<<endl;
	}
	return 0;
}

Measured memory_bytes: 384