akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <bits/stdc++.h>
#include <iomanip>
#include <numeric>
#include <map>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (ll i = a; i < (ll)b; ++i)

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

int main(void)
{
    int t, x;
    cin >> t >> x;
    double ans = (double)t / x;
    cout << fixed << setprecision(20);
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdlib>
#include <cmath>
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <map>
#include <list>
#define MOD 1000000007
#define INF 1000000000
typedef long long ll;
using namespace std;
typedef pair<int,int> P;

int main(void){
    int n,k;
    int x[101];
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>x[i];
    }
    int ans=0;
    for(int i=0;i<n;i++){
        ans+=2*min(abs(k-x[i]),abs(x[i]));
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 888
x,y = (int(i) for i in input().split())
res = abs(y-x)*2
res = y-x if y>=x else res
res = min(res,-y-x+1) if -y>=x else res
res = min(res,y+x+1) if y>=-x else res
res = min(res,x-y+2) if x>y else res
print(res)

Measured memory_bytes: 3064
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            int Z = in.nextInt();
            int W = in.nextInt();

            int[] a = new int[N + 1];
            a[0] = W;
            for (int i = 0; i < N; i++) {
                a[i + 1] = in.nextInt();
            }
            int score = -1;
            for (int i = N; i >= 1; i--) {
                int dfs = dfs(i, 0, a);
                if (dfs > score) {
                    score = dfs;
                } else {
                    break;
                }
            }
            System.out.println("" + score);
        }
    }

    private static int dfs(int i, int j, int[] a) {
        if (memo[i][0][j] != -1) {
            return memo[i][0][j];
        }

        if (i == a.length - 1 || j == a.length - 1) {
            int l = Math.abs(a[i] - a[j]);
            memo[i][0][j] = l;
            return l;
        }

        if (i < j) {
            int max = 0;
            for (int l = j + 1; l < a.length; l++) {
                max = Math.max(max, dfs(l, j, a));
            }
            memo[i][0][j] = max;
            return max;
        } else {
            int min = (int) 1e9;
            for (int l = i + 1; l < a.length; l++) {
                min = Math.min(min, dfs(i, l, a));
            }
            memo[i][0][j] = min;
            return min;
        }
    }

    private static int[][][] memo = new int[2002][2][2002];
    static {
        for (int i = 0; i < memo.length; i++) {
            for (int j = 0; j < memo[i].length; j++) {
                Arrays.fill(memo[i][j], -1);
            }
        }
    }

}

final class Utils {
    private Utils() {
    }

    public static final void debug(Object... o) {
        System.err.println(toString(o));
    }

    public static final String toString(Object... o) {
        return Arrays.deepToString(o);
    }

}


Measured memory_bytes: 82516
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <cstdio>
using namespace std;

template <typename F>
inline void update(map<char, int>& m, char key, int val, F f) {
  if (m.count(key)) {
    m[key] = f(m[key], val);
  } else {
    m[key] = val;
  }
}

bool solve() {
  typedef const int& (*F)(const int&, const int&);
  int H, W; scanf("%d%d", &H, &W);
  vector<string> field(H, string(W, '.'));
  for (int y = 0; y < H; ++y) {
    for (int x = 0; x < W; ++x) {
      scanf(" %c", &field[y][x]);
    }
  }
  for (;;) {
    map<char, int> left, right, top, bottom;
    bool end = true;
    for (int y = 0; y < H; ++y) {
      for (int x = 0; x < W; ++x) {
        const char ch = field[y][x];
        if (ch != '.' && ch != '*') {
          update(left, ch, x, (F)min);
          update(top, ch, y, (F)min);
          update(right, ch, x, (F)max);
          update(bottom, ch, y, (F)max);
          end = false;
        }
      }
    }
    if (end) { return true; }
    bool bad = true;
    for (auto p : left) {
      const char ch = p.first;
      const int l = p.second, r = right[ch], t = top[ch], b = bottom[ch];
      bool ok = true;
      for (int y = t; y <= b; ++y) {
        for (int x = l; x <= r; ++x) {
          if (field[y][x] != ch && field[y][x] != '*') {
            ok = false;
            break;
          }
        }
      }
      if (ok) {
        for (int y = t; y <= b; ++y) {
          for (int x = l; x <= r; ++x) {
            field[y][x] = '*';
          }
        }
        bad = false;
        break;
      }
    }
    if (bad) { return false; }
  }
}

int main() {
  int T; scanf("%d", &T);
  while (T--) {
    puts(solve() ? "SAFE" : "SUSPICIOUS");
  }
}

Measured memory_bytes: 1068
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define m 1000000007

int main()
{
 ll n;
 cin>>n;
 ll ans =1;
 for(int i=1;i<=n;i++)
 {
     ans = (ans*i)%m;
 }
 cout<<ans;
}

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

signed main() {
    cout << setprecision(15) << fixed;
    const double PI = acos(-1);

    double W, H, w, h, x, y;
    cin >> W >> H >> w >> h >> x >> y;

    double left = max(-W / 2, x - w / 2);
    double right = min(W / 2, x + w / 2);
    double top = min(H / 2, y + h / 2);
    double bottom = max(-H / 2, y - h / 2);

    double center_x = (left + right) / 2;
    double center_y = (top + bottom) / 2;
    cout << center_y / center_x << endl;
    return 0;
}


Measured memory_bytes: 3284
#include <iostream>
#include <deque>

using namespace std;

int main() {
    int N;
    cin >> N;
    
    deque<long long int> dq;
    for(int n=0; n<N; n++) {
        long long int a;
        cin >> a;
        if(n%2) {
            dq.push_back(a);
        } else {
            dq.push_front(a);
        }
    }
    
    if(N%2) {
        while(!dq.empty()) {
            cout << dq.front() << " ";
            dq.pop_front();
        }
    } else {
        while(!dq.empty()) {
            cout << dq.back() << " ";
            dq.pop_back();
        }
    }
    cout << endl;


    return 0;
    
}

Measured memory_bytes: 3840
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=100050;
//ここまでテンプレ
int main(){
	int N,K;
	cin>>N>>K;
	cout<<(N+K-3)/(K-1)<<endl;
	/*
	vint A;
	for(int i=0;i<N;i++){
		int a;
		cin>>a;
		A.pb(a);
	}
	int ans=0;
	for(int i=0;i<N;i++){
		if(A[i]==1)
	}*/
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    int n,k,s=0;
	cin>>n>>k;
	int a[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[n];
		if(a[n]>=k) s++;
	} 	
	cout<<s;
	return 0;
}

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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
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;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

// a^b mod M
long myPow(long a,long b,int M) {
    long ret = 1;
    long tmp = a;
    while(b>0) {
        if((b&1)==1) ret = (ret * tmp) % M;
        tmp = (tmp * tmp) % M;
        b = b>>1;
    }
    return ret;
}

 // nCk mod M
int nCk(int n,int k,int M) {
    long ret = 1;
    int mi = min(k, n-k);
    for(int i=1;i<=mi;i++) {
        ret = (ret * myPow(i,M-2,M)) % M;
    }
    for(int i=n-mi+1;i<=n;i++) {
        ret = (ret * i) % M;
    }
    return (int)ret;
};

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}


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

    vector<ll> a(N);
    ll sum = 0;
    REP(i,N){
        cin >> a[i];
        sum += a[i];
    }

    REP(i,N) a[i] = abs(a[i]*N-sum);

    int ans = 0;
    ll mi = a[0];
    REP(i,N) if(mi > a[i]) {
        ans = i;
        mi = a[i];
    }

    pl(ans)

    return 0;
}


Measured memory_bytes: 256
# ABC122B - ATCoder
s = input()
n = len(s)
count = 0

for i in range(n):
    for j in range(i, n):
        if all("ACGT".count(c) == 1 for c in s[i : j + 1]):
            count = max(count, j - i + 1)

print(count)

Measured memory_bytes: 2940
import java.util.ArrayList;
import java.util.Scanner;

public class Main { // https://atcoder.jp/contests/abc096/tasks/abc096_d
	static ArrayList<Integer> primes = new ArrayList<Integer>();
	
	static boolean isPrime(int x) {
		if (x == 2 || x == 3) return true;
		if (x < 2) return false;
		
		for (int i = 2; i * i <= 2 * x; i++) {
			if (x % i == 0) return false;
		}
		return true;
	}
	
	static void init(int psize, int modd) {
		int cur = modd;
		while (primes.size() < psize) {
			if (isPrime(cur)) primes.add(cur);
			
			cur += 5;
		}
	}
	
	public static void main(String[] args) { 
		Scanner x = new Scanner(System.in);
		int n = x.nextInt();
		long start = System.nanoTime();
		init(n, 2); // SIKE its actually 2 mod 5 you just got trolled
	//	System.out.println((System.nanoTime() - start) / 1000000);
		
		for (int i : primes) System.out.print(i + " ");
	}
}


Measured memory_bytes: 38440
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second


void solve()
{
    ll n,i,j,k,x,y,z;
    cin >> n;
    ll a[n];
    ll b[n];
    ll c[n];
    ll dp[3][n];
    for(i=0;i<n;i++)
        cin >> a[i] >> b[i] >> c[i];

    dp[0][0] = a[0];
    dp[1][0] = b[0];
    dp[2][0] = c[0];

    for(i=1;i<n;i++)
    {
        dp[0][i] = a[i] + max(dp[1][i-1],dp[2][i-1]);
        dp[1][i] = b[i] + max(dp[0][i-1],dp[2][i-1]);
        dp[2][i] = c[i] + max(dp[0][i-1],dp[1][i-1]);
    }
    ll ma = 0;
    ma = max(dp[0][n-1],max(dp[1][n-1],dp[2][n-1]));
    cout << ma;




}
int main()
{

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll t=1;
	//cin >> t;
	while(t-- > 0)
	{
		solve();
	}

}


Measured memory_bytes: 8292
#include<bits/stdc++.h>
using namespace std;
namespace io{
    const int l=1<<20;
    char buf[l],*s,*t,c;
    inline void gc(){
        if(s==t){
            t=(s=buf)+fread(buf,1,l,stdin);
            c=s==t?EOF:*s++;
        }else c=*s++;
    }
    template<class IT>inline void gi(IT &x){
        x=0;gc();while(c<'0'||c>'9')gc();
        while('0'<=c&&c<='9'){x=(x<<1)+(x<<3)+(c^48);gc();}
    }
    char buf0[20];int a;
    template<class IT>inline void pi(IT x){
        if(x<0){putchar('-');x=-x;}
        do buf0[++a]=x%10+48;while(x/=10);
        while(a)putchar(buf0[a--]);
        putchar('\n');
    }
};
using io::gi;
using io::pi;
typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<int,ll > pil;
typedef pair<ll ,int> pli;
typedef pair<ll ,ll > pll;
typedef vector<int> vi;
typedef vector<ll > vl;
#define pque priority_queue
#define rep(i,l,r) for(i=(l);i<=(r);++i)
#define per(i,l,r) for(i=(l);i>=(r);--i)
#define REP(i,l,r) for(i=(l);i< (r);++i)
#define PER(i,l,r) for(i=(l);i> (r);--i)
#define mp make_pair
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define fi first
#define se second
template<class IT>inline void cmax(IT &a,IT b){if(a<b)a=b;}
template<class IT>inline void cmin(IT &a,IT b){if(b<a)a=b;}
const int N=1505;
int a[N][N],f[N][N];
short l[N][N],r[N][N];
char c[N];
int main(){
    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
    int n,i,j,k,t;short m;ll ans=0ll;
    scanf("%d",&n);
    rep(i,1,n){
		scanf("%s",c+1);
		rep(j,1,n)a[i][j]=((c[j]=='#')?0:(c[j]^48));
	}
	per(i,n,1)per(j,n,1){
		if(a[i][j]){
			if(a[i+1][j]){
				if(a[i][j+1]){
					l[j][i]=j;r[j][i]=r[j+1][i];
					t=f[i][j+1]+f[i+1][j];m=0;
					rep(k,i+1,n){
						if(r[j][k]>=l[j+1][k]&&l[j+1][k]>m)t-=f[k][l[j+1][k]];
						cmax(m,r[j][k]);
						cmin(l[j][k],l[j+1][k]);
						cmax(r[j][k],r[j+1][k]);
					}
					f[i][j]=t;
				}else{
					l[j][i]=r[j][i]=j;
					f[i][j]=f[i+1][j];
				}
			}else{
				if(a[i][j+1]){
					memcpy(l[j]+i,l[j+1]+i,(n-i+1)<<1);
					memcpy(r[j]+i,r[j+1]+i,(n-i+1)<<1);
					l[j][i]=j;
					f[i][j]=f[i][j+1];
				}else l[j][i]=r[j][i]=j;
			}
			ans+=a[i][j]*f[i][j];
			f[i][j]+=a[i][j];
		}else{
			memset(l[j]+i,0x3f,(n-i+1)<<1);
			memset(r[j]+i,0   ,(n-i+1)<<1);
		}
		//printf("(%d,%d) f=%d\n",i,j,f[i][j]);
		//rep(k,i,n)printf("(%d,[%d,%d])\n",k,l[j][k],r[j][k]);
	}
	printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 26880
#include<iostream>
using namespace std;
void PrintArray(int* a,int n)
{
	for(int i=1;i<n;i++)
	{
		cout<<a[i]<<" ";
	}
	cout<<a[n]<<endl;
}
int BullleSort(int* a,int n)
{
	int flag=1;
	int num=0;
	for(int i=1;flag;i++) 
	{
		flag=0;		//若下列循环不发生交换则已经有序，交换过则令flag=1 
		for(int j=n;j>i;j--)
		{
			if(a[j]<a[j-1])
			{
				int temp=a[j];
				a[j]=a[j-1];
				a[j-1]=temp;
				flag=1;
				num++; 
			}
		 } 
	}
	return num;
}
int main()
{
	int a[101];
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i]; 
	}
	int num=BullleSort(a,n);
	PrintArray(a,n);
	cout<<num<<endl;
	return 0;
}


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

int main() {
  int N, K;
  cin >> N >> K;
  
  int ans = 1;

  for ( int i = 0; i < N; i++){
    if (ans * 2 >= ans + K){
      ans += K;
    }
    else {
      ans *= 2;
    }
  }
    cout << ans << endl;
  }

Measured memory_bytes: 3612
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>

typedef long long ll;
using namespace std;

int main() {
  int index = 0;
  int as[5] = {};
  for (int i = 0; i < 5; i++) {
    cin >> as[i];
    if (as[i] == 0) {
      index = i;
    }
  }
  cout << index + 1 << endl;
  return 0;
}

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

int main(){
  int d, n, ans;
  cin >> d >> n;

  if(d==0){
    if(n==100){
      cout << 101 << endl;
    }else{
      cout << n << endl;
    }
  }else if(d==1){
    ans = 100 * n;
    if(n==100){
      ans = 10100;
    }
    cout << ans << endl;
  }else{
    ans = 10000 * n;
    if(n==100){
      ans = 1010000;
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 256
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()))
## dp ##
def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]
## math ##
def to_bin(x: int) -> str: return format(x, 'b') # rev => int(res, 2)
def to_oct(x: int) -> str: return format(x, 'o') # rev => int(res, 8)
def to_hex(x: int) -> str: return format(x, 'x') # rev => int(res, 16)
MOD=10**9+7
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(MAX_NUM=10**3):
    """Return a list of prime numbers n or less"""
    is_prime = [True]*(MAX_NUM+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(MAX_NUM**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, MAX_NUM+1, i):
            is_prime[j] = False
    return [i for i in range(MAX_NUM+1) if is_prime[i]]
## libs ##
from itertools import accumulate as acc, combinations as combi, product, combinations_with_replacement as combi_dup
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left
#======================================================#

def main():
    n = II()
    s = IS()
    dq = deque()
    l_cnt = r_cnt = 0
    for si in s:
        # print(''.join(dq))
        if si == '(':
            l_cnt += 1
            dq.append(si)
        elif si == ')':
            if l_cnt == 0:
                dq.appendleft('(')
                dq.append(si)
            elif l_cnt > 0:
                dq.append(si)
                l_cnt -= 1
    for _ in range(l_cnt):
        dq.append(')')

    print(''.join(dq))



if __name__ == '__main__':
    main()

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

int main(){
  int N;
  cin >> N;
  vector<char> S(N);
  for(int i=0; i<N; i++) {
    cin >> S.at(i);
  }

  int ans = 1;
  for(int i=0; i<N-1; i++) {
    if(S.at(i) != S.at(i+1)){
      ans++;
    } 
  }
  cout << ans << endl;
}



Measured memory_bytes: 384
#include <stdio.h>
#include <math.h>

struct Point { double x, y; };

typedef struct Point Point;

void print(Point a){

  printf("%.8f %8f\n",a.x,a.y);

}

double koch1(Point a,Point b){

  return (2.0 * a.x + 1.0 * b.x) / 3.0;
}

void koch(int n, Point a, Point b) {
  if (n == 0) return;

  Point s, t, u;
  double th = M_PI * 60.0 / 180.0;

  s.x = koch1(a,b);
  s.y = (2.0 * a.y + 1.0 * b.y) / 3.0;
  t.x = (1.0 * a.x + 2.0 * b.x) / 3.0;
  t.y = (1.0 * a.y + 2.0 * b.y) / 3.0;
  u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
  u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;

  koch(n - 1, a, s);
  print(s);
  koch(n - 1, s, u);
  print(u);
  koch(n - 1, u, t);
  print(t);
  koch(n - 1, t, b);
}

int main() {
  
  Point a, b;
  int n;
  scanf("%d", &n);
  a.x = 0;
  a.y = 0;
  b.x = 100;
  b.y = 0;
  printf("%.8f %.8f\n", a.x, a.y);
  koch(n, a, b);
  printf("%.8f %.8f\n", b.x, b.y);
  return 0;
}



Measured memory_bytes: 2032
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=0;(i)<(n);i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define MOD 1000000007
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; }
#define ALL(v) v.begin(), v.end()
typedef long long ll;


int main(){

string s;
cin >> s;


if(s=="SUN")cout << 7 << endl;
else if(s=="SAT")cout << 1 << endl;
else if(s=="FRI")cout << 2 << endl;
else if(s=="THU")cout << 3 << endl;
else if(s=="WED")cout << 4 << endl;
else if(s=="TUE")cout << 5 << endl;
else if(s=="MON")cout << 6 << endl;


return 0;
}


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

#define p pair<int,int>
#define mp(a,b) make_pair(a,b)
#define ll long long
using namespace std;

int main() {
	int n,want; cin>>n>>want;
	vector<p> point(n);
	set<int>a; set<int>b;
	for(int i=0;i<n;i++){
		int c,d; cin>>c>>d;
		a.insert(c); b.insert(d);
		point[i]=mp(c,d);
	}
	vector<ll>x(a.begin(),a.end()); vector<ll>y(b.begin(),b.end());
	ll ret=8101145141919364364;
	for(int i=0;i<x.size();i++){
		for(int j=i+1;j<x.size();j++){
			for(int k=0;k<y.size();k++){
				for(int l=k+1;l<y.size();l++){
					int count=0;
					for(int z=0;z<n;z++){
						p now=point[z];
						if(x[i]<=now.first&&now.first<=x[j]&&
						   y[k]<=now.second&&now.second<=y[l]) count++;
					}
					if(count>=want)	ret=min(ret,(x[j]-x[i])*(y[l]-y[k]));
				}
			}
		}
	}
	cout<<ret<<endl;
	return 0;
}

Measured memory_bytes: 256
// B

#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll mod=1e9+7;
#define pa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};

int main(){
  int N,M;
  cin>>N>>M;
  long double ans(0);
  int T = 1900*M + 100*(N-M);
  for (int i(1);i<=10000;i++){
    long double a = 1 / (long double)pow(2,M);
    long double b = 1 - a;
    long double tmp = T*i*(long double)pow(b,i-1)/(long double)pow(2,M);
    ans += tmp;
  }
  cout << ans << endl;
}




Measured memory_bytes: 384
n, q = map(int, input().split())
s = input()
a = [list(map(int, input().split())) for i in range(q)]
cum=[0]*n
for i in range(1, n):
    cum[i] = cum[i - 1]
    if s[i-1:i+1]=='AC':
        cum[i]+=1
for i in range(q):
    print(cum[a[i][1]-1]-cum[a[i][0]-1])

Measured memory_bytes: 30704
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
const ll mod=1000000007;
const ll INF=1e15;
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end())
#define pb push_back
#define mp make_pair
#define MODP(A,B) A=(A+B)%mod
typedef pair<ll,ll> P;
typedef pair<double,double> Pd;
vec dx={1,0,-1,0};
vec dy={0,1,0,-1};

int main(){
    double L; cin>>L;
    L/=3;
    cout<<setprecision(9)<<L*L*L<<endl;
}

Measured memory_bytes: 256
import numpy as np
import sys
buf = sys.stdin.buffer

N = int(buf.readline())
M = N // 2 + 1
P = np.array(buf.readline().split(),dtype = float)

dp = np.zeros([(N + 1),(N + 1)])
dp[0][0] = 1.0

for i in range(N):
  tmp = dp[i].copy()
  dp[i + 1] = tmp * (1 - P[i])
  tmp = np.roll(tmp,1)
  dp[i + 1] += tmp * P[i] 
  
print(sum(dp[-1][M:]))


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


int main(void){
	int N;
	cin >> N;
	vector<int> X(N),L(N);
	for(int i=0;i<N;i++)	cin >> X.at(i) >> L.at(i);
	
	vector<pair<int,int>> lr(N);
	for(int i=0;i<N;i++){
		lr.at(i).first=X.at(i)-L.at(i);
		lr.at(i).second=X.at(i)+L.at(i);
	}
	sort(lr.begin(),lr.end());
	
	int ans=N,sub=0;
	int key_l=lr.at(0).first;
	int key_r=lr.at(0).second;
	for(int i=1; i<N ; i++){
		while(i<N){
			int key_l2=lr.at(i).first;
			int key_r2=lr.at(i).second;
			if(key_r<=key_l2){
				key_l=key_l2;
				key_r=key_r2;
				break;
			}
			if(key_r<=key_r2){
				sub++;
				break;
			}
			if(key_r2<=key_r){
				sub++;
				key_l=key_l2;
				key_r=key_r2;
				break;
			}
			sub++;
			i++;
		}
	}
	ans=ans-sub;
	cout << ans << endl;
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long int

signed main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int A, B, C, X, Y;
	cin >> A >> B >> C >> X >> Y;
	int ans = INF2;
	ans = A * X + B * Y;
	ans = min(ans, C * 2 * max(X, Y));
	int tmp = 0;
	if (X < Y) {
		tmp += C * X * 2;
		Y -= X;
		X = 0;
	}
	else {
		tmp += C * Y * 2;
		X -= Y;
		Y = 0;
	}
	ans = min(ans, tmp + A * X + B * Y);
	cout << ans << endl;


    return 0;
}


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

//#define int long long

using namespace std;

int dp[1001][1<<13];
int cost[1001];
int boxes[1001];

int n, m;

int recur(int pos, int mask) {
    if (mask == (1<<n)-1) return 0;
    if (pos == m) return 1e9;
    if (dp[pos][mask] != -1) return dp[pos][mask];
    int res = min(recur(pos+1, mask), recur(pos+1, mask|boxes[pos]) + cost[pos]);
    dp[pos][mask] = res;
    return res;
}

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

    for (int i = 0; i < 1001; i++) {
        cost[i] = 0;
        boxes[i] = 0;
        for (int j = 0; j < (1<<13); j++) dp[i][j] = -1;
    }

    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        cin >> cost[i];
        int q;
        cin >> q;
        int mask = 0;
        for (int j = 0; j < q; j++) {
            int x;
            cin >> x;
            x--;
            mask |= (1<<x);
        }
        boxes[i] = mask;
    }

    int res = recur(0, 0);
    if (res == 1e9) cout << "-1\n";
    else cout << res << '\n';
}
/*

 */

Measured memory_bytes: 35700
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

int main()
{
//	cut here before submit 
//	freopen ("testcase.Palindrome", "r", stdin );
	string str = "";
	int res = 0;
	while (cin >> str ){
		int n = str.length();
		bool ok = true;
		for (int i = 0; i <= n/2; i++ ){
			if (str[i] == str[n-i-1] ) continue;
			ok = false; break;
		} // end for
		if (ok ) res++;
	} // end while
	printf ("%d\n", res );
		
	return 0;
}

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

int main(void){
    long long k;
    int r=7;
    cin >> k;
    if(k%2==0 || k%5==0){
        cout << -1 << endl;
        return 0;
    }
    for(long long i=1;;i++){
        r %= k;
        if(r==0){
            cout << i << endl;
            return 0;
        }
        r*=10;
        r+=7;
    }
}

Measured memory_bytes: 3600
N = int(input())
points = [tuple(map(int, input().split())) for _ in range(N)]
current_time = 0
current_x = 0
current_y = 0
for point in points:
    t, x, y = point
    diff_time = t - current_time
    diff_x = abs(x - current_x)
    diff_y = abs(y - current_y)
    if diff_x + diff_y > diff_time:
        print("No")
        break
    elif diff_x + diff_y < diff_time:
        remainder = diff_time - (diff_x + diff_y)
        if remainder % 2 == 1:
            print("No")
            break
    current_x = x
    current_y = y
    current_time = t
else:
    print("Yes")


Measured memory_bytes: 17312
#include<iostream>

using namespace std;

int main( )
{	
    int n;
    int maxProfit = 1-1000000000;
    int Rj, Ri, t;
   
    cin>>n;
    cin>>Ri;
    for( int i=1; i<n; i++ ) {
    	cin>>Rj;
    	t = Rj - Ri;
    	if( maxProfit < t ) {
       		maxProfit = t;
       	}
       	if( Rj < Ri ) {
    		Ri = Rj;
    	}
    }
    cout<<maxProfit<<endl;
	
	return 0;
}

Measured memory_bytes: 1164
N = int(input())
L = [int(input()) for i in range(N)]

flag = 0
now = 0
ans = 0
for i in range(N+1) :
    if now == 1 :
        flag = 1
        break
    else :
        now = L[now]-1
        ans += 1
if flag == 1 :
    print(ans)
else :
    print(-1)
    

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

int main(){
  int N, Nc, f=0;
  
  cin >> N;
  Nc=N;
    
  while(N!=0){
    f += N % 10;
    N /= 10;
  }
  
  if(Nc % f == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

     
    

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
k=int(input())
if k%2==0 or k%5==0:
  print(-1)
  sys.exit()
s=7
for i in range(k):
  m=s%k
  if m==0:
    print(i+1)
    break
  s=m*10+7

Measured memory_bytes: 9176
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <list>
#include <queue>

using namespace std;
using llint = long long int;
#define int long long int

vector<int> vadd, vxor;

signed main()
{
  int h, w;
  cin >> h >> w;
  int n;
  cin >> n;

  int c[100][100];
  int index = 0;
  for (int i = 1; i <= n; i++)
  {
    int a;
    cin >> a;
    for (int count = 0; count < a; count++)
    {
      c[index / w][index % w] = i;
      index++;
    }
  }

  for (int x = 0; x < h; x++)
  {
    if (x % 2 == 0)
    {
      for (int y = 0; y < w; y++)
      {
        cout << c[x][y] << (y == w - 1 ? "\n" : " ");
      }
    }
    else
    {
      for (int y = w - 1; y >= 0; y--)
      {
        cout << c[x][y] << (y == 0 ? "\n" : " ");
      }
    }
  }

  return 0;
}


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

int main() {
  int X, N, ans;
  cin >> X >> N;
  vector<bool> all(100,false);
  vector<int> p(N);
  
  for(int i=0;i<N;i++){
   cin >> p.at(i);
   all.at(p.at(i)-1)=true;
  }
  //sort(p.begin(),p.end(),greater<int>());
  for(int i=0;i<101;i++){
    if((X-i-1>=0) && (all.at(X-i-1)==false)){
      ans = X-i;
      break;
    } else if(X-i-1<0){
      ans = X-i;
      break;
    } else if((X+i-1<100) && (all.at(X+i-1)==false)){
      ans = X+i;
      break;
    } else if(X+i-1>=100){
      ans = X+i;
      break;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, s, n) for (ll i = s; i < (n); i++)
using namespace std;

int main(){
  ll n;
  cin >> n;
  ll ans = 0;
  rep2(i, 1, n){
    ans += (n-1) / i;
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1000000000
#define LINF 1000000000000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

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

int main() {
    
    int N, D, A;
    cin >> N >> D >> A;
    vector<P> M(N, make_pair(0, 0));
    rep(i,N) cin >> M[i].first >> M[i].second;
    sort(M.begin(), M.end());

    int now_minN = 0;
    int now_maxN = 0;
    long long ans = 0;
    while (now_minN < N) {
        int maxX = M[now_minN].first + 2 * D;
        while (now_maxN < N - 1 && M[now_maxN + 1].first <= maxX) {
            M[now_maxN + 1].second += ans * A;
            now_maxN++;
        }
        M[now_minN].second -= ans * A;
        long long damage_count = M[now_minN].second / A + (M[now_minN].second % A == 0 ? 0 : 1);
        if (M[now_minN].second > 0) {
            ans += damage_count;
        }

        now_minN++;
    }

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

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

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

int main(void)
{
    //エラトステネスのふるい
    int max=1e5+1;
    vector<ll> isprime(max,1);
    isprime[0]=isprime[1]=0;
    for(int i=2;i<max;i++){
        if(!isprime[i]) continue;
        //素数じゃないやつに0入れる
        for(int j=i*2;j<max;j+=i) isprime[j]=0;
    }

    //like2017
    vector<ll> a(max,0);
    rep(i,max){
        if(isprime[i]&&isprime[(i+1)/2]) a[i]=1;
    }

    //累積和
    vector<ll> s(max+1,0);
    rep(i,max) s[i+1]=s[i]+a[i];

    //クエリ処理
    ll q; cin>>q;
    rep(i,q){
        ll l,r; cin>>l>>r;
        cout<<s[r+1]-s[l]<<endl;
    }

    return 0;
}

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

int main()
{
	ll N, D;
	cin >> N >> D;
	D *= D;
	int ans = 0;
	fz(N) {
		ll x, y;
		cin >> x >> y;
		if (D>=x*x+y*y) {
			ans++;
		}
	}
	ce(ans)
    return 0;
}



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

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    string s;
    cin >> n >> s;

    int R = 0, ans = 0;
    for(int i = 0; i < n; i++)
        if(s[i] == 'R') R++;
    
    for(int i = 0; i < R; i++)
        if(s[i] != 'R') ans++;
    
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3764
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>

#define ll long long int
#define ull unsigned long long int

#define INF 100000000000L

using namespace std;

int A,B,C;

int main(){
    cin >> A >> B >> C;
    if(B >= A*C){
        cout << C << endl;
    }
    else{
        cout << B/A << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
input = sys.stdin.readline

n = int(input())
a = [int(item) for item in input().split()]
if 0 in a:
    print(0)
    exit()
ans = 1
for item in a:
    ans *= item
    if ans > 10**18:
        print(-1)
        exit()

print(ans)

Measured memory_bytes: 21772
fun main(args:Array<String>) {
	val ns = readLine()!!
	val len = ns.length
	val n = ns.toInt()
	println((1..9).sumBy {enum753(it,IntArray(it),0,n)})
	
}


fun enum753(len: Int ,x:IntArray, count:Int,n:Int): Int{
	if(len==0) {return if(3 in x && 5 in x && 7 in x &&
			x.joinToString("").toInt()<=n) count+1 else count}
	x[len-1]=3
	val c3 = enum753(len-1,x,count,n)
	x[len-1]=5
	val c5 = enum753(len-1,x,count,n)
	x[len-1]=7
	val c7 = enum753(len-1,x,count,n)
	return c3+c5+c7
}

Measured memory_bytes: 45868
from collections import defaultdict as dd
N, M = map(int, input().split())
c = list(map(int, input().split()))
c.sort()
m = dd(int)
d = dd(int)
for n in c:
  d[n] += 1
  m[n % M] += 1
res = 0
for i in range(M):
  temp = min(m[i], m[(M - i) % M])
  if i == (M - i) % M:
    temp = m[i] // 2
  m[i] -= temp
  m[(M - i) % M] -= temp
  res += temp
for i in range(N):
  n = c[i]
  if m[n % M] > 1:
    k = m[n % M] // 2
    if d[n] > 1:
      temp = min(d[n] // 2, k)
      res += temp
      d[n] -= temp * 2
      m[n % M] -= temp * 2
print(res)

Measured memory_bytes: 73964
#include <iostream>

using namespace std;

int main(void){
  int N;
  cin >> N;

  //N人から3人ずつ抜いてグループを作っていく
  //3人を抜いたとき，残りの人数がi人(i=1,2)の場合はそのグループだけi+3人となる
  //Nから3を何回引けるかがポイントなので，商を考えればよい

  cout << N/3 << endl;
  

  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(N: int):
    ret = N
    if N % 2 == 1:
        ret = N * 2
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define lli long long int
#define llu long long unsigned int
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define FOR(i,s,e) for(i=s; i<e; i++)
#define mod 998244353
#define F first
#define S second
#define plli pair<lli,lli>
#define pqlli priority_queue<lli>
#define test(t) cin>>t; while(t--)
using namespace std;
 
lli power(lli a, lli b, lli M = mod)
{
	lli result = 1;
    for (;;)
    {
        if (b & 1)
            result = (result*a)%M;
        b >>= 1;
        if (!b)
            break;
        a = (a*a)%M;
    }
    return result;
}
 
int main()
{
    IOS;
    lli n;
    cin>>n;
    lli ans = 0;
    for(lli i = 1; i<n+1; i++)
    {
		if((i%3 != 0) and (i%5 != 0))
		ans += i;
	}
	cout<<ans<<endl;
 /*   string s;
    cin>>s;
    lli dp[3][n+1];
    memset(dp, 0, sizeof(dp));
    for(lli i = 1; i<n+1; i++)
    dp[0][i] = dp[0][i-1] + (s[i-1] == 'R'), dp[1][i] = dp[1][i-1] + (s[i-1] == 'G'), dp[2][i] = dp[2][i-1] + (s[i-1] == 'B');
	lli ans = 0;
    for(lli i = 0; i<n; i++)
    {
		for(lli k = i+3; k<n; k++)
		{
			if(s[i] != s[k])
			{
				if(s[i]!='R' and s[k]!='R')
				{
					ans += dp[0][k] - dp[0][i+1];
					if((k-i-1)%2 and (s[(k+i)/2] == 'R'))
					ans--;
				}
				else if(s[i]!='G' and s[k]!='G')
				{
					ans += dp[1][k] - dp[1][i+1];
					if((k-i-1)%2 and (s[(k+i)/2] == 'G'))
					ans--;
				}
				else
				{
					ans += dp[2][k] - dp[2][i+1];
					if((k-i-1)%2 and (s[(k+i)/2] == 'B'))
					ans--;
				}
			}
		}
	}
	cout<<ans<<endl;*/
}

Measured memory_bytes: 3636
#include <iostream>
using namespace std;
int main()
{
	int A,B,C,K;
	cin>>A>>B>>C>>K;
	if(A>=K)
	cout<<K;
	else
	{
		if((A+B)>=K)
		cout<<A;
		else
		cout<<(A-(K-(A+B)));
	}
	return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <list>
#include <deque>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
#define dump(a) cout << (a) << endl;
typedef long long ll;
ll mod = 1e9+7;

int main() {
    int x, y;
    cin >> x >> y;
    dump( x + y/2 );
    return 0;  
}

Measured memory_bytes: 256
#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>
#include <tuple>

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 = 1e12;
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

ll n;

int main() {
	cin >> n;
	if (n == 1) {
		cout << 1 << endl;
		return 0;
	}
	ll l0 = 2, l1 = 1;
	rep(i, n - 1) {
		ll buf = l1;
		l1 = l1 + l0;
		l0 = buf;
	}
	cout << l1 << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <sstream> //string stream its useful!
#include<string>
#include<iostream>
#include<utility> //pair
#include <vector> // vector
#include <algorithm>    // swap,sort,binary_search
#include <functional>   // std::greater
#include <map> //map
#include<set> //set
#include<queue> //queue
#include<list> //list
#include<cmath>
#include<numeric>
#include<cassert>
#include <iomanip> //cout<<setprecision
#include <regex>



typedef long long ll;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
ll W = 1000000007;


using namespace std;
void omajinai() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<setprecision(15);
    //freopen("txt.csv","r",stdin);
}


class Main{
public:
    Main(){
        
    }
    
    
    void run(){
        int N,M;
        cin>>N>>M;
        vector<ll> a(M),b(M),c(M);
        REP(i,M) cin>>a[i]>>b[i]>>c[i];
        
        const ll MYMAX = -1e16;
        vector<ll> dist(N+1,MYMAX);
        dist[1]=0;
        REP(i,N-1){
            REP(j,M){
                dist[b[j]] = max(dist[b[j]],dist[a[j]] + c[j]);
            }
        }
        ll ans = dist[N];
        
        //もう一度更新して、ansが変われば閉路あり
        REP(i,N-1){
            REP(j,M){
                dist[b[j]] = max(dist[b[j]],dist[a[j]] + c[j]);
            }
        }
        if(ans!=dist[N]){
            cout<<"inf"<<endl; return;
        }
        cout<<dist[N]<<endl;
        
    }
};

int main(){
    omajinai();
    Main().run();
}

Measured memory_bytes: 256
N = int(input())
D, X = map(int, input().split())
A = [int(input()) for _ in range(N)]
ans = X
for i in range(N):
    k = 0
    d = 1
    while d <= D:
        ans += 1
        k += 1
        d = 1 + k * A[i]
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
#include <cctype>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <utility>
#include <fstream>

using namespace std;
typedef long long ll;

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; }
template<typename T> T gcd(T a, T b) { a = abs(a), b = abs(b); while (b > 0) { tie(a, b) = make_pair(b, a % b); } return a; }
//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

constexpr long long INF = 1LL << 60;
constexpr int inf = 1000000007;
//constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353;
constexpr int MAX = 5000000;

vector<pair<ll, int>> prime_factor(ll a) {
	vector<pair<ll, int>> ret;
	for (ll i = 2; i * i <= a; i++) {
		int cnt = 0;
		while (a % i == 0 && a != 0) {
			cnt++;
			a /= i;
		}
		if (cnt > 0) ret.emplace_back(i, cnt);
	}
	if (a != 1) {
		ret.emplace_back(a, 1);
	}
	return ret;
}

long long extGCD(long long a, long long b, long long& x, long long& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

int main()
{

	cin.tie(nullptr);
	ios::sync_with_stdio(false);


	ll n; cin >> n;
	n *= 2;
	ll res = INF;
	auto vp = prime_factor(n);
	vector<ll> v; v.reserve(vp.size());
	for (auto p : vp) {
		ll t = 1;
		for (int i = 0; i < p.second; i++) t *= p.first;
		v.emplace_back(t);
	}

	
	int sz = vp.size();
	for (int S = 0; S < (1 << sz); S++) {
		ll a = 1;
		ll b = 1;
		for (int i = 0; i < sz; i++) {
			if (S >> i & 1) {
				a *= v[i];
			}
			else {
				b *= v[i];
			}
		}
		ll x = 1, y = 1;
		ll g = extGCD(a, b, x, y);
		if (x > 0) {
			ll tmp = x / b + 1;
			x -= b * tmp;
			y += a * tmp;
		}
		else {
			ll tmp = (llabs(x) - 1) / b;
			x += b * tmp;
			y -= a * tmp;
		}
		chmin(res, llabs(x * a));
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K;
  cin >> N >> K;
  int x = 1;
  for (int i = 0; i < N; i++) {
    if (x * 2 < x + K) x *= 2;
    else x += K;
  }
  cout << x << endl;
}

Measured memory_bytes: 3584
#include <stdio.h>

int main(void) {
	int n, m;
	int a[100][100];
	int b[100];
	int c = 0;
	int i, j;
	
	scanf("%d %d", &n, &m);
	
	for (i = 0; i < n+1; i++){
		for (j = 0; j < m; j++){
			if (i == n) scanf("%d", &b[j]);
			else scanf("%d", &a[i][j]);
		}
	}
	
	for (i = 0; i < n; i++){
		for (j = 0;j < m; j++){
			c += a[i][j]*b[j];
		}
		printf("%d\n", c);
		c = 0;
	}
	
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <unordered_set>

using namespace std;

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

  int tmp;
  unordered_set<int> d;
  for (int i = 0; i < N; ++i) {
    cin >> tmp;
    d.insert(tmp);
  }

  cout << d.size() << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<complex>
#include<algorithm>
#include<math.h>
using namespace std;
int n,i,j;
double x[100],y[100],a[101],b[101],Ans[100];
complex<double>z[100],w[100];
int main()
{
  cin >> n;
  for(i=0;i<n;i++){
    cin >> x[i] >> y[i];
    z[i]=complex<double>(x[i],y[i]);
  }
    for(i=0;i<n;i++){
      for(j=0;j<n;j++){
        w[j]=z[j]-z[i];
        a[j]=fmod(arg(w[j])+2*M_PI,2*M_PI);
      }
      sort(a,a+n);
      a[n]=a[1]+2*M_PI;
      for(j=1;j<n;j++){
        if(a[j+1]-a[j]>=M_PI){Ans[i]=(a[j+1]-a[j]-M_PI)/2/M_PI;
                              break;
                             }
      }
    }
  for(i=0;i<n;i++){
  cout << Ans[i] << endl;
  }
}

Measured memory_bytes: 256
S=[int(input()) for i in range(5)]
R=list(S)
for i in range(5):
    R[i]=R[i]%10
L=sorted(R)[::-1]

for i in range(5):
    if L[i]!=0:
        L[i]=10-L[i]
W=sorted(L)

total=S[0]+S[1]+S[2]+S[3]+S[4]
mati=W[0]+W[1]+W[2]+W[3]
print(total+mati)

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

int main(void){
  int ans;
  while(cin>>ans){
    if (ans==0) break;
    for (int i=0; i<9; i++){
      int t;
      cin >> t;
      ans -= t;
    }
    cout << ans << endl;
  }
  return 0;
}


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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplece_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; scanf("%lld", &x);
#define int2(x, y) int x, y; scanf("%lld %lld", &x, &y);
#define int3(x, y, z) Int(x); int2(y, z);
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second

//int dxy[5] = {0, 1, 0, -1, 0};
// assign avl ncm dijkstra geo2 kruskal graph uf lca BIT
// matrix dinic next_combination topcoder

signed main()
{
    Int(n);
    vi data(n);
    rep(i, n) cin >> data[i];

    int cnt2 = 0, cnt4 = 0;
    rep(i, n) {
        if (!(data[i] % 4)) {
            cnt4++;
        } else if (!(data[i] % 2)) {
            cnt2++;
        }
    }

    if (cnt4 >= n / 2) {
        std::cout << "Yes" << std::endl;
    } else if ( (n - (cnt4*2)) <= cnt2) {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No" << std::endl;
    }



    return 0;
}



Measured memory_bytes: 1024