akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include <stdlib.h>
#include<string.h>
#include<math.h>
#define loop(i, l, r) for(i=l; i<r; i++)/*Instead of function, (for).*/
#define rep(i,r) for(i=0; i<r; i++)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
typedef long long int lli;
/*Return Combination ,(nCr)*/
int combi(int n, int r)
{
	if(r==0 || r==n) return 1;
	else return combi(n-1,r) + combi(n-1,r-1);
}
/*Return gcd(a, b)*/
int gcd(int a, int b){
	if(b == 0) return a;
	else return gcd(b, a % b);
}
//qsort�֐��Ɏg��compare�֐�,(long long int, int, double�^)
int compare_lli(const void *a, const void *b)
{
    return *(lli*)a - *(lli*)b;
}
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}
int compare_double(const void *a, const void *b)
{
    return *(double*)a - *(double*)b;
}
/*qsort(data, 10, sizeof(int_lli_double), compare_int);*/
/*qsort(�z��, �v�f��, sizeof(�z��̌^), compare_�z��̌^);*/
int main(void)
{
	lli n, i, j, max=0;
	scanf("%lld", &n);
	lli a[n], b[n];
	rep(i,n) scanf("%lld", &a[i]);
	memcpy(b, a, sizeof(a));
	qsort(a, n, sizeof(lli), compare_lli);
	rep(i,n){
		j = n-1;
		if(a[j] == b[i]) j--;
		printf("%lld\n", a[j]);
	}
	return 0;
}

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

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

int main(){
	int K;
	cin >> K;
	
	int ans=0;
	
	repn(a,K){
		repn(b,K){
			repn(c,K){
			ans+=gcd(gcd(a,b),c);
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3616
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
using namespace std;
 
int main() {
	int n,t;
	int a[100000],maa = 0,masa = 0,cnt = 1;
	cin >> n >> t;
	for(int i = 0;i < n;i++){
		cin >> a[i];
	}
	for(int i = n - 1;i >= 0;i--){
		if(a[i] > maa) maa = a[i];
		if(masa == maa - a[i]) {
			cnt++;
		}else if(masa < maa - a[i]){
			cnt = 1;
			masa = maa - a[i];
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define in inline
#define re register
using namespace std;
in int read() {
	re int t=0;
	re char v=getchar();
	while(v<'0'||v>'9')v=getchar();
	while(v>='0'&&v<='9') {
		t=(t<<3)+(t<<1)+(v^48);
		v=getchar();
	}
	return t;
}
char s[14];
signed main(){
	scanf("%s",s+1);
	if(s[2]=='B')puts("ARC");
	else puts("ABC");
}

Measured memory_bytes: 3772
const main = (txt: any): void => {
  const input = txt.split('\n')
  let [W, H, N] = input[0].split(' ').map((i: string) => { return Number(i) })
  let Ma1 = 0
  let Ma2 = W
  let Ma3 = 0
  let Ma4 = H
  for (let i = 1; i <= N; i++) {
    const [x, y, a] = input[i].split(' ').map((i: string) => { return Number(i) })
    if (a === 1 && x > Ma1) {
      Ma1 = x
    }
    if (a === 2 && x < Ma2) {
      Ma2 = x
    }
    if (a === 3 && y > Ma3) {
      Ma3 = y
    }
    if (a === 4 && y < Ma4) {
      Ma4 = y
    }
  }
  const Wn = Ma2 - Ma1
  const Hn = Ma4 - Ma3
  const sum = (Ma2 - Ma1) * (Ma4 - Ma3)
  if (sum >= 0 && Wn > 0 && Hn > 0) {
    console.log(sum)
  }
  else {
    console.log('0')
  }
}


main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7500
def main():
    a = [int(x) for x in input().split()]
    H, W = a[0], a[1]
    grid = [input() for _ in range(H)]
    dp = [[0 for _ in range(W)] for _ in range(H)]
    modder = int(1e9 + 7)
    dp[0][0] = 1
    for row in range(H):
        for col in range(W):
            for row2 in range(row, row+2):
                col2 = col + 1 if row2 == row else col
                if row2 < H and col2 < W and grid[row2][col2] == ".":
                    dp[row2][col2] = (dp[row][col] + dp[row2][col2]) % modder
    print(dp[H-1][W-1])


main()


Measured memory_bytes: 44620
class UnionFind:
    def __init__(self, n):
        self.d = []
        for _ in range(n):
            self.d.append(-1)

    def find(self, x):
        if self.d[x] < 0:
            return x
        else:
            self.d[x] = self.find(self.d[x])
            return self.d[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return False
        if self.d[x] > self.d[y]:
            x, y = y, x
        self.d[x] = self.d[x] + self.d[y]
        self.d[y] = x
        return True

    def same(self, x, y):
        return self.find(x) == self.find(y)
    
    def size(self, x):
        return -self.d[self.find(x)]

n, m, k = map(int, input().split())
uf = UnionFind(n)
dame = [set() for _ in range(n)]

for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    uf.unite(a, b)
    dame[a].add(b)
    dame[b].add(a)

for i in range(k):
    c, d = map(int, input().split())
    c -= 1
    d -= 1
    if not uf.same(c, d):
        continue
    dame[c].add(d)
    dame[d].add(c)

for i in range(n):
    ans = uf.size(i) - 1
    ans -= len(dame[i])
    print(ans, end=" ")

Measured memory_bytes: 62116
/*
g++ --std=c++17 A.cpp
*/

#include <iostream>
#include <iomanip> //! for setprecision(20)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>
#include <limits.h>

using namespace std;

typedef long long LL;

#define rep(i,n) for (int i = 0; i < int(n); ++i)
template<class T> inline bool chmax(T& a, T b) { bool ret = (a < b); if (ret) { a = b; } return ret; }
template<class T> inline bool chmin(T& a, T b) { bool ret = (b < a); if (ret) { a = b; } return ret; }
#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define dumpMap(m) { for (auto it: m) cout << it.first << "=>" << it.second << ' '; }

const int INF = 1e9;
const LL INFL = 1e18;
const int MOD = 1000000007;


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

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

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

  queue<pair<int, int>> q;
  int white = h * w;
  rep(y, h) rep(x, w) {
    if (a[y][x] == '#') {
      q.emplace(y, x);
      --white;
    }
  }

  int ans = 0;
  while (0 < white && !q.empty()) {
    queue<pair<int, int>> nq;
    ++ans;
    while (!q.empty()) {
      int cy = q.front().first; 
      int cx = q.front().second;
      rep(i, 4) {
        int y = cy + dy[i];
        int x = cx + dx[i];
        if (0 <= x && x < w && 0 <= y && y < h && a[y][x] == '.') {
          a[y][x] = '#';
          nq.emplace(y, x);
          --white;
        }
      }
      q.pop();
    }
    q.swap(nq);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 12368
n = int(input())
for i in range(n):
    x1, y1, x2, y2, x3, y3, x4, y4 = map(float, input().split())
    print("YES" if abs((x2 - x1) * (y4 - y3) - (x4 - x3) * (y2 - y1))
          < 1e-10 else 'NO')

Measured memory_bytes: 7632
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(int X = 0; X < N; X++)
#define repvin(V,N) for(int i = 0; i < N; i++) {int tmp; cin >> tmp; V.push_back(tmp);}

using namespace std;

int main(){

    int n;
    cin >> n;

    int ans = 0;

    rep(i,n){
        int tmp;
        cin >> tmp;
        ans = ans + tmp - 1;
    }

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

Measured memory_bytes: 256
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rel register ll
#define rec register char
#define gc getchar
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
template <typename mitsuha>
inline bool read(mitsuha &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';
  if (!~c) return 0;
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return x=f?x:-x,1;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return 0&pc(48);
  if (x<0) pc('-'),x=-x;
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  return 0;
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;
const int yuzu=1e5;
//struct node{
//int l,r,id;
//void rd(int i){l=read(),r=read(),id=i;}
//bool operator <(const node &b) const{
//  return l<b.l;
//  }
//}e[yuzu|10],p[yuzu|10];

vector<int> lj[yuzu|10];

int main(){
int i,j,n,m,q;
cin>>n>>m>>q;
for (i=1;i<=m;++i) {
  int l=read(),r=read();
  lj[l].push_back(r);
  }
for (i=1;i<=500;++i) sort(lj[i].begin(),lj[i].end());
for (i=1;i<=q;++i){
  int l=read(),r=read(),ans=0;
  for (j=l;j<=r;++j){
    ans+=upper_bound(lj[j].begin(),lj[j].end(),r)-lj[j].begin();
    }
  write(ans),pl;
  }
}

Measured memory_bytes: 4480
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            long[] Wab = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
            if(Math.Abs(Wab[1] - Wab[2]) <= Wab[0])
            {
                Console.WriteLine(0);
                return;
            }
            else
            {
                Console.WriteLine(Math.Abs(Wab[1] - Wab[2])- Wab[0]);
            }
        }
    }
}
// 文字列の入力
//string s = Console.ReadLine();

// 整数の入力
//long n = long.Parse(Console.ReadLine());

// 文字列配列の入力
//string[] inputStrArray = Console.ReadLine().Split(' ');

// 整数配列の入力
//long[] inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();


//Console.WriteLine(ans);


Measured memory_bytes: 27948
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define CLR(a) memset(a,0,sizeof(a))
#define SET(a,c) memset(a,c,sizeof(a))

#define DEBUG(x) cout<<"#x"<<": "<<x<<endl

using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;

const ll INF = INT_MAX/3;
const ll MOD = 1000000007;
const double EPS = 1e-14;
const int dx[] = {1,0,-1,0} , dy[] = {0,1,0,-1};

int main(){
    vector<int> a;
    vector<int> primes;
    FOR(i,6,300000){
	int m = i % 7;
	if(m == 1 || m == 6) a.PB(i);
    }
    REP(i,a.size()){
	bool flg = true;
	for(int j=0;a[j]*a[j] <= a[i];j++){
	    if( a[i] % a[j] == 0){
		flg = false;
		break;
	    }
	}
	if(flg) primes.PB(a[i]);
    }
    while(true){
	int n;
	cin >> n;
	if( n == 1) break;
	printf("%d:",n);
	REP(i,primes.size()) {
	    if( n % primes[i] == 0)
		printf(" %d",primes[i]);
	}
	printf("\n");
    }
    return 0;
}

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

int a[110];

int main() {
    int n, alice = 0, bob = 0;
    bool is_alice = true;
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a, a + n, greater<int>());
    for (int i = 0; i < n; i++) {
        if (is_alice) alice += a[i];
        else bob += a[i];
        is_alice = !is_alice;
    }
    cout << alice - bob << endl;
}


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

void solve(int n){
  vector <int> num;
  for(int i=1;i<n;i++)num.push_back(i*i%n);
  sort(num.begin(),num.end());
  num.erase(unique(num.begin(),num.end()),num.end());
  
  int used[10001]={};
  for(int i=0;i<num.size();i++){
    for(int j=0;j<num.size();j++){
      if(i==j)continue;
      int a=num[i]-num[j];
      if(a<0)a+=n;
      if((n-1)/2<a)a=n-a;
      used[a]++;
    }
  }
  for(int i=1;i<=(n-1)/2;i++)cout << used[i]<<endl;
}

int main(){
  int n;
  while(cin>>n,n)solve(n);
  return 0;
}

Measured memory_bytes: 3156
#include <iostream>
#include <vector>
using namespace std;
int main() {
  int n;
  vector<int> t, x, y;
  cin >> n;
  t.push_back(0);
  x.push_back(0);
  y.push_back(0);
  for (int i = 0; i < n; i++) {
    int tmpt, tmpx, tmpy;
    cin >> tmpt >> tmpx >> tmpy;
    t.push_back(tmpt);
    x.push_back(tmpx);
    y.push_back(tmpy);
  }

  int flag = 1;
  for (int i = 0; i < n; i++) {
    int dt = t[i + 1] - t[i];
    int dist = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]);
    if (dt < dist) {
      flag = 0;
    }
    if (dist % 2 != dt % 2) {
      flag = 0;
    }
  }

  if (flag == 0) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
  return 0;
}

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;
constexpr int mod2 = 998244353;
template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }
template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	os << v[0];
	for (int i = 1; i < v.size(); i++) os << " " << v[i];
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	int N, M; cin >> N >> M;
	int mm = M*2+1;
	int a = mm/2, b = mm-a;

	for (int i = 1; i <= a/2; i++) {
		cout << i << " " << a-i+1 << el;
	}
	for (int i = 1; i <= b/2; i++) {
		cout << a+i << " " << a+b-i+1 << el;
	}	
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF INT_MAX/3
#define ALL(a) (a).begin(),(a).end()
#define CLR(a) memset(a,0,sizeof(a))

typedef long long int ll;

using namespace std;

int main(){

    ll n;
    n = 0;
    REP(i,10){
	int temp;
	cin >> temp;
	n += temp;
    }
    cout << n << endl;
    return 0;
}

Measured memory_bytes: 1156
#include <iostream>

using namespace std;

typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(0);
    ll a, b;
    cin >> a >> b;
    ll odp = 2019;
    if (b - a + 1 >= 2 * 2019)
    {
        for (ll i = 0; i < 2019; ++i)
            for (ll j = 0; j < 2019; ++j)
                odp = min(odp, (i * j) % 2019);
    }
    else
    {
        for (ll i = a; i <= b; ++i)
            for (ll j = i + 1; j <= b; ++j)
                odp = min(odp, (i * j) % 2019);
    }
    cout << odp;
    return 0;
}


Measured memory_bytes: 256
A=[0 for i in range(2)]
A=input().split()
n=int(A[0])
m=int(A[1])


max=[]
k=0
while n>0 and m>0:
    B=[0 for i in range(n)]
    B=input().split()
    for i in range(n):
        B[i]=int(B[i])
    ma=0
    for i in range(n):
        for j in range(i+1,n):  
            x=0 
            x=B[i]+B[j]
            if ma<x and x<=m:
                ma=x
    max.append(ma)
    A=input().split()
    n=int(A[0])
    m=int(A[1])
    k+=1
for i in range(k):
    if max[i]>0:
        print(max[i])
    else:
        print("NONE")


Measured memory_bytes: 5716
#include<stdio.h>

int main(void)
{
  int i,count=0;
  char s[100000];
  
  scanf("%s",s);
  

      for(i=0;s[i]!='\0';i++){
        
        
         if(s[i]==s[i+1])
         {
           
           if(s[i]=='1')    //ww
           {
              s[i+1]='0';
              count++;                  
           }
           else if(s[i]=='0')  //bb
           {
             s[i+1]='1';
             count++;
           }
         }
      }
  
    printf("%d",count);  
  
 return 0 ;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
static const int MAX = 200000;

int main(void) {
	int R[MAX], n;

	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> R[i]; 
	}

	int maxv = -2000000000;
	int minv = R[0];

	for (int i = 1; i < n; i++) {
		maxv = max(maxv, R[i] - minv);
		minv = min(minv, R[i]);
	}
	
	cout << maxv << endl;

	return 0;
}


Measured memory_bytes: 3868
n = int(input())
x = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
]

print(x[n-1])

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

int main(){
    string s;
    while(cin>>s){
        if(s=="#") break;
        string t[9];
        int n=s.size();
        int c=0;
        for (int i = 0; i < n; i++)
        {
            if(s[i]=='b') t[c]+='#';
            else if(s[i]=='/') c++;
            else {
                int k=(int)s[i]-'0';
                for(int j=0;j<k;j++) t[c]+='.';
            }
        }
        int a,b,f,d;
        cin>>a>>b>>f>>d;
        a--,b--,f--,d--;
        t[a][b]='.';
        t[f][d]='#';
        string ans="";
        int cnt=0;
        for(int i=0;i<=c;i++){
            cnt=0;
            for(int j=0;j<t[i].size();j++){
                if(t[i][j]=='.') cnt++;
                else if(t[i][j]=='#'){
                    if(cnt) ans+=(char)cnt+'0';
                    cnt=0;
                    ans+='b';
                }
            }
            if(cnt) ans+=(char)cnt+'0';
            cnt=0;
            if(i!=c)ans+='/';
        }
        cout<<ans<<endl;
    }

}


Measured memory_bytes: 3144
#include <iostream>
#include <string>
using namespace std;
int main()
{
 int i,n,c;
 c=1;
 string s;
 char p,q;
 cin >> n;
 cin >> s;
 for(i=0;i<(n-1);i++)
 {
  p=s.at(i);
  q=s.at(i+1);
  if(p!=q)
  c++;
 }
 cout << c;
 return 0;
}

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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;

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

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

    ll X;
    std::cin >> X;

    ll res = 1ll;
    while(res * (res + 1) < 2ll * X){
        ++res;
    }

    std::cout << res << std::endl;
}


Measured memory_bytes: 256
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007

#+++++

def main():
	#a = int(input())
	#b , c = tin()
	s = input()	
	add = 'es' if s[-1]=='s' else 's'
	return s+add
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 61932
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

ll n, f[108][11], p[108][20];

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	cin >> n;
	rep(i, 1, n){
		rep(j, 0, 9){
			cin >> f[i][j];
		}
	}
	rep(i, 1, n){
		rep(j, 0, 10){
			cin >> p[i][j];
		}
	}
	
	ll ans = -INF;
	rep(bit, 1, (1 << 10)-1){
		ll cnt[108];
		memset(cnt, 0, sizeof(cnt));
		rep(i, 1, n){
			rep(j, 0, 9){
				if((bit & (1 << j)) && f[i][j]){
					cnt[i]++;
				}
			}
		}
		
		ll buf = 0;
		rep(i, 1, n){
			buf += p[i][cnt[i]];
		}
		ans = max(buf, ans);
	}
	
	print(ans)
	return 0;
}

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

int main(void) {
    int n; cin >> n;
    int a[105];
    int temp = 1;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        if(a[i] % 2 == 0) temp = temp*2;
    }
    int ans = 1;
    for(int i = 0; i < n; i++){
        ans = ans*3;
    }
    cout << ans - temp << endl;
    return 0;

}

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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int main() {
    ll N;
    cin >> N;
    ll sum = 0, mi = 1e10, cnt = 0;
    rep(i, N) {
        ll tmp; cin >> tmp;
        sum += abs(tmp);
        if (tmp < 0) cnt++;
        mi = min(mi, abs(tmp));
    }
    if (cnt%2) sum -= mi*2;
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <stdexcept>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define x first
#define y second
#define debug(a) cout << (a) << endl
namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;
template <class T>
bool chmax(T &a, const T &b)
{
	if (a < b)
	{
		a = b;
		return 1;
	}
	return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
	if (a > b)
	{
		a = b;
		return 1;
	}
	return 0;
}

ll M = 1000000007;

void solve()
{
	int a,b;
	cin>>a>>b;
	cout<<a*b<<endl;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	solve();
	return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin>>n>>k;
  int d,a;
  vector<int> v(n);
  for(int i=0;i<k;i++){
    cin>>d;
    for(int j=0;j<d;j++){
      cin>>a;
      v[a-1]++;
    }
  }
  int count=0;
  for(int i=0;i<n;i++){
    if(v[i]==0){
      count++;
    }
  }
  cout<<count;
  return 0;
}

Measured memory_bytes: 3588
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;
int n;
map<string,int>S;
main()
{
  cin>>n;
  for(int i=0;i<n;i++)
  {
    int c;string s;cin>>c>>s;
    if(c==0)
    {
      int x;cin>>x;S[s]=x;
    }
    else if(c==1)
    {
      cout<<S[s]<<endl;
      if(S[s]==0)S.erase(s);
    }
    else if(c==2)S.erase(s);
    else
    {
      string t;cin>>t;
      map<string,int>::iterator a=S.lower_bound(s),b=S.upper_bound(t);
      for(map<string,int>::iterator it=a;it!=b;it++)cout<<it->first<<" "<<it->second<<endl;
    }
  }
}



Measured memory_bytes: 27824
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll ; 
typedef long double ld ;
typedef pair<ll , ll> pll ;

const ll N = 2e6 + 30 , Mod = 1e9 + 7 ;
const ll SQ = 330 ;

int main () {
    ios::sync_with_stdio(0), cin.tie(0) ;
    ll n , p ;
    cin >> n >> p ;
    ll s = p ;
    ll ans = 1 ;
    for (int i = 2 ;  i < N ; i ++) {
    	ll cnt = 0 ;
    	while (s % i == 0) {
    		s /= i ;
    		cnt ++ ;
		}
		for (int k = 0 ;k < (cnt / n) ; k ++) ans *= i ;
	}
	if (s != 1) if (n == 1) ans *= s ; 
	cout << ans ;
    return (0) ;
}

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

class Program
{
    static void Main(string[] args)
    {
        var (A, B) = ReadLine().Split(' ').Select(int.Parse).ToArray();
        var ans = (A - 1) * (B - 1);

        WriteLine(ans);
    }
}

static class ArrayDeconstructExtensions
{
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2) => (i1, i2) = (a[0], a[1]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3) => (i1, i2, i3) = (a[0], a[1], a[2]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3, out T i4) => (i1, i2, i3, i4) = (a[0], a[1], a[2], a[3]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3, out T i4, out T i5) => (i1, i2, i3, i4, i5) = (a[0], a[1], a[2], a[3], a[4]);
}


Measured memory_bytes: 28152
N,M=map(int,input().split())
Glaph=[[0 for i in range(N)] for j in range(N)]
flag_ans=[[0 for i in range(N)] for j in range(N)]
for i in range(M):
  a,b,c=map(int,input().split())
  Glaph[a-1][b-1]=c
  Glaph[b-1][a-1]=c
  
def djikstra(s):
  flag=[0 for i in range(N)]
  cost=[float("Inf") for i in range(N)]
  rout=[-1 for i in range(N)]
  
  cost[s]=0
  flag[s]=1
  
  for i in range(N):  
    minc=float("Inf")
    for j in range(N):
      if  flag[j]==0:
        if Glaph[s][j]!=0:
          if cost[j]>cost[s]+Glaph[s][j]:
            cost[j]=cost[s]+Glaph[s][j]
            rout[j]=s
            if minc>cost[j]:
              k=j
              minc=cost[j]
          elif minc>cost[j]:
            k=j
            minc=cost[j]
        elif minc>cost[j]:
          k=j
          minc=cost[j]

    s=k
    flag[s]=1
  
    flag_ans[ rout[s] ][ s ]=1
    flag_ans[s][ rout[s] ]=1

for i in range(N):
  djikstra(i)
  
ans=0
for i in range(N):
  for j in range(i+1,N):
    if flag_ans[i][j]==0 and Glaph[i][j]!=0:
      ans+=1
print(ans)
    

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

int main() {
  int N; cin >> N;
  int T[N]; for (int i=0; i<N; i++) cin >> T[i];
  int M; cin >> M;
  int P[M], X[M];
  for (int i=0; i<M; i++) cin >> P[i] >> X[i];

  long long ans;
  for (int i=0; i<M; i++) {
    ans = 0;
    for (int j=0; j<N; j++) {
      if (j == (P[i]-1)) ans += X[i];
      else ans += T[j];
    }
    cout << ans << endl;
  }
  return 0;
}


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

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
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 S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)

def scc(n, e, re):

    v = [None] * n
    t = []
    def dfs(i):
        v[i] = 0
        for b in e[i]:
            if v[b] is None:
                dfs(b)
        t.append(i)

    for i in range(n):
        if v[i] is None:
            dfs(i)

    r = [None] * n
    def dfs2(i, p):
        r[i] = p
        for b in re[i]:
            if r[b] is None:
                dfs2(b, p)

    for c in t[::-1]:
        if r[c] is None:
            dfs2(c, c)

    return r

def main():
    n,m = LI()
    st = [LI() for _ in range(m)]
    q = I()
    uv = [LI() for _ in range(q)]

    e = collections.defaultdict(set)
    re = collections.defaultdict(set)
    for s,t in st:
        e[s].add(t)
        re[t].add(s)

    r = scc(n, e, re)
    rr = []
    for u,v in uv:
        if r[u] == r[v]:
            rr.append(1)
        else:
            rr.append(0)

    return JA(rr, "\n")

# start = time.time()
print(main())
# pe(time.time() - start)






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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  int M=0;
  ll ans=0;
  rep(i,n){
    M = max(M,a[i]);
    ans += M-a[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3980
import sys
input=sys.stdin.readline
n,k=map(int,input().split())
ab=[]
for i in range(n):
	a,b=map(int,input().split())
	ab.append((a,b))
K=[k]
for i in range(1,len(bin(k)[2:])):
	r=(k-(2**i))//(2**i)*(2**i)+(2**i-1)
	K.append(r)
ans=[0]*len(K)
for x,y in ab:
	for i in range(len(K)):
		if K[i]|x==K[i]:
			ans[i]+=y
print(max(ans))


Measured memory_bytes: 22624
#include<iostream>
#include<string>
using namespace std;
int main(){
  string s;
  cin >> s;
  if(s[0] == 'S'){
    cout << "Cloudy\n";
    return 0;
  }
  if(s[0] == 'C'){
    cout << "Rainy\n";
    return 0;
  }
  cout << "Sunny";
}

Measured memory_bytes: 3568
N, M, R = map(int, input().split())
R_LIST = list(map(int, input().split()))
ABC = []
for _ in range(M):
    a,b,c = map(int, input().split())
    ABC.append((a,b,c))
    

    
edges = ABC[:]


def warshall_floyd(d, n):
    # d: グラフ二次元リスト
    # n: 頂点数 (0始まり)
    #d[i][j]: iからjへの最短距離
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d

# グラフ無効グラフ化
graph = [[float("inf") for i in range(N+1)] for i in range(N+1)] 
for x,y,z in edges:
    graph[x][y] = z
    graph[y][x] = z
for i in range(N+1):
    graph[i][i] = 0 #自身のところに行くコストは０

#最短経路
shortest =  warshall_floyd(graph, N+1)
    
# 順列全探索
import sys
INT_MAX = sys.maxsize # 9223372036854775807
ans = INT_MAX

import queue

rest = set(R_LIST[:])

import copy  
def dfs(cost,pre,rest):
    if len(rest) == 0:
        return cost
    
    ret = INT_MAX
    for r in rest:
        if pre == None:
            next_cost = 0
        else:
            next_cost = cost + shortest[pre][r]
        next_rest = copy.copy(rest)
        next_rest.remove(r)
        
        tmp_ret = dfs(next_cost, r, next_rest)
        ret = min(ret, tmp_ret)
        
    return ret
        
    

print(dfs(0, None, rest))
            
      
        
        



Measured memory_bytes: 75092
import math

a, b, x = (int(_) for _ in input().split())

t = (a**2) * b * 0.5
if t >= x:
	s = math.atan((a * (b**2)) / (2 * x))
else:
	s = math.atan((2*b*(a**2)-2*x) / a**3)
print(math.degrees(s))


Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main()
{
	int x, y;

	cin >> x >> y;
	
	if (y > x * 4 || x * 2 > y)
		cout << "No";
	else if ((x * 4 - y) % 2)
		cout << "No";
	else
		cout << "Yes";

	cout << endl;

	return 0;	
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N ,K;
  cin>>N>>K;
  vector<int> wage(N);
  for(int i=0; i<N; i++){
    cin>>wage.at(i);
  }
  sort(wage.begin(),wage.end());
  int answer=0;
  
  for(int i=0; i<K; i++){
    answer=answer+wage.at(i);
  }
  cout<<answer<<endl;
  
}

Measured memory_bytes: 3600
import java.util.Scanner;

import org.omg.PortableServer.ID_ASSIGNMENT_POLICY_ID;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String string = sc.nextLine();
		
		String[] array = string.split(" ");
		Double[] array2 = new Double[2];
		for(int i=0; i<array.length; i++) {
				array2[i] = Double.parseDouble(array[i]);
		}
		Double[] r = new Double[]{1.0,2.0,4.0,8.0,16.0,32.0,64.0,128.0,256.0,512.0,1024.0,2048.0,4096.0,8192.0,16384.0,32768.0,65536.0};
		double ans = 0.0;
		for(int i=0; i<array2[0];i++) {
			Double a = array2[1] / (Double.parseDouble(String.valueOf(i))+1.0);
			int b = 17;
			for(int j=0; j<17; j++) {
				if(r[j] >= a) {
					b=j;
					break;
				}
			}
			ans += (1.0/array2[0])*(Math.pow(0.5,b));
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 37804
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb                 push_back
#define bug(x)             cerr<<#x<<" "<<x<<endl;
#define T int time;        scanf("%d", &time); while(time--)
    vector<ll>ar;
  bool check(ll i,ll n){
    if(abs(i-n)<=1)return true;
    for(ll ii=n-1; ii>i; ii--)if(ar[ii]<ar[ii-1])
      cout<<ar[ii]<<" ";
    cout<<endl;
    return true;
  }

   int main(){
       set<ll>s;
        ll a,b,c;
        cin>>a>>b>>c;
        s.insert(a);
        s.insert(b);
        s.insert(c);
        if(s.size()==2)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
     }
   

Measured memory_bytes: 3640
# N問の問題が用意されている
N = int(input())
# 問題を解くのにかかる時間
T = list(map(int, input().split()))

# ドリンクの種類M
M = int(input())
# ドリンクを飲んだ場合の時間をリストに格納する
X = []

# まずはドリンクを飲んだ場合の時間をXに格納する
for i in range(M):
    X.append(list(map(int,input().split())))
    X[i][0] = X[i][0]-1

Y = []
# それぞれの問題の解く時間を取得する
for i in range(N):
    Y.append(T[i])
    
for i in range(len(X)):
    Y_copy = Y.copy()
    Y_copy[X[i][0]] = X[i][1]
    print(sum(Y_copy))

Measured memory_bytes: 9184
#include<iostream>
#include<vector>
#include<cstdio>
#include<cstring>
#include<climits>

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

using namespace std;

typedef unsigned long long ull;

int main(){
  int n,m;
  while(scanf("%d%d",&n,&m),n+m){
    int  cost[n][n];
    bool f[n];
    memset(cost, 0, sizeof(cost));
    memset(f, 0, sizeof(f));
    REP(i,m){
      int a,b,c;
      scanf("%d%d%d",&a,&b,&c);
      cost[a][b] = cost[b][a] = c;
    }
    f[0] = true;
    int ans = 0;
    REP(i,n-1){
      int m = INT_MAX;
      int ii,jj;
      for(int i=0; i<n; i++){
	for(int j=i+1; j<n; j++){
	  if(f[i] ^ f[j] && cost[i][j] != 0){
	    if(m > cost[i][j]){
	      ii = i; jj = j;
	      m = cost[i][j];
	    }
	  }
	}
      }
      f[ii] = f[jj] = true;
      ans += m;
    }

    printf("%d\n",ans);
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int dp[5001];
int a[5001],b[5001];
int main() {
    int A,B;
    scanf("%d %d",&A,&B);
    for(int i=1;i<=A;i++) {
        scanf("%d",&a[i]);
    }
    for(int i=1;i<=B;i++) {
        scanf("%d",&b[i]);
    }
    int ans=0;
    for(int i=1;i<=A;i++) {
        for(int j=B;j>=1;j--) {
            if(a[i]==b[j]) {
               dp[j]=dp[j-1]+1;
            }
            ans=max(ans,dp[j]);
        }
    }
    printf("%d\n",ans);
}

Measured memory_bytes: 1248
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq 
from itertools import *
import math
import random
import re
import string
import sys

nums = list(map(int, input().split()))

nums.sort()

ans = 0
while nums[0] != nums[-1]:
    if nums[0] < nums[1]:
        nums[0] += 2
    else:
        nums[0] += 1
        nums[1] += 1
    ans += 1
    nums.sort()
print(ans)



Measured memory_bytes: 5588
n = int(input())
a = list(map(int, input().split()))
k = max(a)
b = [0] * n
for i in range(n):
    if a[i] == k:
        b[i] = k
    else: b[i] = abs(a[i]-k/2)
r = a[b.index(min(b))]
print(k, r)

Measured memory_bytes: 14428
#include <iostream>

using namespace std;

int main()
{

  int n,c=0;
  string s;
  cin >>n>>s;

  for(int j=0;j<n;j++){
    if(s[j]=='A'&& s[j+1]=='B'&& s[j+2]=='C'){
        c+=1;}

  }
  cout << c;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
using uint = unsigned int;
using ull = unsigned long long;
 
int main() {
	uint N, K, R, S, P;
	cin >> N >> K >> R >> S >> P;
	
	string T;
	cin >> T;
	
	ull ans = 0;
	
	for(uint i=0; i<K; i++) {
		vector<ull> dpR(2);
		vector<ull> dpS(2);
		vector<ull> dpP(2);

		uint prv = 0;
		uint cur = 1;
		
		for(uint j=i; j<N; j+=K) {
			char c = T[j];
			
			uint r = (c == 's') ? R : 0;
			uint s = (c == 'p') ? S : 0;
			uint p = (c == 'r') ? P : 0;
			
			dpR[cur] = max(dpP[prv], dpS[prv]) + r; 
			dpS[cur] = max(dpR[prv], dpP[prv]) + s;
			dpP[cur] = max(dpR[prv], dpS[prv]) + p;
			
			//cout << j << " " << dpR[cur] << " " << dpS[cur] << " " << dpP[cur] << endl;
			prv = cur;
			cur = (cur + 1) % 2;
		}
		
		ans += max(dpR[prv], max(dpS[prv], dpP[prv]));
	}
	
	cout << ans;
	
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
#include <array>
#include <cmath>
#include <climits>
#include <cstdint>
using namespace std;

/*
 * dp[i][j] = iまでの品物を重さj以下でナップサックに入れたときの価値の総和の最大値
 *
 * dp[0][j] = 0
 * dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w[i]] + v[i])
 */

int main() {
    int n, w; cin >> n >> w;
    vector<array<int, 2>> wv(n);
    for (auto &e1 : wv) for (auto &e2 : e1) cin >> e2;

    vector<vector<int64_t>> dp(n + 1, vector<int64_t>(w + 1));
    for (int i = 1; i <= n; ++i) {
        for (int j = 0; j <= w; ++j) {
            if (j < wv[i - 1][0]) {
                dp[i][j] = dp[i - 1][j];
            }
            else {
                dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - wv[i - 1][0]] + wv[i - 1][1]);
            }
        }
    }

    cout << dp[n][w] << endl;
}

#if false

// メモ化再帰による解法

int64_t solve(vector<vector<int64_t>> &memo, vector<array<int, 2>> &wv, int i, int j) {
    if (memo[i][j] != -1) return memo[i][j];

    if (j < wv[i - 1][0]) {
        return memo[i][j] = solve(memo, wv, i - 1, j);
    }

    return memo[i][j] = max(
        solve(memo, wv, i - 1, j),
        solve(memo, wv, i - 1, j - wv[i - 1][0]) + wv[i - 1][1]
    );
}

int main() {
    int n, w; cin >> n >> w;
    vector<array<int, 2>> wv(n);
    for (auto &e1 : wv) for (auto &e2 : e1) cin >> e2;

    vector<vector<int64_t>> memo(n + 1, vector<int64_t>(w + 1, -1));
    fill(begin(memo[0]), end(memo[0]), 0);

    cout << solve(memo, wv, n, w) << endl;
}

#endif



Measured memory_bytes: 83048
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using pii=pair<ll,ll>;
#define For(i,a,b)  for(int i=a;i<=b;i++)
#define Forr(i,a,b) for(int i=a;i>=b;i--)
#define F first
#define S second
#define int ll
#define sz(x) ((ll)x.size())
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define mkp make_pair
#define INF (ll)(1e17)
#define MOD (ll)(998244353)

int32_t main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	//I won't misunderstand the problem statement anymore.
	//I won't misunderstand the problem statement anymore.
	//I won't misunderstand the problem statement anymore.
	//I won't misunderstand the problem statement anymore.
	//I won't misunderstand the problem statement anymore.
	//I won't misunderstand the problem statement anymore.
	//I won't misunderstand the problem statement anymore.
	//I won't misunderstand the problem statement anymore.
	//I won't misunderstand the problem statement anymore.
	//I won't misunderstand the problem statement anymore.
	int n; cin>>n;
	int ans=0;
	For(i,1,n){
		ans+=(n-1)/i;
	}
	cout<<ans<<"\n";
}























Measured memory_bytes: 3608
import java.util.*;

class Place {
	private int num , count;
	public Place(int num) {
		this.num = num;
		this.count = 0;
	}
	public void add(int n) {
		this.count+=n;
	}
	public boolean lower( Place p ) {
		return this.count < p.count;
	}
	public int getSum() {
		return this.count;
	}
	public int getNum() {
		return this.num;
	}
}
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while ( true ) {
			int st = sc.nextInt(),
				num = sc.nextInt();
			if ( st == 0 && num == 0 ) break;
			Place[] result = new Place[num];
			for ( int i = 0; i < num; i++ )
				result[i] = new Place(i+1);
			for ( int i = 0; i < st; i++ )
				for ( int j = 0; j < num; j++ )
					result[j].add(sc.nextInt());
			boolean sort_complete = true;
			while ( sort_complete ) {
				int count = 0;
				for ( int i = 0; i < result.length-1; i++ ) {
					if ( result[i].lower(result[i+1]) ) {
						Place p = result[i];
						result[i] = result[i+1];
						result[i+1] = p;
						count++;
					}
				}
				sort_complete = 0 != count;
			}
			for ( int i = 0; i < result.length-1; i++ )
				System.out.print(result[i].getNum()+" ");
			System.out.println(result[result.length-1].getNum());
		}
	}
}

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

const int MOD = 1000000007;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

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

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

// 最小公倍数
unsigned lcm(unsigned a, unsigned b){
    return a / gcd(a, b) * b; 
}

int main(){
  int N, M;
  cin >> N >> M;
bool x[N] = {false};
int num[N] = {0};

int WA = 0, AC = 0;
REP(i, M){
  int a;
  string s;
  cin >> a >> s;
  a--;
  if(x[a] == false && s == "WA") num[a]++;
  if(x[a] == false && s == "AC") {
    AC++;
    WA += num[a];
    x[a] = true;
  }
}

cout << AC << ' ' << WA << endl;
}

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

int main() {
 int N ;
 cin >> N ;
 vector<int> price(N);
 vector<int> cost(N);
  int sum = 0;
 for (int i = 0;i < N; i++){
   cin >> price.at(i) ;
 }
 for (int j = 0;j < N; j++){
   cin >> cost.at(j);
 }

  for (int k = 0;k < N; k++){
    if (price.at(k) > cost.at(k) ){
      sum += price.at(k) - cost.at(k);
    }
    else {
      continue;
    }
  }
  cout << sum << endl;
}





Measured memory_bytes: 256
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
  int A = sc.nextInt();
  int B = sc.nextInt();
  if(A == 1)A = 14;
  if(B == 1)B = 14;
  if(A > B)System.out.println("Alice");
  else if(A == B)System.out.println("Draw");
  else System.out.println("Bob");
}
}

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

using namespace std;

#define ll long long

/* 長さnの数列aの最長増加部分列の長さを計算する. */
int LIS(int n,ll* a){
    ll inf = numeric_limits<ll>::max();
    /*
            dp[i] : min value of the last element in an
                    increasing subsequence of length i + 1.
     */
    // initialize the dp table
    ll* dp = new ll[n];
    for (int i = 0;i < n;++i)
        dp[i] = inf;
    // fill the dp table
    for (int i = 0;i < n;++i)
        *lower_bound(dp,dp + n,a[i]) = a[i];
    // calculate the return value
    int r = lower_bound(dp,dp + n,inf) - dp;
    // freeing memory
    delete[] dp;

    return r;
}

signed main(){
    int n;
    cin >> n;
    ll* a = new ll[n];
    for (int i = 0;i < n;++i)
        cin >> a[i];
    
    cout << LIS(n,a) << endl;

    return 0;
}


Measured memory_bytes: 4412
#include<bits/stdc++.h>
using namespace std;
int main(){
 int a,b,c,k;
 cin >> a >> b >> c >> k;
 if(k<=a) cout << k;
 else if(k>a&&k<=a+b) cout << a;
 else if(k>(a+b)&&k<=a+b+c) cout << a+(k-a-b)*(-1);
 return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
 
using namespace std;
 
#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(nullptr)
#define FOR(i, a, b) for(int i = (a); i <= (b); i++)
#define REP(n) FOR(O, 1, (n))
#define pb push_back
#define f first
#define s second
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<ll> vl;
typedef vector<piii> viii;
 
const int MAXN = 500100, MAXK = 30;
const ll MOD = 998244353;
const int INF = 1e8;
const ld PI = asin(1) * 2;
 
void setIO () {
    FAST_IO;
}
 
void setIO (string s) {
    setIO();
 	freopen((s+".in").c_str(),"r",stdin);
	freopen((s+".out").c_str(),"w",stdout);
}
 
 
 
int main() {
	setIO();
 
    int n;
    cin >> n;
    ll sum = 0;
    FOR(i, 1, n) {
        if (i%3 && i%5) sum += i;
    }
    cout << sum;
 
	return 0;
}
 

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

using ll = long long;
#define REP(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}

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

  bool fla, flb; fla = false; flb = false;

  REP(i, s.size()) {
    if(fla == false && s[i] == 'C') fla = true;
    if(fla == true && flb == false && s[i] == 'F') {
      flb = true;
      break;
    }
  }

  if(fla == true && flb == true) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
int N = 10;
int main(void){
    int i,j=0,counter=0,max=0,check=0;
    char a[N];
    scanf("%s",&a);
    
    for(i=0;i<N;i++){
        j = i;
        while(check == 0){
            if(a[j] == 'A' || a[j] == 'T' || a[j] == 'G' || a[j] == 'C') counter++;
            else check = 1;
            j++;
        }
        if(counter>max) max = counter;
        check = 0;
        counter = 0;
    }
    
    printf("%d",max);
    return 0;
}

Measured memory_bytes: 128
/*
ID: espr1t
TASK: 
KEYWORDS: 
*/

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;
FILE* in = stdin; FILE* out = stdout;

const int MAX = 404;

int n, m;
char a[MAX][MAX];
int vis[MAX][MAX];
int cntW[MAX * MAX];
int cntB[MAX * MAX];
int dir[4][2] = { {-1, 0}, {0, 1}, {1, 0}, {0, -1} };


void fill(int row, int col, int color) {
    vis[row][col] = color;
    for (int i = 0; i < 4; i++) {
        int nrow = row + dir[i][0]; if (nrow < 0 || nrow >= n) continue;
        int ncol = col + dir[i][1]; if (ncol < 0 || ncol >= m) continue;
        if (!vis[nrow][ncol] && a[row][col] != a[nrow][ncol])
            fill(nrow, ncol, color);
    }
}

int main(void) {
	// in = fopen("C.in", "rt");
	
	fscanf(in, "%d %d", &n, &m);
	for (int i = 0; i < n; i++)
	    fscanf(in, "%s", a[i]);
    
    int nextCol = 1;
    for (int row = 0; row < n; row++) {
        for (int col = 0; col < m; col++) {
            if (vis[row][col] == 0) {
                fill(row, col, nextCol++);
            }
        }
    }
	
	for (int row = 0; row < n; row++) {
	    for (int col = 0; col < m; col++) {
	        a[row][col] == '.' ? cntW[vis[row][col]]++ : cntB[vis[row][col]]++;
        }
    }

    long long ans = 0;
	for (int col = 1; col < nextCol; col++) {
	    ans += (long long)cntB[col] * cntW[col];
    }
    fprintf(out, "%lld\n", ans);
	
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  for (int i=0; i < N; i++) {
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end(), greater<>());
  int alice = 0;
  int bob = 0;
  for (int j=0; j < N; j++) {
    if (j % 2 == 0) {
      alice += vec.at(j);
    } else {
      bob += vec.at(j);
    }
  }
  cout << alice - bob << endl;
}

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

int main() {
    long long w,h; scanf("%lld %lld", &w, &h);
    long long x,y; scanf("%lld %lld", &x, &y);

    int res = (2*x == w && 2*y == h);
    if ((w * h) % (long long)2 == (long long)0) {
        printf("%lld.000000 %d\n", w * h / (long long)2, res);
    } else {
        printf("%lld.500000 %d\n", w * h / (long long)2, res);
    }
    return 0;
}


Measured memory_bytes: 384