akhauriyash/Code-Regression huggingface dataset:
L, R = map(int, input().split())

a = R//2019*2019
if L <= a <= R:
  print((a * (a+1))%2019)
else:
  C = []
  for i in range(L,R):
    for j in range(i+1, R+1):
      C.append(i*j%2019)
  print(min(C))
  


Measured memory_bytes: 75408
#include<iostream>
#include<algorithm>
#include<math.h>
#include<string>
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ci cin >>
#define co cout <<
int N, M;
string S;
int ans = 0;
int main() {
	ci S;
	REP(i, 4) {
		if (S[i] == '2')ans++;
	}
	






	co ans;
	ci ans;
	return 0;

}

Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define vint(a,n) vint a(n); rep(i, n) cin >> a[i];
#define vll(a,n) vll a(n); rep(i, n) cin >> a[i];
#define ALL(n) begin(n),end(n)
#define RALL(n) rbegin(n),rend(n)
#define MOD (1000000007)
#define INF (2e9)
#define INFL (2e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
using vint=vector<int>;
using vll=vector<ll>;
using vbool=vector<bool>;
template<class T>using arr=vector<vector<T>>;
template<class T>int popcount(T &a){int c=0; rep(i, 8*(int)sizeof(a)){if((a>>i)&1) c++;} return c;}
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} pr(a[a.size()-1]);}
template<class T>void prarr(arr<T>& a){rep(i, a.size()) if(a[i].empty()) pr(""); else prvec(a[i]);}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main()
{
    int n; cin >> n;
    vll(a, n);

    ll neg=0, sum=0, min=INFL;
    rep(i, n){
        if(a[i]<0) neg++;
        sum += abs(a[i]);
        chmin(min, abs(a[i]));
    }

    if(neg%2==0) pr(sum);
    else pr(sum - 2*min);
    return 0;}

Measured memory_bytes: 4028
N = int(input())
inf = float("inf")
dp = [inf]*(100011)
def main():
    dp[0] = 0
    for i in range(1,100011):
        dp[i] = inf
        power_6 = 1
        power_9 = 1
        while power_6 <= i:
            dp[i] = min(dp[i],dp[i-power_6]+1)
            power_6 *= 6
        while power_9 <= i:
            dp[i] = min(dp[i],dp[i-power_9]+1)
            power_9 *= 9

if __name__ == "__main__":
    main()
    print(dp[N])

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

typedef long long int lli;

int main () {
  lli a, b, x;
  cin >> a >> b >> x;
  lli ans = 0;
  if (a > 0) {
    a--;
  } else {
    ans++;
  }
  ans += (b / x - a / x);
  cout << ans << endl;
  return 0;
}


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

int main(){
  int N;
  cin >> N;
  int sum = 0;
  for(int i = 0; i < N; i++){
    int l, r;
    cin >> l >> r;
    sum += r - l + 1;
  }
  cout << sum << endl;
}
       
      

Measured memory_bytes: 256
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter,defaultdict
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)
# INF =  float("inf")
INF = 10**18
import bisect
import statistics
mod = 10**9+7
# mod = 998244353

S = input()

if S[0] == S[1]:
    if S[0] != S[2] and S[2] == S[3]:
        print("Yes")
    else:
        print("No")
elif S[0] == S[2]:
    if S[0] != S[1] and S[1] == S[3]:
        print("Yes")
    else:
        print("No")
elif S[0] == S[3]:
    if S[0] != S[1] and S[1] == S[2]:
        print("Yes")
    else:
        print("No")
else:
    print("No")



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

int n,m,sum;
int a[110];
vector<int> v, ansa, ansb;
int main() {
    cin >> n >> m;
    int odd = 0;
    for (int i = 0; i < m; i++) {
        cin >> a[i];
        if (a[i] & 1) {
            v.push_back(a[i]);
        }
    }
    if (v.size() > 2) {
        cout << "Impossible" << endl;
        return 0;
    }
    if (v.size() >= 1) ansa.push_back(v[0]);
    for (int i = 0; i < m; i++) {
        if (!(a[i] & 1)) ansa.push_back(a[i]);
    }
    if (v.size() == 2) ansa.push_back(v[1]);
    
    if (ansa[0] - 1 > 0) ansb.push_back(ansa[0] - 1);
    sum += ansa[0] - 1;
    for (int i = 1; i < ansa.size(); i++) {
        ansb.push_back(ansa[i] + (i == (int)ansa.size() - 1));
        sum += ansb[ansb.size() - 1];
    }
    if (sum != n) ansb.push_back(1);
    for (int i = 0; i < ansa.size(); i++) {
        cout << ansa[i] << " \n"[i == ansa.size() - 1];
    }
    cout << ansb.size() << endl;
    for (int i = 0; i < ansb.size(); i++) {
        cout << ansb[i] << " \n"[i == ansb.size() - 1];
    }
    return 0;
}

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

int A,B,C,X;
int x,y,z,ans;
int main()
{
	cin>>A>>B>>C>>X;
	for(x=0;x<=A;x++)
	   for(y=0;y<=B;y++)
	      for(z=0;z<=C;z++)
	      if(x*500+y*100+z*50==X)ans++;
	cout<<ans<<endl;
}

Measured memory_bytes: 256
/*
      author : nishi5451
      created: 11.08.2020 19:39:58
*/

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


int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    int ans = a+b-c-d;
    if(ans==0) cout << "Balanced" << endl;
    else if(ans>0) cout << "Left" << endl;
    else cout << "Right" << endl;
    return 0;
}

Measured memory_bytes: 3560
package main

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

const size = 1000000
var reader = bufio.NewReaderSize(os.Stdin,size)
func NextLine() string {
  var line,buffer []byte
  var isPrefix bool = true
  var err error
  for ;isPrefix; {
    line,isPrefix,err = reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer,line...)
  }
  return string(buffer)
}
func NextInt() int {
  var x int
  x,_ = strconv.Atoi(NextLine())
  return x
}
func Next2Ints() (int,int) {
  var x,y int
  var s []string = strings.Split(NextLine()," ")
  x,_ = strconv.Atoi(s[0])
  y,_ = strconv.Atoi(s[1])
  return x,y
}

func main() {
  var n int = NextInt()
  var x []int = make([]int,n)
  var y []int = make([]int,n)
  var u []int64 = make([]int64,n)
  var v []int64 = make([]int64,n)
  for i:=0;i<n;i++ {
    x[i],y[i] = Next2Ints()
    u[i] = int64(x[i]) + int64(y[i])
    v[i] = int64(x[i]) - int64(y[i])
  }
  var p int64 = abs(u[0])%2
  for i:=1;i<n;i++ {
    if abs(u[i])%2 != p {
      fmt.Println(-1)
      os.Exit(0)
    }
  }
  var m int = 31
  var d []int64 = make([]int64,m)
  d[0] = 1
  for i:=1;i<m;i++ {
    d[i] = 2*d[i-1]
  }
  if p == 0 {
    d = append(d,1)
    for i:=0;i<n;i++ {
      u[i]--
      v[i]--
    }
  }
  fmt.Println(m+int(1-p))
  fmt.Print(d[0])
  for i:=1;i<len(d);i++ {
    fmt.Print(" ")
    fmt.Print(d[i])
  }
  fmt.Println()
  var max int64 = 2*d[m-1]-1
  for i:=0;i<n;i++ {
    var us string = strconv.FormatInt((u[i]+max)/2,2)
    var vs string = strconv.FormatInt((v[i]+max)/2,2)
    var t string = ""
    for {
      if len(us) == m { break }
      us = "0" + us
    }
    for {
      if len(vs) == m { break }
      vs = "0" + vs
    }
    us = reverse(us)
    vs = reverse(vs)
    for i:=0;i<m;i++ {
      if us[i:i+1] == "0" && vs[i:i+1] == "0" {
        t += "L"
      } else if us[i:i+1] == "0" && vs[i:i+1] == "1" {
        t += "D"
      } else if us[i:i+1] == "1" && vs[i:i+1] == "0" {
        t += "U"
      } else {
        t += "R"
      }
    }
    if p == 0 { t += "R" }
    fmt.Println(t)
  }
}
func abs(n int64) int64 {
  if n < 0 { return -n }
  return n
}
func reverse(s string) string {
  var r []rune = []rune(s)
  var n int = len(s)
  for i:=0;i<n-i;i++ {
    r[i],r[n-i-1] = r[n-i-1],r[i]
  }
  return string(r)
}

Measured memory_bytes: 1792
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30);
const int INF = (1LL << 60);
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}



signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int n;
    cin>>n;
    vector<int> a(n);
    REP(i,n) cin >> a[i];
    vector<int> b(101);
    rep(i,101){
        rep(j,n){
            b[i]+=(a[j]-i)*(a[j]-i);
        }
    }
    sort(all(b));
    cout<<b[0]<<endl;
}

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



int main() {

	int r;
	cin >> r;
	if (r < 1200) {
		cout << "ABC" << endl;
	}
	else if (r < 2800) {
		cout << "ARC" << endl;
	}
	else cout << "AGC" << endl;

	return 0;
}



Measured memory_bytes: 256
#AC済み
x,y,z,k=map(int,input().split())
a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]
c=[int(i) for i in input().split()]
a.sort()
b.sort()
c.sort()
ab=[a[i]+b[j] for j in range(y) for i in range(x)]
ab.sort(reverse=True)
ab=ab[:k]
l=len(ab)
abc=[ab[i]+c[j] for j in range(z) for i in range(l)]
abc.sort(reverse=True)
for i in range(k):
    print(abc[i])


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

int main(){

int ans = -1;
int n;
cin >> n;
vector<int>a(n);
rep(i,n){
    cin>>a[i];
}
int j = 1;
int cnt = 0;

while(cnt<=n){
    if(a[j-1]==2){
        ans=cnt+1;
        break;
    }
    if(a[j-1]!=2){
        j = a[j-1];
        cnt++;
        
    }
}


cout << ans << endl;

}


Measured memory_bytes: 640
//
// Created by Mahmoud Rashad on 11/27/19.
//

#include <bits/stdc++.h>


using namespace std;

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<pair<ii, ii>> vii;

const int Mod = (int)1e9 + 7;

int mul(int a, int b) {
    return 1LL * a * b % Mod;
}

const int MAXN = 100005;
int memo[2][MAXN], n;
string str;

int solve(int idx, bool f) {
    if(idx == n)
        return 1;
    int &ret = memo[f][idx];
    if (~ret)
        return ret;
    ret = 0;
    if (f) {
        ret += 3LL * solve(idx + 1, f) % Mod;
        ret %= Mod;
    } else {
        if (str[idx] == '1') {
            ret += 2LL * solve(idx + 1, f) % Mod;
            ret %= Mod;
            ret += solve(idx + 1, true);
            ret %= Mod;
        } else {
            ret += solve(idx + 1, f) % Mod;
        }
    }
    return ret;
}

int main() {
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.out", "w", stdout);
#endif
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0), cout.precision(10), cout << fixed;


    cin >> str;
    n = (int) str.size();
    memset(memo, -1, sizeof memo);
    cout << solve(0, false) << '\n';
}

Measured memory_bytes: 5968
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000009
#define ll long long
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define set0(a) memset ((a), 0 , sizeof(a))
#define set1(a) memset((a),-1,sizeof (a))
#define pi pair<int, int>
#define ps pair<string, string>
#define pl pair<long, long>
#define pll pair<long long, long long>
#define vll vector<long long>
#define vl vector<long>
#define vi vector<int>
#define vs vector<string>
#define vps vector< ps >
#define vpi vector< pi >
#define vpl vector< pl >
#define vpll vector< pll >
#define flash  ios_base::sync_with_stdio(false); cin.tie(NULL);
#define tc(t,T) for(long long t=0;t<T;t++)
#define rep(i,s,n,d) for(long long i=s;i<n;i=i+d)

bool sortbysec(const pll &a,
              const pll &b)
{
    return (a.second < b.second);
}
/*bool cxp pair<ll, pll> &a,
              const pair<ll, pll> &b)
{
    return (a.ff < b.ff);
}*/

void func(void)
{
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    else return gcd(b,a%b);
}
void printStack(stack<string> s){
    if(s.empty())return;

    string x=s.top();
    s.pop();
    printStack(s);
    cout<<x;
    s.push(x);

}


ll binaryexp(ll n,ll p){

    if(p==0) return 1;
    if(p%2==0) return binaryexp((n%mod)*(n%mod),p/2);
    else return ((n%mod)*binaryexp(((n%mod)*(n%mod))%mod,(p-1)/2)%mod);

}

#define meax 10000001
vll spf(meax,0);
void siv(){
    spf[1]=1;

   for(ll i=2;i<meax;i++)spf[i]=i;

   for(ll i=4;i<meax;i+=2){
        spf[i]=2;
    }
    for(ll i=3;i*i<meax;i++){
        if(spf[i]==i){
            for(ll j=i*i;j<meax;j+=i){
                if(spf[j]==j){
                    spf[j]=i;
                }
            }
        }
    }
}

ll dp[105][100007];
ll item[1000];
ll value[1000];
ll solve(ll i, ll W,ll n){



    if(i>=n)return 0;



    if(dp[i][W]!=-1){
        return dp[i][W];
    }
    if(W<item[i]){
        dp[i][W]=solve(i+1,W,n);
        return dp[i][W];
    }
    ll s1;
    s1=solve(i+1,W-item[i],n)+value[i];
    ll s2=solve(i+1,W,n);
    ll ans=max(s1,s2);

    dp[i][W]=ans;
    return dp[i][W];
}
int main(){
    ll n;
    cin>>n;
    ll W;
    cin>>W;
    for(int i=0;i<105;i++){
        for(ll j=0;j<100007;j++){
            dp[i][j]=-1;
        }
    }
    for(int i=0;i<n;i++){
        ll it=0;
        cin>>it;
        ll val;
        cin>>val;
        item[i]=it;
        value[i]=val;
    }


    ll d2=solve(0,W,n);

    cout<<d2<<endl;

}


Measured memory_bytes: 163496
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  int h[100009];
  cin>>n>>k;
  for(int i=0;i<n;i++){
    cin>>h[i];
  }
  sort(h,h+n);
  int ans=1000000000;
  for(int i=0;i<n-k+1;i++){
    ans=min(ans,h[i+k-1]-h[i]);
  }
  cout<<ans<<endl;
  return(0);
}


Measured memory_bytes: 640
#include <iostream>
#include <math.h>
using namespace std;
int main(void){
    int banks, year, bank_num, type,  max_bank_num;
    double rate, money, max_money;
    
    while(true){
        max_money=0;
        max_bank_num=0;
        cin >> banks;
        if(banks==0) break;
        cin >> year;
        for(int i=0; i<banks; i++){
            cin >> bank_num >> rate >> type;
            if(type == 1){ //tanri
                money=1+year*rate/100;
            }
            else if(type == 2){ //hukuri
                money=pow(1+rate/100, year);
            }
            //cout << "money=" << money << endl;
            if(max_money < money){
                max_money = money;
                max_bank_num=bank_num;
            }
        }
        cout << max_bank_num << endl;
    }
    return 0;
}



Measured memory_bytes: 3452
import sys
sys.setrecursionlimit(10**8)
input = sys.stdin.readline

N = int(input())

table = [1]*(N+1)
for i in range(2,N+1):
    for j in range(i, N+1, i):
        table[j] += 1
ans = 0
for i in range(1, N+1):
    ans += i*table[i]
print(ans)

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

int main() {
    int n, T;
    cin >> n >> T;
    int ans = 1e9;
    rep(i,n) {
        int c, t;
        cin >> c >> t;
        if (t <= T) ans = min(ans,c);
    }
    if (ans == 1e9) cout << "TLE" << endl;
    else cout << ans << endl;
}

Measured memory_bytes: 256
/**
*   @Author : MeGaCrazy
*   @InitTime : Mon Feb 18 15:34:45 2019
*   @Idea :
*
*
*
*
*
*  Happy Solving :)
**/
#include <bits/stdc++.h>
using namespace std;
int main(){
#ifndef ONLINE_JUDGE
   //freopen("in","r",stdin);
   //freopen("out","w",stdout);
#endif
   int n,k;
   cin>>n>>k;
   long long cnt=0;
   long long ans=0;
   for(int i=1;i<=n;i++){
   	if(i%k==0)cnt++;
   }
   ans=cnt*cnt*cnt;
   cnt=0;
   if(k%2==0){
   	for(int i=1;i<=n;i++){
   	   if((i%k)==(k/2))cnt++;
   	}
   }
   ans+=(cnt*cnt*cnt);
   cout<<ans;
  




}

Measured memory_bytes: 256
/** @Date    : 2017-05-06 20:21:53
  * @FileName: B.cpp
  * @Platform: Windows
  * @Author  : Lweleth (SoundEarlf@gmail.com)
  * @Link    : https://github.com/Lweleth
  * @Version : $Id$
  */
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int ,int>
#define MP(x, y) make_pair((x),(y))
#define fi first
#define se second
#define PB(x) push_back((x))
#define MMG(x) memset((x), -1,sizeof(x))
#define MMF(x) memset((x),0,sizeof(x))
#define MMI(x) memset((x), INF, sizeof(x))
using namespace std;

const int INF = 0x3f3f3f3f;
const int N = 1e5+20;
const double eps = 1e-8;

int c[N];
int n, q;

int main()
{
	while(~scanf("%d%d", &n, &q))
	{
		MMF(c);
		int flag = 0;
		for(int i = 0; i < q; i++)
		{
			int x, y;
			scanf("%d%d", &x, &y);
			c[x]++;
			c[y]++;
		}
		for(int i = 1; i <= n; i++)
			if(c[i] % 2)
			{
				flag = 1;
				break;
			}
		if(flag) printf("NO\n");
		else printf("YES\n");
	}
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define int long long int
int x[10],y[10];
double dist(int i,int j)
{
    double dx=x[i]-x[j];
    double dy=y[i]-y[j];
    return pow(dx*dx+dy*dy,0.5);
}
signed main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>x[i]>>y[i];
    
    double sum=0.0;
    vector<int> v(n);
    for(int i=0;i<n;i++)
        v[i]=i+1;
    do
    {
        for(int i=0;i<n-1;i++)
            sum+=dist(v[i],v[i+1]);
    }while(next_permutation(v.begin(),v.end()));
    
    int f=1;
    for(int i=2;i<=n;i++)
        f*=i;
    cout<<fixed<<setprecision(10)<<sum/f<<endl;
}

Measured memory_bytes: 384
#include<stdio.h>
    int main(void){
      int H,W,i,j,cou,cou2,S[100001],Y,M,N,K;
      double answer;
      char A[1000];
      scanf("%d %d",&N,&K);
      for(i=0;i<N;i++){
        cou+=i+1;
        S[i]=N;
        while(1){
          
          if(cou>=K){
            break;
          }
          cou=cou*2;
          S[i]=S[i]*2;
        }
        cou=0;
      }
      for(i=0;i<N;i++){
        answer+=1.0/(double)S[i];
      }
      printf("%.12f",answer);

     }
      

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

#define _GLIBCXX_DEBUG

//vector<int> A(M), B(M);
//vector<vector<char>> answer(N, vector<char>(N, '-'));

int main() {
  char a;
  string ans;
  
  cin >> a;
  
  if(isupper(a)) ans = "A";
  else ans = "a";
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3560
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
const int MOD = (int)1e9 + 7;
int add(int &a, int b) { return (a += b) >= MOD ? a -= MOD : a; }

int main() {
    int N; cin >> N;
    vector<vector<int>> a(N, vector<int>(N));
    for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) cin >> a[i][j];

    vector<vector<int>> dp(N + 1, vector<int>(1 << N, 0));
    dp[0][0] = 1;
    for (int i = 0; i < N; i++) for (int msk = 0; msk < 1 << N; msk++) {
        if (i != __builtin_popcount(msk)) continue;
        for (int j = 0; j < N; j++) if (!(msk & (1 << j)) && a[i][j]) {
                add(dp[i + 1][msk | (1 << j)], dp[i][msk]);
        }
    }
    cout << dp[N][(1 << N) - 1] << endl;
    return 0;
}

Measured memory_bytes: 188800
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 19;
int MOD = 10000000;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<n;i++)
#define Se second
#define Fi first

int r[100050];
int root(int x) {
	return (x == r[x]) ? x : r[x] = root(r[x]);
}
int lc = 0;
vector <int> Vl[100050];
vector <int> Vx;
ll in[100050];
int pos[100050];

int main() {
	int N, M, i, j;
	scanf("%d %d", &N, &M);
	for (i = 1; i <= N; i++) r[i] = i;
	for (i = 1; i <= N; i++) scanf("%lld", &in[i]);
	for (i = 1; i <= M; i++) {
		int t1, t2;
		scanf("%d %d", &t1, &t2);
		t1++, t2++;
		r[root(t1)] = root(t2);
	}
	for (i = 1; i <= N; i++) if (r[i] == i) Vx.push_back(i);
	lc = Vx.size();
	for (i = 1; i <= N; i++) {
		int t = lower_bound(all(Vx), root(i)) - Vx.begin() + 1;
		Vl[t].push_back(i);
	}

	if (2 * lc - 2 > N) return !printf("Impossible\n");
	for (i = 1; i <= lc; i++) {
		sort(all(Vl[i]), [](int a, int b) {
			return in[a] < in[b];
		});
		Vl[i].push_back(0);
	}
	in[0] = INF;
	if (lc == 1) return !printf("0\n");

	priority_queue <pll, vector<pll>, greater<pll>> Hx;
	ll ans = 0;
	int c = lc - 2;
	for (i = 1; i <= lc; i++) {
		pos[i] = 1;
		ans += in[Vl[i][0]];
		Hx.emplace(in[Vl[i][1]], i);
	}
	while (c) {
		c--;
		pll u = Hx.top();
		Hx.pop();
		ans += u.first;
		pos[u.second]++;
		Hx.emplace(in[Vl[u.second][pos[u.second]]], u.second);
	}
	return !printf("%lld\n", ans);
}
//*/

Measured memory_bytes: 7288
#pragma GCC optimize("Ofast,inline,unroll-loops,fast-math")
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <sstream>
#include <bitset>
#include <memory>
#include <string>
#include <vector>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <deque>
#include <algorithm>
#include <random>
#include <iomanip>
using namespace std;

const int mod = 1000000007;
long long int mypow(long long int a, long long int p) {
	if (p == 0) return 1;
	if (p == 1) return a;
	long long int res = mypow(a, p / 2);
	res = res * res % mod;
	if (p % 2 == 1)
		res = res * a % mod;
	return res;
}

int main(int argc, char *argv[]) {
	int n;
	cin >> n;
	vector<pair<int, int>> vp;
	unordered_map<int, unordered_set<int>> um;
	unordered_map<int, int> weight;
	unordered_map<int, unordered_map<int, int>> pw;
	for (int i = 1; i < n; i++) {
		int a, b;
		cin >> a >> b;
		vp.push_back(make_pair(a, b));
		um[a].insert(b);
		um[b].insert(a);
	}
	for (int i = 1; i <= n; i++)
		weight[i] = 1;

	vector<int> v1, v2;
	for (int i = 1; i <= n; i++) {
		if (um[i].size() == 1)
			v1.push_back(i);
	}

	while (v1.size() > 0) {
		v2.clear();
		for (auto node : v1) {
			if (um[node].size() == 0) continue;
			int next = *(um[node].begin());
			pw[node][next] = weight[node];
			pw[next][node] = n - weight[node];
			weight[next] += weight[node];
			um[next].erase(node);
			if (um[next].size() == 1) v2.push_back(next);
		}
		v1 = v2;
	}

	for (int i = 0; i < n - 1; i++) {
		um[vp[i].first].insert(vp[i].second);
		um[vp[i].second].insert(vp[i].first);
	}

	long long int a = 0, b = mypow(2, n - 1);
	for (int i = 1; i <= n; i++) {
		if (um[i].size() < 2) continue;

		// i -> 
		a += um[i].size();
		a += b;
		a %= mod;
		for (auto next : um[i]) {
			int right = pw[next][i];
			a -= mypow(2, right);
			while (a < 0)
				a += mod;
		}
		a -= 1;
		if (a < 0) a += mod;
	}
	b = mypow(2, n);
	long long int step = 1;
	while (a % b != 0) {
		long long int next_b = (mod / b * b + b) % mod;
		step = step * (mod / b + 1) % mod;
		b = next_b;
	}
	cout << a / b * step % mod << endl;
}









Measured memory_bytes: 88504
#include<bits/stdc++.h>
using namespace std;
#define start ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define f(i, a, n) for( i=a; i<n;i++)
#define ll long long
#define pi 3.141592653589793
int main()
{
    start;
    ll i,j,k,l,m,n,s=0;
    cin>>n; ll a[n];
    f(i,0,n) cin>>a[i];
    sort(a,a+n,greater<>());
    s=a[0];
    //f(i,0,n) cout<<a[i]<<endl;
    for(i=2;i<n;i++)
    {
        s+=a[i/2];
    }
    cout<<s<<endl;
}


Measured memory_bytes: 5120
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<tuple>
#include<cmath>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

double const eps = 1e-11;
int const MAXN = 100;
struct { double x, y, th; } p[MAXN*2];
int N;

int main() {
  std::cout << std::setprecision(15) << std::fixed;
  std::cin >> N;
  int j = 0;
  for(int i = 0; i < N; ++i) {
    double x, y; std::cin >> x >> y;
    if(std::fabs(x) < eps && std::fabs(y) < eps) continue;
    p[j++] = { x, y, std::atan2(y, x) };
  }
  N = j;
  if(N < 1) fin(0.0);
  std::sort(p, p+N, [&](auto const& l, auto const& r){ return l.th < r.th; });
  for(int i = 0; i < N; ++i) p[i+N] = p[i];
  double sumx = 0, sumy = 0, sum2 = 0, ans2 = 0;
  j = 0;
  for(int i = 0; i < N; ++i) {
    while(j < i+N) { 
      double nx = sumx + p[j].x, ny = sumy + p[j].y;
      double n2 = nx*nx + ny*ny;
      if(n2 <= sum2) break;
      sumx = nx; sumy = ny; sum2 = n2;
      ans2 = std::max(ans2, sum2);
      ++j;
    }
    sumx -= p[i].x;
    sumy -= p[i].y;
    sum2 = sumx*sumx + sumy*sumy;
    ans2 = std::max(ans2, sum2);
  }
  fin(std::sqrt(ans2));
  return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <math.h>
int main(void)
{
  double c,f;
  double x, y;
  double matrix;

  scanf("%lf %lf",&c,&f);
  
	matrix = -2;

	
	x = (2*c - f) / matrix;
	y = (f - 4*c) / matrix;

  if(x >= 0)
  {
    if(y >= 0)
    {
      if (ceil(x) == floor(x))
      {
        if (ceil(y) == floor(y))
        {
          printf("Yes");
        }
        else
        {
          printf("No");
        }
      }
      else
      {
        printf("No");
      }
    }
    else
    {
      printf("No");
    }
  }
  else
  {
    printf("No");
  }
	return 0;
}

Measured memory_bytes: 2276
N,K=map(int,input().split())
V=[int(i) for i in input().split()]
ans=0
for i in range(N):
  for j in range(i,N+1):
    c=0
    if i+N-j<=K:
      k=K-(i+N-j)
      s=V[:i]+V[j:]
      s.sort()
      c=0
      #print(s,k)
      for t in s:
        if k>=1 and t<0:
          k-=1
        else:
          c+=t
    ans=max(c,ans)
print(ans)        
      

Measured memory_bytes: 39792
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = (1LL << 31) - 1;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100 * 3

int n;

int main() {
	while (cin >> n&&n) {
		bool table[100][100] = {};
		REP(i, n) {
			int f;
			cin >> f;
			REP(j, f) {
				int num;
				cin >> num;
				table[i][num - 1] = 1;
			}
		}
		int ans = 10000;
		ll msk[100] = {};
		REP(i, n)msk[i] = (1LL << i);
		REP(j, 30) {
			REP(i, n) {
				REP(l, n) {
					if (table[i][j] && table[l][j]) {
						msk[l] |= msk[i];
						msk[i] |= msk[l];
					}
				}
			}
			//REP(i, n) {
			//	cout << msk[i] << " ";
			//}
			//cout << endl;
			REP(k, n) {
				if (msk[k] == (1LL << n) - 1) {
					ans = min(ans, j + 1);
					break;
				}
			}
		}
		if (ans == 10000)cout << -1 << endl;
		else cout << ans << endl;
	}
}

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

int main(){
  int n, k;
  cin >> n >> k;
  int f[1005];
  
  rep(i, n)cin >> f[i];
  sort(f, f+n);
  int ans = 0;
  rep(i, k){
    ans += f[i];
  }
  cout << ans;

  return 0;
}


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

using namespace std;

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

	stack<int> ss;
	stack<pair<int,int>> ike;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == '\\') {
			ss.push(i);
		}
		else if (s[i] == '/') {
			int menseki = 0;;
			int j = 0;
			if (ss.empty() != true) {
				j = i - ss.top();
				if (i - j >= 0) {
					menseki += (j - 1 + j + 1) / 2;
					if (ike.empty() != true) {
						while (ike.top().first > i - j) {
							menseki += ike.top().second;
							ike.pop();
							if (ike.empty() == true) { break; }
						}
						ike.push(make_pair(i - j, menseki));
					}
					else {
						ike.push(make_pair(i - j, menseki));
					}

					ss.pop();
				}
			}
		}
	}
	int total = 0;
	vector<int> a(ike.size(), 0);
	int kk = ike.size();
	for (int i = 0; i < kk; i++) {
		total += ike.top().second;
		a[i] = ike.top().second;
		ike.pop();
	}
	cout << total << endl;
	cout << a.size();
	for (int i = a.size()-1; i >=0; i--) {
		cout << " " << a[i];
	}
	cout << endl;
}


Measured memory_bytes: 3264
import math

a, b = map(int, input().split())

ab = int(str(a) + str(b)) 
root = math.sqrt(ab)

#print(ab)

#print(math.sqrt(ab))

#print(isinstance(root, float))
#print('1')
if isinstance(root, int) == True:
    ans = 'Yes' 
    #print('2')
elif isinstance(root, float) == True:
    #print('3')
    #print('float')
    #print(root.is_integer())
    if root.is_integer() == True:
        #print('4')
        ans = 'Yes' 
    #print(root.is_integer())
    else:
        ans = 'No'
        #print('5')

print(ans)

Measured memory_bytes: 3060
import Data.List
main = mapM_ (print . solve) . map (map read . words) . lines =<< getContents
solve abc = f a b c 0 where [a,b,c] = sort abc
f a b c n
  |odd a || odd b || odd c = n
  |a==b && b==c = -1
  |otherwise = f ((a+b)`div`2) ((a+c)`div`2) ((b+c)`div`2) (n+1)

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

int main() 
{  
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n,m;
  cin>>n>>m;
  int a[m];
  int b[2][100005];
  memset(b,0,sizeof(b));
  string s1="WA",s2="AC";
  for(int i=0;i<m;i++)
  {
    string s;
    cin>>a[i];
    cin>>s;
    if(s.compare(s1)==0)
    {
      if(b[1][a[i]]==0)
      {
        b[0][a[i]]++;
      }
    }
    else
    {
      b[1][a[i]]=1;
    }
  }
  int right=0,wrong=0;
  for(int i=0;i<100005;i++)
  {
    if(b[1][i]==0)
    {
      continue;
    }
    else
    {
      right++;
      wrong+=b[0][i];
    }
  }
  cout<<right<<" "<<wrong;
  return 0; 
} 

Measured memory_bytes: 1408
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
using namespace std;
typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b, c = 0;
    cin >> a >> b;
    for (int i = a ; i <= b ; i++) if (i / 10000 == i % 10 && ( i / 1000 ) % 10 == ( i % 100 ) / 10) c++;
    cout << c;	
}


Measured memory_bytes: 3584
S=input()
Q=int(input())
Query=[input().split() for i in range(Q)]

m=1
A=[]
B=[]
for i in range(Q):
  if int(Query[i][0])==1:
    m*=-1
  else:
    
    if m*((-2*int(Query[i][1]))+3)==1:
      A.append(Query[i][2])
    else:
      B.append(Query[i][2])
if m==1:
  print(''.join(A)[::-1]+S+''.join(B))
else:
  print(''.join(B)[::-1]+S[::-1]+''.join(A))

Measured memory_bytes: 41848
N, x = [int(j) for j in input().split()]
a = sorted(list(map(int, input().split())))
sum = 0
flag = True

for i in range(N):
    sum += a[i]
    if sum > x:
        flag = False
        break

if sum != x:
    flag = False
    
print(i+1 if flag else i)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <bitset>
#include <iterator>
#include <cmath>
#include <stack>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<long long, long long>
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

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; }

using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
const double PI = acos(-1.0);

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

  string s; cin >> s;
  bool findc = false;
  rep(i, s.size()) {
    if (!findc) {
      if (s[i] == 'C') {
        findc = true;
      }
    } else {
      if (s[i] == 'F') {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }

  cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <queue>
#include <stack>

using namespace std;
#define rep(i,n) for(int i=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int i=(m);(i)<(n);(i)++)
#define ll long long
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){
    int x1,y1,x2,y2,x3,y3,x4,y4;
    cin >> x1 >> y1 >> x2 >> y2;
    int xd = x2-x1, yd = y2-y1;
    x3=x2-yd;
    y3=y2+xd;
    x4=x3-xd;
    y4=y3-yd;
    printf("%d %d %d %d\n",x3,y3,x4,y4);
    return 0;
}

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

int main(){
    int m;
    cin >> m;

    long long int sum = 0;
    long long int digit = 0;
    vector<long long int> d(m), c(m);
    for(int i=0; i<m; i++){
        cin >> d[i] >> c[i];
        sum += d[i] * c[i];
        digit += c[i];
    }

    long long int ans = digit - 1;
    long long int dsum = 0;
    while(sum > 0){
        if(sum >= 10){
            ans += sum / 10;
            dsum += sum % 10;
            sum /= 10;
        }
        else{
            sum += dsum;
            dsum = 0;
            if(sum < 10) break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6352
#include<stdio.h>
#include<math.h>
#define PI 3.14159
int main()
{
	int d,r,t=90;
	double x = 0,y = 0;
	do{
		scanf("%d%*c%d",&d,&r);
		x+=d*cos(t/180.0*PI);
		y+=d*sin(t/180.0*PI);
		t-=r;
	}while(d||r);
	printf("%d\n%d\n",(int)x,(int)y);
	return 0;
}
 

Measured memory_bytes: 604
#include<iostream>
#include <list>
#include<stack>
#include<queue>
#include <vector>
#include <set>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include <functional>
#include<fstream>

#define FOR(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define LL long long
#define CLR(a) memset((a),0,sizeof(a))
#define SZ(x) (int((x).size()))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<<str<<endl
using namespace std;

const LL MOD = 1000000007;// 10^9+7
const int INF = (1 << 30);


//変数







//サブ関数
//入力
void input()
{

}


//計算
bool calc(const string s)
{
	vector<int> v;
	for (auto c : s)v.push_back(c - 'A');
	REP(i, (int)s.size() - 1) {
		//同一は除外
		if (v[i] == v[i + 1])return false;
		//→
		if (v[i] % 3 != 2 && v[i] + 1 == v[i + 1])continue;
		//左
		if (v[i] % 3 != 0 && v[i] - 1 == v[i + 1])continue;
		//上
		if (3 <= v[i] && v[i] - 3 == v[i + 1])continue;
		//↓
		if (v[i] < 6 && v[i] + 3 == v[i + 1])continue;
		return false;
	}
	return true;
}


//出力
void output()
{

}


//デバッグ
void debug()
{
	int N;
	cin>>N;
}


//メイン関数
int main()
{
	REP(i, 1000) {
		string s;
		cin >> s;
		if (calc(s))cout << s << endl;
	}
	output();
	debug();
	
	return 0;
}




Measured memory_bytes: 3132
import java.util.*;
public class Main {
	public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      int N = sc.nextInt();
      int X = sc.nextInt();
      int T = sc.nextInt();
      int ans;
      if(N%X==0){
        ans = N/X*T;
      }else{
        ans = (N/X+1)*T;
      }      
       System.out.println(ans);
    }
}

Measured memory_bytes: 35764
import java.io.*;
import java.lang.*;
import java.util.*;
public class Main{  
    public static void main(String[] args) throws IOException{
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        int N=Integer.parseInt(br.readLine());
        int[] arr=new int[N+1];
        StringTokenizer st=new StringTokenizer(br.readLine()," ");
        for(int i=2;i<=N;i++) {
            int n=Integer.parseInt(st.nextToken());
            arr[n]++;
        }
        StringBuffer sb=new StringBuffer();
        for(int i=1;i<=N;i++) sb.append(arr[i]+"\n");
        System.out.print(sb);
    }
}


Measured memory_bytes: 55984
#include <bits/stdc++.h>
#define int long long 
using namespace std ;

signed main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	int x;
	cin>>x;
	int ans = 1000*(x/500);
	x = x%500 ;
	ans += 5*(x/5);
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <algorithm>
#include <vector>
#include <fstream>

using namespace std;

ifstream fin("../data.txt");

char sa[104], sb[104], sc[104], *s;
int ia, ib, ic, *i;
char winner;

int main() {

  cin.getline(sa, 104);
  cin.getline(sb, 104);
  cin.getline(sc, 104);

  s = sa;
  i = &ia;
  while (*i < strlen(s)) {
    *i += 1;
    if (s[(*i)-1] == 'a') {
      s = sa;
      i = &ia;
      winner = 'A';
    } else if (s[(*i)-1] == 'b') {
      s = sb;
      i = &ib;
      winner = 'B';
    } else if (s[(*i)-1] == 'c') {
      s = sc;
      i = &ic;
      winner = 'C';
    }
  }

  cout << winner;
  return 0;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
	int a,b;
	string s;
	cin>>a>>b>>s;
	for(int i=0;i<a+b+1;i++){
		if(i<a){
			if(s[i]!='0' && s[i]!='1' && s[i]!='2' && s[i]!='3' && s[i]!='4' && s[i]!='5' && s[i]!='6' && s[i]!='7' && s[i]!='8' && s[i]!='9'){
				cout<<"No"<<endl;
				return(0);
			}
		}
		else if(i==a){
			if(s[i]!='-'){
			cout<<"No"<<endl;
			return(0);
			}
		}
		else{
			if(s[i]!='0' && s[i]!='1' && s[i]!='2' && s[i]!='3' && s[i]!='4' && s[i]!='5' && s[i]!='6' && s[i]!='7' && s[i]!='8' && s[i]!='9'){
				cout<<"No"<<endl;
				return(0);
			}
		}
	}
	cout<<"Yes"<<endl;
    return(0);
}

Measured memory_bytes: 3576
'use strict'

function Main(input) {
    input = input.split("\n")[0]
    input = input.split(' ').map(str => parseInt(str, 10))
    const span = input[0]
    const amount = input[1]
    const maxTime = input[2] 

   const shou = Math.floor(maxTime / span)

   console.log(shou * amount)
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"))

Measured memory_bytes: 21064
#include <set>
#include <map>
#include <iostream>
#include <cstdio>
#include <queue>
#define REP(i,n) for(int i=0; i<(int)(n); i++)
/*
  3344
  1122

 */

const int _dx[] = {0,1,0,-1};
const int _dy[] = {-1,0,1,0};

using namespace std;

map<pair<int, int>, int>  memo;
vector<vector<pair<int, int> > > futon;
vector<bool> decide;
vector<vector<int> > foot;

bool dfs(int i){
  REP(j,2){
    int x = futon[i][j].first;
    int y = futon[i][j].second;
    
    REP(k,4){
      int xx = x + _dx[k];
      int yy = y + _dy[k];
      pair<int, int> p = make_pair(xx, yy);
      
      if(memo.count(p) && memo[p] != i){
	int adj = memo[p];
	if(!decide[adj]){
	  decide[adj] = true;
	  if(xx == futon[adj][0].first && yy == futon[adj][0].second){
	    foot[adj][0] = foot[i][j];
	    foot[adj][1] = foot[i][j] ^ 1;
	  }else{
	    foot[adj][0] = foot[i][j] ^ 1;
	    foot[adj][1] = foot[i][j];
	  }
	  if(!dfs(adj)) return false;
	}else{
	  if(xx == futon[adj][0].first && yy == futon[adj][0].second){
	    if(foot[adj][0] != foot[i][j]) return false;
	  }else{
	    if(foot[adj][1] != foot[i][j]) return false;
	  }
	}
      }
    }
  }
  return true;
}

int main(){
  int n;
  while(scanf("%d", &n), n){
    memo.clear();
    futon  = vector<vector<pair<int, int> > >(n, vector<pair<int, int> >(2));
    decide = vector<bool>(n, false);
    foot   = vector<vector<int> >(n, vector<int>(2));

    REP(i,n){
      int x, y;
      char dir[2];

      scanf("%d%d%s", &x, &y, dir);

      futon[i][0] = make_pair(x, y);
      if(dir[0] == 'x'){
	futon[i][1] = make_pair(x + 1, y);
      }else{
	futon[i][1] = make_pair(x, y + 1);
      }
      memo[futon[i][1]] = memo[futon[i][0]] = i;
    }

    bool ok = true;

    REP(i,n) if(!decide[i]){
      decide[i] = true;
      foot[i][0] = 1; foot[i][1] = 0;
      if(!dfs(i)){
	ok = false;
	break;
      }
      // printf("%d: ok\n", i);
    }
    puts(ok ? "Yes" : "No");
  }
  return 0;
}

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int main()
{
    int n;
    cin >> n;

    vector<pii> v;

    rep(i, n)
    {
        int a;
        cin >> a;
        v.push_back(pii(a, i + 1));
    }

    sort(ALL(v));

    rep(i, n) i != n - 1 ? cout << v[i].second << " " : OP(v[i].second);

    return 0;
}

Measured memory_bytes: 1780
#include<iostream>
#include<vector>
#include<algorithm>
void print_vector(std::vector<int> v){
    for(int i=0;i<v.size();i++){
        std::cout<<v[i]<<" ";
    }
    std::cout<<"\n";
}
bool binary_search(std::vector<int> v,int num);
int main(){
    int a,b;
    std::vector<int> s;
    std::vector<int> t;
    std::cin>>a;
    for(int i=0;i<a;i++){
        int x;
        std::cin>>x;
        s.push_back(x);
    }
    // print_vector(s);
    std::cin>>b;
    for(int i=0;i<b;i++){
        int x;
        std::cin>>x;
        t.push_back(x);
    }
   int cnt=0;
    for(int i=0;i<b;i++){
        if(binary_search(s,t[i]))cnt++;
    }
    // print_vector(t);
    
   std::cout<<cnt<<"\n";

}

bool binary_search(std::vector<int> v,int num){
    int mid,left,right;
    mid=v.size()/2;
    left=0;
    right=v.size();
    int cnt=0;
    while(left<right){
        cnt++;
        if(v[mid]==num)return true;
        else if(num<v[mid]){
            right=mid;
            mid=(left+right)/2;
        }
        else{
            left=mid+1;
            mid=(left+right)/2;
        }
    }
    return false;
}


Measured memory_bytes: 4156
#!venv/bin/python
 
import math
import numpy as np
import random
import copy
import statistics 
import bisect
import heapq
from collections import defaultdict 
 
arg = [int(input()) for i in range(6)] 
if arg[4] - arg[0] > arg[5]:
    print (":(")
else:
    print ("Yay!")




Measured memory_bytes: 24696
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <numeric>
#include <iomanip>
#include <climits>
#include <cstring>
#include <cmath>

using namespace std;

#define int long long
#define rep(i, n) for (int i=0;i<(int)(n);++i)
#define rep1(i, n) for (int i=1;i<=(int)(n);++i)
#define rrep(i, n) for (int i=(int)(n)-1;i>=0;--i)
#define rrep1(i, n) for (int i=(int)(n);i>=1;--i)
#define range(i, l, r) for (int i=l;i<(int)(r);++i)
#define rrange(i, l, r) for (int i=(int)(r)-1;i>=l;--i)
#define unless(a) if(!(a))
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back
#define UNIQ(a) a.erase(unique(all(a)), end(a))

using vi=vector<int>;
using pii=pair<int, int>;
using vpii=vector<pii>;
using ll=long long;

constexpr int TEN(int n){return n==0?1:10*TEN(n-1);}
template<typename T>bool chmin(T&a,T b){return a>b?(a=b,1):0;}
template<typename T>bool chmax(T&a,T b){return a<b?(a=b,1):0;}
int read(){int a;scanf("%lld",&a);return a;}

const double pi = acos(-1);
constexpr int inf = 3*TEN(18) + 10;
constexpr int mod = TEN(9) + 7;

int N;
vpii x[100010]; // x[i] := y = i にあるx座標の列(sorted)
vpii y[100010]; // y[i] := x = i にあるy座標の列(sorted)
pii P[100010];
bool visited[100010];

int bfs(int idx)
{
	queue<pair<pii, int>> q;
	q.emplace(P[idx], idx);

	set<int> SX, SY;
	SX.insert(P[idx].first);
	SY.insert(P[idx].second);
	visited[idx] = true;

	int sz = 1;

	while (q.size()) {
		auto cur = q.front(); q.pop();

		int curx = cur.first.first, cury = cur.first.second;
		int id = cur.second;

		int xidx = lower_bound(all(x[cury]), pii(curx, id)) - begin(x[cury]);
		int yidx = lower_bound(all(y[curx]), pii(cury, id)) - begin(y[curx]);

		for (int i = -1; i <= 1; ++i) {
			if (0 <= xidx + i and xidx + i < x[cury].size()) {
				pii neix = x[cury][xidx + i];
				int nx = neix.first;
				int nid = neix.second;

				if (visited[nid]) continue;
				sz++;

				SX.insert(nx);
				q.emplace(pii(nx, cury), nid);
				visited[nid] = true;
			}
		}

		for (int i = -1; i <= 1; ++i) {
			if (0 <= yidx + i and yidx + i < y[curx].size()) {
				pii neiy = y[curx][yidx + i];
				int ny = neiy.first;
				int nid = neiy.second;

				if (visited[nid]) continue;
				sz++;
				SY.insert(ny);
				q.emplace(pii(curx, ny), nid);
				visited[nid] = true;
			}
		}
	}

	return SX.size() * SY.size() - sz;
}

signed main()
{
	cin >> N;

	rep(i, N) {
		int a, b; cin >> a >> b;
		P[i] = pii(a, b);
		x[b].PB(a, i);
		y[a].PB(b, i);
	}

	rep(i, 100010) {
		sort(all(x[i]));
		sort(all(y[i]));
	}

	int ans = 0;

	rep(i, N) {
		if (visited[i]) continue;
		int v = bfs(i);
		ans += v;
	}

	cout << ans << endl;
}



Measured memory_bytes: 19888
#include<stdio.h>
int main(void)
{
	int h[2],k[2],a,b,c,d,i,w,x,y,z;
	for(i=0;i<2;i++){
		scanf("%d",&h[i]);
	}
	for(i=0;i<2;i++){
		scanf("%d",&k[i]);
	}
	scanf("%d %d %d %d",&a,&b,&c,&d);
	x=h[0]*a+h[1]*b;
	w=h[0]/10;
	x=x+c*w;
	z=h[1]/20;
	x=x+d*z;
	y=k[0]*a+k[1]*b;
	w=k[0]/10;
	y=y+c*w;
	z=k[1]/20;
	y=y+d*z;
	if(x<y) printf("kenjiro\n");
	else if(x==y) printf("even\n");
	else printf("hiroshi\n");
	return 0;
}
	


Measured memory_bytes: 2132
def main():
  n = int(input())
  t = []
  for _ in range(n):
    t.append(int(input()))
  print(lcm_list(t))
  
def input_list():
  return map(int, input().split())

def input_list_str():
  return map(str, input().split())

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

# 2で割り切れる回数
def divide_two(arg):
  c = 0
  while True:
    if c >= 2:
      break
    if arg % 2 != 0:
      break
    arg //= 2
    c += 1
  return c 

import math
import fractions
from functools import reduce
main()

Measured memory_bytes: 5588
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;

int main()
{
  int n, m; cin >> n >> m;
  int yado[n];// ????????????
  yado[0] = 0;
  FOR(i,0,n-1) {
    int in; cin >> in;
    yado[i+1] = yado[i] + in;
  }
  int now = 0;
  ll ans = 0;
  FOR(i,0,m) {
    int d; cin >> d;
    ans += abs(yado[d+now] - yado[now]);
    now += d;
  }
  cout << ans % 100000 << endl;
  return 0;
}

Measured memory_bytes: 3484