akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(){
  
  double a;
  
  while(cin >> a){
    
    if(a <= 48.00) printf("light fly\n");
    else if(a <= 51.00) printf("fly\n");
    else if(a <= 54.00) printf("bantam\n");
    else if(a <= 57.00) printf("feather\n");
    else if(a <= 60.00) printf("light\n");
    else if(a <= 64.00) printf("light welter\n");
    else if(a <= 69.00) printf("welter\n");
    else if(a <= 75.00) printf("light middle\n");
    else if(a <= 81.00) printf("middle\n");
    else if(a <= 91.00) printf("light heavy\n");
    else printf("heavy\n");
  
  }

  return (0);
}
    

Measured memory_bytes: 3084
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n;
long long ans = 0;
void check(int x) {
	if(x == 1 || x == 2)
		return;
	x--;
	if(n / x == n % x) {
		ans += x;
	}
}

int32_t main() {
	cin >> n;
	int i;
	for(i = 1; i * i < n; i++) {
		if(n % i == 0) {
			check(i);
			check(n / i);
		}
	}
	if(n % i == 0)
		check(i);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>

using namespace std;
typedef long long ll;

int main()
{
    ll n, a;
    map<ll, ll> mp;

    cin >> a;

    for (int i = 2; i <= a; i++)
    {
        int tmp = i;
        for (int j = 2; j <= i; j++)
        {
            while (tmp % j == 0)
            {
                mp[j] += 1;
                tmp = tmp / j;
            }
        }
    }

    /*
    for (auto x : mp)
    {
        cout << x.first << " => " << x.second << "\n";
    }
    */

    int ans = 0;
    for (auto i : mp)
    {
        if (i.second >= 74)
        {
            ans++;
        }
    }

    for (auto i : mp)
    {
        for (auto j : mp)
        {
            if (i.first == j.first)
                continue;
            if (i.second >= 2 && j.second >= 24)
                ans++;
            if (i.second >= 4 && j.second >= 14)
                ans++;
        }
    }
    for (auto i : mp)
    {
        for (auto j : mp)
        {
            for (auto k : mp)
            {

                if (i.first == j.first)
                    continue;
                if (i.first == k.first)
                    continue;
                if (i.second >= 2 && j.second >= 4 && k.second >= 4 && j.first < k.first)
                    ans++;
            }
        }
    }

    cout << ans << endl;

    return 0;
}


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

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

 
typedef pair<int,int> P;
typedef long long ll;
 
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI=acos(-1);

int main(){
    string S;
    cin >> S;
    int ans = 0;
    int tmp = 0;
    bool t = false;
    rep(i,3) {
        if (S[i]=='R' && t) ans++;
        else if (S[i]=='R') t = true, ans++;
        else if (S[i]=='S') t = false, tmp = max(tmp,ans), ans = 0;
    }
    tmp = max(tmp,ans);
    cout << tmp << endl;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
int const MX = 2e5 + 2;

int main()
{
    string s, t;
    cin>>s>>t;
    int mi = MX;
    for(int i = 0; i < s.size() - t.size() + 1; i++){
        int cnt = 0;
        for(int j = 0; j < t.size(); j++){
            if(s[i + j] != t[j]) cnt++;
        }
        mi = min(mi, cnt);
    }
    cout<<mi;
}




Measured memory_bytes: 3588
unittest
{
	assert( [ "2", "1 5", "2 4", "3 6" ].parse.expand.solve == 3 );
	assert( [ "3", "1 1 1", "2 2 2", "3 3 3" ].parse.expand.solve == 27 );
	assert( [ "6", "3 14 159 2 6 53", "58 9 79 323 84 6", "2643 383 2 79 50 288" ].parse.expand.solve == 87 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.strip.to!( long );
	input.popFront;
	auto as = input.front.split.to!( long[] );
	input.popFront;
	auto bs = input.front.split.to!( long[] );
	input.popFront;
	auto cs = input.front.split.to!( long[] );
	return tuple( as, bs, cs );
}

auto solve( long[] as, long[] bs, long[] cs )
{
	auto r = 0L;
	auto ai = 0L;
	auto ci = 0L;
	
	as.sort();
	bs.sort();
	cs.sort();
	
	// Bを基準にする
	foreach( b; bs )
	{
		// Bより小さいAの数を検索
		while( ai < as.length && as[ ai ] < b ) ai++;
		
		// Bより大きいCの数を検索
		while( ci < cs.length && cs[ ci ] <= b ) ci++;
		auto cr = cs.length - ci;
		
		// 組み合わせの数を計算
		r += ai * cr;
	}
	
	return r;
}


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

int main() {
  int H, W;
  cin >> H >> W;
  vector<char> A((H+2) * (W+2));
  for (int i = 0; i < W + 2; i++) {
    A.at(i) = '#';
    A.at((H + 1) * (W + 2) + i) = '#';
  }
  for (int j = 1; j < H + 1; j++) {
    for (int k = 2; k < W + 2; k++) {
      cin >> A.at((W + 2) * j + k - 1);
    }
  }
  for (int i = 1; i < H + 1; i++) {
    A.at(i * (W + 2)) = '#';
    A.at((i + 1) * (W + 2) - 1) = '#';
  }
  for (int i = 0; i < (H+2) * (W+2); i++) {
    cout << A.at(i);
    
    if ((i + 1) % (W + 2) == 0) {
      cout << endl ;
    }
  }
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  char str1[11], str2[11], str3[11];
  int i=0, j=0;

  scanf("%s", str1);
  scanf("%s", str2);
  scanf("%s", str3);

  while(str1[i]!='\0'){
    i++;
  }

  while(str2[j]!='\0'){
    j++;
  }

  if(str1[i-1]==str2[0]&&str2[j-1]==str3[0])
  puts("YES");
  else
  puts("NO");

  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD=1e9+7;

ll inv(ll a, ll b = MOD){
    ll x0 = 1, y0 = 0, x1 = 0, y1 = 1;
    while (b != 0) {
        const ll q = a / b;
        ll tmp = a % b;
        a = b;
        b = tmp;
        tmp = x0 - q * x1;
        x0 = x1;
        x1 = tmp;
        tmp = y0 - q * y1;
        y0 = y1;
        y1 = tmp;
    }
    return (x0 + MOD) % MOD;
}

ll ncr(int n, int r){
    ll ret = 1;
    for(int i=0; i<r; ++i){
        ret = ((ret * (n-i)) % MOD) * inv(1+i) % MOD;
    }
    return ret;
}

ll pow_mod(ll x, ll n){
    if(n==0)return 1;
    if(n==1)return x;
    ll pow_half = pow_mod(x, n/2);
    return (pow_half * pow_half % MOD) * (n%2==0 ? 1 : x) % MOD;
}

constexpr int MAX_N = 2000000;
ll i_c_n[MAX_N+1], pow_25[MAX_N+1], pow_26[MAX_N+1];
void preprocess(ll n){
    pow_25[0]=1;
    pow_26[0]=1;
    for(int i=1; i<=MAX_N; ++i){
        pow_25[i] = (pow_25[i-1] * 25) % MOD;
        pow_26[i] = (pow_26[i-1] * 26) % MOD;
    }
    i_c_n[n]=1;
    for(int i=n+1; i<=MAX_N; ++i){
        i_c_n[i] = (inv(i-n) * (i-1) % MOD) * i_c_n[i-1] % MOD;
    }
}

int main()
{
    int k;
    string s;
    cin >> k >> s;
    int n = s.length();
    ll ret = 0;
    preprocess(n);
    for (int i=n; i<=n+k; ++i){
        // 延長した文字列で s[n-1] が i 文字目にあるとき
        // s[j] たち（ j < n-1 ）は i-1 箇所の候補から n-1 箇所選んで順番に埋める
        // s[n-1] より前の要素（ i - n 個 ）は、重ならないように選ぶ
        // s[n-1] より後の要素（ n + k - i 個 ）は任意に選べる
        //ll pattern_ = (ncr(i-1, n-1) * pow_mod(25, i-n) % MOD) * pow_mod(26, n+k-i);
        ll pattern = (i_c_n[i] * pow_25[i-n] % MOD) * pow_26[n+k-i] % MOD;
        //cout << pattern_ << " " << pattern << endl;
        ret = (ret + pattern) % MOD;
    }
    cout << ret % MOD;
    return 0;
}


Measured memory_bytes: 50500
#include <iostream>
#include <string>
#include <cctype>
using namespace std;
int main()
{
    string str,s;
    int cnt=0;
    cin >> s;
    for(int i=0,l=s.size();i<l;i++)
        if (isupper(s[i])) s[i]=tolower(s[i]);
    while(cin >> str)
	{
       if(str=="END_OF_TEXT")break;
       for(int i=0,l=str.size();i<l;i++)
           if (isupper(str[i])) str[i]=tolower(str[i]);
       if(s==str) cnt++;
  	}
  	cout << cnt << endl;
  	return 0;
}


Measured memory_bytes: 3212
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>

using namespace std;


int main() {

    int A, B;
    cin >> A >> B;

    cout << max(A - (B * 2), 0) << endl;

    return 0;
}

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

if __name__ == '__main__':
    main()

Measured memory_bytes: 78284
from sys import exit
import fractions

A, B, C, D = map(int, input().split())

CD = (C * D) // fractions.gcd(C, D)

c_sum = B // C - (A - 1) // C
d_sum = B // D - (A - 1) // D
cd_sum = B // CD - (A - 1) // CD

print(B - A + 1 - (c_sum + d_sum - cd_sum))


Measured memory_bytes: 5052
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;

set<vector<int> > isi;
vector<int> datas;
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    for(int a=0;a<3;a++)
    {
        int inp;
        cin>>inp;
        datas.push_back(inp);
    }
    sort(datas.begin(), datas.end());
    int cnt=0;
    while(isi.count(datas)==0)
    {
        for(int a=0;a<3;a++)
        {
            if(datas[a]%2==1)
            {
                cout<<cnt<<endl;
                return 0;
            }
        }
        isi.insert(datas);
        vector<int> tmp;
        for(int a=0;a<3;a++)
        {
            tmp.push_back(0);
        }
        for(int a=0;a<3;a++)
        {
            tmp[a]=(datas[(a+1)%3]/2) + (datas[(a+2)%3]/2);
        }
        datas=tmp;
        cnt++;
        sort(datas.begin(), datas.end());
    }
    cout<<-1<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
    #include<queue>
    #include<cstring>
    using namespace std;
    int n,m,xs,ys,xt,yt,ans[10005][10005];
    int yi[10]={0,0,0,1,-1};
    int xi[10]={0,1,-1,0,0};
    int ym[30]={-2,-2,-2,-2,-2,-1,0,1,2,2,2,2,2,1,0,-1,1,-1,-1,1};
    int xm[30]={-2,-1,0,1,2,2,2,2,2,1,0,-1,-2,-2,-2,-2,1,1,-1,-1};
    char a[1005][1005];
    struct node{int x,y,w;node(){}node(int X,int Y,int W){x=X;y=Y;w=W;}
    bool operator<(const node o)const{return w>o.w;}};
    inline bool chcek(int xx,int yy,int ww)
    {
    	if(a[xx][yy]=='#'||xx<1||xx>n||yy<1||yy>m||ans[xx][yy]<=ww)
    		return 0;
    	return 1;
    }
    inline void bfs()
    {
    	priority_queue<node> q;
    	node now;
    	q.push(node(xs,ys,0));
    	while(q.size())
    	{
    		now=q.top();
    		q.pop();
    		if(ans[now.x][now.y]<now.w)
    			continue;
    		ans[now.x][now.y]=now.w;
    		for(int i=1;i<=4;i++)
    			if(chcek(now.x+xi[i],now.y+yi[i],now.w))
    				q.push(node(now.x+xi[i],now.y+yi[i],now.w));
    		for(int i=1;i<=20;i++)
    			if(chcek(now.x+xm[i],now.y+ym[i],now.w+1))
    				q.push(node(now.x+xm[i],now.y+ym[i],now.w+1));
    	}
    }
    inline int read() 
    {
        int x=0;char ch=getchar();
        while(ch<'0'||ch>'9')
    		ch=getchar();
        while(ch>='0'&&ch<='9')
    	{
    		x=(x<<1)+(x<<3)+(ch^48);
    		ch=getchar();
    	}
        return x;
    }
    inline char read1() 
    {
        char x=getchar();
        while(x!='.'&&x!='#')
    		x=getchar();
        return x;
    }
    int main()
    {
    	n=read();m=read();
    	xs=read();ys=read();
    	xt=read();yt=read();
    	for(int i=1;i<=n;i++)
    		for(int j=1;j<=m;j++)
    			a[i][j]=read1();
    	for(int i=1;i<=n;i++)
    		for(int j=1;j<=m;j++)
    			ans[i][j]=0x3f3f3f3f;
    	ans[xs][ys]=0;
    	bfs();
    	if(ans[xt][yt]==0x3f3f3f3f)
    		printf("-1");
    	else
    		printf("%d",ans[xt][yt]);
    }

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

using namespace std;

#define pb push_back
#define mp make_pair
#define F first
#define S second
#define fo(i, n) for(int i = 1; i <= n; ++i)

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int N = 200200;
const int mod = 1e9 + 7;
int n, d[3][N], a[3][N];

int main()
{
	cin >> n;
	fo(i, 2) fo(j, n) {
		cin >> a[i][j];
		d[i][j] = max(d[i - 1][j], d[i][j - 1]) + a[i][j];
	}
	cout << d[2][n];
	
	return 0;            
}

Measured memory_bytes: 2304
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)

using namespace std;
using ll = long long;
using P = pair<int, int>;

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

    int N;
    cin>>N;
    bool ans = false;
    rep(i, 15) {
        if (N - 7 * i < 0) continue;
        if ((N - 7 * i) % 4 == 0) {
            ans = true;
            break;
        }
    }
    if (ans) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
/*author @dhanush*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define se second
#define fi first
/* FUCK ratings iam in love with expreience*/
ll freq[1001][1001];
ll dp[1001];
ll mod = 1000000007;
int main()
{


  ll n;
  cin >> n;
  ll arr[n];
  for (int i = 0; i < n; i++)
  {cin >> arr[i];}
  ll ans = 0;
  for (int i = 0; i < n; i++)
  {
    for (int j = i + 1; j < n; j++)
    {
      for (int k = j + 1; k < n; k++)
      {
        if (arr[i] != arr[j] && arr[j] != arr[k] && arr[k] != arr[i])
        {
          if (arr[i] + arr[j] > arr[k])
          {
            if (arr[j] + arr[k] > arr[i])
            {
              if (arr[i] + arr[k] > arr[j])
              {
                ans++;
              }

            }
          }
        }
      }
    }
  }
  cout << ans << endl;

}





Measured memory_bytes: 3632
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cstring>
#include <set>
#include <utility>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <string>
#include <map>
#define ll long long
#define read(x) scanf("%d",&x);
#define readll(x) cin>>x;
#define FOR(x,a,b) for(int x=a;x<b;x++)
#define MP make_pair
#define PB push_back
#define pii pair<int,int>
using namespace std;
int N, W;
map <int,int> lho[101];
int w[101];
int v[101];


int kagi(int pos, int sisa){
	if (pos == N) return 0;
	if (lho[pos].count(sisa))
		return lho[pos][sisa];
	int best = 0;
	if (sisa >= w[pos])
		best = v[pos] + kagi(pos + 1, sisa - w[pos]);
	best = max(best, kagi(pos + 1, sisa));
	lho[pos][sisa] = best;
	return best;
}

int main(){
	read(N); read(W);
	FOR(i,0,N){
		read(w[i]); read(v[i]);
	}

	cout<<kagi(0,W)<<endl;
}

Measured memory_bytes: 4736
#include<stdio.h>

int main()
{
	int n, b;
	bool flag=0;
	scanf("%d", &n);
	for(int i = 1; i <= 9; ++i)
	{
		if(n%i) continue;
		b = n/i;
		if(b >= 1 && b <= 9)
		{
			flag = 1;
			break;
		}
	}
	if(flag) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main() {
	int a, b, c, k;
	scanf("%d %d %d %d", &a, &b, &c, &k);

	int *p;
	int max = 0;
	if (max < a) {
		max = a;
		p = &a;
	}
	if (max < b) {
		max = b;
		p = &b;
	}
	if (max < c) {
		max = c;
		p = &c;
	}
	for (int i = 0; i < k; i++) {
		(*p) *= 2;
	}
	printf("%d\n", a + b + c);
}

Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
#include <cstdint>
using namespace std;
using LL = long long;

int N;

int main() {
	cin >> N;
	if (N == 1) {
		cout << "No" << endl;
		return 0;
	}
	int two = 1;
	while (two < N)two *= 2;
	if (two == N) {
		cout << "No" << endl;
		return 0;
	}
	two /= 2;
	auto f = [&](int i, int j) {return i + j * N; };
	vector < pair<int, int>>ans;
	auto con = [&](int a, int b) {ans.push_back({ a, b }); };
	con(f(1, 0), f(2, 0));
	con(f(2, 0), f(3, 0));
	con(f(3, 0), f(1, 1));
	con(f(1, 1), f(2, 1));
	con(f(2, 1), f(3, 1));
	for (int x = 4; x < N; x += 2) {
		if (x == two && N % 2 == 0) {
			int res = N - two;
			con(f(x, 0), f(x + 1, 0));
			con(f(x, 1), f(x + 1, 1));
			con(f(x + 0, 0), f(res + 0, 0));
			con(f(x + 1, 1), f(res + 1, 0));
		}
		else {
			con(f(x, 0), f(x + 1, 0));
			con(f(x, 1), f(x + 1, 1));
			con(f(x + 0, 0), f(1, 0));
			con(f(x + 1, 1), f(1, 0));
		}
	}
	if (N % 2 == 0) {
		int res = N - two;
		con(f(two + 0, 0), f(N, 0));
		con(f(N, 1), f(res + 0, 0));
	}
	cout << "Yes" << endl;
	for (auto p : ans) {
		cout << p.first << " " << p.second << endl;
	}
	return 0;
}

Measured memory_bytes: 4080
#include <stdio.h>

int main() {
	int number, one, two, three, four;

	scanf("%d", &number);

	one = number % 10;
	two = number % 100 - one;
	three = number % 1000 - one - two;
	four = number - one - two - three;
	
	two /= 10;
	three /= 100;
	four /= 1000;

	if (one == two && two == three)
		printf("Yes");
	else if (two == three && three == four)
		printf("Yes");
	else
		printf("No");

	return 0;
}

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

#define ll long long
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define SPEED ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define sz size()
#define all(x) x.begin(),x.end()
#define OO 1e18
#define iOO INT_MAX
#define Mdp memset(dp,-1,sizeof dp)
#define R return
#define Test int TT;cin>>TT;for(int T=1;T<=TT;T++)
using namespace std;
const int Mx = 100010;
ll Dp[110][300010];

int main()
{

    SPEED;

    int n,a[100010][2],W;
    cin >> n >> W;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<=Mx;j++)
            Dp[i][j]= OO;
        cin >> a[i][0] >> a[i][1];
    }
    for(int j=0;j<=Mx;j++)
            Dp[n][j]= OO;
    Dp[0][0]=0;

    for(int i=0;i<n;i++)
    {
        int w = a[i][0], cost = a[i][1];
        for(int j=0;j<Mx;j++)
        {
            Dp[i+1][j] = Dp[i][j];
        }
        for(int j=0;j<Mx;j++)
        {
            Dp[i+1][j+cost] = min(Dp[i+1][j+cost],Dp[i][j]+w);
        }
    }

    for(int i=Mx;i>=0;i--)
       if(Dp[n][i] <= W)
       {
            cout  << i << endl;
            break;
       }
    R 0;
}


Measured memory_bytes: 234624
#include<bits/stdc++.h>
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    map<string,ll> mp;
    for(int i=0; i<N; i++){
        string S;
        cin >> S;
        sort(S.begin(),S.end());
        mp[S]++;
    }
    ll ans = 0;
    for(auto m: mp){
        ans += m.second * (m.second-1)/2LL;
    }
    cout << ans << enld;
    return 0;
}

Measured memory_bytes: 11264
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,K,p=0,i=0,r;
  cin >> N >> K;
  r=1;
  do{
    p=(K-1)*r;
    N=N-p;
    i++;
    r=r*K;
  }while(0<N);
  cout << i << endl;
}

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

int main(){
    int D,T,S;
    cin>>D>>T>>S;
    
    cout<<(D<=T*S?"Yes":"No")<<endl;
}


Measured memory_bytes: 3628
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
#include <stack>
#include <iomanip>
#include <limits>
using namespace std;
#define REP(i,n) for(int i=0; i<n; ++i)
#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 ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
using Graph=vector<vector<int>>;
using edge= struct{int to;ll cost;};
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
typedef priority_queue<ll> PQ_HIGH;
typedef priority_queue<ll,VL,greater<ll>> PQ_LOW;//昇順

int main(){
  int N;cin>>N;
  VI a(N);
  VI ans(N,0);
  REP(i,N-1){
    cin>>a[i];
    a[i]--;
    ans[a[i]]++;
  }
  REP(i,N){
    cout<<ans[i]<<endl;
  }
}


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

#define endl '\n'

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

    int n, q;
    string s;
    cin >> n >> s >> q;
    set<int> freq[26];

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

    for (int g=1; g<=q; g++){
        int t; cin >> t;
        if (t == 1){
            int i;
            char c;
            cin >> i >> c;
            i--;
            freq[s[i]-'a'].erase(i);
            freq[c-'a'].insert(i);
            s[i] = c;
        } else{
            int l, r, ans=0; cin >> l >> r;
            l--; r--;
            for (int i=0; i<26; i++){
                set<int>::iterator f = freq[i].lower_bound(l);
                if (f != freq[i].end() && *f <= r) ans++;
            }
            cout << ans << endl;
        }
    }
}

Measured memory_bytes: 24196
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        int Q = scanner.nextInt();

        int[][] a = new int[n + 1][n + 1];
        for (int i = 0; i < m; i++) {
            a[scanner.nextInt()][scanner.nextInt()]++;
        }
        for (int[] b : a) {
            Arrays.parallelPrefix(b, Integer::sum);
        }
        for (int i = 0; i < Q; i++) {
            int p = scanner.nextInt();
            int q = scanner.nextInt();
            int sum = 0;
            for (int j = p; j <= q; j++) {
                sum += a[j][q] - a[j][p - 1];
            }
            System.out.println(sum);
        }
    }
}

Measured memory_bytes: 166928
#include<stdio.h>
//#include<string>
//using namespace std;
int main(){
   long  l;
  scanf("%d",&l);
  double a=l/3.0;
  double b=l/3.0;
  double c=l/3.0;
  double v=a*b*c;
  printf("%.6f",v);



    return 0;
}





Measured memory_bytes: 128
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n,m = list(map(int, input().split()))
a = list(map(int, input().split()))
if n<sum(a):
    ans = -1
else:
    ans = n - sum(a)
print(ans)

Measured memory_bytes: 79876
from collections import defaultdict, deque
dic = defaultdict(list)
N, M  = map(int, input().split())
for i in range(M):
    a, b = map(int, input().split())
    dic[a].append(b)
    dic[b].append(a)
ans = 0
now = 1
seen = [-1]*N
queue = deque()

for i in range(N):
    if seen[i]!=-1:
        continue
    queue.append(i+1)
    seen[i]=now
    temp=0
    while queue:
        temp+=1
        q = queue.popleft()
        for j in dic[q]:
            if seen[j-1]!=-1:
                continue
            queue.append(j)
            seen[j-1]=now
    now+=1
    ans = max(ans, temp)

print(ans)

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define Rep(i,n) for(int i = 1; i <= n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
template<class T> using V = vector<T>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



int main(){
    int n;
    cin >> n;
    if(65 <= n && n <= 90) cout << 1 << endl;
    else if(97 <= n && n <= 122) cout << 2 << endl;
    else cout << 0 << endl;
}


Measured memory_bytes: 3112
N = int(input())

# A,C,G,T: 0/1/2/3
answer = [1]*64;
answer[9]=0; #AGC
answer[6]=0; #ACG
answer[33]=0;#GAC

if(N>3):
    for i in range(3,N):
        new_answer = [0]*64;
        for j in range(64):
            if j==25 or j==37 or j==41 or j==45 or j==57:
                #CGC / GCC / GGC / GTC / TGC
                for k in range(1,4):
                    new_answer[j] += answer[j//4 + 16*k];
            else:
                for k in range(4):
                    new_answer[j] += answer[j//4 + 16*k];
            new_answer[9]=0;
            new_answer[6]=0;
            new_answer[33]=0;
        for j in range(64):
            answer[j]=new_answer[j];

total = 0;

for j in range(64):
    total += answer[j];

print(total % 1000000007);


Measured memory_bytes: 3064
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int T = sc.nextInt();
        int[] t = new int[N];
        for (int i = 0; i < N; i++) {
            t[i] = sc.nextInt();
        }
        long total = 0;
        for (int i = 0; i < N; i++) {
            total += T;
            if (i + 1 != N) {
                int target = t[i];
                int next = t[i + 1];
                if (next - target < T) {
                    total -= T - (next - target);
                }
            }
        }
        System.out.println(total);
    }
}


Measured memory_bytes: 63472
n = int(input())
aa = list(map(int,input().split()))

d2 = 0
d4 = 0

for ai in aa:
  if ai % 4 == 0:
    d4 += 1
  elif ai % 2 == 0:
    d2 += 1
  else:
    pass  

if d2<=1:
  d2=0
else:
  d2 -= 1
dd = n - d2
if d4 >= dd//2:  
  print('Yes')
else:
  print('No')  

Measured memory_bytes: 15020
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long A, B, M, mx = INT_MAX, mx1 = INT_MAX, i, j, x, y, z, ans, ans1, in;
	cin >> A >> B >> M;
	long long a[A + 1], b[B + 1],a1[A + 1], b1[B + 1];
	for (i = 1; i <= A; i++)
	{
		cin >> a[i];
     a1[i]=a[i];
 	}
	for (i = 1; i <= B; i++)
	{
		cin >> b[i];
		b1[i]=b[i];
	}
	for (i = 1; i <= M; i++)
	{
		cin >> x >> y >> z;
		ans = a[x] + b[y] - z;
		ans = min(ans, mx);
		mx = ans;

	}
	sort(a+1,a+A+1);
	sort(b+1,b+B+1);
     ans1=a[1]+b[1];
	ans = min(ans, ans1);
	cout << ans << endl;
	return 0;

}

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

int main(){
    int S , h , m ,s;
    cin >> S;
    h = S / 3600;
    m = (S % 3600) / 60;
    s = (S % 3600) % 60;

    cout << h << ":" << m << ":" << s << '\n';
    return 0;

}



Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<ll,pll> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-11;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n;

int main(){
	while(1){
		cin>>n;
		if(n==0) break;
		vvi a(n,vi(n));
		for(int i=0;i<n;i++){
			int m;
			cin>>m;
			for(int j=0;j<m;j++){
				int x;
				cin>>x;
				a[i][x-1]++;
			}
		}
		int m;
		cin>>m;
		vi b(m);
		for(int i=0;i<m;i++){
			cin>>b[i];
			b[i]--;
		}
		vi c;
		for(int i=0;i<n;i++){
			bool flag=1;
			for(auto j:b) if(!a[i][j]) flag=0;
			if(flag) c.push_back(i+1);
		}
		if(c.size()==1) cout<<c[0]<<endl;
		else cout<<-1<<endl;
	}
}


Measured memory_bytes: 3184
n=gets.to_i
d,x=gets.split.map &:to_i
p res=n.times.inject(0){|arr,i|
  j=0
  tmp=0
  span=gets.to_i
  while true
    day=1+span*j
    break if day>d
    tmp+=1
    j+=1
  end
  arr+=tmp
}+x

Measured memory_bytes: 1788
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long ll;
int main()
{
	ll x;
	cin>>x;
	ll ans=0;
	ll a=x%500;
	ans+=(x/=500)*1000;
	ll b=a%5;
	ans+=(a/=5)*5;
	cout<<ans<<endl;
} 

Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
li = [a, b, c, d, e]
for i in range(5):
    for j in range(5):
        if i == j:
            continue
        if abs(li[j] - li[i]) > k:
            print(":(")
            exit()
print("Yay!")


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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};


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

  ll n;
  cin >> n;
  ll a[n][n];
  REP(i, n){
    REP(j, n)
      cin >> a[i][j];
  }

  REP(k, n){
    REP(i, n){
      REP(j, n){
        if(a[i][j] > a[i][k]+a[k][j]){
          cout << -1 << endl;
          return 0;
        }
      }
    }
  }


  ll ans = 0;
  REP(i, n){
    for(ll j = i+1; j<n; j++){
      bool flag = true;
      REP(k, n){
        if(k == i || j == k)
          continue;

        if(a[i][j] == a[i][k]+a[k][j]){
          flag = false;
        }
      }

      if(flag)
        ans += a[i][j];
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 1024
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    switch (S){
      case "SUN":
        System.out.println("7"); break;
      case "MON":
        System.out.println("6"); break;
      case "TUE":
        System.out.println("5"); break;
      case "WED":
        System.out.println("4"); break;
      case "THU":
        System.out.println("3"); break;
      case "FRI":
        System.out.println("2"); break;
      case "SAT":
        System.out.println("1"); break;
    }
  }
}

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

int main() {
  int X,Y,Z,A,B,C,ans,a,b;
  string S;
  cin>>S>>X>>Y;
  A=0;
  C=0;
  int x[16001],y[16001],v[16001],w[16001];
  for(int i=0;i<16001;i++){
      x[i]=0;
    y[i]=0;
    v[i]=0;
    w[i]=0;
  }
  x[8000]=1;
  
  y[8000]=1;
    for(int i=0;i<S.length();i++){
    if(S[i]=='T'){
      break;
    }
      if(i==S.length()-1){
        x[8000+1+i]=1;
        x[8000]=0;
          if(x[8000+X]==1&&y[8000+Y]==1){
    cout<<"Yes"<<endl;
    return 0;
  }
  cout<<"No"<<endl;
        return 0;
      }
        
    }
  for(int i=0;i<S.length();i++){
    if(S[i]=='F'){
      C++;
    }
    else{
      if(A==0){
                for(int j=0;j<16001;j++){
          if(x[j]==1){
            v[j+C]=1;
          }
        }
        for(int j=0;j<16001;j++){
                  x[j]=v[j];
                  v[j]=0;
        }
      }
     else if(A%2==0){
        for(int j=0;j<16001;j++){
          if(x[j]==1){
            v[j-C]=1;
            v[j+C]=1;
          }
        }
        for(int j=0;j<16001;j++){
                  x[j]=v[j];
                  v[j]=0;
        }
      }
      else{
        for(int j=0;j<16001;j++){
          if(y[j]==1){
            w[j-C]=1;
            w[j+C]=1;
          }
        }
        for(int j=0;j<16001;j++){
                  y[j]=w[j];
                  w[j]=0;
        }
      }
      A++;
      C=0;
    }
  }
        if(A%2==0){
        for(int j=0;j<16001;j++){
          if(x[j]==1){
            v[j-C]=1;
            v[j+C]=1;
          }
        }
        for(int j=0;j<16001;j++){
                  x[j]=v[j];
        }
      }
      else{
        for(int j=0;j<16001;j++){
          if(y[j]==1){
            w[j-C]=1;
            w[j+C]=1;
          }
        }
        for(int j=0;j<16001;j++){
                  y[j]=w[j];
        }
      }
  if(x[8000+X]==1&&y[8000+Y]==1){
    cout<<"Yes"<<endl;
    return 0;
  }
  cout<<"No"<<endl;
}


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

void main()
{
	int scanCheck = 0;
	int x, n;
	int p[100];
	int hik = 0;
	int cnt = 0;


	scanCheck = scanf("%d", &x);
	scanCheck = scanf("%d", &n);

	for (int i = 0; i < n; i++) {
		scanf("%d", &p[i]);
	}
	for (int i = 0; i < 500; i++) {
		hik = i;
		if (hik % 2 == 0) {
			hik *= 1;
		}
		else {
			hik *= -1;
		}
		x = x + hik;
		for (int i = 0; i < n; i++) {
			if (x != p[i]) {
				cnt++;
			}
		}
		if (cnt == n) {
			break;
		}
		else {
			cnt = 0;
		}	
	}
	printf("%d", x);
}

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

class vertex{
public:
  vector<vertex*> to;
  bool visited;
  int num;
  int group;

  vertex(){
    visited=false;
  }

  void dfs(int group){
    visited=true;
    this->group = group;
    for(int i=0; i<to.size(); i++){
      if(!to[i]->visited) to[i]->dfs(group);
    }
  }
};

int main(){
  int n, m; cin >> n >> m;
  vertex graph[n];

  //隣接リストにグラフを格納
  int v, k, to;
  for(int i=0; i<m; i++){
    cin >> v >> to;
    graph[v].num = v;
    graph[v].to.push_back(&graph[to]);
    graph[to].num = to;
    graph[to].to.push_back(&graph[v]);
  }

  //頂点0からdfsを行い、グループ分け(各連結成分ごとに1から昇順に番号をつける)
  for(int v=0, group=1; v<n; v++){
    if(!graph[v].visited){
      graph[v].dfs(group);
      group++;
    }
  }

  //回答を得る
  int q, v1, v2; cin >> q;
  bool ans[q];
  for(int i=0; i<q; i++){
    cin >> v1 >> v2;
    if(graph[v1].group==graph[v2].group) ans[i]=true;
    else ans[i]=false;
  }

  //回答出力
  for(int i=0; i<q; i++){
    if(ans[i]) cout << "yes" << endl;
    else cout << "no" << endl;
  }

  return 0;
}



Measured memory_bytes: 12020
given_n = STDIN.gets.chomp.to_i
nums = STDIN.gets.chomp.split(' ').map { |n| n.to_i }

nums.sort!
middle_idx = nums.size / 2 - 1
middle_smaller_num = nums[middle_idx]
middle_bigger_num = nums[middle_idx + 1]
count = middle_bigger_num - middle_smaller_num
puts count


Measured memory_bytes: 9472
N,K=map(int,input().split())
A=[0]*(N+1)
for i in range(N+1):
    A[i]=i
ans=0

B=[0]*(N+2)
for i in range(N+1):
    B[i+1]=B[i]+A[i]

while True:
    if K>N+1:
        break
    else:
        ans+=B[-1]-B[N-K+1]-B[K]+1
        K+=1

print(ans%(10**9+7))

Measured memory_bytes: 26984
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();
            int[] x = new int[n + 1];
            int[] y = new int[m + 1];
            x[0] = in.nextInt();
            y[0] = in.nextInt();

            for (int i = 1; i <= n; i++)
                x[i] = in.nextInt();
            for (int i = 1; i <= m; i++)
                y[i] = in.nextInt();

            Arrays.sort(x);
            Arrays.sort(y);
            out.println(x[n] < y[0] ? "No War" : "War");
        }

    }

    static class FastScanner {
        private InputStream in;
        private byte[] buffer = new byte[1024];
        private int bufPointer;
        private int bufLength;

        public FastScanner(InputStream in) {
            this.in = in;
        }

        private int readByte() {
            if (bufPointer >= bufLength) {
                if (bufLength == -1)
                    throw new InputMismatchException();

                bufPointer = 0;
                try {
                    bufLength = in.read(buffer);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (bufLength <= 0)
                    return -1;
            }
            return buffer[bufPointer++];
        }

        private static boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public long nextLong() {
            long n = 0;

            int b = readByte();
            while (isSpaceChar(b))
                b = readByte();

            boolean minus = (b == '-');
            if (minus)
                b = readByte();

            while (b >= '0' && b <= '9') {
                n *= 10;
                n += b - '0';
                b = readByte();
            }

            if (!isSpaceChar(b))
                throw new NumberFormatException();

            return minus ? -n : n;
        }

        public int nextInt() {
            long n = nextLong();

            if (n < Integer.MIN_VALUE || n > Integer.MAX_VALUE)
                throw new NumberFormatException();

            return (int) n;
        }

    }
}



Measured memory_bytes: 22740
import scala.io.StdIn._
object Main extends App{
  val sc = new java.util.Scanner(System.in)
  var a,b,c,d = sc.nextInt
  var sum=0
  if(a<b){
    if(c<d){
      println(a+c)
    }
    else{
      println(a+d)
    }
  }
  else{
    if(c<d){
      println(b+c)
    }
    else{
      println(b+d)
    }
  }
}

Measured memory_bytes: 27200
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define f first
#define s second
#define mp make_pair
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int a,b,c;
	cin>>a>>b>>c;
	ll area = (c/2)*(b-a)+a*c;
	cout<<area<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <vector>
using namespace std;

#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)
#pragma GCC optimize("unroll-loops")

#define DEBUG(x) cout << ">> " << #x << ": " << x << endl;
#define _ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int MOD = 1000000007;
typedef long long ll;
typedef long double ld;

int main() { _
  int a, b; cin >> a >> b;
  if (b == 1) cout << 0;
  else {
    for (int i = 1; i < 25; i++) {
      if (i*a - i + 1 >= b) { cout << i; break; }
    }
  }
  return 0;
}

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

const int inf = 1e9;
const int N = 100010;

int n, k;
int h[N], cost[N];

int main() {
	cin >> n >> k;
	for (int i = 1; i <= n; ++i) {
		cin >> h[i];
	}
	for (int i = 1; i <= n; ++i) {
		cost[i] = inf;
	}
	cost[1] = 0;
	for (int i = 2; i <= n; ++i) {
		for (int j = i - 1; j > 0 && i - j <= k; --j) {
			cost[i] = min(cost[i], cost[j] + abs(h[i] - h[j]));
		}
	}
	cout << cost[n] << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <string.h>
#define rep(i, n) for(int i = 0; i<(n); i++)
using namespace std;
typedef long long ll;
static const int MAX = 200000; 
//pi = 3.14159265358979323846

int main() {

  int r;
  cin >> r;
  cout << r * r << endl;

}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define pii std::pair<int,int>
#define pli std::pair<ll,int>
#define pil std::pair<int,ll>
#define psi std::pair<string,int>
#define pll std::pair<ll,ll>
#define pci std::pair<char,int>
#define sll(x) scanf("%lld",&x)
#define prll(x) printf("%lld ",x)
#define pri(x) printf("%d ",x)
#define si(x) scanf("%d",&x)
#define pb push_back
#define vll std::vector<ll>
#define vpi std::vector<std::pair<int,int>>
#define vi std::vector<int>
#define vvi std::vector<std::vector<int>>
#define vvpil std::vector<std::vector<std::pair<int,ll>>>
#define vlpii std::vector<std::list<pii>>
#define vlpil std::vector<std::list<pil>>
#define li std::list<int>
#define lpil std::list<pil>
#define Endl printf("\n")
#define vli vector<list<int>>
#define vvll vector<vector<ll>>
#define mp make_pair
#define x first
#define y second
#define ull uint64_t
#define ma 100000000
#define imie(...) "[" << #__VA_ARGS__": " << (__VA_ARGS__) << "] "
const ll  INF=10000000000000;
const ll mod =  1e9 + 7;
using namespace std;
void add(ll& a , ll b){
	a += b;
	if(a >= mod) a -= mod;
}
ll mul(ll a , ll b){
	return (a * b) % mod;
}
ull Pow(ull a , ull b){
	if(b == 0) return 1 ;
	ull c = Pow(a , b / 2) ;
	if(b % 2) return (a * ((c * c) % mod)) % mod;
	return (c * c) % mod ;
}

		

int main(){
	IOS;
	cout.precision(30) ;
	int n , k; cin >> n >> k ;
	vll a(n);for(int i = 0 ; i < n ; i++) cin >> a[i] ;
	sort(a.begin() , a.end()) ;
	ll ans = 1e9 ;
	for(int i = k - 1 ; i < n ; i++){
		ans = min(ans , a[i] - a[i - (k - 1)]) ;
	}
	cout << ans << endl ;
	return 0;
}


Measured memory_bytes: 1152
import copy

n, m, q = map(int, input().split())
Q = [list(map(int, input().split())) for _ in range(q)]

B = []

# 一列の玉を，仕切り板によって分ける問題だと考えれば良い
# 全ての並び方の候補を全探索する。
# 再帰を用いる。

# 深さ優先探索で再帰を当たり前に使えるようにならないといけない。

# 各ボールがどこに入っているかの候補リストを出す再帰関数
# 例えば最初の例題の答えの物は，全ての結果の中から[1, 3, 4]というものを選んだことになる。
def dfs(A, l):
    if l == n:
        # 長さが，Nになったときにのみ，Bというグローバル変数に代入する。
        B.append(A)
    else:
        # ボールを，入る箇所でラベルしながら加えていく。forで回す。
        # ただし，入る箇所は前のものと同じかそれより後ろにならないといけなのでrangeに注意
        for i in range(A[-1], m+1):
            nA = copy.copy(A)
            nA.append(i)
            dfs(nA, l+1)
dfs([1],1)


# ここまでで，ありうる全ての候補が上がった。
ans = 0
for ls in B:
    point = 0
    for que in Q:

        if ls[que[1]-1] - ls[que[0]-1] == que[2]:
            point += que[3]
    ans = max(point, ans)

print(ans)

Measured memory_bytes: 83100
a,b=map(int,input().split())
L=[[] for i in range(a)]
u=0
for i in range(b):
    u+=1
    c=list(map(int,input().split()))
    c.append(u)
    L[int(c[0])-1].append(c)
for i in L:
    i.sort(key=lambda x:x[1])
for i in L:
    e=0
    for j in i:
        e+=1
        j.append(e)
q=[]
for w in L:
   q.extend(w) 
q.sort(key=lambda x:x[2])
for r in range(b):
        print(str(q[r][0]).zfill(6)+str(q[r][3]).zfill(6))

Measured memory_bytes: 43172
#include<iostream>
#include<utility>
using namespace std;
typedef pair<int, int> P;

int main(void){
  int n,w; cin>>n>>w;
  P item[n];
  for(int i=0; i<n; ++i){
    int v,weight; cin>>v>>weight;
    item[i] = P(v,weight);
  }
  int dp[n+1][w+1];
  for(int i=0; i<=w; ++i) dp[0][i]=0;
  for(int i=0; i<n; ++i){
    for(int j=0; j<=w; ++j){
      if( j<item[i].second){
        dp[i+1][j] = dp[i][j];
      }
      else{
        dp[i+1][j] = max(dp[i+1][j-item[i].second] + item[i].first, dp[i][j]);
      }
    }
  }
  cout << dp[n][w] << endl;
  return 0;
}



Measured memory_bytes: 7028
#include<stdio.h>

void trace(int a[], int n) {
  int i;
  for ( i = 0; i < n; i ++) {
    if ( i > 0 ) printf(" ");
    printf("%d", a[i]);
  }
  printf("\n");
}

void insertSort(int a[], int n) {
  int v, i, j;
  for ( i = 1; i < n; i++ ) {
    v = a[i];
    j = i - 1;
    while ( j >= 0 && a[j] > v ) {
      a[j+1] = a[j];
      j--;
    }
    a[j+1] = v;
    trace(a, n);
  }
}

int main() {
  int n, i, j, a[100];
  scanf("%d", &n);
  for ( i = 0; i < n; i++ ) scanf("%d", &a[i]);

  trace(a, n);
  insertSort(a, n);

  return 0;
}



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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ASC(x) sort(ALL((x)))
#define DESC(x) sort(ALL((x)),greater<ll>())
#define REV(x) reverse(ALL((x)))
#define pb push_back
#define eb emplace_back

int main()
{
    ll H, W, K;
    cin >> H >> W >> K;
    vector<vector<char>> c(H, vector<char>(W));
    REP(i,0,H) {
        REP(j,0,W) cin >> c[i][j];
    }

    ll cnt = 0, cnt_b;
    REP(i,0,1<<H) {
        REP(j,0,1<<W) {
            cnt_b = 0;
            REP(k,0,H) {
                REP(l,0,W) {
                    bool c1 = (((i>>k) & 1) == 0);
                    bool c2 = (((j>>l) & 1) == 0);
                    bool c3 = (c[k][l] == '#');
                    if(c1 && c2 && c3) {
                        ++cnt_b;
                    }
                }
            }
            if(cnt_b == K) ++cnt;
        }
    }
    PR(cnt);

    return 0;
}

/*



*/

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

bool prime_check(int n){
    switch(n){
        case 1: return false;
        case 2: return true;
    } 
    if(n%2 == 0) return false;
    for(int i=3;i*i<=n;i+=2){
        if(n%i == 0) return false;
    }
    return true;
}

int main(){
    int a,d,n;
    while(cin>>a>>d>>n, n!=0){
       int count=0,ans=0,num;
       for(int i=0; count!=n ;i++){
            num = a + (d*i);
            if(prime_check(num)==true){
               count++;
               ans = num;
           }
       }
       cout << ans << endl;
    }
}

Measured memory_bytes: 3076