akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;

long long MOD = 1000000007;

/*
long long choose(long long a,long long b){
    if(a == b){
        return 1;
    }
    else if(b == 1){
        return a;
    }
    else{
        return choose(a - 1,b) + choose(a - 1,b - 1);
    }
}
*/

/*aからbこ*/
long long sum1 (long long a,long long b){
    long long ans = (a + a + b - 1)*b/2;
    return ans;
}

/*aからbこ*/
long long sum2 (long long a,long long b){
    long long ans = (a + a - b + 1)*b/2;
    return ans;
}

int main(){
    long long n,k;
    cin >> n >> k;
    long long ans = 0;
    for(int i = k;i <= n + 1;i++){
        ans = (ans + (sum2(n,i) - sum1(0,i) + 1))%MOD;
        //cout << sum2(n,i) << " " << sum1(0,i) << endl;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
//////////////////////////////
// Author: whatisit
// Date: 2020-05-14 20:56 
//////////////////////////////
#include <bits/stdc++.h>
using namespace std;

void solve() {
	int a, b, ans = -1;
	cin >> a >> b;
	int upper_bound = 101*100/8;
	for (int i = 1; i <= upper_bound; ++i) {
		if (i * 8 / 100 == a && i / 10 == b) {
			ans = i;
			break;
		}
	}
	cout << ans;
}

int main() {
	//cin.tie(0); ios_base::sync_with_stdio(0);
	solve();
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

#include <iostream>
#include <iomanip>
#include <sstream>
#include <stdint.h>
#include <string.h>

#include <unordered_set>

#define _USE_MATH_DEFINES
#include <math.h>


#include <vector>
#include <list>

#include <set>
#include <map>

#include <unordered_map>

#include <queue>
#include <stack>

#include <string>

#include <vector>

#define sqr(x) (x) * (x)

#include <algorithm>
#include <functional>

#include <bitset>

#include <functional>

#include <chrono>

typedef unsigned int u32;
typedef int i32;

typedef unsigned long long int u64;
typedef long long int i64;

typedef uint16_t u16;
typedef int16_t i16;

typedef uint8_t u8;
typedef int8_t i8;


using namespace std;
using namespace std::chrono;

struct less_key
{
    bool operator() (pair<i64, i64> p1, pair<i64, i64> p2)
    {
        return p1.first > p2.first || (p1.first == p2.first && p1.second < p2.second);
    }
};

struct pair_hash {
public:
    std::size_t operator()(const std::pair<u64, u64> &x) const
    {
        return std::hash<u64>()(x.first) ^ std::hash<u64>()(x.second);
    }
};
#include <random>

const i64 mod = 1000000007ll;
const i64 smod = 998244353ll;
const i64 inf = 10000000000000007ll;

const double eps = 1e-10;

// del

const i64 MAXN = 100005;

i64 r, g, b, n;

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed);

    cin >> r >> g >> b >> n;


    i64 R = 0;
    for (i64 i = 0; i <= n; i++) {
        if (i * r > n) {
            break;
        }
        for (i64 j = 0; j <= n; j++) {
            if (i * r + j * g > n) {
                break;
            }
            if ((n - (i * r + j * g)) % b == 0) {
                R++;
            }
        }
    }

    cout << R;

    return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
	int a[]=new int[4];

	a[0]=-9;
	a[1]=sc.nextInt();
	a[2]=sc.nextInt();
	a[3]=sc.nextInt();

	Arrays.sort(a);

	int ans=0;
	ans=a[3]-a[2];
	a[2]+=ans;
	a[1]+=ans;
if((a[3]-a[1])%2==0){
	ans+=(a[3]-a[1])/2;
}else{
	ans+=1+(a[3]-a[1]+1)/2;
}
System.out.println(ans);
	}}

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

int main() {
  int K ;
  cin >> K;
  int a=0;
  bool exist=false;
  for (int i=1 ; i<=K;i++) {
    a=(a*10+7)%K;
    if (a==0) {
      cout << i << endl;
      exist=true;
      break;
    }
  }
  if (!exist) cout << -1 << endl;
}


Measured memory_bytes: 3644
import sys
N = int(input())

A = [0] * N
count = 0
for n in range(N):
    A[n] = int(input())

if all(A):
    print(sum(A) // 2)
    sys.exit()

index = 0
for n in range(N):
    if A[n] == 0:
        count += (sum(A[index: n]) // 2)
        index = n
count += sum(A[index:]) // 2
print(count)

Measured memory_bytes: 7284
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
const int INF = 1000000007;
typedef long long ll;
using namespace std;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
ll fac(ll a) { return a > 1 ? fac(a - 1) * a : 1; }
int solve(){
  string s,tmp = "CODEFESTIVAL2016";
  cin >> s;
  int ans = 0;
  rep(i,16){
    if(s[i] != tmp[i])ans++;
  }
  cout << ans << endl;
  return 0;
}
int main(){
  ios::sync_with_stdio(false);cin.tie(nullptr);
  solve();
  return 0;
}

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

const int maxn=100+5;
int n[maxn];

void prev(void){
    memset(n,0,sizeof(n));
    int num=2;
    while(num<100){
        n[num]=num;
        num=num*2;
    }
}

int main(void){
    int num;
    cin>>num;
    prev();

    if(num==1) cout<<1<<endl;
    else{
        for(int i=num;i>=2;i--)
        if(n[i]) {
            cout<<n[i]<<endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
(format t "~A~%" (let* ((S (coerce (read-line) 'list))
                       (a (find-if-not (lambda (x)
                                         (member x S))
                                       (loop for n from 97 to 122
                                             collect (code-char n)))))
                      (if a
                          a
                          "None")))

Measured memory_bytes: 8424
/*||>>>> Praveen Ojha <<<<>>>> 27 July 2019 <<<<>>>> 17:28:27 <<<<||*/
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC optimize("unroll-loops")
// #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define F first
#define S second
#define mod 1000000007
#define inf (int)1e18+5
#define sz(x) (int)x.size()
#define PI 3.141592653589793238510
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define __ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define vi vector<int>
#define vpii vector<pair<int,int> > 
#define vvi vector<vector<int> >
#define PRINT_TIME cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." <<endl;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename   enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long double ld;
typedef pair<int,int> pii;
//Read Problems Carefully & Check for corner cases N=0,1 ?
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////

int32_t main(){__
    int a,b;
    cin>>a>>b;
    if((a+b)%2==0){
        cout<<(a+b)/2<<"\n";
    }
    else
        cout<<"IMPOSSIBLE\n";
return 0;
}

Measured memory_bytes: 256
import sys
import os
import math
import bisect
import itertools
import collections
import heapq
import queue
import array

# 時々使う
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
# from decimal import Decimal
# from collections import defaultdict, deque

# 再帰の制限設定
sys.setrecursionlimit(10000000)


def ii(): return int(sys.stdin.buffer.readline().rstrip())
def il(): return list(map(int, sys.stdin.buffer.readline().split()))
def fl(): return list(map(float, sys.stdin.buffer.readline().split()))
def iln(n): return [int(sys.stdin.buffer.readline().rstrip())
                    for _ in range(n)]


def iss(): return sys.stdin.buffer.readline().decode().rstrip()
def sl(): return list(map(str, sys.stdin.buffer.readline().decode().split()))
def isn(n): return [sys.stdin.buffer.readline().decode().rstrip()
                    for _ in range(n)]


def lcm(x, y): return (x * y) // math.gcd(x, y)


MOD = 10 ** 9 + 7
INF = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    D = [il() for _ in range(N)]
    for i in range(N - 2):
        for j in range(i, i + 3):
            if D[j][0] != D[j][1]:
                break
        else:
            print('Yes')
            exit()
    else:
        print('No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 9760
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int inf{int(1e9)};
int main(void){
  int K;
  cin >> K;
  rep(i,K) cout << "ACL";
  cout << endl;
  return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <unordered_map>

using namespace std;

long long pow(int base, int expo)	{
  if (base == 0) return 0;
  if (expo == 0) return 1;
  int result = 1;
  for (int i = 0; i < expo; i++)	{
    result *= base;
    result %= 1000000007;
  }
  return result % 1000000007;
}

int main()	{
  int n;
  cin >> n;
  int input[n];
  unordered_map<int, int> freq;
  for (int i = 0; i < n; i++)	{
    cin >> input[i];
    freq[input[i]]++;
  }
  for (auto it : freq)	{
    if (it.first == 0 && it.second > 1)	{
      cout << 0 << endl;
      return 0;
    }
	else if (it.first != 0 && it.second != 2)	{
      cout << 0 << endl;
      return 0;
    }
  }
  cout << pow(2, (n / 2)) << endl;
  return 0;
}

Measured memory_bytes: 7028
n,m=map(int,input().split())
AB=[list(map(int,input().split())) for i in range(m)]
root=[-1]*n

def find(x):
    if root[x]<0:
        return x
    else:
        root[x]=find(root[x])
        return root[x]
    
def unite(x,y):
    parent_x=find(x)
    parent_y=find(y)
    
    if parent_x==parent_y:
        return

    if parent_x>parent_y:
        parent_x,parent_y=parent_y,parent_x

    root[parent_x]+=root[parent_y]
    root[parent_y]=parent_x

def size(x):
    a=find(x)
    return -root[a]

for i in range(m):
    unite(AB[i][0]-1,AB[i][1]-1)

ans=0
for i in range(n):
    ans=max(ans,size(i))

print(ans)


Measured memory_bytes: 53296
from fractions import gcd

def answer():
    def make_divisors(n):
        divisors = []
        for i in range(1, int(n ** 0.5) + 1):
            if n % i == 0:
                divisors.append(i)
                if i != n // i:
                    divisors.append(n // i)

        divisors.sort()
        return divisors

    a, b = map(int, input().split())
    g = gcd(a, b)
    divisors = make_divisors(g)

    length = len(divisors)
    removed = 1

    for i in range(1, length):
        d1 = divisors[i]
        for d2 in divisors[i:-1]:
            if d1 * d2 in divisors:
                divisors.remove(d1*d2)
                removed += 1
        if i + removed >= length:
            break

    print(length - removed + 1)


if __name__ == '__main__':
    answer()


Measured memory_bytes: 5340
#include <bits/stdc++.h>
#define LL long long
#define Accel ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define Re(a,b) memset(a,b,sizeof a)
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define ALL(X) (X).begin(), (X).end()
#define FOR(I, A, B) for (int I = (A); I <= (B); I++)
#define REP(I, N) for (int I = 0; I < (N); I++)
#define PII pair<int,int>
#define PLL pair<LL,LL>
#define SZ(a) ((int)a.size())
//#pragma GCC optimize(2)
using namespace std;
const int N=1e5+10;
const int M=1e9+7;
const int inf=1e9+7;
const double eps=1e-6;
typedef complex<double>C;
const double PI(acos(-1.0));
//for(int mask=i;mask>0;mask=(mask-1)&i)
//int a[25]= { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97 };
//__gcd, atan2(y,x)=y/x , __int128
//c(n,k)=c(n-1,k-1)+c(n-1,k)
//c(i,r),i for r to n =c(n+1,r+1)
//void add(int x){while(x<N)BIT[x]++,x+=x&-x;}
//void add(int x){while(x<N)BIT[x]++,x+=x&-x;}
//int sum(int x){int t=0;while(x){t+=BIT[x];x-=x&-x;}return t;}
//LL pw(LL a,LL b){LL t=1;for(;b;b>>=1,a=a*a%M)b&1?t=t*a%M:0;return t;}
//log() = ln() , log(x)/log(y)=log(y)-base-x
//INT_MAX 127,INT_MIN 128
//int dw[4][2]={{0,1},{1,0},{0,-1},{-1,0}};
//int dw[8][2]={{0,1},{1,0},{0,-1},{-1,0},{1,1},{1,-1},{-1,1},{-1,-1}};
//cout<<fixed<<setprecision(12)<<ans<<endl;
//__builtin_popcount(mask)
LL n,m,d;
int main(){Accel
	cin>>n>>m>>d;

	double ans=n-d;
	if(d)ans*=2;
	ans*=m-1;
	ans/=n;
	ans/=n;
	cout<<fixed<<setprecision(12)<<ans<<endl;
}

Measured memory_bytes: 256
###template###
import sys
def input(): return sys.stdin.readline().rstrip()
def mi(): return map(int, input().split())
###template###

N, P = mi()

def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct

flist = factorize(P)

ans = 1 #絶対1以上
for fctr, nowcnt in flist:
  if nowcnt//N >= 1:
    ans *= (fctr ** (nowcnt//N))

print(ans)



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

int main(){
    int n;
    cin >> n;
    int a[n];
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    for(int i=0;i<n;i++){
        cout << a[i];
        if(i!=n-1){
            cout << " ";
        }else{
            cout << endl;
        }
    }
    for(int i=1;i<n;i++){
        int v = a[i];
        int j = i-1;
        for(;j>=0 && a[j] > v;j--){
            a[j+1] = a[j];
        }
        a[j+1] = v;
        for(int i=0;i<n;i++){
            cout << a[i];
            if(i!=n-1){
                cout << " ";
            }else{
                cout << endl;
            }
        }
    }
}


Measured memory_bytes: 3096
#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<iostream>
#include<cmath>
#include<map>
#include<set>
using namespace std;
typedef vector<string>vs;
typedef vector<int>vi;
typedef vector<vi>vvi;
typedef vector<double>vd;
typedef pair<int,int>pii;
typedef long long ll;
typedef pair<ll,ll>pll;
typedef vector<ll>vl;
#define rrep(i,x,n) for(int i=(x);i<(n);++i)
#define rep(i,x) rrep(i,0,(x))
#define fi first
#define se second
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define maxs(a,b) (a)=max(a,b)
#define mins(a,b) (a)=min(a,b)

bool check(string sub){
    map<char,int>M;
    rep(i,sub.size())M[sub[i]]++;

    if(M['A']==2&&M['I']==1&&M['D']==1&&M['U']==1&&M['N']==2&&M['Y']==1){
            return true;
    }
    return false;
}

int main(){
    string str;
    cin>>str;
    int idx=0;
    while(idx<str.size()){
        if(idx+8<=str.size()&&check(str.substr(idx,8))){
            cout<<"AIZUNYAN";
            idx+=8;
        }
        else{
            cout<<str[idx];
            idx++;
        }
    }
    cout<<endl;

    return 0;
}

Measured memory_bytes: 1184
/******************************************
*    AUTHOR:         julianferres         *
******************************************/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define forr(i, a, b) for(int i = (a); i < (int) (b); i++)
#define forn(i, n) forr(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define DBG(x) cerr << #x << " = " << (x) << endl
#define esta(x,c) ((c).find(x) != (c).end())
#define RAYA cerr << "===============================" << endl
const int N = 3005;

vector<vi> dp(N, vi(N,-1));
int n;
vi a(N);

ll fill(int l, int r){
    if(dp[l][r]!=-1) return dp[l][r];

    if(l > r)
        return dp[l][r] = 0;
    if (l == r)
        return dp[l][r] = a[l];
    if(l+1 == r)
        return dp[l][r] = max(a[l] - a[r], a[r] - a[l]);

    ll ansll = fill(l + 2, r) + a[l] - a[l + 1];
    ll anslr = fill(l + 1, r - 1) + a[l] - a[r];
    ll ansrl = fill(l + 1, r - 1) + a[r] - a[l];
    ll ansrr = fill(l, r - 2) + a[r] - a[r - 1];

    return dp[l][r] = max(min(ansll,anslr),min(ansrl,ansrr));
}

int main(){
    FIN;
    cin >> n;
    forn(i, n) cin >> a[i];

    fill(0, n - 1);
    cout << dp[0][n - 1] << endl;
    return 0;
}



Measured memory_bytes: 71040
#include<stdio.h>
#include<string.h>
//言語は「C++14(GCC 5.4.1)」
//AtCoder Beginner Contest 58-A

int main(void)
{
	int A, B, C;
	scanf("%d", &A);
	scanf("%d", &B);
	scanf("%d", &C);
	if (B - A == C - B)
		printf("YES");
	else
		printf("NO");
	return 0;
}

Measured memory_bytes: 128
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys  # {{{
import os
import time
import re
from pydoc import help
import string
import math
from operator import itemgetter
from collections import Counter
from collections import deque
from collections import defaultdict as dd
import fractions
from heapq import heappop, heappush, heapify
import array
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy as dcopy
import itertools
# }}}

# pre-defined{{{
sys.setrecursionlimit(10**7)
INF = 10**20
GOSA = 1.0 / 10**10
MOD = 10**9+7
ALPHABETS = [chr(i) for i in range(ord('a'), ord('z')+1)]  # can also use string module
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 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 DP(N, M, first): return [[first] * M for n in range(N)]
def DP3(N, M, L, first): return [[[first] * L for n in range(M)] for _ in range(N)]
from inspect import currentframe
# }}}

def solve():
    s = input()
    if s == "ABC":
        print("ARC")
    else:
        print("ABC")

    return 0

if __name__ == "__main__":# {{{
    solve()

# vim: set foldmethod=marker: }}}


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

typedef long long ll;
#define pa pair<int, int> 
#define pal pair<long long, long long>
#define pad pair<double, double>
#define pb push_back
#define mp make_pair
#define VIN(v) for(int64_t i=0;i<(v).size();i++){cin >> (v).at(i);}

typedef vector<bool> bvec;
typedef vector<int> ivec;
typedef vector<long long> lvec;
typedef vector<double> dvec;
typedef vector<pa> pvec;

typedef vector< vector<bool> > bmat;
typedef vector< vector<int> > imat;
typedef vector<string> svec;
typedef vector< vector<string> > smat;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    lvec a(n);
    ivec m(2, 0);
    for (int i=0; i<n; i++) cin >> a[i];
    for (int i=0; i<n; i++) {
        if(m[0]< a[i]) m[0] = a[i];
        else if(m[1] < a[i]) m[1] = a[i];
    }

    for (int i=0; i<n; i++){
        if (a[i] == m[0]) cout << m[1] << endl;
        else cout << m[0] << endl;
    }
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define INT(str) stoi((str), 0)
#define INTB(str) stoi((str), 0, 2) // 2進数の文字列を int に
//cout << fixed << setprecision(15);

int main() {
  string s;
  cin >> s;
  if(s[s.size()-1] == 's') {
    s += "e";
  }
  cout << s + "s" << endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
  ll K;
  cin>>K;
  string S;
  cin>>S;
  if(S.size()<=K) {
cout<<S<<endl;
  }
  else {
for(ll i=0;i<K;i++) {
cout<<S[i];
}
    cout<<"..."<<endl;
  }
  
}


Measured memory_bytes: 3600
//minamoto
#include<bits/stdc++.h>
#define R register
#define inline __inline__ __attribute__((always_inline))
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
char buf[1<<21],*p1=buf,*p2=buf;
inline char getc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}
int read(){
    R int res,f=1;R char ch;
    while((ch=getc())>'9'||ch<'0')(ch=='-')&&(f=-1);
    for(res=ch-'0';(ch=getc())>='0'&&ch<='9';res=res*10+ch-'0');
    return res*f;
}
int read(char *s){
	R int len=0;R char ch;while(((ch=getc())>'Z'||ch<'A'));
	for(s[++len]=ch;(ch=getc())>='A'&&ch<='Z';s[++len]=ch);
	return s[len+1]='\0',len;
}
const int N=2e5+5;
char s[N],t[N];int n,m,len,sx,sy;
bool calc(int n,int x,char a,char b){
	int p=x;
	fp(i,1,len){
		if(s[i]==b)++p;if(p>n)return false;
		if(t[i]==a)p=max(p-1,1);
	}
	p=x;
	fp(i,1,len){
		if(s[i]==a)--p;if(p<1)return false;
		if(t[i]==b)p=min(p+1,n);
	}
	return true;
}
int main(){
//	freopen("testdata.in","r",stdin);
	n=read(),m=read(),len=read(),sx=read(),sy=read(),read(s),read(t);
	puts(calc(n,sx,'U','D')&&calc(m,sy,'L','R')?"YES":"NO");
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <cstdlib>  // abs() for integer
#include <cmath>
#include <bitset>

using namespace std;


int main(void) {
    int a;
    string s;
    cin >>a>>s;
    if (a>=3200)
        cout << s;
    else cout <<"red";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

int main() {
    int N;
    cin >> N;
    
    vec<int> A(N);
    rep(i, N) cin >> A[i];
    
    vec<int> B(N);
    rep(i, N) cin >> B[i];
    
    vec<int> C(N);
    rep(i, N) cin >> C[i];

    sort(all(A));
    sort(all(B));
    sort(all(C));

    ll ans = 0;
    rep(i,N) {
        ll cntA = lower_bound(all(A),B[i]) - A.begin();
        ll cntC = N - (upper_bound(all(C),B[i]) - C.begin());
        ans += cntA*cntC;
    }
    cout << ans << endl;
}


Measured memory_bytes: 4576
//In the name of ALLAH the most merciful the most beneficial

#include<cstdio>
#include<cstring>
#include<bits/stdc++.h>
#include<iostream>
#include<math.h>
#include<fstream>
#define sc(x) scanf("%d",&x)
#define ll long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORd(i,a,b) for(int i=a;i>b;i--)
#define ff first
#define ss second
#define sz(x) x.size()
#define pb push_back

using namespace std;

typedef pair<int,int> pii;
typedef vector<pii> vii;
const int con = 1e9;
static const int INF = 0x3f3f3f3f;
static const int MOD = 998244353;

int main(){

    int arr[4];
    FOR(i,0,4)
        sc(arr[i]);
    sort(arr,arr+4);
    if(arr[0] == 1 && arr[1] == 4 && arr[2] == 7 && arr[3] == 9)
        cout << "YES";
    else
        cout << "NO";
    return 0;
}



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

int main(){
  int n;
  cin >> n;
  char hina[n];
  for(int i = 0; i < n; i++){
    cin >> hina[i];
  }
  for(int i = 0; i < n; i++){
    if( hina[i] == 'Y' ){
      cout << "Four\n";
      break;
    }else if( i == n-1 )
      cout << "Three\n";
  }

  return 0;
}


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

public class Program
{
    static void Main()
    {
        var grid = new int[3][];
        for (int i = 0; i < 3; i++)
        {
            grid[i] = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        }

        var min = grid.Select(x => x.Min()).Min();
        grid = grid.Select(x => x.Select(y => y - min).ToArray()).ToArray();

        //全探索
        for (int i = 0; i <= 100; i++)
        {
            var a = new int[3];
            var b = new int[3];

            a[0] = i;
            for (int j = 0; j < 3; j++)
            {
                b[j] = grid[0][j] - a[0];
            }

            for (int j = 1; j < 3; j++)
            {
                a[j] = grid[j][0] - b[0];
            }

            var flag = true;
            for (int row = 0; row < 3; row++)
            {
                for (int col = 0; col < 3; col++)
                {
                    if (grid[row][col] != a[row]+b[col])
                    {
                        flag = false;
                        break;
                    }
                }
            }

            if (flag)
            {
                Console.WriteLine("Yes");
                return;
            }
        }

        Console.WriteLine("No");
    }
}

Measured memory_bytes: 13908
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int N;
    cin >> N;
    string S;
    cin >> S;
    vector<int> a(3);
    int ans = 0;
    for (int i = 0; i < 1000; i++) {
        a[0] = i / 100;
        a[1] = (i % 100) / 10;
        a[2] = i % 10;
        int id = 0;
        for(auto &&s : S){
            if(s-'0' == a[id]) id++;
            if(id == 3) break;
        }
        if(id == 3) ans++;
    }
    pr(ans);
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>

using namespace std;

#define ll long long
#define ld long double
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

const double PI=acos(-1);
const double EPS=1e-9; //うまくいかなかったらゆるめる

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

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

#define in(a,b,c) pip(a,pii(b,c))

signed main(void) {
    int n,m;
    cin >> n >> m;
    vvi g(n);
    rep(i,m){
        int a,b;
        cin >> a >> b;
        a--,b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    priority_queue< pii, vector<pii>, greater<pii> > q;
    q.push(pii(0,0));//きょり、頂点
    vector<pii> d(n,pii(INF,-1));//距離、前の頂点
    d[0] = pii(0,-1);
    while(q.size()){
        pii p = q.top();
        q.pop();
        int v = p.second;
        if(d[v].first < p.first)continue;
        rep(i,g[v].size()){
            int to = g[v][i];
            if(d[to].first > d[v].first + 1){
                d[to] = pii(d[v].first + 1, v);
                q.push(pii(d[to].first,to));
            }
        }
    }
    cout << "Yes" << endl;
    loop(i,1,n){
        cout << d[i].second+1 << endl;
    }
}


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

using namespace std;

inline int read(){
	char ch=getchar();int x=0,f=1;
    while(ch<'0' || ch>'9') {
       if(ch=='-') f=-1;
	  	  ch=getchar();
	}
    while(ch<='9' && ch>='0') {
	   x=x*10+ch-'0';
	   ch=getchar();
	}
    return x*f;
}

int n;

int main(){
	n=read();
	int sum=0;
	for(int i=1;i<=n;i++){
		int k=read();
		while(k%2==0){
			sum++;
			k/=2;
		}
	}
	printf("%d\n",sum);
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <cmath>

using namespace std;
long long n,ans;

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cin >> n;
    vector<int> H(n);
    for (int i = 0; i < n; i++) {
        cin >> H[i];
    }

    long long cpath = 0;
    for (int i = 0; i < n - 1; i++) {
        if (H[i] >= H[i+1]) {
            cpath++;
        } else {
            ans = max(ans, cpath);
            cpath = 0;
        }
    }
    ans = max(ans, cpath);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
using namespace std;
typedef long long ll;
#define rep(i,a,n)	for(int i=a;i<n;i++)
#define rrep(i,a,n) for(int i=(a-1);i>=n;i--)
 
ll gcd(ll a,ll b){
	if(b==0)return a;
	return gcd(b,a%b);
}
ll lcm(ll a,ll b){
	ll g=gcd(a,b);
	return a/g*b;
}
 
ll digitsum(ll a){
	ll x=0;
	while(a>0){
		x+=a%10;
		a/=10;
	}
	return x;
}
int main(){
	ll n;
	cin>>n;
	ll sum=0;
	rep(i,0,n){
		ll a;
		cin>>a;
		sum+=(a-1);
	}
	cout<<sum<<endl;
}

Measured memory_bytes: 888
import java.util.*;
public class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
 
        int N = sc.nextInt();
        
        int otsuri;
        if(N%1000==0)otsuri=0;
        else{
            int Amari = N%1000;
            otsuri = 1000-Amari;
        }
        System.out.println(otsuri);
    }
}

Measured memory_bytes: 35372
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>

using namespace std;

typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define Fst first
#define Snd second
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))

const char s[2][15] = {"Possible" , "Impossible"};
int N;
int a;
int x[100];
int m = 99;
bool b;

int main(){
	scanf("%d" , &N);
	for(int i = 0 ; i < N ; ++i){
		scanf("%d" , &a);
		++x[a];
		m = min(m , a);
	}
	b = (x[m] < 3);
	int z;
	if(b) z = 2 * m + 1 - x[m];
	for(int i = m + 1 ; b && i < 100 ; ++i){
		if(i <= z  && x[i] < 2) b = 0;
		if(i > z && x[i] > 0) b = 0;
	}
	printf("%s\n" , b ? s[0] : s[1]);
	return 0;
}


Measured memory_bytes: 128
/*
Saurabh Joshi
IIIT Jabalpur
*/
#include<bits/stdc++.h>
#define LL long long int
#define M 1000000007
#define endl "\n"
#define eps 0.00000001
LL pow(LL a,LL b,LL m){LL x=1,y=a;while(b > 0){if(b%2 == 1){x=(x*y);if(x>m) x%=m;}y = (y*y);if(y>m) y%=m;b /= 2;}return x%m;}
LL gcd(LL a,LL b){if(b==0) return a; else return gcd(b,a%b);}
LL gen(LL start,LL end){LL diff = end-start;LL temp = rand()%start;return temp+diff;}
using namespace std;
double a[100001];
vector<pair<int , int> > v;
int main()
    {
        ios_base::sync_with_stdio(0);
        int n;
        double sum = 0;
        cin >> n;
        for(int i = 1; i <= n; i++) {
            cin >> a[i];
            sum += a[i];
        }
        for(int i = 1; i <= n; i++) {
            v.push_back({abs(sum - a[i] * n) , i});
        }
        sort(v.begin() , v.end());
        cout << v[0].second - 1;
    }

Measured memory_bytes: 256
import java.util.*;
import java.util.stream.Collectors;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	int N;
	List<String> list;
	Map<String, Integer> map;
	List<String> result;

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	Main(BufferedReader in) throws IOException {
		N = Integer.parseInt(in.readLine());
		list = new ArrayList<>(N);
		for (int i = 0; i < N; ++i) {
			list.add(in.readLine());
		}
	}

	void calc() {
		map = new HashMap<>();
		for (String str : list) {
			if (map.containsKey(str)) {
				map.put(str, map.get(str) + 1);
			} else {
				map.put(str, 1);
			}
		}
		// 最大の回数を求める
		int count = 0;
		for (Integer val : map.values()) {
			count = Math.max(val, count);
		}
		// 最大の回数と同じ回数出現した要素を求める
		result = new ArrayList<>();
		for (String str : map.keySet()) {
			if (count == map.get(str)) {
				result.add(str);
			}
		}
		Collections.sort(result);
	}

	void showResult() {
		for (String str : result) {
			System.out.println(str);
		}
	}
}


Measured memory_bytes: 66576
#include <iostream>
#include <vector>
#define repeat(i,n) for (int i = 0; (i) < (n); ++(i))
using namespace std;
const int inf = 1e9+7;
int main() {
    int n, t; cin >> n >> t;
    vector<int> a(n); repeat (i,n) cin >> a[i];
    vector<int> minacc(n+1); minacc[0] = inf; repeat (i,n) minacc[i+1] = min(minacc[i], a[i]);
    auto profit = [&](int i) { return a[i] - minacc[i+1]; };
    int max_profit = -1, cnt = 0;
    repeat (i,n) {
        if (max_profit < profit(i)) {
            max_profit = profit(i);
            cnt = 1;
        } else if (max_profit == profit(i)) {
            cnt += 1;
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 1656
//#include <climits>
//#include <vector>
#include <iostream>
#include <math.h>
using namespace std;

bool isPrime(int number) {

    //1は素数ではない
    if(number == 1) {
        return false;
    }

    //2は素数
    if(number == 2) {
        return true;
    }

    //偶数は素数ではない
    if(number % 2 == 0) {
        return false;
    }

    //素数判定
    for (int i = 3; i <= sqrt(number); i+=2)
    {
        //割り切れるときは素数ではない
        if(number % i == 0) {
            return false;
        }
    }

    //素数
    return true;
}


int main() {

    int n;
    cin >> n;

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

        if(isPrime(number)) {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

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

// 自動でmodを取ってくれる整数型
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

mint f(int n){ // 2のn乗
    if(n==0) return 1;
    mint x=f(n/2);
    x*=x;
    if(n%2==1) x*=2;
    return x;
}

// a^n mod を計算する
long long modpow(long long a, long long n) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//////////////////////////
int main(){
    string k;
    ll d;
    cin>>k>>d;
    int n=k.size();
    vector<vector<mint>> dp(d, vector<mint>(2,0));
    dp[0][0]=0;
    dp[0][1]=1;
    rep(i,n){
        ll c=k[i]-'0';
        vector<vector<mint>> dpt(d, vector<mint>(2,0));
        rep(j,d){
            rep(l,10){
                if(l<c){
                    dpt[(j+l)%d][0]+=dp[j][0];
                    dpt[(j+l)%d][0]+=dp[j][1];
                }
                else if(l==c){
                    dpt[(j+l)%d][0]+=dp[j][0];
                    dpt[(j+l)%d][1]+=dp[j][1];
                }
                else dpt[(j+l)%d][0]+=dp[j][0];
            }
        }
        dp=dpt;
    }
  cout<<dp[0][1]+dp[0][0]-1<<endl;
}


Measured memory_bytes: 3644
//
// Created by ss250251 on 2/16/2020.
//

#include<bits/stdc++.h>
using namespace std;
#define INFL 1e18L + 7
#define MOD 1e9+7
template <typename T>
void max_self(T&a,T b){
    a = max(a,b);
}
template <typename T>
void min_self(T&a,T b){
    a = min(a,b);
}
template <typename T>
void add_self(T&a,T b){
    a +=b;
    if(a>=1e9+7){
        a-=(1e9+7);
    }
}
template <typename T>
void sub_self(T&a,T b){
    a -=b;
    if(a<0){
        a+=(1e9+7);
    }
}
using ll= long long;
int main(){
    int n;
    cin>>n;
    vector<vector<int>>compatible(n,vector<int>(n));
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cin>>compatible[i][j];
        }
    }
    vector<int>dp(1<<n);
    int mask=0;
    dp[0]=1;
//    for(int man = 0;man < n;man++){
        for(int mask = 0;mask<(1<<n)-1;mask++){
            int man = __builtin_popcount(mask);
            for(int woman =0;woman<n;woman++){
                if(compatible[man][woman] && !(mask&(1<<woman))){
                    int new_mask = mask ^ (1<<woman);
                    add_self(dp[new_mask], dp[mask]);
                }
            }
        }
//    }
    cout<<dp[(1<<n)-1];
}

Measured memory_bytes: 8448
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;

const int mod = 1e9 + 7;
int dp[1001][1001];
char a[1001][1001];

int main(){
    int n, m;
    cin >> n >> m;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            cin >> a[i][j];
        }
    }
    dp[0][0] = 1;
    for(int i = 1; i < n; i++){
        if(a[0][i] != '#')dp[0][i] = dp[0][i-1];
    }
    for(int i = 1; i < m; i++){
        if(a[i][0] != '#')dp[i][0] = dp[i-1][0];
    }
    for(int i = 1; i < n; i++){
        for(int j = 1; j < m; j++){
            if(a[i][j] !=  '#'){
                dp[i][j] = dp[i-1][j] + dp[i][j-1];
                dp[i][j] %= mod;
            }
        }
    }
    cout << dp[n-1][m-1] << endl;
    return 0;
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
#include<chrono>
using namespace std;
using ll = long long;

int main() {
  ll X;
  cin >> X;
  ll ans = 0;
  ll m = 100;
  while (true) {
    if (m >= X) {
      break;
    }
    m *= 1.01;
    ans++;
  }
  cout << ans << endl;
}

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

using namespace std;

int main()
{
    vector<string> X;
    for(;;){
        string s;
        cin >> s;
        if(s == "0") break;
        X.push_back(s);
    }

    for(int i = 0; i < X.size(); i++){
        int sum = 0;
        string x = X.at(i);
        for(int j = 0; j < x.size(); j++){
            sum += (int)(x.at(j) - '0');
        }
        cout << sum << endl;
    }

}


Measured memory_bytes: 3176
#include <iostream>
#define llint long long

using namespace std;

llint n;
short dp[1<<8][1<<15][5];

int main(void)
{
	dp[1][0][0] = 1;
	llint N = 1<<15, M = 1<<8;
	for(int i = 0; i < M-1; i++){
		for(int j = 0; j < N; j++){
			for(int k = 0; k <= 4; k++){
				dp[i+1][j][k] += dp[i][j][k];
				if(j+i*i < N && k+1 <= 4) dp[i][j+i*i][k+1] += dp[i][j][k];
			}
		}
	}
	
	while(1){
		cin >> n;
		if(n == 0) break;
		llint ans = 0;
		for(int i = 1; i <= 4; i++) ans += dp[M-1][n][i];
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 84972
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=1e9+7;
const int size=1e6;
const int inf=1e9;
int N;
priority_queue<pair<long,pair<int,int>>> pq;
class union_find{//union by rank
public:
	vector<int> g;
	union_find(int n){
		rep(i,0,n) g.push_back(i);
	}
	int root(int v){
		if(this->g[v]==v) return v;
		else{ this->g[v]=root(this->g[v]);return this->g[v]; }
	}
	void unite(int x,int y){ 
		this->g[root(x)]=root(y);
		return;
	}
	bool same(int x,int y){
		return root(x)==root(y);
	}
};
long kruskal(union_find uf){// O(ElogV)
	long cost=0;
	int v,u;
	while(!pq.empty()){
		v=pq.top().second.first;
		u=pq.top().second.second;
		if(!uf.same(v,u)){
			uf.unite(v,u);
			cost-=pq.top().first;
		}pq.pop();
	}return cost;
}
int main(){
	cin>>N;
	long X[N],Y[N];
	pair<long,int> vx[N],vy[N];
	rep(i,0,N){
		cin>>X[i]>>Y[i];
		vx[i]={X[i],i};
		vy[i]={Y[i],i};
	}
	sort(vx,vx+N);
	sort(vy,vy+N);
	int v,u;
	union_find uf(N);
	rep(i,0,N-1){
		v=vx[i].second;
		u=vx[i+1].second;
		if(abs(X[v]-X[u]) <= abs(Y[v]-Y[u])){
			pq.push({-abs(X[v]-X[u]),{v,u}});
		}
		v=vy[i].second;
		u=vy[i+1].second;
		if(abs(Y[v]-Y[u]) <= abs(X[v]-X[u])){
			pq.push({-abs(Y[v]-Y[u]),{v,u}});
		}
	}
	cout<<kruskal(uf)<<endl;
}

Measured memory_bytes: 11504
////////////////////////////////////////////
///                                      ///
///         Template ver. 1 rapel        ///
/// Fear is Temporary, Regret is Forever ///
///          Must Try and Get AC         ///
///                                      ///
////////////////////////////////////////////
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <iomanip>

#include <algorithm>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <utility>

#include <math.h>
#include <complex>

#include <assert.h>
#include <time.h>
//#include <chrono>
//#include <random>

#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <list>
#include <bitset>

#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define endl '\n'
using namespace std;

typedef long long LL;
typedef unsigned long long ULL;

void desperate_optimization(int precision){
  	ios_base::sync_with_stdio(false);
  	cin.tie(0);
  	cout.tie(0);
  	cout.setf(ios::fixed);
  	cout.setf(ios::showpoint);
  	cout.precision(precision);
}

void hora(int tc) {
	int m, d;
	int tot = 0;
	cin>>m>>d;
	for(int i = 22;i <= d;i++) {
		int u = i / 10;
		int v = i % 10;
		if(u < 2 || v < 2) continue;
		if(u * v <= m) tot++;
	}
	cout<<tot<<endl;
}

int main(){
	desperate_optimization(10);
	int ntc = 1;
	//cin>>ntc;
	for(int tc = 1;tc <= ntc;tc++) hora(tc);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/
 

// void chmod(ll &M){
//     if(M >= mod) M %= mod;
//     else if(M < 0){
//         M += (abs(M)/mod + 1)*mod;
//         M %= mod;
//     }
// }

const ll mod = 1e9+7;


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
 
    int n; cin >> n;
    vector<ll> a(n), r(n, 0);
    ll sum = 0;
    for(int i=0; i<n; ++i) { cin >> a[i]; sum += a[i]; }

    ll part = 0;
    for(int i=1; i<=n-2; i+=2) part += 2*a[i];

    r[0] = sum - part;
    for(int i=1; i<n; ++i) r[i] = 2*a[i-1]-r[i-1];

    for(int i=0; i<n; ++i){
        if(i) cout << ' ';
        cout << r[i];
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 2944
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = int.Parse(line[0]);
        var b = int.Parse(line[1]);
        var c = int.Parse(line[2]);
        Console.WriteLine(c /a * b);
    }
}

Measured memory_bytes: 11092
results = Array.new
while true do
   result = gets.split.map(&:to_i)
   if result[0] == -1 && result[1] == -1 && result[2] == -1
      break
   end
   results << result
end

ans = []
results.each do |val|
   goukei = val[0] + val[1]
   if val[0] == -1 || val[1] == -1
      ans.push "F"
   elsif goukei >= 80
      ans.push "A"
   elsif goukei >= 65 && goukei < 80
      ans.push "B"
   elsif goukei >= 50 && goukei < 65
      ans.push "C"
   elsif goukei >= 30 && goukei < 50
      if val[2] >= 50
         ans.push "C"
      else
         ans.push "D"
      end
   elsif goukei < 30
      ans.push "F"
   end
end

ans.each do |an|
   puts an
end

Measured memory_bytes: 8596
# include <iostream>
using namespace std;
const int N=56;
string a[N];
int n,m;
void work (void)
{
	int i,j,f;
	f=1;
	for (i=0;i<n;i++)
	for (j=0;j<m;j++)
	if (a[i][j]=='#')
	{
		f=0;
		if (i>0&&a[i-1][j]=='#')
		f=1;
   else if (j>0&&a[i][j-1]=='#')
		f=1;
   else if (i<=n-2&&a[i+1][j]=='#')
		f=1;
   else if (j<=m-2&&a[i][j+1]=='#')
		f=1;
		if (f==0)
		goto loop;
	}
	loop:;
	if (f==1)
	cout<<"Yes";
else cout<<"No";
}
int main (void)
{
	int i;
	cin>>n>>m;
	for (i=0;i<n;i++)
	cin>>a[i];
	work ();
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
typedef long long ll;
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll n,ans=0;
  cin>>n;
  for(ll i=1;i<n;i++){
    ans+=i;
  }
  cout<<ans<<endl;
  return 0;
}


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

int main(void)
{
  int D; cin >> D;
  if(D==25)cout<<"Christmas"<<endl;
  else if(D==24)cout<<"Christmas Eve"<<endl;
  else if(D==23)cout<<"Christmas Eve Eve"<<endl;
  else if(D==22)cout<<"Christmas Eve Eve Eve"<<endl;

  return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int A = s.nextInt();
        int B=s.nextInt();
        int C=Math.max((A+B),(A-B));

        System.out.print(Math.max(C,(A*B)));
        }
    }


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

int main() {
    long long K;
    cin >> K;
    int x = 7%K;
    set<int> s;
    int i=1;
    while (s.count(x)==0) {
        if (x==0) {
            cout << i << endl;
            return 0;
        }
        s.insert(x);
        x = (x*10+7)%K;
        ++i;
    }
    cout << "-1" << endl;
    return 0;
}

Measured memory_bytes: 50504