akhauriyash/Code-Regression huggingface dataset:
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		ArrayList<String> input = new ArrayList<String>();
		Scanner insert = new Scanner(System.in);
		String line = insert.nextLine();
		int nn = Integer.parseInt(line);
		for(int i = 0; i < nn; i++) {
			String line2 = insert.nextLine();
			if (line2.equals("")) {
				break;
			}
			input.add(line2);
		}
		for(String a:input) {
			int sum = 0;
			String array1[] = a.split(" ");
			int y = Integer.parseInt(array1[0]);
			int m = Integer.parseInt(array1[1]);
			int day = Integer.parseInt(array1[2]);
			int n = 1000-y;
			for(int i = 0;i < n; i++) {
				if(i % 3 == 0) {
					sum+=200;
				}
				else {
					sum+=195;
				}
			}
			if(y % 3 == 0) {
				for(int i = 1; i <= m; i++) {
					sum-=20;
				}
			}
			else {
				for(int i = 1; i <= m; i++) {
					if(i % 2 == 0) {
						sum-=19;
					}
					else {
						sum-=20;
					}
				}
			}
			if((y % 3 != 0) && (m % 2 ==0)) {
				sum+=(20-day);
			}
			else {
				sum+=(21-day);
			}
			System.out.println(sum);
		}
	}


}



Measured memory_bytes: 26220
// 045-1 台形の面積
#include <stdio.h>
int main(int argc, char const *argv[])
{
	int a;
	int b;
	int h;
	//int area;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&h);
	printf("%d\n",(a+b)*h/2);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <cmath>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

using namespace std;

int main(void){
  int n;
  cin >> n;
  string s0;
  string s1;
  string s2;
  cin >> s0 >> s1 >> s2;
  int ans = 0;
  rep(i,n) {
    vector<string> t(3);
    t[0] = s0[i];
    t[1] = s1[i];
    t[2] = s2[i];
    sort(t.begin(), t.end());
    t.erase(unique(t.begin(), t.end()), t.end());
    ans += t.size() - 1;
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

#define NUM 100000

struct Edge{
	Edge(int arg_from,int arg_to,int arg_dist){
		from = arg_from;
		to = arg_to;
		dist = arg_dist;
		festival_dist = BIG_NUM;
	}
	bool operator<(const struct Edge &arg) const{
		return festival_dist > arg.festival_dist; //祭りまでの最短距離の降順
	}
	int from,to,dist,festival_dist;
};

struct Info{
	Info(int arg_node_id,int arg_sum_dist){
		node_id = arg_node_id;
		sum_dist = arg_sum_dist;
	}
	bool operator<(const struct Info &arg) const{
		return sum_dist > arg.sum_dist; //総移動距離の昇順(PQ)
	}
	int node_id,sum_dist;
};

vector<Edge> EDGE,G[NUM];
set<int> QUERY[NUM];
int min_dist[NUM];
int ans[NUM],boss[NUM];

int get_boss(int id){
	if(id == boss[id])return id;
	else{
		return boss[id] = get_boss(boss[id]);
	}
}

void unite(int x,int y,int festival_dist){

	int x_boss = get_boss(x);
	int y_boss = get_boss(y);

	if(x_boss == y_boss)return;

	//x_bossの方を大きくする
	if(QUERY[y_boss].size() > QUERY[x_boss].size())swap(x_boss,y_boss);

	bool FLG;

	//クエリ番号が出会うかどうか調べる

	for(auto it = QUERY[y_boss].begin(); it != QUERY[y_boss].end(); it++){
		FLG = true;
		if(QUERY[x_boss].count(*it)){
			FLG = false;
			ans[*it] = festival_dist;
		}
		if(FLG){
			QUERY[x_boss].insert(*it);
		}
	}

	boss[y_boss] = x_boss; //y_bossをx_bossに併合
}

int main(){

	int N,M,K,num_query;
	scanf("%d %d %d %d",&N,&M,&K,&num_query);

	int from,to,dist;
	for(int loop = 0; loop < M; loop++){
		scanf("%d %d %d",&from,&to,&dist);
		from--;
		to--;
		EDGE.push_back(Edge(from,to,dist));
		G[from].push_back(Edge(from,to,dist));
		G[to].push_back(Edge(to,from,dist));
	}

	int node_id;
	stack<int> S;

	for(int loop = 0; loop < K; loop++){
		scanf("%d",&node_id);
		node_id--;
		S.push(node_id);
	}

	//クエリ情報を取得
	int start,goal;
	for(int loop = 0; loop < num_query; loop++){
		scanf("%d %d",&start,&goal);
		start--;
		goal--;
		QUERY[start].insert(loop); //ノードに、クエリ番号の集合を作る
		QUERY[goal].insert(loop);
	}

	//各ノードの、祭りノードまでの最短距離を求める
	for(int i = 0; i < N; i++)min_dist[i] = BIG_NUM;
	priority_queue<Info> Q;

	int next_node,next_cost;

	while(!S.empty()){
		node_id = S.top();
		S.pop();

		min_dist[node_id] = 0;
		Q.push(Info(node_id,0));

		while(!Q.empty()){

			if(Q.top().sum_dist > min_dist[Q.top().node_id]){

				Q.pop();
			}else{

				for(int i = 0; i < G[Q.top().node_id].size(); i++){
					next_node = G[Q.top().node_id][i].to;
					next_cost = Q.top().sum_dist+G[Q.top().node_id][i].dist;

					if(min_dist[next_node] > next_cost){
						min_dist[next_node] = next_cost;
						Q.push(Info(next_node,next_cost));
					}
				}
				Q.pop();
			}
		}
	}

	//エッジを、祭りノードとの距離の降順にsortする
	for(int i = 0; i < M; i++){
		EDGE[i].festival_dist = min(min_dist[EDGE[i].from],min_dist[EDGE[i].to]); //近い方の値を採用
	}
	sort(EDGE.begin(),EDGE.end());

	for(int i = 0; i < N; i++){
		boss[i] = i;
	}

	for(int i = 0; i < M; i++){
		unite(EDGE[i].from,EDGE[i].to,EDGE[i].festival_dist);
	}

	for(int i = 0; i < num_query; i++){
		printf("%d\n",ans[i]);
	}

	return 0;
}



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

int high(int H, int x, int y, int cx, int cy);
int main()
{
	int N;
	int CX, CY, H;
	cin >> N;
	vector<int> x;
	vector<int> y;
    vector<int> h;

    for(int i=0; i<N; i++)
    {
    	int a,b,c;
    	cin >> a >> b >> c;
    	x.push_back(a);
    	y.push_back(b);
    	h.push_back(c);
    }

    int M = *max_element(h.begin(), h.end());
    vector<int>::iterator maxIt = max_element(h.begin(), h.end());
    size_t maxIndex = distance(h.begin(), maxIt);
    
    bool flag = true;
            
    	for(int i=0;i<=100;i++)
    	{
    		for(int j=0;j<=100;j++)
    		{
    			flag = true;
    			H = h[maxIndex] 
    			    + abs(x[maxIndex]-i)
    			    + abs(y[maxIndex]-j);
    			for(int k=0; k<N; k++)
    			{
                     if(h[k]!=high(H,x[k],y[k],i,j))
                     { 
                       flag = false;
                       break;
                     }
    			}
    			if(flag==true)
    			{
    				CY = j;
    				break;
    			}
    		}
    		if(flag==true)
    		{
    		    CX = i; 
    			break;
    		}
    	}

    cout << CX << " " << CY << " " << H << endl;

	return 0;
}

int high(int H, int x, int y, int cx, int cy)
{
	return max(H-abs(x-cx)-abs(y-cy),0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;

#define rep(i, a, n) for (ll i = a; i < (ll)n; ++i)
#define INF 10e12
#define MOD 1000000000 + 7
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))

using namespace std;
int main(void)
{
    int a, b;
    cin >> a >> b;
    cout << max(0, a - 2 * b) << endl;
}

Measured memory_bytes: 3560
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < (ll)(n); ++i)
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(){
	int n;
	cin >> n;
	vector<ll> a(n);
	REP(i,n) cin >> a[i];
	
	ll ans=0;
	
	REP(i,n-1){
		if(a[i] > a[i+1]){
			ans += a[i]-a[i+1];
			a[i+1] = a[i];
		}
	}
	
	cout << ans << endl; 
	
	return 0;
}

Measured memory_bytes: 4844
#include <bits/stdc++.h>
#define y second
#define x first

using namespace std;

const int maxn = 200001;
int dp1[maxn], dp2[maxn];

int main() {
    srand(time(0));
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    string s;
    cin >> s;
    dp1[0] = 1;
    if (s.size() == 1) {
        cout << 1;
        return 0;
    }
    dp2[1] = 1; dp1[1] = 2 * (s[1] != s[0]);
    if (s.size() == 2) {
        cout << max(dp2[1], dp1[1]);
        return 0;
    }
    dp2[2] = 2; dp1[2] = 2 + (s[0] != s[1] && s[1] != s[2]);
    for (int i = 3; i < s.size(); i++) {
        dp2[i] = dp1[i - 2] + 1;
        if (s[i - 1] != s[i - 3] || s[i] != s[i - 2])
            dp2[i] = max(dp2[i], dp2[i - 2] + 1);
        dp1[i] = dp2[i - 1] + 1;
        if (s[i] != s[i - 1])
            dp1[i] = max(dp1[i], dp1[i - 1] + 1);
    }
    cout << max(dp1[s.size() - 1], dp2[s.size() - 1]);
    return 0;
}


Measured memory_bytes: 2196
def ans():
  N, M = map(int,input().split())
  PY = [list(map(int,input().split()))+[0] for _ in range(M)]
  sort_PY = sorted(PY, key = lambda x: x[1])
  city = {}
  for i in range(M):
    p, y, z = sort_PY[i][0], sort_PY[i][1], sort_PY[i][2]
    if(p in city):
      city[p] += 1
    else:
      city[p] = 1
    sort_PY[i][2] = city[p]
  for p, y, z in PY:
    print(str(p).zfill(6) + str(z).zfill(6))
ans()

Measured memory_bytes: 30136
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int D = sc.nextInt();
    int N = sc.nextInt();
    output(D, N);
  }
  public static void output(int D, int N) {
    if (N != 100) {
      System.out.println((int) (N * Math.pow(100, D)));
    } else {
      System.out.println((int) ((N + 1) * Math.pow(100, D)));
    }
  }
}


Measured memory_bytes: 22612
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n,m,a,b = map(int,input().split())
ab = a * 60 + b
A = ab/2
B = b*6
AB = abs(-B+A) 
theta = min(360-AB,AB)
# print(theta,math.radians(theta))
# print(A,B,math.radians(theta),2*n*m*math.cos(theta),math.cos(math.radians(theta)))
print(math.sqrt((n**2 + m ** 2 - 2*n*m*math.cos(math.radians(theta)))))

Measured memory_bytes: 65888
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        int sum = 0;
        for(int i = 1;i<=n;i++)
        {
            sum+=i;
        }
        printf("%d\n",sum);
    }
}

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

int main(void) {
	char c[100];
	int n = 0,m = 0;
	cin >> c;
	for (int i = 0;;i++) {
		if (c[i] == '\0')break;
		n++;
	}
	for (int i = 0; i < (n - 1) / 2; i++) {
		if (c[i] != c[n - 1 - i]) {
			m++;
			break;
		}
	}
	for (int i = 0; 4 * i < (n - 3); i++) {
		if (c[i] != c[((n - 3)/2) - i]) {
			m++;
			break;
		}
	}

	for (int i = 0; 4 * i < (n - 3); i++) {
		if (c[((n + 1) / 2) + i] != c[n - 1 - i]) {
			m++;
			break;
		}
	}
	if(m == 0)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;

}

Measured memory_bytes: 256
// panasonic2020_d
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int K;
string s = "a";

void dfs(int n, int c){

    if (n == K){
        print(s);
        return;
    }

    REP(i, c){
        s += i + 'a';
        dfs(n+1, c);
        s.erase(n);
    }

    s += c + 'a';
    dfs(n+1, c+1);
    s.erase(n);

}


int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif


    cin >> K;
    dfs(1, 1);

    return 0;
}


Measured memory_bytes: 1536
import java.util.Scanner;

//AtCoder Beginner Contest 124
//A	Buttons
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
        int T = sc.nextInt();

		System.out.print((T/A)*B);
	}
}


Measured memory_bytes: 23764
#include "bits/stdc++.h"

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define rrep(i, n) for(ll i=(n)-1; i >=0; i--)
#define ALL(v) v.begin(),v.end()
#define rALL(v) v.rbegin(),v.rend()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cerr<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct edge{ll x, c;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

ll gcd(ll a, ll b){
  ll r = a%b;
  if(r==0) return b;
  else return gcd(b, a%b);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}

struct UnionFind{
  ll N;
  llvec p;
  llvec cnt;
  UnionFind(ll n){
    N = n;
    p=llvec(N);
    cnt=llvec(N, 0);
    rep(i, N){
      p[i] = i;
      cnt[i] = 1;
    }
  }

  void con(ll a, ll b){
    P at = root(a);
    P bt = root(b);
    if(at.second!=bt.second){
      if(at.first>bt.first){
        swap(at, bt);
        swap(a, b);
      }
      p[at.second] = bt.second;
      cnt[bt.second]+=cnt[at.second];
      p[a]=bt.second;
    }
  }

  P root(ll a){
    ll atmp = a;
    ll c=0;
    while(atmp!=p[atmp]){
      atmp = p[atmp];
      c++;
    }
    p[a] = atmp;
    return {c, atmp};
  }

  bool is_con(ll a, ll b){
    P at=root(a);
    P bt=root(b);
    return at.second == bt.second;
  }
  
};

struct dijkstra{
  ll N;
  llvec d;
  vector<vector<edge>> e;
  dijkstra(ll n){
    N = n;
    //d = llvec(N, 1e18);
    e = vector<vector<edge>>(N);
  }

  void add_edge(ll from, ll to, ll cost){
    e[from].push_back({to, cost});
  }

  void run(ll start){
    priority_queue<P, vector<P>, greater<P>> que;
    que.push({0, start});
    d = llvec(N, 1e18);
    d[start]=0;
    while(!que.empty()){
      P q = que.top();que.pop();
      ll dc = q.first;
      ll x = q.second;
      if(dc>d[x]){
        continue;
      }else{
        for(auto ip: e[x]){
          if(d[ip.x]<=d[x]+ip.c){
            continue;
          }else{
            d[ip.x]= d[x]+ip.c;
            que.push({d[ip.x], ip.x});
          }
        }
      }
    }
  }  
};


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll A, B;
  cin >> A >> B;
  A--;B--;
  cout << A * B;
  return 0;
}


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

int main() {
  int A, B, C;
  cin >> A >> B >> C;

  if (A + B >= C)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

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

int n, k;
int a[200010];
int c[200010] = {};
int x = 0;
int main()
{
    cin >> n >> k;
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
        c[a[i]] = c[a[i]] + 1;
    }
    
    sort(c, c+200010);
    
    for(int i = 0; i < k; i++)
    {
        x = x + c[200009 - i];
    }
    
    cout << n - x << endl;
}

Measured memory_bytes: 1792
a,b = input().split()
a = int(a)
b = int(b)
A = a-1
B = b-1
X = a*A
Y = b*B
S = X/2
F = Y/2
if a<1.9 and b<1.9:
  print(0)
elif a<1.9 and b>1.9:
  print(int(F))
elif a>1.9 and b<1.9:
  print(int(S))
elif a>1.9 and b>1.9:
  print(int(S+F))
        


Measured memory_bytes: 3188
n=int(input())
 
L=[list(map(int,input().split())) for i in range(n)]
LSort=sorted(L,key=lambda x:x[2])
x,y,h=LSort[-1]

for cx in range(0,101):
	for cy in range(0,101):
		H=h+abs(x-cx)+abs(y-cy)
		if all([h==max(H-abs(x-cx)-abs(y-cy),0) for x,y,h in LSort]):
		    print(cx,cy,H)
		    exit()

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
	public static void main(String[] args)throws IOException{
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader reader = new BufferedReader(isr);
		String string;
		int n, old;
		
		while(!(string = reader.readLine()).equals("0")){
			n = Integer.parseInt(string);
			
			int[] age = new int[7];
			for(int i = 0; i < n; i++){
				old = Integer.parseInt(reader.readLine());
				if(old < 10) age[0]++;
				if(10 <= old && old < 20) age[1]++;
				if(20 <= old && old < 30) age[2]++;
				if(30 <= old && old < 40) age[3]++;
				if(40 <= old && old < 50) age[4]++;
				if(50 <= old && old < 60) age[5]++;
				if(60 <= old) age[6]++;
			}
			for(int var : age)System.out.println(var);
		}
		reader.close();
	}
}

Measured memory_bytes: 62092
n = gets.to_i
ss = n.times.map { gets.strip.chars.sort.join('') }
h = {}
ss.each do |s|
  if h[s]
    a, b = h[s]
    h[s] = [a + b, b + 1]
  else
    h[s] = [0, 1]
  end
end

puts(h.values.map(&:first).sum)


Measured memory_bytes: 36828
#include <iostream>
#include <iomanip>
#include <algorithm>
using namespace std;
#include <cstdio>
#include <tuple>
#include <string>
#include <vector> 
#include <set>
#include <string.h>
#include <map>
#include <cmath>
#include <deque>
using ll = long long;
using Graph = vector<vector<int>>;
#include <queue>
#include <stack>

//#define _USE_MATH_DEFINES
#include <math.h>  /* M_PI */

int main(){

    double r;
    cin >> r;
    double pi = 3.14159265358979;
     // double型定数2
    // double a = std::numbers::pi;
    // std::cout << 2 * r * a << std::endl;


    printf("%.5f\n", 2* r * pi);
}

Measured memory_bytes: 3744
#include<stdio.h>
main(){
  int a=0;
  int W,H,x,y,r=0;
  scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
  if(x-r>=0&&x+r<=W){
    if(y-r>=0&&y+r<=H){
      a=1;
    }
  }
  else{
    a=0;
  }
  if(a==1){
    printf("Yes\n");
  }
  else if(a==0){
    printf("No\n");
  }
  return 0;
}


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

using namespace std;

typedef long long int ll;
typedef pair<int,int> P;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
	int t,a,b;
	cin>>a>>b>>t;
	cout<<(t/a)*b<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <numeric>
using namespace std;


int main(){
    int A,B,C;
    cin >> A >> B >> C;
    int ans = 0;
    for(int i = A;i<=C;i=i+A){
        ans = ans + B;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
def calc(r, n)
    res = 0
    sum = r
    base = 1
    bs = r
    while n > 0
        if n%2 == 1
            res += sum * base
            base *= bs
        end
        sum *= 1+bs
        bs *= bs
        n /= 2
        res %= MOD
        sum %= MOD
        base %= MOD
        bs %= MOD
    end
    res
end

def calc2(r, n)
    res = 0
    sum = r
    base = 1
    bs = r
    num = 0
    b = 1
    while n > 0
        if n%2 == 1
            res += (sum + num * calc(r, b)) * base
            num += b
            base *= bs
        end
        sum *= 1+bs
        sum += b * bs * calc(r, b)
        bs *= bs
        b *= 2
        n /= 2
        res %= MOD
        sum %= MOD
        base %= MOD
        bs %= MOD
    end
    res
end

def power_mod(num, power)
    prod = 1
    num %= MOD
    while power > 0 do
        if power & 1 == 1
            prod = (prod * num) % MOD
        end
        num = (num * num) % MOD
        power >>= 1
    end
    return prod
end

L, A, B, MOD = gets.split.map(&:to_i)
C = A + B*(L-1)

mn = 1
mx = 9
ans = 0
(1..18).each do |d|
    if d > 1
        mn *= 10
        mx = (mx+1) * 10 - 1
    end
    l = [0, (mn-A-1)/B+1].max
    r = [L-1, (mx-A)/B].min
    if l <= r
        rnum = A + B*r
        num = r-l+1
        ans *= power_mod(10, num*d)
        b = power_mod(10, d)
        ans += rnum * (1 + calc(b, num-1))
        ans -= B * calc2(b, num-1)
        ans %= MOD
    end
end
puts ans

Measured memory_bytes: 1788
#include<iostream>
#include<algorithm>
#include<map>
using namespace std;
int main()
{
    int n;
    cin>>n;
    map<string,long long> g;
    while(n--)
    {
        string s;
        cin>>s;
        sort(s.begin(),s.end());
        g[s]++;
    }
    long long ans = 0;
    for(auto it:g)
    {
        ans += it.second * (it.second-1) / 2;
    }
    cout<<ans;
}

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


int pre[500010],suf[500010];
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string s;
	cin>>s;
	int n=s.size()+1;
	for(int i=1;i<n;i++)
		pre[i]=(s[i-1]=='<'?pre[i-1]+1:0);
	for(int i=n-2;i>=0;i--)
		suf[i]=(s[i]=='>'?suf[i+1]+1:0);
	long long int ans=0;
	for(int i=0;i<n;i++)
		ans+=max(pre[i],suf[i]);
	cout<<ans<<endl;
}


Measured memory_bytes: 4764
H,W=map(int,input().split())
l=[] # l[i][j]は有向グラフ上での辺i->jの長さ
for i in range(10):
    l.append(list(map(int,input().split())))

# この有向グラフを1から逆方向に辿っていくことを考える。
dis=[l[i][1] for i in range(10)] # 頂点1からiまでの距離
# print(dis)
for i in range(9):
    dis=[min(dis[v],min([dis[u]+l[v][u] for u in range(10)])) for v in range(10)]
    # print(dis)

A=[]
for i in range(H):
    A.extend(list(map(int,input().split())))

ans=sum([A.count(i)*dis[i] for i in range(10)])
print(ans)

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

typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define ARR(array) for(int i=0;i<array.size();i++)
#define all(in) (in).begin(),(in).end()
#define ALL(in,K) (in),(in)+(K)

#define INF 1e18
#define MOD 1000000007
#define SIZE 10005
#define PI 	3.14159265358979323846

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; } //最小公倍数

ll input(){
  ll a;
  cin >> a;
  return a;
}

int main(){
  int n,k;
  cin >> n >> k;
  vector<int> vec(n);
  REP(i,n)cin >> vec.at(i);
  sort(vec.begin(),vec.end());
  reverse(vec.begin(),vec.end());
  int ans = 0;
  REP(i,k)ans += vec.at(i);
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
    int N,i,v,j,k;
    scanf("%d",&N);
    int A[N]; 
    for(i=0; i<N; i++){
        scanf("%d",&A[i]);
    }
    for(i=0; 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;
        for(k=0; k<N; k++){
            printf("%d",A[k]);
            if(k<N-1) printf(" ");
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2056
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
#======================================================#
def main():
    n = II()
    ans = ''
    while n > 0:
        n -= 1
        ans += chr(ord('a')+n%26)
        n //= 26
    print(ans[::-1])

if __name__ == '__main__':
    main()

Measured memory_bytes: 9232
import java.io.*;
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try {
            String line;
            /* input */
            while(true){
                line = br.readLine();
                if(line.equals("END OF INPUT")) break;
                
                String[] str = line.split(" ");
                
                for(String s : str){
                	System.out.print(s.length());
                }
                	
                System.out.println();
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

Measured memory_bytes: 16916
from itertools import permutations
import heapq

def dijkstra(N, G, s):
    INF = 10**40
    d = [INF] * N
    d[s] = 0
    q = [(0, s)]
    while q:
        c, v = heapq.heappop(q)
        if d[v] < c:
            continue
        for t, co in G[v]:
            if d[v] + co < d[t]:
                d[t] = d[v] + co
                heapq.heappush(q, (d[t], t))
    return d


def main():
    N, M, _ = map(int, input().split())
    R = list(map(int, input().split()))
    R = [r - 1 for r in R]
    G = [[] for _ in range(N)]
    for _ in range(M):
        a, b, c = map(int, input().split())
        G[a - 1].append((b - 1, c))
        G[b - 1].append((a - 1, c))
    RM = []
    for r in R:
        d = dijkstra(N, G, r)
        RM.append([d[rr] for rr in R])
    m = 10 ** 40
    for i in permutations(range(len(R))):
        t = i[0]
        c = 0
        for r in i[1:]:
            c += RM[t][r]
            t = r
        m = min(m, c)
    return m


print(main())


Measured memory_bytes: 6736
#C
n, m = list(map(int, input().split()))
h = list(map(int, input().split()))


result = [1 for _ in range(n)]
for i in range(m):
    a, b = list(map(int, input().split()))
    if h[a-1] < h[b-1]:
        result[a-1] = 0
    elif h[a-1] > h[b-1]:
        result[b-1] = 0
    else:
        result[b-1] = 0
        result[a-1] = 0

print(result.count(1))

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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N, K; cin >> N >> K;
    vector<int> H(N); rep(i, N) cin >> H[i];
    sort(H.begin(), H.end());
    int ans = mod;
    rep(i, N){
        if(i+K <= N){
            ans = min(ans, H[i+K-1]-H[i]);
            //cout << H[i+K-1] << " " << H[i] << endl;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"

using namespace std;

void solve()
{
    long n, k;
    cin >> n >> k;
    vector<int> as(n);
    for (int i = 0; i < n; i++)
    {
        cin >> as[i];
    }
    long ans = n + 1, r = -1, s = 0;
    for (int l = 0; l < n; l++)
    {
        while (r < l || (s < k && r + 1 < n))
        {
            s += as[++r];
        }
        if (s >= k)
        {
            ans = min(ans, r - l + 1);
        }
        s -= as[l];
    }
    if (ans == n + 1)
    {
        ans = 0;
    }
    cout << ans << endl;
}

int main()
{
    solve();
    return 0;
}



Measured memory_bytes: 3148
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<climits>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  int n,m; cin >> n >> m;
  priority_queue<ll> que;
  for(int i=0;i<n;i++){
    ll a; cin >> a;
    que.push(a);
  }
  for(int i=0;i<m;i++){
    ll t = que.top();
    que.pop();
    t /= 2;
    que.push(t);
  }
  ll ans = 0;
  while(!que.empty()){
    ll q = que.top();
    que.pop();
    ans += q;
  }
  cout << ans << endl;
  return 0;
}

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



int main() {
  int A,B;
  string s;
  cin >> A >> B >> s;
  bool flag = true;
  for(int i=0;i<s.size();i++){
    char c = s[i];
    if(c!='-'){
      if(i==A){
        cout << "No" << endl;
        flag = false;
        break;
      }
    }else{
      if(i!=A){
        cout << "No" << endl;
        flag = false;
        break;
      }
    }
  }
  if(flag){
    cout << "Yes" << endl;
  }

  
}

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

using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

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

	int N, M, K;
	cin >> N >> M >> K;
	vi A(N), B(M);
	for(int i = 0; i < N; ++i) cin >> A[i];
	for(int i = 0; i < M; ++i) cin >> B[i];
	int t = 0, j = 0;
	while(j < M && t+B[j] <= K) t += B[j++];
	int ans = j;
	for(int i = 0; i < N; ++i) {
		t += A[i];
		while(t > K && j > 0) t -= B[--j]; 
		if(t > K) break;
		ans = max(ans, j+i+1);
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 4780
#include<map>
#include<stack>
#include<deque>
#include<queue>
#include<cmath>
#include<vector>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<fstream>
#include<iostream>
#include<algorithm>
#define inf 1e9
#define re register
#define ll long long
#define Flj(i,a,b) for(int i=(a);i;i=(b))
#define Fze(i,a,b) for(int i=(a);i<(b);i++)
#define For(i,a,b) for(int i=(a);i<=(b);i++)
#define Fer(i,a,b) for(int i=(a);i>=(b);i--)
#define Fer1(i,a,b) for(int i=(a);i>b;i--)
#define Dfor(i,a,b,k) for(double i=(a);i<(b);i+=k)
#define Qmax priority_queue
#define Qmin priority_queue<int,vector<int>,greater<int> >
using namespace std;
int read(){
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int minn,len,a[5];
char c[10000000];
int main(){
	scanf("%s",c+1);
	len=strlen(c+1);
	a[1]=c[1]-'0';
	a[2]=c[2]-'0';
	a[3]=c[3]-'0';
	if(len==1){printf("%d",753-a[1]);return 0;}
	if(len==2){printf("%d",753-(a[1]*10+a[2]));return 0;}
	if(len==3){printf("%d",abs(753-(a[1]*100+a[2]*10+a[3])));return 0;}
	minn=abs(753-(a[1]*100+a[2]*10+a[3]));
	For(i,4,len){
		a[1]=a[2];
		a[2]=a[3];
		a[3]=c[i]-'0';
		if(a[1]*100+a[2]*10+a[1]==753){printf("0");return 0;}
		minn=min(minn,abs(753-(a[1]*100+a[2]*10+a[3])));
	}
	printf("%d",minn);
} 

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

long long gcd(long long a, long long b) {
    
    if(a < b){
        long long tmp = a;
        a = b;
        b = tmp;
    }
    
    if (b == 0) return a;
    else return gcd(b, a % b);
}

int main(){

    long long N;
    cin >> N;

    vector <long long> num(N);
    for(long long i = 0; i < N; i++){
        cin >> num[i];
    }

    long long gcdL[N] = {0};
    long long gcdR[N] = {0};

    for(long long i = 1; i < N; i++){
        gcdL[i] = gcd(num[i-1], gcdL[i-1]);
    }

    for(long long i = N-2; i >= 0; i--){
        gcdR[i] = gcd(num[i+1],gcdR[i+1]);
    }

    
    long long gcdMax = 0;
    for(long long i = 0; i < N; i++){
        gcdMax = max(gcdMax, gcd(gcdL[i], gcdR[i]));
    }
    cout << gcdMax << endl;
    
}



Measured memory_bytes: 2560
#include <stdio.h>

int main(void){
    int n;
    int v[20];
    int c[20];
    int profit[20];
    int i,max = 0;
    
    scanf("%d", &n);
    
    for(i = 0; i < n; i++){
        scanf("%d", &v[i]);
    }
    
    for(i = 0; i < n; i++){
        scanf("%d", &c[i]);
    }
    
    for(i = 0; i < n; i++){
        profit[i] = v[i] - c[i];
    }
    
    for(i = 0; i < n; i++){
        if(profit[i] > 0){
            max += profit[i];
        }
    }
    
    printf("%d\n", max);
    
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> Aa(N);
  vector<int> Ab(N);
  for(int i=0;i<N;i++) cin >> Aa[i];
  for(int i=0;i<N;i++) cin >> Ab[i];
  int max=0;
  for(int i=0;i<N;i++){
  	int sum=0;
    for(int a=0;a<N-i;a++){
      sum+=Aa[a];
    }
    for(int b=N-i-1;b<N;b++) sum+=Ab[b];
    if(max<=sum) max=sum;
  }
  cout << max << endl;
}

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

using namespace std;

int main() {
    int k = 0;
    int n = 0;
    cin >> k >> n;

    int sum = 0;

    int array[n];

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

    int last = array[n - 1];
    int first = array[0];

    for(int i = n - 1 ;i > 0 ; i--){
        array[i] -= array[i - 1];
    }

    array[0] += k - last;

    
    sort(array,array + n);

    sum = k - array[n -1];
    
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> iint;
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;

int main(){
    int N;
    cin >> N;
    vector<ll> A(N);
    vector<ll> B(N);
    for(int i = 0; i < N; i++) cin >> A.at(i) >> B.at(i);
    for (int i = 0; i < N; i++) {
        A[i] = 2 * A[i];
        B[i] = 2 * B[i];
    }   
    

    ll mi, ma, ans;

    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    
    if(N % 2 == 1){
        mi = A[(N-1)/2];
        ma = B[(N-1)/2];
        ans = (ma - mi)/2 + 1;
    }
    else{
        mi = (A[N/2 - 1] + A[N/2]) / 2;
        ma = (B[N/2 - 1] + B[N/2]) / 2;
        ans = ma - mi + 1;
    }

    printf("%lld\n", ans);

}



Measured memory_bytes: 6428
import java.util.*;

public class Main{
	public static void main(String args[]){
    	Scanner scan = new Scanner(System.in);
        String S = scan.next();
        String str[] = new String[S.length()];
        for( int i = 0 ; i < S.length() ; i++ ){
            str[i] = String.valueOf(S.charAt(i));
        }
        Arrays.sort(str);
        String bol = str[0].equals(str[1]) && !(str[1].equals(str[2])) && str[2].equals(str[3]) ? "Yes" : "No" ;
        System.out.println(bol);
	}
}

Measured memory_bytes: 22228
# -*- coding: utf-8 -*-
# 整数の入力
a = list(input())

ans = 0
next = 0

a.reverse()
a.append('0')

for i in range(len(a)-1):
  num = int(a[i]) + next
  nextnum = int(a[i+1])
  if num <= 4:
    ans += num
    next = 0
  elif num == 5 and nextnum <=4:
    ans += num
    next = 0
  else:
    ans += 10-num
    next = 1
    
if next == 1:
  ans += 1

print(ans)

Measured memory_bytes: 12864
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    const size_t M = 1000000000;
    size_t N;    
    vector<size_t> A;
    cin >> N;
    A.resize(N, 0);
    for(size_t i = 0; i < N; ++i)
    {
        cin >> A[i];
    }

    // 0 チェック
    for(size_t i = 0; i < N; ++i)
    {
        if(A[i] == 0)
        {
            cout << 0 << endl;    
            return 0;
        }
    }

    // M*M チェック    
    for(size_t i = 0; i < N; ++i)
    {
        if(A[i] > M*M)
        {
            cout << -1 << endl;    
            return 0;
        }
    }

    size_t T2 = 0;    // M*M
    size_t T1 = 0;    // M
    size_t T0 = 0;    // 1
    for(size_t i = 0; i < N; ++i)
    {
        // A[i] = a*M*M + b*M + c    
        size_t a = A[i] / (M*M);
        size_t b = (A[i] % (M*M)) / M;
        size_t c = A[i] % M;

        if(i == 0)
        {
            T2 = a;    
            T1 = b;
            T0 = c;    
        }
        else
        {
            size_t s4 = T2 * a;
            size_t s3 = T1 * a + T2 * b;
            size_t s2 = T0 * a + T1 * b + T2 * c;
            size_t s1 = T0 * b + T1 * c;
            size_t s0 = T0 * c;

            size_t t0 = s0 % M; s1 += s0 / M;
            size_t t1 = s1 % M; s2 += s1 / M;
            size_t t2 = s2 % M; s3 += s2 / M;
            size_t t3 = s3 % M; s4 += s3 / M;
            size_t t4 = s4 % M;

            if( (t4 > 0) || (t3 > 0) || (t2 >= 2))
            {
                cout << -1 << endl;    
                return 0;
            }
            else if(t2 == 1) 
            {
                size_t n = t1 * 1000000000 + t0;    
                if(n > 0)
                {
                    cout << -1 << endl;    
                    return 0;
                }
            }
            T2 = t2;
            T1 = t1;
            T0 = t0;  
        }
    }
    cout << T2 * M * M + T1 * M + T0 << endl;


    return 0;    
}

Measured memory_bytes: 3976
n = int(input())
a = list(map(int, input().split()))
ans = 10 ** 6
for i in range(n):
    cnt = 0
    while a[i] > 0:
        if a[i] % 2 == 0:
            a[i] = a[i] // 2
            cnt += 1
        else:
            break
    ans = min(ans, cnt)
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
long long a[200020];
int main() {
	int n;
#define int long long
	int sum = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		sum += a[i];
	}
	int mi = 100000000000000007;
	int sum1 = 0;
	for (int i = 0; i < n - 1; i++) {
		sum1 += a[i];
		if (abs((sum - sum1) - sum1) < mi) {
			mi = abs((sum - sum1) - sum1);
		}
	}
	cout << mi << endl;
	return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  ll n,k;
  cin >> n >> k;
  set<ll> cnt;
  for(ll i=0;i<k;i++) {
    ll d;
    cin >> d;
    while(d--) {
      ll s;
      cin >> s;
      cnt.insert(s);
    }
  }
  cout << n-cnt.size() << endl;
}

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

using namespace std;

#define ll       long long

#define  sci(x)   scanf("%d", &x)
#define  scl(x)   scanf("%lld", &x)
#define  scd(x)   scanf("%lf", &x)

#define  pfi(x)   printf("%d", x)
#define  pfl(x)   printf("%lld", x)
#define  pfd(x)   printf("%lf", x)
#define  pfc(x)   printf("Case %d: ", x++)
#define  ps       printf(" ")
#define  pn       printf("\n")

#define  pb       push_back
#define  ppb      pop_back
#define  pf       push_front
#define  ppf      pop_front
#define  In       insert
#define  All(a)   a.begin(), a.end()

ll dp[100005], n, h[100005];

ll solve(int pos)
{
	if(pos == n)
		return 0;

	ll ret = dp[pos];

	if(ret != -1)
		return ret;

	ret = abs(h[pos] - h[pos + 1]) + solve(pos + 1);
	if(pos + 2 <= n)
		ret = min(ret, abs(h[pos] - h[pos + 2]) + solve(pos + 2));

	return dp[pos] = ret;
}

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    memset(dp, -1, sizeof dp);
    scl(n);

    for(int i = 1; i <= n; i++)
    	scl(h[i]);

    cout << solve(1);

    return 0;
}

Measured memory_bytes: 4992
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define Vd vector<double>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b?gcd(b,a%b):a;} //最小公倍数

// デフォルト変数定義
double n,m,a,b,c,x,y,z;
double d,e,f;
string s,t;
//

signed main() {
  RAPID;
  IN3(a,b,x);
  OUT(floor(x/a)*b);
}

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

namespace AtCorder
{
	public class Program
	{
		public static void Main()
		{
			var n = int.Parse(ReadLine());
			double[] list = Array.ConvertAll(ReadLine().Split(), double.Parse);
			double ans = (list.Sum() - n);
			WriteLine(ans);
		}
	}
}


Measured memory_bytes: 13268
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;


int main() {
    int n;
    cin>>n;
    int a[8],b[n];
    int sum=0;
    int color=0;
    for(int i=0;i<8;i++)a[i]=0;
    for(int i=0;i<n;i++)cin>>b[i];
    for(int i=0;i<n;i++)
        {
        int r=b[i]/400;
        if(r>=8)sum++;
        else
        if(a[r]==0){
            color++;
            a[r]=1;
        }
        
    }
    if(color==0)
     cout<<1<<" "<<sum<<endl;
    else
    cout<<color<<" "<<(color+sum)<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main ()
{

    int A,B,C;
    scanf ("%d%d%d",&A,&B,&C);
    if((1<=A) && (A<=10) && (1<=B) && (B<=10) && (1<=C) && (C<=10)){
        if(A==5 && B==5 && C==7){
            printf ("YES");
        }
        else if(A==5 && B==7 && C==5){
            printf ("YES");

                }
        else if(A==7 && B==5 && C==5){
            printf ("YES");
          }
          else{
            printf ("NO");
          }

    }
    return 0;
}

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

int main() {
  int a,b,x;
  
  cin >> a >> b;
  
  x = a*b;
  
  if(x%2==0){
    cout << "Even" << endl;
  }
  
  else{
    cout << "Odd" << endl;
  }
  


}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    int n;
    cin >> n;

    long long a, sum1 = 0, sum2 = 0;
    long long ans1 = 0, ans2 = 0;
    for (int i = 1; i <= n; ++i) {
        cin >> a;
        sum1 += a;
        sum2 += a;
        if (i % 2 != 0) { // 奇数番目が正の場合と負の場合
            if (sum1 <= 0) { // 負なら正にする
                ans1 += 1 - sum1;
                sum1 = 1;
            }
            if (sum2 >= 0) { // 正なら負にする
                ans2 += 1 + sum2;
                sum2 = -1;
            }
        } else { // 符号が逆になる
            if (sum1 >= 0) {
                ans1 += 1 + sum1;
                sum1 = -1;
            }
            if (sum2 <= 0) {
                ans2 += 1 - sum2;
                sum2 = 1;
            }
        }
    }
    cout << min(ans1, ans2) << '\n';
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
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(){
    ll n,k;cin >> n >>k;
    vl a(n);rep(i,n)cin >> a[i];
    rep(i,n)a[i]--;
    vl cum(n+1,0);
    rep(i,n)cum[i+1]=(cum[i]+a[i])%k;
    map<ll,ll> m;
    ll ans=0;
    rep(i,n+1){
        if(i-k>=0){
            m[cum[i-k]]--;
        }
        if(m.count(cum[i])){
            ans+=m[cum[i]];
            m[cum[i]]++;
        }
        else m.ins({cum[i],1});
    }
    cout <<ans <<endl;
}

Measured memory_bytes: 15872
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
using namespace std;
typedef long long int lo;
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define inf (lo)1e10 + 7
#define FOR for(lo i = 0 ; i < n ; i++)
#define FORV for(lo i = 0 ; i < (lo)v.size() ; i++)
#define ii pair<lo,lo>
#define iii pair<lo, pair<lo,lo> >
lo a,b,c,d,e,n,m,k,t,h,x,y,a1[100005],a2[100005];
char c1,c2,c3,c4;
string s1,s2,s3,s4;
double d1,d2,d3;
vector <lo> v;
map <lo,lo> mp1;
map <lo,lo> mp2;
set <lo> stt;
queue <lo> q;
priority_queue <lo> pq;
lo vis [10000];
int main() {
    // freopen("gir.gir", "r", stdin);
    // freopen("cik.cik", "w", stdout);
    cin >> a1[0] >> a1[1] >> a1[2];
    sort(a1, a1 + 3);
    if(a1[0] == a1[1] && a1[1] != a1[2]){
        cout << "Yes\n";
    }
    else if(a1[1] == a1[2] && a1[1] != a1[0]){
        cout << "Yes\n";
    }
    else{
        cout << "No\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
map<int,int>mat;
int n,p[10005],vis[10005];
ll a[505][505];
ll gcd(ll x,ll y){
	if (!y)return x;
	return gcd(y,x%y);
}
ll lcm(ll x,ll y){
	if ((!x)||(!y))return x+y;
	return x/gcd(x,y)*y;
}
int nex(int x){
	if (!mat[x])mat[x]=p[p[0]--];
	return mat[x];
}
int main(){
	scanf("%d",&n);
	if (n==2){
		printf("4 7\n23 10\n");
		return 0;
	}
	for(int i=2;i<=10000;i++){
		if (!vis[i])p[++p[0]]=i;
		for(int j=1;(j<=p[0])&&(i*p[j]<=10000);j++){
			vis[i*p[j]]=1;
			if (i%p[j]==0)break;
		}
	}
	for(int i=1;i<=p[0]/2;i++)swap(p[i],p[p[0]-i+1]);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			if ((i+j)%2==0)a[i][j]=nex(i+j);
	mat.clear();
	for(int i=n;i;i--)
		for(int j=n;j;j--)
			if ((i+j)%2==0)a[i][j]*=nex(i-j);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			if ((i+j)%2)a[i][j]=lcm(lcm(a[i-1][j],a[i][j-1]),lcm(a[i+1][j],a[i][j+1]))+1;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++)printf("%lld ",a[i][j]);
		printf("\n");
	}
}

Measured memory_bytes: 5120
import java.util.Scanner;

public class Main {
	final boolean DEBUG = false;

	class Node {
		int id;
		Node p, l, r;
		Node(int id) {
			this.id = id;
			this.p = this.l = this.r = null;
		}
		
		Node getRoot() {
			Node n = this;
			while (n.p != null)
				n = n.p;
			return n;
		}

		void preorder() {
			System.out.print(" " + this.id);
			if (this.l != null)
				this.l.preorder();
			if (this.r != null)
				this.r.preorder();
		}
		void inorder() {
			if (this.l != null)
				this.l.inorder();
			System.out.print(" " + this.id);
			if (this.r != null)
				this.r.inorder();
		}
		void postorder() {
			if (this.l != null)
				this.l.postorder();
			if (this.r != null)
				this.r.postorder();
			System.out.print(" " + this.id);
		}
	}

	void run() {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		Node[] nodes = new Node[n];
		for (int i = 0; i < n; i++)
			nodes[i] = new Node(i);
		for (int i = 0; i < n; i++) {
			int id = scan.nextInt();
			int left  = scan.nextInt();
			int right = scan.nextInt();
			if (left != -1) {
				nodes[id].l = nodes[left];
				nodes[left].p = nodes[id];
			}
			if (right != -1) {
				nodes[id].r = nodes[right];
				nodes[right].p = nodes[id];
			}
		}
		Node root = nodes[0].getRoot();
		System.out.println("Preorder");
		root.preorder();
		System.out.println("\nInorder");
		root.inorder();
		System.out.println("\nPostorder");
		root.postorder();
		System.out.println();
	}
	public static void main(String[] args) {
		new Main().run();
	}
}




Measured memory_bytes: 26364