akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

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

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

#define SIZE 8000000
int make(int m, int n) {
    int cnt = 0;
    bool primes[SIZE + 10] = {};
    for(int i=m; i<=SIZE; i++) {
        if(!primes[i]) {
            cnt++;
            if(cnt == n + 1) return i;
            for(int j=i+i; j<=SIZE; j+=i) {
                primes[j] = true;
            }
        }
    }
    return 0;
}

signed main() {
    int m, n;
    while(cin >> m >> n, m || n) {
        if(m > n) cout << m + n << endl;
        else {
            cout << make(m, n) << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 10892
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
typedef long long i64;
int main(){
    int A,B;
    cin >> A >> B;
    cout << A*B-A-B+1 << endl;
}


Measured memory_bytes: 256
# HonestOrUnkind2
# input
N = int(input())
maxlen = len(bin(2**N-1)[2:])
testimonies = []
res = 0

for i in range(N):
    testimony = [-1] * N
    n = int(input())
    
    for j in range(n):
        x, y = map(int, input().split())
        testimony[x-1] = y

    testimonies.append(testimony)

for _ in range(1 << N):
    # 仮定とした正直者と，仮定とした正直者の証言を比較すれば十分であることに注意(仮定により，どうあるべきかは決まっているので)
    ok = True
    ans = [int(e) for e in bin(_)[2:].zfill(maxlen)]
    for i, t in enumerate(ans.copy()):
        if t==1: # 正直者の仮定により証言を検証
            for j, v in enumerate(testimonies[i]):
                if v != -1: # -1は言及なし
                    if ans[j] == -1:
                        ans[j] = v 
                    elif ans[j] != v:
                        ok = False
    # print('modified ans: ', ans)
    if ok:
        # print('here')
        res = max(res, sum(e for e in ans if e==1))
    
    
# output
print(res)


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

struct edge{int to, cost;};
typedef pair<int, int> P;
const int INF = 1e9;
const int MAX_V = 1e5;

vector<edge> G[MAX_V];
vector<int> d(MAX_V,INF);
int n;

void dijkstra(int s){
  priority_queue<P,vector<P>,greater<P>> que;
  rep(i,n) d[i] = INF;
  d[s] = 0;
  que.push(P(0,s));
  while(!que.empty()){
    P p = que.top();
    que.pop();
    int v = p.second;
    if(d[v] < p.first) continue;
    for(auto e : G[v]){
      if(d[e.to] > d[v] + e.cost){
        d[e.to] = d[v] + e.cost;
        que.push(P(d[e.to], e.to));
      }
    }
  }
}

int main(){
  int u, v;
  cin >> n >> u >> v;
  u--; v--;
  vector<int> up;
  rep(i,n-1) {
    int x, y;
    cin >> x >> y;
    x--; y--;
    if(x == u) up.push_back(y);
    if(y == u) up.push_back(x);
    G[x].push_back(edge{y,1});
    G[y].push_back(edge{x,1});
  }
  if(up.size() == 1 && up[0] == v) {
    cout << 0 << endl;
    return 0;
  }
  vector<int> du(n), dv(n);
  dijkstra(u);
  rep(i,n) du[i] = d[i];
  dijkstra(v);
  rep(i,n) dv[i] = d[i];
  int ans = 1;
  rep(i,n) {
    if(du[i] < dv[i]) {
     ans = max(ans,dv[i]-1);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 8328
import collections

dq = collections.deque()
N, Q = map(int, input().split())
for i in range(N):
    name, time = input().split()
    dq.append((name, int(time)))
total_time = 0
while dq:
    name, time = dq.popleft()
    total_time += min(Q, time)
    if time <= Q:
        print(name, total_time)
    else:
        dq.append((name, time-Q))

Measured memory_bytes: 14496
N, M = map(int, input().split())
d = []
for i in range(1, int(M**0.5)+1):
	if M%i == 0:
		d.append(i)
		d.append(M//i)
d.sort()
for i in range(1,len(d)+1):
	if d[-i] <= M//N:
		print(d[-i])
		exit()


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

using namespace std;

typedef pair<int, int> ii;
typedef long long ll;
const int oo = 1e9 + 7;

const int N = 1e5 + 5;
int n, a[N], l[N], r[N];

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; ++i)
    cin >> a[i];
  l[0] = r[n + 1] = 0;
  for (int i = 1; i <= n; ++i)
    l[i] = __gcd(l[i - 1], a[i]);
  for (int i = n; i >= 1; --i)
    r[i] = __gcd(r[i + 1], a[i]);
  int ans = 0;
  for (int i = 1; i <= n; ++i)
    ans = max(ans, __gcd(l[i - 1], r[i + 1]));
  cout << ans;
  return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define ll long long
#define read(x) scanf("%d",&x)
using namespace std;
const int maxn = 1e3 + 10;

int n;
int b[maxn];
int a[maxn];

int main()
{   
	cin>>n;
	for(int i=1;i<n;i++){
		read(b[i]);
	}
	ll res = 0;
	a[1] = b[1];
	res += a[1];
	for(int i=2;i<n;i++){
		a[i] = min(b[i-1],b[i]);
		res += a[i];
	}
	a[n] = b[n-1]; 
	res += a[n];
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

func abs(a int) int {
	if a < 0 {
		return -a
	} else {
		return a
	}
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func main() {
	var a int
	var b float64
	fmt.Scan(&a,&b)
	b=b*100
	bi:=int(math.Round(b))
	fmt.Println(a*bi/100)


}


Measured memory_bytes: 1772
#include<bits/stdc++.h>
using namespace std;
int arr[1000000];

int main()
{
long long int n,mx,sum=0;
cin>>n;
for(int i=0;i<n;i++)
{
    cin>>arr[i];
    if(i==0){mx=arr[i]; continue;}
    if(arr[i]<mx){
    sum+=mx-arr[i];
    }
    else{mx=arr[i];}
}
cout<<sum<<endl;
}


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

int main() {
  int n, mil = 196470;
  cin >> n;
  for(int i = 0; i < n; i++) {
    int y, m, d, ans = mil;
    cin >> y >> m >> d;
    ans -= (y-1)*39*5 + (y-1)/3*5;
    ans -= (m-1)*20;
    if(y%3 != 0) ans += (m-1)/2;
    ans -= d-1;

    cout << ans << endl;
  }
}

Measured memory_bytes: 1160
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
int n, a, b, p;
ll sum, c[100000], d[100000], maxi;
vector<int> v[100000];

void dfs(int x, int y) {
  d[x] = c[p];
  p--;
  for (int i = 0; i < v[x].size(); i++) {
    if (v[x][i] != y) {
      dfs(v[x][i], x);
    }
  }
}

int main() {
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    cin >> a >> b;
    a--;
    b--;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  for (int i = 0; i < n; i++) {
    cin >> c[i];
    sum += c[i];
    maxi = max(maxi, c[i]);
  }
  sum -= maxi;
  sort(c, c + n);
  p = n - 1;
  dfs(0, -1);
  cout << sum << endl;
  for (int i = 0; i < n; i++) {
    cout << d[i] << " ";
  }
  cout << endl;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
int d,s=0,m=-1;  
char c[110];        
int main() {
    cin>>d>>c;
    for(int i=0;i<d;i++){
        if(c[i] == 'I')       
            s ++;
        else
            s --;              
        m=max(m,s);       
    }
    if(m==-1) 
        m = 0;     
    cout<<m;         
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define repr(i, a, b) for(int i = b-1; i >= a; i--)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
using ll = long long;
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl
#define coel cout << endl
#define pb push_back
#define sz(v) ((ll)(v).size())
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define pp pair<ll, pair<ll, ll>> 
#define fi first
#define se second

////////////////////////////////////////////////////////


int main() {
    ll x; cin >> x;
    ll now = x;
    ll cnt = 1;
    while(now%360 != 0){
        now += x;
        cnt++;
    }
    co(cnt);

    return 0;
}




Measured memory_bytes: 3584
from heapq import heappush, heappop
n = int(input())
G = [[] for i in range(n)]
for i in range(n-1):
    a, b, c = map(int, input().split())
    G[a-1].append((b-1, c))
    G[b-1].append((a-1, c))

q, k = map(int, input().split())

dist = [10**18]*n
que = [(0, k-1)]
dist[k-1] = 0
while que:
    cost, v = heappop(que)
    if dist[v] < cost:
        continue
    for t, c in G[v]:
        if cost + c < dist[t]:
            dist[t] = cost + c
            heappush(que, (cost + c, t))
ans = []
for i in range(q):
    x, y = map(int, input().split())
    ans.append("%d" % (dist[x-1] + dist[y-1]))
print("\n".join(ans))



Measured memory_bytes: 53800
#include <bits/stdc++.h> 
using namespace std;
///////////////////////////////////////////
const long long int INF = 100000000000;
const long long int Mod = 1000000007;
using ll = long long int; //long long int は64bit
using vi = vector<int>; using Vi = vector<long long int>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(long long int i=0;i<N;i++)
#define np nullptr
template<class T>bool chmax(T &former, const T &b) { if (former<=b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define fill(x,num) memset(x,num,sizeof(x));
typedef vector<vector<ll> > matrix;
typedef pair<ll,ll> Pair;
bool p_compare(const Pair& firstP, const Pair& secondP){ 
    return firstP.second < secondP.second; 
}//sort(all(v),p_compare)で昇順ソート
//////////////////////////^^ *Emile ^^^//////////////////////////////////////////////////////
//Snipet -> Caps Lock

vi v;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll a,b,c,d,e,k;
    vi v;ll aaa;
    bool ck = true;
    rep(i,5){
        cin>>aaa;
        v.pb(aaa);
    }
    cin>>k;
    rep(i,5){
        if(v[i]-v[0]>k)ck = false;
    }
    if(ck)cout<<"Yay!"<<endl;
    else cout<<":("<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

typedef unsigned int uint;
typedef long long llong;
typedef unsigned long long ullong;
typedef long double ldouble;

typedef vector<llong> vecllong;
typedef vector<vecllong> vvecllong;

const llong MOD = 1e9 + 7;
const llong INF = 1e17;

#define FOR(i, n) for (llong i = 0; i < n; i++)
#define FORS(i, a, b) for (llong i = a; i < b; i++)
#define FORR(i, n) for (llong i = n; i > 0; i++)
#define asc less<llong>()
#define desc greater<llong>()

struct edge {
    llong from;
    llong to;
    llong cost;
};

llong ctoi(char c) {
    switch (c) {
        case '0': return 0;
        case '1': return 1;
        case '2': return 2;
        case '3': return 3;
        case '4': return 4;
        case '5': return 5;
        case '6': return 6;
        case '7': return 7;
        case '8': return 8;
        case '9': return 9;
        default: return 0;
    }
};

bool search(llong start, llong end, vector<vector<edge>> map){
    vector<bool> confilm(map.size() + 10, false);

    stack<llong> st;
    st.push(start);

    while(!st.empty()) {
        llong now = st.top();
        st.pop();

        if(confilm[now]) continue;
        confilm[now] = true;
        if(now == end) return true;

        for_each(map[now].begin(), map[now].end(), [&](edge e) {
            st.push(e.to);
        });
    }

    return false;
};

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

    llong N, M, P;
    cin >> N >> M >> P;

    vector<edge> edges;
    vecllong minDist(N + 10, INF);

    vector<vector<edge>> map(N + 10, vector<edge>(0));

    minDist[0] = 0;

    FOR(i, M) {
        llong from, to, cost;
        cin >> from >> to >> cost;
        from--;
        to--;
        cost -= P;
        edges.push_back({from, to, -cost});
        map[from].push_back({from, to, -cost});
    }

    FOR(i, N) {
        FOR(j, edges.size()) {
            edge e = edges[j];
            if(minDist[e.to] > minDist[e.from] + e.cost) {
                minDist[e.to] = minDist[e.from] + e.cost;
            }
        }
    }

    llong ans = -minDist[N - 1];

    FOR(i, N) {
        FOR(j, edges.size()) {
            edge e = edges[j];
            if(minDist[e.to] > minDist[e.from] + e.cost) {
                minDist[e.to] = minDist[e.from] + e.cost;
            }
        }
    }

    if(ans != -minDist[N - 1]) {
        cout << "-1" << endl;
        return 0;
    }

    cout << max(ans, 0LL) << endl;

    return 0;
}

Measured memory_bytes: 768
import math
from collections import Counter
n,k=map(int,input().split())
di={}
for i in range(k):
	d=int(input())
	l=[int(x) for x in input().split()]
	for j in l:
		if j not in di:
			di[j]=1
		else:
			di[j]+=1
c=0
for i in range(1,n+1):
	if i not in di:
		c+=1
print(c)


Measured memory_bytes: 68144
#include<iostream>
#include<vector>
#include<cstring>
#include<map>
#include<cassert>

using namespace std;

const int MAX = 51;
const int GOODS = 8;
struct data{
  char c;
  int maxX,maxY,minX,minY;
};
vector<data> V;
map<char,int> M;
bool come[MAX][MAX];
char field[MAX][MAX];
int W,H,cnt;
int dx[] = {0,1,0,-1};
int dy[] = {1,0,-1,0};
bool Edge[GOODS][GOODS];

void init(){
  cnt=0;
  V.clear();
  M.clear();
  memset(come,false,sizeof(come));
  memset(Edge,false,sizeof(Edge));
}

void input(){
  cin >> H >> W;
  for(int i = 0; i < H; i++)
    for(int j = 0; j < W; j++) cin >> field[i][j];
}

void set(char c, int x, int y){
  for(int i = 0; i < V.size(); i++)
    if(c == V[i].c){
      V[i].maxX = max(V[i].maxX,x);
      V[i].maxY = max(V[i].maxY,y);
      V[i].minX = min(V[i].minX,x);
      V[i].minY = min(V[i].minY,y);
      return;
    }
  
  V.push_back((data){c,x,y,x,y});
  M[c] = ++cnt;
}

bool isInside(int x, int y){ return 0<=x&&x<W&&0<=y&&y<H;}

void rec(int x, int y, char c){
  
  if(come[y][x]) return;
  come[y][x] = true;
  set(c,x,y);

  for(int i = 0; i < 4; i++){
    int nx = x+dx[i];
    int ny = y+dy[i];
    if(isInside(nx,ny) && field[ny][nx] == c) rec(nx,ny,c);
  }
}

bool check(data d){
  for(int i = d.minY; i <= d.maxY; i++)
    for(int j = d.minX; j <= d.maxX; j++)
      if(field[i][j] == '.') return false;
      else if(d.c != field[i][j]) Edge[M[d.c]][M[field[i][j]]] = true;
  return true;
}

bool circle(){

  for(int i = 1; i <= cnt; i++)
    for(int j = 1; j <= cnt; j++)
      for(int k = 1; k <= cnt; k++) Edge[i][j] = Edge[i][j]||Edge[i][k]&&Edge[k][j];

  for(int i = 1; i <= cnt; i++)
    if(Edge[i][i]) return true;
  return false;
}

void solve(){
  for(int i = 0; i < H; i++)
    for(int j = 0; j < W; j++)
      if(!come[i][j] && field[i][j] != '.') rec(j,i,field[i][j]);
    

  for(int i = 0; i < V.size(); i++)
    if(!check(V[i])){
      cout << "SUSPICIOUS" << endl;
      return;
    }

  if(!circle()) cout << "SAFE" << endl;
  else cout << "SUSPICIOUS" << endl;
}

int main(){
  int T;
  cin >> T;
  while(T--){
    init();
    input();
    solve();
  }
  return 0;
}

Measured memory_bytes: 1272
import java.util.Scanner;
import java.util.TreeSet;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		TreeSet<Integer> ts = new TreeSet<>();
		int n = scan.nextInt();
		for (int i = 0; i < n; i++) {
			ts.add(scan.nextInt());
		}
		System.out.println(ts.last() - ts.first());
	}

}

Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define endl "\n"
#define rep(i, a, n) for (int i = a; i < n; ++i)
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, x, t;
    cin >> n >> x >> t;

    if (n % x != 0) {
        cout << (n / x + 1) * t << endl;
    } else {
        cout << n / x * t << endl;
    }
    return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
//#include<string.h>
//#include <iostream>
using namespace std;
int main(void){

  int N;
  int j=0;


  string S;
  cin >> N;
  cin >> S;
  int K=N/2;
  string tmp="No";
  if(N%2==0 && S.substr(0,K)==S.substr(K,K)){
    tmp ="Yes"  ;
  }

  cout << tmp<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long 
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define ii pair<int,int>
#define vii vector<ii>
#define vi vector<int>

#define F_OR(i, a, b, s) for (int i=(a); (s)>0?i<(b):i>(b); i+=(s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define EACH(x, a) for (auto& x: a)
 
// debug templates 
#define debug(x)       cerr<< #x <<" : "<< x << endl;
#define debuga(A,N)    cerr<< #A <<" : [";for(int i = 0; i<N;i++) cerr<<A[i]<<" "; cerr<<"]\n";
#define debuga2(A,N,M) cerr<< #A << " : \n"; for(int i=0;i<N;i++){cerr<<"[";for(int j=0;j<M;++j) cerr<<A[i][j]<<" ";cerr<<"]\n";}
#define debugp(p)      cerr<< #p <<" : "<<"("<<(p).first<<","<<(p).second<<")\n";
#define debugv(v)      cerr<< #v <<" : "<<"[";for(int i = 0; i< (v).size(); i++) cerr<<v[i]<<" "; cerr<<"]\n";
#define debugv2(v)     cerr<< #v << " : \n"; for(int i=0;i<v.size();i++){cerr<<"[";for(int j=0;j<(v[0].size());++j) cerr<<v[i][j]<<" ";cerr<<"]\n";}
#define debugs(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin(); itr!=m.end();itr++) cerr<<*itr<<" "; cerr<<"]\n";
#define debugm(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin();itr!=m.end(); itr++) cerr<<"("<<itr->first<<","<<itr->second<<") ";cerr<<"]\n";

const int mod = 1e9 + 7, nax = 1e6 + 50;
 
int n,m,k; 

//p1 * (nm-2 ncR k-2)
//p2 * (nm-2 ncR k-2)


//(nm-2 ncR k-2)(p1 + p2 + p3 + ....)

//1,0 2,0 3,0, overall manhattan distance of all pairs = 3

//1,2,3
//0,1,1 + 1*2 = 3

ll fac[nax*2], fin[nax*2];

ll power(ll a, ll b){
	ll result = 1;
	while(b>0){
		if(b&1) result = (result*a)%mod;
		(a*=a)%=mod;
		b/=2;
	}
	return result;
}

int inv(ll x){
	ll e= mod-2, r= 1;
	while(e){
		if(e&1) r = r*x%mod;
		x = x*x % mod;
		e >>= 1;
	}
	return r;
}

int ncr(ll a, ll b){
	if(b<0 || b>a) return 0;
	return fac[a]*fin[b] %mod * fin[a-b]%mod;
}


ll dist(){
	ll ans = 0;
	vector<ll> x,y;
	FOR(i,1,n+1) FOR(_,m) x.pb(i);
	FOR(i,1,m+1) FOR(_,n) y.pb(i);
	
	ll prev_sum = 0;
	FOR(i,1,x.size()){
		ans += ((x[i]-x[i-1]) * i + prev_sum)%mod;
		ans %= mod;
		prev_sum += ((x[i]-x[i-1]) * i)%mod;
		prev_sum %= mod;
	}
	
	prev_sum = 0;
	FOR(i,1,y.size()){
		ans += ((y[i]-y[i-1]) * i + prev_sum)%mod;
		ans %= mod;
		prev_sum += ((y[i]-y[i-1]) * i)%mod;
		prev_sum %= mod;
	}
	return ans;
}


void solve(){
	cin >> n >> m >> k;
	fac[0] = 1;
	FOR(i,1,nax*2) fac[i] = fac[i-1] * i % mod;
	fin[nax*2-1] = inv(fac[nax*2-1]);
	for(int i = nax*2-2; i>=0; --i) fin[i] = fin[i+1]*(i+1)%mod;
	cout << (dist() * ncr(n*m-2,k-2))%mod;
}
 
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	solve();
	return 0;
}
 


Measured memory_bytes: 39204
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ld INF = (ld)10000000000000;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
int n, q;
vector<ll> v;

ll sum[1 << 17];
vector<LP> vl[1 << 17];

int main() {
	cin >> n >> q;
	v.push_back(n);
	rep(i, q) {
		ll x; cin >> x;
		while (!v.empty() && v[v.size() - 1] >= x)v.pop_back();
		v.push_back(x);
	}
	if (v.size() == 1) {
		rep1(i, n) {
			if (i <= v[0])cout << 1 << endl;
			else cout << 0 << endl;
		}
		return 0;
	}
	vl[v.size() - 2].push_back({ v[v.size() - 1],1 });
	for (int i = v.size() - 2; i > 0;i--) {
		sort(vl[i].begin(), vl[i].end());
		rep(j, vl[i].size()) {
			ll csum = vl[i][j].second;
			while (j + 1 < vl[i].size() && vl[i][j].first == vl[i][j + 1].first) {
				j++; csum += vl[i][j].second;
			}
			ll d = vl[i][j].first / v[i]; ll r = vl[i][j].first%v[i];
			if (d > 0) {
				vl[i - 1].push_back({ v[i],d*csum });
			}
			if (r > 0) {
				int id = lower_bound(v.begin(), v.end(),r) - v.begin();
				id = max(id - 1, 0);
				vl[id].push_back({ r,csum });
			}
		}
	}
	rep(i, vl[0].size()) {
		ll d = vl[0][i].first / v[0], r = vl[0][i].first%v[0];
		sum[v[0]] += d * vl[0][i].second;
		sum[r] += vl[0][i].second;
	}
	ll ans = 0;
	vector<ll> out;
	per1(i, v[0]) {
		ans += sum[i];
		out.push_back(ans);
	}
	reverse(out.begin(), out.end());
	rep(i, v[0]) {
		cout << out[i] << endl;
	}
	Rep(i, v[0], n) {
		cout << 0 << endl;
	}
	//stop
		return 0;
}



Measured memory_bytes: 24692
#include <bits/stdc++.h>
using namespace std;
typedef long long       ll;
typedef pair<int,int>   ii;
typedef vector<int>     vi;
typedef vector<ii>      vii;
typedef set<int>        si;
typedef set<ii>         sii;

#define all(x) x.begin(),x.end()
#define clr(x,v) memset(x,v,sizeof x)
#define sz(x) (int)x.size()
#define re return

template<typename T> T sgn (T x)      {re x<0? -1:(x>0? 1:0); }
template<typename T> T gcd (T a, T b) {re a ? gcd (b % a, a) : b; }
template<typename T> T abs (T x)      {re x < 0 ? -x : x; }
template<typename T> T sqr (T x)      {re x*x;}

#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define ins insert
#define y second
#define x first
#define endl "\n"
#define MOD (int)1e9+7
#define N (int)2e5+123

int n,a,b;

void solve(){
	ll x;
    cin >> x;
    ll p = 100, result = 0;
    while(p < x){
        p += p/100;
        result++;
}
	cout << result << endl;
}

int main(){_
        solve();
}

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

using namespace std;
#define inputInt(a) int a; cin >> a; 
#define inputInt2(a,b) int a; int b; cin >> a >> b; 
#define inputInt3(a,b,c) int a; int b; int c; cin >> a >> b >> c;
#define inputLong(a) long a;cin >> a; 
#define inputIntArray(a,N) int a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputLongArray(a,N) long a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputIntArray2(a,b,N) int a[N]; int b[N]; for(int i=0;i<N;i++){cin >> a[i] >> b[i];}
#define output(answer) cout << answer << endl;
#define fN(i,N)    for(int i=0; i<N; i++)
#define fSE(i,s,e) for(int i=s; i<=e; i++)
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i,N) for(int i=0; i<N; i++)
#define cinv(v,N) vector<int> v(N); for(int i=0; i<N; i++){ cin >> v[i]; }
#define mt make_tuple
const ll MOD2 = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

//互除法
ll GCD(ll a, ll b){
  return b ? GCD(b,a%b) : a;
}

ll LCM(ll a, ll b){
  return (a / GCD(a,b))*b;
}

//素因数分解
pair<map<ll,ll>,bool> PrimeFactorization(ll N){
  pair<map<ll,ll>,bool> ret;//<素因数分解,素数判定>
  ret.second = true;
  
  //素因数分解
  if(N != 2){
    while(N%2 == 0){//p=2の時。
      N /= 2;
      ret.first[2] ++;
      ret.second = false;
    }
  }
  for(ll i=3; i*i<=N; i+=2){//p>=3の時。
    while(N%i == 0){
      N /= i; 
      ret.first[i] ++;
      ret.second = false;
    }
  }
  if(N != 1){//Nが素数の時
    ret.first[N] ++;
  }
  
  //返り値
  return ret;
}


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

  //main
  ll n; cin >> n;
  ll ans = 0;
  for(int i=1; i<=n; i+=2){
    ll tmp = 1;
    auto pmb = PrimeFactorization(i);
    for(auto j=pmb.first.begin(); j!=pmb.first.end(); j++){
      tmp *= ((j->second)+1);
    }
    if(tmp == 8){ ans ++; }
  }
  
  // output
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int n;
    cin>>n;
    vector<int> a(n);
    int sum=0;
    rep(i,n){
        cin>>a[i];
        sum+=a[i];
    }
    sort(all(a));
    int i=0;
    while(sum%10==0&&i<n){
        if(a[i]%10!=0) sum-=a[i];
        i++;
    }
    if(sum%10==0) sum=0;
    cout<<sum;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define MOD 1000000007
#define pb push_back
#define cy cout<<"Yes\n"
#define cn cout<<"No\n"
#define ci cout<<"impossible\n"
typedef unsigned long long int ull;
typedef long long int ll;

int a[500005];
const int M=1e4;
ll cnt[M];
int main()
{
    int tc=1;
    //cin>>tc;
    while(tc--)
    {
        int d,t,s;
        cin>>d>>t>>s;
        if(t*s>=d)
            cy;
        else
            cn;
    }

}


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

int main(){
	int n;
	while( cin >> n , n ){
		double BMI[1000001];
		for(int i=0 ; i < 1000001 ; i++ ){
			BMI[i] = -1;
		}

		for(int i=0 ; i < n ; i++ ){
			int id,h,w;
			cin >> id >> h >> w;
			BMI[id] = fabs( 22.0 - (double) w / ( (h/100.0)*(h/100.0) ) );
		}
		double m = 1000.0;
		for(int i=0 ; i < 1000001 ; i++ ){
			if( BMI[i] != -1 )
				m = min( m , BMI[i] );
		}
		for(int i=0 ; i < 1000001 ; i++ ){
			if( BMI[i] == m ){
				cout << i << endl;
				break;
			}
		}
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  int64_t k;
  cin>>n>>k;
  vector<int> b;
  while(k>1){
    b.push_back(k%2);
    k/=2;
  }
  reverse(b.begin(),b.end());
  vector<int> a(n);
  vector<int> t(n);
  for(int i=0;i<n;i++){
    cin>>a.at(i);
    a.at(i)--;
    t.at(i)=a.at(i);
  }
  for(int d:b){
    vector<int> c=t;
    for(int i=0;i<n;i++)
      t.at(i)=c.at(c.at(i));
    if(d==1){
      c=t;
      for(int i=0;i<n;i++)
        t.at(i)=a.at(c.at(i));
    }
  }
  cout<<t.at(0)+1<<endl;
}

Measured memory_bytes: 5636
#define rep(i, a, b) for(int i = a; i < (int)(b); i++)
#include <bits/stdc++.h>

typedef long long ll;
using namespace std;
template<class T> inline void chmax(T &a, const T &b) {if(a < b) a = b;}
template<class T> inline void chmin(T &a, const T &b) {if(a > b) a = b;}
const long long INF = 1LL<<60;
const long long MOD = (ll)1e9+7;
// const long long MOD = (ll)1e6+3;
const long long MAX = (ll)1e5+10;



int main(void) {
    ll H,A;
    cin>>H>>A;
    ll cnt = 0;
    while (H>0) {
        H-=A;
        cnt++;
    }
    cout<<cnt<<endl;

   return 0;
}

Measured memory_bytes: 256
function main(_stdin) {
    const stdin = _stdin.split('\n').filter(e => e.length);
    const [len, maxWeight] = stdin.shift().split(' ').map(Number);
    const items = stdin.map(e => {
        return e.split(' ').map(Number);
    });

    console.log(findMaxVal(items, maxWeight)[0]);
}

/**
 *
 * @param {array} items
 * @param {int} items[0]
 * @param {int} items[1]
 * @param {int} maxWeight
 */
function findMaxVal(items, maxWeight) {
    const table = new Array(maxWeight + 1).fill([0,0]);
    let tableCache = [];

    for (let i = 0, l = items.length; i < l; i++) {
        tableCache = table.slice();
        for (let j = 0; j <= maxWeight; j++) {
            if(j === 0) {
                table[j] = [0, 0];
            } else {
                const item = items[i];

                // 1. items[i][1]がjより小さく、items[i][0]がtable[j][0]より大きい
                table[j] = j >= item[1] && item[0] > table[j][0] ? item.slice() : table[j];

                // 2. items[i]の重さと足してjになるインデックスのtableCacheのvalとitems[i]のvalを足して、table[j]の価値より大きい
                const ref = tableCache[j - item[1]];
                table[j] = ref !== undefined && ref[0] + item[0] > table[j][0] ? [ref[0] + item[0], ref[1] + item[1]] : table[j];

                // 3. items[i]の重さと足してjになるインデックスのtableのvalとitems[i]のvalを足して、table[j]の価値より大きい
                const tableRef = table[j - item[1]];
                table[j] = tableRef !== undefined && tableRef[0] + item[0] > table[j][0] ? [tableRef[0] + item[0], tableRef[1] + item[1]] : table[j];
            }
        }
    }
    return table[maxWeight];
}

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



Measured memory_bytes: 25952
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	int aA=0,Bb=0,BA=0;
	ll ans=0,cnt=0;
	cin>>n;
	vs v(n);
	rep(i,n){
		cin>>v[i];
		rep(j,v[i].size()-1){
			if(v[i][j]=='A'&&v[i][j+1]=='B')cnt++;
		}
		if(v[i].front()=='B'&&v[i].back()=='A')BA++;
		else if(v[i].front()=='B')Bb++;
		else if(v[i].back()=='A')aA++;
	}
	if(BA==0){
		ans=min(aA,Bb)+cnt;
	}
	else{
		ans=BA-1;
		if(aA!=0){ans++;aA--;}
		if(Bb!=0){ans++;Bb--;}
		ans+=min(aA,Bb)+cnt;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 25;
const int MOD = 1e9+7;
int n, t[1010], a[1010]; 
int main() {
	cin >> n;
	rep(i,n) cin >> t[i] >> a[i];

	ll x=t[0],y=a[0];
	rep(i,n) {
		ll r = max((x+t[i]-1)/t[i],(y+a[i]-1)/a[i]);
		x = r*t[i];
		y = r*a[i];
	}
	cout << x+y << endl;

	return 0;
}


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

int main(){
  vector<int> a(4,0);
  string s;
  cin >>s;
  int l=s.size();
  for(int i=0;i<l;i++){
    if(s[i] == 'N') a.at(0) = 1;
    if(s[i] == 'S') a.at(1) = 1;
    if(s[i] == 'E') a.at(2) = 1;
    if(s[i] == 'W') a.at(3) = 1;
  }
  if(a.at(0) == a.at(1) && a.at(2) == a.at(3)){
    cout << "Yes" <<endl;
  }
  else cout << "No" << endl;
}

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

int main(){
  int N;
  cin >> N;  
  vector<tuple<string,int,int>> info(N);
  for(int i=0;i<N;i++){
  string city;
  int grade;
  cin >> city >> grade;
  info.at(i) = make_tuple(city,grade,(i+1));
  }
  sort(info.begin(),info.end());
  int count=0;
  vector<tuple<string,int,int>> data;
  for(int i=0;i<N;i++){
    data.push_back(info.at(i));
    if((i+1 < N && get<0>(info.at(i)) != get<0>(info.at(i+1)))||(i+1==N)){
    reverse(data.begin(),data.end());
    for(int j=count;j<i+1;j++){
    info.at(j) = data.at(j-count);
    }
    count = i+1;
    data.clear();
    }
  }
  for(int i=0;i<N;i++){
  int num;
  tie(ignore,ignore,num) = info.at(i);
  cout << num << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  vector<ll> A(n), B(n);
  rep(i, n) cin >> A[i];
  rep(i, n) cin >> B[i];
  ll mx = accumulate(all(B), 0LL) - accumulate(all(A), 0LL);
  ll cnt1 = 0, cnt2 = 0;
  rep(i, n) if(A[i]<B[i]) {
    cnt2 += (B[i]-A[i])/2;
    if((B[i]-A[i])%2) cnt2++, cnt1++;
    A[i] = B[i];
  }
  rep(i, n) if(A[i]>B[i]) {
    cnt1 += A[i]-B[i];
    B[i] = A[i];
  }
  cout << (cnt2<=mx&&cnt1<=mx ? "Yes" : "No") << "\n";
  return 0;
}


Measured memory_bytes: 3792
H, W = map(int, input().split())
d = [(1, 0), (0, 1), (-1, 0), (0, -1), (1, 1), (-1, 1), (1, -1), (-1, -1)]
G = [list(input()) for _ in range(H)]
ans = [[""] * W for _ in range(H)]
for i in range(H):
    for j in range(W):
        if G[i][j] == '#':
            ans[i][j] = '#'
            continue
        cnt = 0
        for dx, dy in d:
            ni = i + dx
            nj = j + dy
            if ni < 0 or H <= ni or nj < 0 or W <= nj:
                continue
            if G[ni][nj] == '#':
                cnt += 1
        ans[i][j] = str(cnt)
for a in ans:
    print(''.join(a))


Measured memory_bytes: 9176
#define LOCAL

#undef _GLIBCXX_DEBUG

#include <bits/stdc++.h>

using namespace std;

#define IOS ios::sync_with_stdio(false);cin.tie(0)
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
#define LLINF 0x3f3f3f3f3f3f3f3f
#define INF 0x3f3f3f3f

// Copied from Gennady-Korotkevich's template

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
	return '"' + s + '"';
}

string to_string(const char* s) {
	return to_string((string)s);
}

string to_string(bool b) {
	return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
	bool first = true;
	string res = "{";
	for (int i = 0; i < static_cast<int>(v.size()); i++) {
		if (!first) {
			res += ", ";
		}
		first = false;
		res += to_string(v[i]);
	}
	res += "}\n";
	return res;
}

template <size_t N>
string to_string(bitset<N> v) {
	string res = "";
	for (size_t i = 0; i < N; i++) {
		res += static_cast<char>('0' + v[i]);
	}
	return res;
}

template <typename A>
string to_string(A v) {
	bool first = true;
	string res = "{";
	for (const auto& x : v) {
		if (!first) {
			res += ", ";
		}
		first = false;
		res += to_string(x);
	}
	res += "}\n";
	return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
	return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
	return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
	return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

template <typename A, typename B, typename C, typename D, typename E>
string to_string(tuple<A, B, C, D, E> p) {
	return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + "," + to_string(get<4>(p)) + ")";
}

void debug_out() {
	cerr << endl;
}

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
	cerr << " " << to_string(H);
	debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "\n[" << #__VA_ARGS__ << "]:\n", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

// End of Gennady-Korotkevich's template 

using llong = long long;
using PII = pair<int, int>;

const llong MOD = 1e9 + 7;
const double PI = acos(-1);

int main() {
	IOS;
	string s, t; cin >> s >> t;
	int ans = 0;
	for (int i = 0; i < 3; i++) {
		if (s[i] == t[i]) ans++;
	}
	cout << ans << "\n";
}

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

#define F first 
#define S second
#define PB push_back

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef priority_queue<int> HEAP;
typedef priority_queue<int, vector<int>, greater<int> > RHEAP;

const int N = 100010, M = 1010;

int n;
string s;

bool check(int len)
{
	map<string, int> h;
	for (int i = 0; i <= n - len + 1; i ++ )
	{
		string t = s.substr(i, len);
		if (h.count(t))
		{
			if (h[t] + len <= i) return true;
		}
		else h[t] = i;
	}
	return false;
}

int main()
{
	cin >> n >> s;
	
	int l = 0, r = n;
	while (l < r)
	{
		int mid = l + r + 1 >> 1;
		if (check(mid)) l = mid;
		else r = mid - 1;
	}
	cout << r << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e16+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

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

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

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

    ll n;
    cin>>n;
    Vec x(n);
    Vec y(n);

    ll nc2 = n*(n-1)/2;
    ll nkai = 1;
    rep(i,n){
        nkai *= (i+1);
    }

    rep(i,n){
        cin>>x[i]>>y[i];
    }
    double ans=0;

    rep(j,n)rep(i,j){
        ans += sqrt(pow(x[i]-x[j],2)+pow(y[i]-y[j],2));
    }
    ans *= n-1;
    ans /= nc2;
    cout<<ans<<endl;
    return  0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
		String num = sc.nextLine();
		String count = "No";	
      	for(int i=0;i<num.length();i++){
            if(num.charAt(i)=='7'){
              count = "Yes";
              break;
            }
		}
        System.out.println(count);
    }
}

Measured memory_bytes: 35740
#include "bits/stdc++.h"
using namespace std;    

#define COUNTOF(array) (sizeof(array) / sizeof(array[0]))    
#define OUT(P) cout << (P) << endl    
#define OUT2(P1, P2) cout << (P1) << " " << (P2) << endl    
#define PRINT_ARRAY(P) for(int i=0; i<P.size(); i++) cout << P[i] << endl;    
#define PRINT_ARRAY_INLINE(P) do { for(int i=0; i<P.size(); i++) cout << P[i] << " "; cout << endl; } while(0)    
#define PRINT_ARRAY_WITH_LABEL(L, P) do { cout << L << ": "; PRINT_ARRAY_INLINE(P); cout << endl; } while(0)    
typedef long long ll;    

int sum_digits(int num);    
template <class T>    
vector<T> copy_vector(vector<T> vec);    
int gcd(int a, int b);    

int main() {    
    int n;
    cin >> n;
    while(n != 0) {
        vector<int> a(n);
        for(int i=0; i<n; i++) {
            cin >> a[i];
        }
        int ave = accumulate(a.begin(), a.end(), 0) / n;
        sort(a.begin(), a.end());
        int cnt = 0;
        for(int i=0; i<n && a[i] <= ave; i++) {
            cnt++;
        }
        cout << cnt << endl;

        cin >> n;
    }

    return 0;    
}    

/******************************/    
/***** DECRARED FUNCTIONS *****/    
/******************************/    

int sum_digits(int num) {    
    int rtn = 0;    
    while(num != 0) {    
        int tmp = num % 10;    
        rtn += tmp;    
        num /= 10;    
    }    
    return rtn;    
}    

// vectorのコピー    
template <class T>    
vector<T> copy_vector(vector<T> vec) {    
    vector<T> rtn;    
    rtn.reserve(vec.size());    
    copy(vec.begin(), vec.end(), back_inserter(rtn));    
    return rtn;    
}    

// ユークリウッドの互除法    
int gcd(int a, int b) {    
    if(b==0) return a;    
    else return gcd(b, a % b);    
}



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

using namespace std;

int main() {
    int len;
    string a, b, c;
    int count = 0;
    cin >> len >> a >> b >> c;

    for(int i = 0; i < len; i++) {
        if(a[i] == b[i] && b[i] == c[i]) {
            continue;
        } else if((a[i] == b[i] && b[i] != c[i]) ||
                  (a[i] != b[i] && a[i] == c[i]) ||
                  (a[i] != c[i] && b[i] == c[i])) {
            count++;
            continue;
        } else {
            count += 2;
            continue;
        }
    }
    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
prime = [1 for i in range(1000000)]

prime[0] = 0
prime[1] = 0

for i in range(1000):
    if prime[i] == 1:
        for j in range(2, 1000000):
            try:
                prime[i * j] = 0
            except:
                break

for i in range(1, 1000000):
    prime[i] = prime[i] + prime[i - 1]

while True:
    try:
        n = int(input())
        print(prime[n])
    except:
        break

Measured memory_bytes: 47328
#include <bits/stdc++.h>
using namespace std;
int main(){
	string S, T; cin >> S >> T; 
	vector<int> A[30] = {}; 
	for(int i = 0; i < S.size(); i++){
		A[S.at(i) - 'a'].push_back(i); 
	}
	for(int i = 0; i < 26; i++){
		int M = A[i].size(); 
		for(int j = 0; j < M; j++){
			A[i].push_back(A[i].at(j) + S.size()); 
		}
	}
	long long int ans = 0; 
	for(int i = 0; i < T.size(); i++){
		int L = T.at(i) - 'a'; 
		if(A[L].size() == 0){
			cout << -1 << endl; return 0; 
		}
		int next; long long int now; 
        if(i == 0) now = -1; 
		else now = ans % (long long) S.size(); 
		next = upper_bound(A[L].begin(), A[L].end(), (int) now) - A[L].begin(); 
        if(i == 0) ans = (long long) A[L].at(next); 
		else ans += (long long) A[L].at(next) - now; 
	}
	cout << ans + 1 << endl; 
}

Measured memory_bytes: 1724
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N, ans=0;
    char tmp='Z'+1;
    vector<char> s(tmp, 0);
    
    cin >> N;
    for(int i=0; i<N; i++){
	cin >>tmp;
	s[tmp]++;
    }

    for(int i='A'; i<'Z'+1; i++){
	if(s[i]>=1)
	    ans++;
    }        
    cout << (ans==3? "Three": "Four") << endl;    
}



Measured memory_bytes: 256
package main

import (
	"fmt"
	"os"
	"bufio"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

/*
func nextLine() string {
    sc.Scan()
    return sc.Text()
}
*/

func nextInt() int {
    sc.Scan()
    i, e := strconv.Atoi(sc.Text())
    if e != nil {
        panic(e)
    }
    return i
}


func main() {
    sc.Split(bufio.ScanWords)
    n:=nextInt()
    var a []int
    var b []int
    var i,max int
    max = 0

    for i=0; i < n-1; i++{
	    b=append(b,nextInt())
    }

    a=append(a,b[0])
    for i=0; i < n-2; i++{
	    if (b[i+1]<b[i]){
		    a=append(a,b[i+1])
	    }else{
		    a=append(a,b[i])
	    }
    }
    a=append(a,b[n-2])

    for i=0; i < n; i++{
	    max+=a[i]
    }

    fmt.Println(max)
}

Measured memory_bytes: 640
using System;
class aoj
{
    static void Main()
    {
        while (true)
        {
            string a=Console.ReadLine();
            if (String.IsNullOrEmpty(a)) break;
            double c = double.Parse(a);
            double e = c;
            double[] d = new double[10];
            d[0] = c;
            for(int i = 1; i < 10; i++)
            {
                if (i % 2 == 0)
                {
                    d[i] = d[i - 1] / 3;
                    e += d[i];
                }
                else
                {
                    d[i] = d[i - 1] * 2;
                    e += d[i];
                }
            }
            Console.WriteLine(e);
        }
    }
}

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

int main() {
    int n; cin >> n;
    vector<int> a(n);
    rep(i, n) {
        cin >> a[i];
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (((i+1) % 2 == 1) && (a[i] %2 == 1)) {
            ans++;
        }
    }
    cout << ans << endl;
}


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

int main(){
	int K;
	cin>>K;
	int amari = K%2;
	int number_kisu;
	if(amari==0){
		number_kisu = K/2;
	}	else{
		number_kisu = K/2 + 1;
	}
	cout<<number_kisu*(K-number_kisu);
	return 0;
}


Measured memory_bytes: 256