akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
 
typedef long long ll;
 
using namespace std;
 
int dp[2001][2001][2]={0};
int m,n,ans=0;
char t[2001],s[2001];
 
int main(){
    
    scanf("%d%d%s%s",&m,&n,t,s);
    
    for(int i=0;i<m+n;i++){
        
        for(int k=0;k<=i;k++){
            if(k<m && i-k<=n){
                if(t[k]=='I'){
                    dp[k+1][i-k][1]=max(dp[k+1][i-k][1],dp[k][i-k][0]+1);
                }else{
                    if(dp[k][i-k][1])
                        dp[k+1][i-k][0]=max(dp[k+1][i-k][0],dp[k][i-k][1]+1);
                }
                ans=max(ans,dp[k+1][i-k][1]);
            }
            if(k<=m && i-k<n){
                if(s[i-k]=='I'){
                    dp[k][i-k+1][1]=max(dp[k][i-k+1][1],dp[k][i-k][0]+1);
                }else{
                    if(dp[k][i-k][1])
                        dp[k][i-k+1][0]=max(dp[k][i-k+1][0],dp[k][i-k][1]+1);
                }
                ans=max(ans,dp[k][i-k+1][1]);
            }
        }
    }
    
    printf("%d\n",ans);
    
    return 0;
}

Measured memory_bytes: 34508
#include<bits/stdc++.h>
#define ll long long int 
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a;i<n;i++)
#define ve vector
#define ss second 
#define ff first
#define pf pop_front
#define pob pop_back
#define psf push_front
#define it vector<ll>:: iterator
#define res(x) cout<<x<<'\n'
#define read(t) ll t;cin>>t
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    read(n);
    ll a[n];
    f(i,0,n)
    cin>>a[i];
    ll dp[n];
    dp[0]=0;
    dp[1]=abs(a[0]-a[1]);
    for(int i=2;i<n;i++){
        dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
    }
    res(dp[n-1]);
    return 0;
    }

Measured memory_bytes: 5112
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int studentCount = stdIn.nextInt();
		float[] studentHeight = new float[studentCount];
		for(int i=0;i<studentCount;i++){
			studentHeight[i] = stdIn.nextFloat();
		}
//		int midasi1 = 0,midasi2 = 0,midasi3 = 0,midasi4 = 0,midasi5 = 0,midasi6 = 0;
		int[] midasi = new int[6];
		for(float i:studentHeight){
			if(i < 165.0){
				midasi[0]++;
			}else if(165.0 <= i & i < 170.0){
				midasi[1]++;
			}else if(170.0 <= i & i < 175.0){
				midasi[2]++;
			}else if(175.0 <= i & i < 180.0){
				midasi[3]++;
			}else if(180.0 <= i & i < 185.0){
				midasi[4]++;
			}else if(185.0 <= i){
				midasi[5]++;
			}
		}
		for(int i = 0; i < midasi.length;i++){
			System.out.print((i + 1) + ":");
			for(int j = 0;j < midasi[i];j++){
				System.out.print("*");
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
 using namespace std;
 int main() {
  long X;
  long A = 100; 
  long i = 0;
  cin >> X;
  for(long k = 0; k < X; k++){
   A += (A / 100);
   i++;
  if(A >= X){
   break;
  }
  }
  cout << i << endl;
} 


Measured memory_bytes: 3632
n = int(input())
a = list(map(int, input().split()))
ans = 'APPROVED'
for i in range(n):
  if a[i]%2==0:
    if a[i]%3==0 or a[i]%5==0:
      ans = 'APPROVED'
    else:
      print('DENIED')
      exit()
print(ans)
    


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

int main(){
  ll n,m;
  cin >> n >> m;
  vector<ll> a;
  ll tmp;
  for(int i=0; i<n; i++){
    cin >> tmp;
    a.push_back(tmp);
  }
  sort(a.begin(),a.end());
  vector<pair<ll,ll>> c_b;
  ll b,c;
  for(int i=0; i<m; i++){
    cin >> b >> c;
    c_b.push_back(make_pair(-c,b));
  }
  sort(c_b.begin(),c_b.end());
  ll ans=0;
  ll count = 0;
  ll c_b_p = 0;
  for(int i=0; i<n; i++){
    if(c_b_p>=m){c=0;b=-1;}
    else{
      b = c_b.at(c_b_p).second;
      c = -(c_b.at(c_b_p)).first;
    }
    if(a.at(i)<=c)ans += c;
    else ans += a.at(i);
    count++;
    if(b==count){c_b_p++;count=0;}
  }
  cout << ans << endl;
}
          

Measured memory_bytes: 3188
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

int A[35][35], cnt[35];
signed main() {
    int N, M; cin >> N >> M;
    for(int i=0; i<N; i++) {
        int K; cin >> K;
        for(int j=0; j<K; j++) {
            int val; cin >> val;
            val--;
            cnt[val]++;
        }
    }

    int ans = 0;
    for(int i=0; i<M; i++) {
        ans += (cnt[i] == N);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(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; i >= n; i--)

#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))

#define endl "\n"
#define pb push_back
#define rtn return
#define elif else if

#define INF 2000000000	//int型は2 * 10^9ぐらいまで
#define MOD 1000000007
 
const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};

typedef long long ll;
typedef unsigned long long ull;

template <typename T>
inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T>
inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T>
inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T>
inline T nHr(T a,T b){return nCr(a+b-1,b);}
template <typename T>
inline T POW(T a,T b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}

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

	int a, b, c, cnt = 0;
	cin >> a >> b >> c;

	int first = max({a, b, c}), third = min({a, b, c});
	int second = a + b + c - first - third;

	cnt += first - second;
	third += first - second;

	if((first-third) % 2 == 0) cnt += (first-third) / 2;
	else cnt += (first-third+1) / 2 + 1;

	cout << cnt << endl;

	rtn 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>

using namespace std;

long long MOD = 1000000007;

int main(){
    int N;
    cin >> N;
    int min_;
    int cnt=1;
    cin >> min_;
    for(int i=0; i<N-1; i++){
        int p;
        cin >> p;
        if(p<=min_){
            cnt++;
        }
        min_=min(min_,p);
    }
    cout << cnt << endl;
}

Measured memory_bytes: 384
"""
author : halo2halo
date : 22, Jan, 2020
"""

import sys

# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(readline())
if N == 1:
    print("Hello World")
else:
    A, B = map(int, read().split())
    print(A + B)


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

int main() {
    int i = 1;
    int input = 1;
    while (1) {
        cin >> input;
        if (!input) {
            break;
        }
        cout << "Case " << i << ": " << input << endl;
        i++;
    }

    return 0;
}



Measured memory_bytes: 3012
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
const int MOD=1000000007;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;

int main(void){
    lint N;
    cin >> N;
    lint ans=0;
    for(int i=1;i<=N;i++){
        if(i%3!=0 && i%5!=0) ans+=i;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define ll int
int main()
{
    ll n,m,t;
    cin>>n>>t>>m;
    double x;
    x=(double)n/m;
   // printf("%.2lf\n",x);
    if(x<=t)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long int
#define ld long double
using namespace std;
const int N = 1e6 + 5;
const int MOD = 1e9 + 7;

int main(){
	fast;
	ll n;
	cin >> n;
	pair<int, int> a[n];
	for(int i = 0; i < n; ++i){
		cin >> a[i].first;
		cin >> a[i].second;
	}
	for(int i = 0; i < n - 2; ++i){
		if(a[i].first == a[i].second && a[i + 1].first == a[i + 1].second && a[i + 2].second == a[i + 2].first){
			cout << "Yes";
			return 0;
		}
	}
	cout << "No";
	return 0;
}


Measured memory_bytes: 3656
import java.util.*;

public class Main {
	Scanner in = new Scanner(System.in);
	public static void main(String[] args) {
		new Main();
	}
	public Main(){
		new AOJ1180().doIt();
	}
	
	class AOJ1180{
		int input,l;
		
		int rehyou(int a){
			int result = 0;
			ArrayList<Integer> list = new ArrayList<Integer>();
			String b = Integer.toString(a);
			for(int i=0;i<Integer.toString(a).length();i++)list.add(Integer.parseInt(b.charAt(i)+""));
			while(list.size()<l)list.add(0);
			Collections.sort(list);
			int c=0,d=0;
			for(int i=list.size()-1;i>=0;i--){
				c*=10;
				c+=list.get(i);
			}
			for(int i=0;i<list.size();i++){
				d*=10;
				d+=list.get(i);
			}
			return c-d;
		}
		
		void solve(){
			HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
			int a = input;
			map.put(a, 0);
			for(int i=1;;i++){
				a = rehyou(a);
				if(map.containsKey(a)){
					System.out.print(map.get(a)+" ");
					System.out.print(a+" ");
					System.out.println(i-map.get(a));
					break;
				}
				map.put(a, i);
			}
		}
		
		void doIt(){
			while(in.hasNext()){
				input = in.nextInt();
				l = in.nextInt();
				if(input+l == 0)break;
				solve();
			}
		}
	}
	
}

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

// Shrotening
#define fst first
#define snd second
#define pb push_back
#define mp make_pair

// Loop
#define FOR(i,a,b) for(auto i=(a);i<(b);++i)
#define RFOR(i,a,b) for(auto i=(a);i>=(b);--i)

#define REP(i,a) for(long i=0;i<(a);++i)
#define RREP(i,a) for(long i=(a);i>=0;--i)

#define EACH(i,a) for(auto (i)=(a).begin(),_END=(a).end();i!=_END;++i)
#define REACH(i,a) for(auto (i)=(a).rbegin(),_END=(a).rend();i!=_END;++i)

//Algorithm
#define ALL(a) (a).begin(), a.end()
#define RALL(a) (a).rbegin(), a.rend()
#define EXIST(a,x) ((a).find(x)!=(a).end())
#define SORT(a) std::sort((a).begin(), (a).end())
#define UNIQUE(a) std::sort((a).begin(), a.end()), a.erase(std::unique((a).begin(), a.end()), a.end());
#define SUM(a) std::accumulate((a).begin(), (a).end(), 0);

//Setting
#define OPT std::cin.tie(0);std::ios::sync_with_stdio(false);

//debug message
bool debug = true;
#define MSG(s)   if(debug){std::cout << s << std::endl;}
#define DEBUG(x) if(debug){std::cout << "debug(" << #x << "): " << x << std::endl;}

//alias
typedef long long LL;
typedef std::vector<char> VC;
typedef std::vector<int>  VI;
typedef std::vector<long> VL;
typedef std::vector<long long> VLL;

typedef std::vector< VC > VC2;
typedef std::vector< VI > VI2;
typedef std::vector< VL > VL2;
typedef std::vector< VLL > VLL2;

typedef std::pair<int,int> PII;

inline int calc(int p, int x) {
    return p*(100+x)/100;
}

int x, y, s;
int main() {
    while(std::cin >> x >> y >> s) {
        if(x == 0 && y == 0 && s == 0) continue;
        int ans = 0;
        FOR(i, 1, s) {
            FOR(j, 1, s) {
                if(calc(i, x) + calc(j, x) == s) {
                    int i2 = calc(i, y);
                    int j2 = calc(j, y);
                    ans = std::max(i2+j2, ans);
                }
            }
        }
        std::cout << ans << std::endl;
    }
}


Measured memory_bytes: 3080
a = list(map(int, input().split()))
likefood = []
result = 0

for i in range(a[0]):
    b = list(map(int, input().split()))
    for k in range(b[0]):
        likefood.append(b[k+1])

for i in range(a[1]):
    if likefood.count(i+1) == a[0]:
        result += 1

print(result)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define PI acos(-1.0)
typedef long long ll;
const int INF=0x3f3f3f3f;
int d[8][2]={-1,0,0,-1,0,1,1,0,1,1,-1,-1,-1,1,1,-1};
int n,m,k;
char s[10];
int a[10];
int main()
{
    cin>>n;
    for(int i=0;i<4;i++)
    {
        a[i]=n%10;
        n/=10;
    }
    for(int i=0;i<2;i++)
    {
        if(a[i]==a[i+1])
        {
            if(a[i+1]==a[i+2])
            {
                printf("Yes\n");
                return 0;
            }
        }
    }
    printf("No\n");
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define N 10001
char s[N][N];
int main(){
    ios::sync_with_stdio(false);//输入加速 
    int n,m;
    cin>>n>>m;//输入行、列 
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            cin>>s[i][j];//输入 
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(s[i][j]=='#')s[i][j]='#';
            if(s[i][j]=='.'){//如果不是雷 
                s[i][j]='0';//清零 
                for(int p=i-1;p<=i+1;p++){//寻找附近3*3是不是雷 
                    for(int q=j-1;q<=j+1;q++){
                        if(s[p][q]=='#')s[i][j]++;//如果是雷ASCLL码+1 
                    }
                }
            }
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            cout<<char(s[i][j]);//输出 
        }
        cout<<endl;//记得换行 
    }
    return 0;//Nice!~~ 
}

Measured memory_bytes: 512
X, K, D = map(int, input().split())

if abs(K*D) <= abs(X):
    ans = abs(abs(X) - abs(K*D))
    print(ans)
    exit()
    
tmp1 = X%D
tmp2 = abs(tmp1-D)

cnt = X//D

check = K - cnt
if check%2 == 0:
    print(tmp1)
else:
    print(tmp2)

Measured memory_bytes: 9192
#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 sax(x) cout << "!!!!!!!!!!! " << #x << " = " << x << '\n'
#define inf (sizeof(int) == 4 ? (int)1E9 : (int)1E18)
#define one(x) x.insert(x.begin(), 0);
#define TCT template <class T>
#define TCT12 template <class T1, class T2>
#define IS istream
#define OS ostream
#define OP operator

//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less_equal<int>,rb_tree_tag,
//tree_order_statistics_node_update> imsi;

TCT IS& OP>>(IS &I, vector<T>& v) {for (T &e: v) I >> e; return I;}
TCT OS& OP<<(OS &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}
TCT OS& OP<<(OS &O, const unordered_set<T>& v) {for (const T &e: v) O << e << ' '; return O;}
TCT OS& OP<<(OS &O, const set<T>& v) {for (const T &e: v) O << e << ' '; return O;}
TCT OS& OP<<(OS &O, const unordered_multiset<T>& v) {for (const T &e: v) O << e << ' '; return O;}
TCT OS& OP<<(OS &O, const multiset<T>& v) {for (const T &e: v) O << e << ' '; return O;}
TCT IS& OP>>(IS &I, deque<T>& v) {for (T &e: v) I >> e; return I;}
TCT OS& OP<<(OS &O, const deque<T>& v) {for (const T &e: v) O << e << ' '; return O;}
TCT OS& OP<<(OS &O, priority_queue<T> v) {while (!v.empty()) {O << v.top() << ' '; v.pop();} return O;}
TCT OS& OP<<(OS &O, stack<T> v) {while (!v.empty()) {O << v.top() << '\n'; v.pop();} return O;}
TCT OS& OP<<(OS &O, queue<T> v) {while (!v.empty()) {O << v.front() << ' '; v.pop();} return O;}
TCT12 IS& OP>>(IS &I, pair<T1,T2>& p) {return I >> p.first >> p.second;}
TCT12 OS& OP<<(OS &O, const pair<T1,T2>& p) {return O << '(' << p.first << ' ' << p.second << ')';}
TCT12 OS& OP<<(OS &O, const unordered_map<T1,T2>& v) {for (const auto &e: v) O << e << ' '; return O;}
TCT12 OS& OP<<(OS &O, const map<T1,T2>& v) {for (const auto &e: v) O << e << ' '; return O;}
typedef pair<int,int> pii;
typedef vector<int> vi;





void _main() {
        int n; cin >> n;
        vi vec(n); cin >> vec;
        sort(all(vec));


        const int mx = *max_element(all(vec));
        vector<bool> dp(mx + 1, 1);
        map<int, int> freq;
        for (const auto num: vec) {
                freq[num]++;
                for (int j = 2 * num; j <= mx; j += num) {
                        dp[j] = false;
                }
        }

        int ans = 0;
        for (int i = 0; i < n; i++)
                ans += dp[vec[i]] && freq[vec[i]] == 1;

        cout << ans;
}



signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}


Measured memory_bytes: 17388
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<vector>
#include<string>
#define int long long
using namespace std;

int a[90];
signed main() {
	a[1] = 2, a[2] = 1;
	int n; cin >> n; n++;
	for (int i = 3; i <= n; i++) {
		a[i] = a[i - 1] + a[i - 2];
	}
	cout << a[n] << endl;
}

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

#include <math.h>
#include <stdlib.h>


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

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

//INT_MAX	2,147,483,647 = 2*1.0e9

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    vector<int> ABC(3);
    cin >> ABC[0] >> ABC[1] >> ABC[2];
    sort(ABC.begin(), ABC.end());

    int dif1 = ABC[1] - ABC[0];
    int dif2 = ABC[2] - ABC[1];
    int ans = (dif1+1) /2 + dif2;
    if(dif1%2 == 1) ans++;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <string>
#include <algorithm>
using namespace std;
int main(void){
    // Your code here!
    string S;
    bool can = true;
    cin >> S;
    string divide[4] = {"dream", "dreamer", "erase", "eraser"};
    
    //反転
    reverse(S.begin(),S.end());
    for(int i=0; i<4; i++) reverse(divide[i].begin(),divide[i].end());
    
    for(int i=0; i<S.size();){
        bool can2 = false;
        for (int j = 0; j < 4; j++) {
            string d = divide[j];
            if (S.substr(i, d.size()) == d) 
            { 
                can2 = true;
                i += d.size(); 
            }
        }
        if(can2 == false){
            can = false;
            break;
        }
    }
    if(can == true) cout << "YES";
    else  cout << "NO";
}


Measured memory_bytes: 512
#include <stdio.h>
 
int main(void) {
    int a,b,c;
    while(scanf("%d%d%d", &a,&b,&c)){
        if(a == -1 && b == -1 && c == -1) break;
        if(a == -1 || b == -1) printf("F\n");
        else if(a+b >= 80) printf("A\n");
        else if(a+b >= 65) printf("B\n");
        else if(a+b >= 50) printf("C\n");
        else if(a+b >= 30){
            if(c >= 50) printf("C\n");
            else printf("D\n");
        }
        else printf("F\n");
         
    }
    return 0;
}

Measured memory_bytes: 584
//11
#include<iostream>
#include<vector>
#include<complex>

using namespace std;

typedef complex<double> P;

double cr(P a,P b){
  return a.real()*b.imag()-a.imag()*b.real();
}

int main(){
  for(int n;cin>>n,n;){
    P l[100][2];
    int na=1;
    for(int i=0;i<n;i++){
      int x,y,xx,yy;
      cin>>x>>y>>xx>>yy;
      l[i][0]=P(x,y);
      l[i][1]=P(xx,yy);
      int np=0;
      vector<P> v;
      for(int j=0;j<i;j++){
	P a,b,c,d;
	a=l[i][0];
	b=l[i][1];
	c=l[j][0];
	d=l[j][1];
	if(cr(a-b,c-b)*cr(a-b,d-b)<0&&cr(c-d,a-d)*cr(c-d,b-d)<0){
	  P ll=a-b;
	  double d1=fabs(cr(ll,c-b)/abs(ll)),d2=fabs(cr(ll,d-b)/abs(ll));
	  P ip=d1/(d1+d2)*(d-c)+c;
	  int k;
	  for(k=0;k<v.size();k++){
	    if(abs(v[k]-ip)<1e-10)break;
	  }
	  np+=k==v.size();
	  v.push_back(ip);
	}
      }
      na+=np+1;
    }
    cout<<na<<endl;
  }
  return 0;
}
      

Measured memory_bytes: 1220
import sys
import collections
readline = sys.stdin.readline
 
n = int(readline().strip())
 
a = []
while n % 2 == 0:
  a.append(2)
  n //= 2
f = 3
while f * f <= n:
  if n % f == 0:
    a.append(f)
    n //= f
  else:
    f += 2
if n != 1:
  a.append(n)

if len(a) == 0:
  print(0)
  exit()

c = collections.Counter(a)
p = c.keys()

ans = 0
for i in p:
  v = c[i]
  m = 0
  ans += 1
  for j in range(1,v):
    m += j
    if m + j >= v:
      break
    else:
      ans += 1

print(ans)

Measured memory_bytes: 9476
#include <bits/stdc++.h>
using namespace std;
using ll= long long;
using vi= vector<int>;
using vvi= vector<vi>;
using vd= vector<double>;
using vvd= vector<vd>;
using vc= vector<char>;
using vb= vector<bool>;
using vl= vector<ll>;
using vs= vector<string>;
#define rep(i,x,n) for(int i=x; i<n; i++)
#define all(x) x.begin(), x.end()

int main(){
  ll h,w;
  cin >> h >> w;
  if(h==1 || w==1){
    cout << 1;
  }else{
    cout << (h*w+1)/2;
  }
  
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int hito = scan.nextInt();
        int nmin = scan.nextInt();
        int nmax = scan.nextInt();
        int p[] = new int[201];
        while (hito != 0 || nmin != 0 || nmax != 0) {

            int g;
            int max = 0;
            int ninnzu = 0;
            for (int i = 1; i <= hito; i++) {
                p[i] = scan.nextInt();
            }
            for (int h = nmin; h <= nmax; h++) {
                g = p[h] - p[h + 1];

                if (max <= g) {
                    max = g;
                    ninnzu = h;
                }

            }
            System.out.println(ninnzu);
            hito = scan.nextInt();
            nmin = scan.nextInt();
            nmax = scan.nextInt();
        }
    }
}



Measured memory_bytes: 56040
#include <bits/stdc++.h>
using namespace std;
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define watch(x) cout<<"->"<<#x<<": "<<x<<endl;
#define int long long
const int INF = 1000000000;
const int MOD = 1000000007;
const double PI = 2*acos(0.0);
signed main()
{
	//freopen("","r",stdin);
	//freopen("","w",stdout);
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n,k;
	cin>>n>>k;
	int a[n];
	for(int i=0;i<n;i++)
		cin>>a[i];
	int cnta=0,cntb=0;
	for(int i=0;i<n;i++)
		for(int j=i+1;j<n;j++)
			if(a[i]>a[j])
				++cnta;
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			if(a[i]>a[j])
				++cntb;
	int x = cnta*k;
	int y = k * (k-1) / 2; y%=MOD;
	int res = (x%MOD+cntb*y)%MOD;
	return cout<<res%MOD<<endl,0;	
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
public class Main {
	public static void main(String[] args)throws Exception {
		InputStreamReader is = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader (is);
		String []input = br.readLine().split("");
		Main m = new Main();
		stack st = m.new stack();
		for(String s: input) {
			st.push(s);
			if(st.getSize() > 1) {
				String temp = st.pop()+ st.pop();
				if(!"TS".equals(temp)) {
					st.push(temp.substring(1,2));
					st.push(temp.substring(0,1));
				}
			}
		}
		System.out.println(st.getSize());
	}
	public class stack{
		private ArrayList<String> stackList;
		private int count;
		stack(){
			stackList = new ArrayList<String>();
			count = 0;
		}
		public String pop() {
			String s = stackList.get(count-1);
			stackList.remove(count-1);
			count--;
			return s;
		}
		public void push(String s) {
			stackList.add(s);
			count++;
		}
		public int getSize() {
			return count;
		}
	}
}

Measured memory_bytes: 66184
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        long n = sc.NextLong();
        long x = sc.NextLong();

        long[] counts = new long[n + 1];
        long[] pCounts = new long[n + 1];
        counts[0] = 1;
        pCounts[0] = 1;
        for (int i = 1; i <= n; i++)
        {
            counts[i] = counts[i - 1] * 2 + 3;
            pCounts[i] = pCounts[i - 1] * 2 + 1;
        }

        long answer = dfs(x, n, counts, pCounts);

        Console.WriteLine(answer);
    }

    private static long dfs(long x, long level, long[] counts, long[] pCounts)
    {
        if (x <= 0)
        {
            return 0;
        }

        if (level == 0)
        {
            return 1;
        }

        long mid = (counts[level] + 1) / 2;
        if (x >= mid)
        {
            return dfs(x - mid, level - 1, counts, pCounts) + 1 + pCounts[level - 1];
        }
        else
        {
            return dfs(x - 1, level - 1, counts, pCounts);
        }
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 27532
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define mod 1000000007
 
#define p(x) cout<<x<<" ";
#define p2(x,y) cout<<x<<" "<<y<<" "
#define p3(x,y,z) cout<<x<<" "<<y<<" "<<z<<" "
#define F(i,a,b) for(ll i=a;i<=b;i++)
#define RF(i,a,b) for(ll i=a;i>=b;i--)
 
#define ff first
#define ss second
#define mp(x,y) make_pair(x,y)
#define pi pair<ll,ll>
#define ppi pair<ll,pi>
#define pb push_back
#define all(v) v.begin(), v.end() 
int dp[3005][3005];

int lcs(string s1,string s2,int n,int m){
  F(i,0,n){
    F(j,0,m){
      if(i==0||j==0){
        dp[i][j]=0;
      }else{
        if(s1[i-1]==s2[j-1])
          dp[i][j]=1+dp[i-1][j-1];
        else
         dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
      }
    }
  }
  return dp[n][m];
}

int main()
{

ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cout<<fixed<<setprecision(6);

// #ifndef ONLINE_JUDGE
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
// #endif
  
    ll t=1;
    //cin>>t;
    
    while(t--)
    {
      string s1,s2;
      cin>>s1>>s2;
      lcs(s1,s2,s1.length(),s2.length());
      int i=s1.length();
      int j=s2.length();
      string str="";
      while(i>0&&j>0){
        if(s1[i-1]==s2[j-1]){
          str+=s1[i-1];
          i--;
          j--;
        }else{
          if(dp[i-1][j]>=dp[i][j-1])
            i--;
          else
            j--;
        }
      }
      reverse(str.begin(),str.end());
      cout<<str<<"\n";

    }
        
}

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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

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

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

  int N;
  cin >> N;
  vector<ll> a(3*N);
  for(int i = 0; i < 3*N; i++) cin >> a[i];

  vector<ll> left_vec(N+1);

  ll sum_tmp = 0;
  multiset<ll> ms;
  for(int i = 0; i < N; i++){
    ms.insert(a[i]);
    sum_tmp += a[i];
  }

  left_vec[0] = sum_tmp;

  for(int i = 0; i < N; i++){
    // a[i]を追加し、最小の値を削除
    ms.insert(a[N+i]);
    ll min_val = *ms.begin();
    left_vec[i+1] = left_vec[i] + a[N+i] - min_val;
    ms.erase(ms.begin());

  }

  vector<ll> right_vec(N+1);
  sum_tmp = 0;
  multiset<ll> ms2;
  for(int i = 0; i < N; i++){
    ms2.insert(a[3*N-1-i]);
    sum_tmp += a[3*N-1-i];
  }
  right_vec[0] = sum_tmp;
  for(int i = 0; i < N; i++){
    ms2.insert(a[2*N-1-i]);
    auto itr_max = ms2.end();
    itr_max--;
    right_vec[i+1] = right_vec[i] + a[2*N-1-i] - *itr_max;
    ms2.erase(itr_max);
  }

  ll ans = -INF;
  for(int i = 0; i < N+1; i++){
    chmax(ans, left_vec[i] - right_vec[N-i]);
  }
  
  cout << ans << endl;

  return 0;
}


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

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



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

  int x;
  cin >> x;
  int ans = 1;
  int tmp = 1;
  while(tmp <= x) {
    tmp += ans;
    ans++;
  }
  cout << ans-1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1);

int main(void) {
    string S, T;
    cin >> S >> T;

    int s_size = S.size();
    if ( !S.compare(T.substr(0, s_size))) {
        if (T.size() == s_size + 1) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

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

using ll = long long;
const ll MOD = 1e9 + 7;

int main() {
    int N, K;
    string S;
    cin >> N >> K >> S;
    int c = 1;
    rep(i, N - 1) {
        if (S[i] != S[i + 1]) c++;
    }
    int ans = min(N - (c - K * 2), N - 1);
    cout << ans << endl;
}

Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Deque;

public class Main {

	static Deque<Integer> stack = new ArrayDeque<>();
	static ArrayList<ArrayList<Integer>> list = new ArrayList<ArrayList<Integer>>();

	static int count = 0;
	static int n;

	static boolean flag = false;

	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str[] = br.readLine().split("");
		int count = 0;
		for (int i = 0; i < str.length; i++) {
			if(str[i].equals("1")) {
				count++;
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 21332
#include <stdio.h>

int a[100];
int cnt=0;
int i;
int main(void){
	scanf("%d",&cnt);
	for(i=0;i<cnt; i++) scanf("%d",&a[i]);
	for(i=cnt-1;i>0; i--) printf("%d ",a[i]);
	printf("%d\n",a[0]);
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define INF 1LL << 60;
#define LLINF 1e12
#define PI 3.14159265359
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
int ny, nx;
typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

ll llpow(ll x, ll y)
{
    ll ans = 1;
    REP(i, y)
    ans *= x;
    return ans;
}

ll llmin(ll x, ll y) { return x < y ? x : y; }
ll llmax(ll x, ll y) { return x > y ? x : y; }

template <typename Container>
bool exist_in(const Container &c, const typename Container::value_type &v)
{
    return (c.end() != std::find(c.begin(), c.end(), v));
}

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

//std::cout << std::defaultfloat << std::setprecision(10);
////////////////////////////////////////
int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

    string S; cin >> S;
    int N = S.size();
    //cout << N << endl;

    REP(i,N/2){
        //cout << "S[i]= " << S[i] << " S[N-i]= " << S[N-i-1] << endl; 
        if(S[i]!=S[N-i-1]){
            cout << "No" << endl;
            return 0;
        }
    }

    REP(i,(N-1)/2){
        //cout << "S[i]= " << S[i] << " S[(N-1)/2-i]= " << S[(N-i)/2-i-1] << endl;
        if(S[i]!=S[(N-1)/2-i-1]){
            cout << "No" << endl;
            return 0;
        }
    }

    FOR(i,(N+3)/2, N){
        if(S[i]!=S[N-i-1]){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define fio ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;

constexpr int N = 10005,H=100,W=100;

int g[H][W],a[N];

int main() {	
	int h,w,n;
	scanf("%d%d%d",&h,&w,&n);
	for(int i = 1; i <= n; ++i)
		scanf("%d",a+i);
	int cur = 1;
	for(int i = 0; i < h; ++i) {
		int s = (i&1)?0:w-1;
		int e = (i&1)?w:-1;
		int m = (i&1)?1:-1;
		for(int j = s; j != e; j += m) {
			while(a[cur] == 0) ++cur;
			g[i][j] = cur, --a[cur];
		}
	}
	for(int i = 0; i < h; ++i) {
		for(int j = 0; j < w; ++j)
			printf("%d ",g[i][j]);
		printf("\n");
	}
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int W = sc.nextInt();
        String[] s = new String[H];
        for (int i = 0 ; i < H ; i++) {
            s[i] = sc.next();
            }

        for (int i = 0 ; i < H ; i++) {
            System.out.println(s[i]);
            System.out.println(s[i]);
        }
    }

}

Measured memory_bytes: 23508
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // fixed, setprecision 
#include <math.h> // double sqrt
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
string zisho(string a){
    sort(a.begin(), a.end());
    return a;
}

int main(){
    long long n;
    cin>>n;
    vector<string>s(n);
    rep(i,n)cin>>s[i];
    rep(i,n)s[i]=zisho(s[i]);
    map<string,int>xx;
    long long count=0;
    rep(i,n){
    if(xx.count(s[i])){xx.at(s[i])++;count+=xx.at(s[i])-1;}
    else xx[s[i]]=1;
    }
    cout<<count;
return 0;
}

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

int main(void){
    long n;
    cin >> n;
    vector<char> s(n);
    for (long i = 0; i < n; i++) {
        cin >> s[i];
        if(s[i] == 'Y'){
            cout << "Four" <<endl;
            return 0;
        }
    }
    cout << "Three" <<endl;
    return 0;
}


Measured memory_bytes: 256
# ABC135C - City Savers
# greedy algorithm
def main():
    n = int(input())
    A = tuple(map(int, input().rstrip().split()))
    B = tuple(map(int, input().rstrip().split()))
    ans, a1 = 0, A[0]
    for a2, b in zip(A[1:], B):
        cnt1 = min(a1, b)
        cnt2 = min(a2, b - cnt1)
        ans += cnt1 + cnt2
        a1 = a2 - cnt2  # a2 becomes a1 in next turn
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 19244
// Atcoder beginner round 174 C - Repsept

#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long ll;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int K;
    ll a = 7;
    cin >> K;
    if (K % 2 == 0 || K % 10 == 5) 
        cout << "-1";
    for (ll x = 1; x <= K; x++) {
        if(a % K == 0) {
            cout << x;
            break; 
        }
        a = (a *10 + 7) % K;
    }
    return 0;
}

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

#define debug(x) cerr<<#x<<'='<<x<<endl
#define set0(x) memset(x,0,sizeof(x))
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pii;
template<typename T> void read(T &x){
	x = 0;char ch = getchar();ll f = 1;
	while(!isdigit(ch)){if(ch == '-')f*=-1;ch=getchar();}
	while(isdigit(ch)){x = x*10+ch-48;ch=getchar();}x*=f;
}
int mod = 998244353;
inline int mul(int x,int y){return 1ll*x*y%mod;}
inline int add(int x,int y){return x+y>=mod?x+y-mod:x+y;}
inline int sub(int x,int y){return x-y<0?x-y+mod:x-y;}
inline int sq(int x){return 1ll*x*x%mod;}
int pow(int a,int b){return b == 0 ? 1 : ( b&1 ? mul(a,sq(pow(a,b/2))) : sq(pow(a,b/2)));}

typedef __int128 B;

map< pair<B,int> ,int> Mp;

void opt(B c,int len){
	if(len == 0)return;
	opt(c>>1,len-1);
	putchar((c&1)+'0');
}

int val(B cc,int cu){
	if(cu == 0){
		return 1;
	}
	if(Mp[make_pair(cc,cu)]){
		return Mp[make_pair(cc,cu)];
	}
	int ret = 0;
	if((cc&1) == 0)ret+=val(cc>>1,cu-1);
	if((cc&1) == 1)ret+=mul(2,val(cc>>1,cu-1));
	//opt(cc,cu);cout<<' '<<cu<<' '<<ret<<endl;
	for(int i=2;i<=cu;i++){
		for(int j=1;j*i<=cu;j++){
			int nxt = val(cc>>(i*j),cu-i*j);
			B cn = cc;
			for(int k=1;k<i;k++)cn&=(cc>>(k*j));
			cn&=(((B)1)<<j)-1;
			int xn = val(cn,j);
			ret = add(ret,mul(xn,nxt));
			//cout<<i<<' '<<j<<' ';opt(cc,cu);cout<<' '<<cu<<' '<<ret<<endl;
		}
	}
	Mp[make_pair(cc,cu)] = ret;
	//opt(cc,cu);cout<<' '<<cu<<' '<<Mp[make_pair(cc,cu)]<<endl;
	return ret;
}
int main() {
	string cc;
	cin>>cc;
	B c = 0;
	for(int i=0;i<cc.length();i++){
		c+=(((B)1)<<i)*(cc[i]-'0');
	}
	cout<<val(c,cc.length())<<endl;
	return 0;
}


Measured memory_bytes: 4480
n, *cs = map(int, open(0))
fwd = [0] * n
mod = 10 ** 9 + 7
d = {}
for i, c in enumerate(cs[::-1], start=1):
	f = d.get(c, 0)
	if f:
		fwd[n - i] = f
	d[c] = n - i
dp = [0] * (n + 1)
dp[0] = 1
for i in range(1, n + 1):
	dp[i] += dp[i - 1]
	dp[i] %= mod
	# 隣だったら無視
	if fwd[i - 1] > i:
		dp[fwd[i - 1] + 1] += dp[i]
print(dp[-1])

Measured memory_bytes: 38144
#include <iostream>
#include <string>

using namespace std;


int main(){
    
    string cards;
    int m, n;

    while(true){
        cin >> cards;
        if(cards=="-"){
            break;
        }
        cin >> m;
        for(int i=0; i<m; i++){
            cin >> n;
            string str1, str2;
            str1 = cards.substr(0, n);
            str2 = cards.substr(n, cards.length());
            cards = str2 + str1;
        }
        cout << cards << endl;
    }

    return 0;
}




Measured memory_bytes: 3172
#include<stdio.h>
int main()
{
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if(a==b)
        printf("%d\n",c);
    else if(b==c)
        printf("%d\n",a);
    else if(c==a)
        printf("%d\n",b);
    return 0;
}

Measured memory_bytes: 128
import java.util.*

fun main(args:Array<String>){
    val n = readLine()!!.toInt()
    val a = readLine()!!.split(" ").map{it.toInt()}
    var mi = n + 1
    var ans = 0
    for(i in 0 until n){
        if(a[i] < mi){
            ans++
            mi = a[i]
        }
    }
    println(ans)
}


Measured memory_bytes: 82868
n = int(input())
a = list(map(int, input().split()))

ans = 0
dic1 = {}
dic2 = {}
for i in range(n):
    tmp1 = a[i] + (i + 1)
    tmp2 = -a[i] + (i + 1)
    if tmp1 in dic1:
        dic1[tmp1] += 1
    else:
        dic1[tmp1] = 1
    if tmp2 in dic2:
        dic2[tmp2] += 1
    else:
        dic2[tmp2] = 1
for key in dic1.keys():
    if key in dic2:
        ans += dic1[key] * dic2[key]
print(ans)


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

int main()
{
	string s,t,temp;
    cin>>s>>t;
    ll n=s.length();
    ll m=t.length();
    ll ans=m;
    
    for(ll i=0;i<n-m+1;i++)
    {  ll count=0;
       temp=s.substr(i,m);
     
        
        for(ll j=0;j<m;j++)
        {
            if(temp[j]!=t[j])
            {
                count++;
            }
        }
       ans=min(count,ans);
    }
    cout<<ans;
	return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5, mod = 998244353;
int n, m, ans;
int inv[maxn + 10], fac[maxn + 10], ifac[maxn + 10];

inline int add(int x, int y) {
	x += y; return x < mod ? x : x - mod;
}
inline int dec(int x, int y) {
	x -= y; return x < 0 ? x + mod : x;
}
inline int mul(int x, int y) { 
	return 1ll * x * y % mod;
}
inline int fpow(int x, int y) {
	int ans = 1;
	while (y) {
		if (y & 1) ans = mul(ans, x);
		y >>= 1; x = mul(x, x);
	}
	return ans;
}

void init() {
	fac[0] = ifac[0] = 1;
	for (int i = 1; i <= maxn; ++i) {
		inv[i] = i == 1 ? 1 : dec(0, mul(mod / i, inv[mod % i]));
		fac[i] = mul(fac[i - 1], i);
		ifac[i] = mul(ifac[i - 1], inv[i]);
	}
}

int comb(int x, int y) {
	return mul(fac[x], mul(ifac[y], ifac[x - y]));
}

namespace fft {

	int rev[maxn + 10], l, lgl;

	void init(int n) {
		for (l = 1, lgl = -1; l <= n; l <<= 1) ++lgl;
		for (int i = 0; i < l; ++i)
			rev[i] = rev[i >> 1] >> 1 | (i & 1) << lgl;
	}

	void dft(int *a) {
		for (int i = 0; i < l; ++i)
			if (i < rev[i]) swap(a[i], a[rev[i]]);
		for (int i = 1; i < l; i <<= 1) {
			int wn = fpow(3, (mod - 1) / (i << 1));
			for (int j = 0; j < l; j += i << 1)
				for (int k = 0, w = 1; k < i; ++k, w = mul(w, wn)) {
					int x = a[j + k], y = mul(w, a[i + j + k]);
					a[j + k] = add(x, y); a[i + j + k] = dec(x, y);
				}
		}
	}

	void idft(int *a) {
		reverse(a + 1, a + l); dft(a);
		int invl = fpow(l, mod - 2);
		for (int i = 0; i < l; ++i) a[i] = mul(a[i], invl);
	}

}
int a[maxn + 10], b[maxn + 10], c[maxn + 10];

int main() {
	init();
	scanf("%d%d", &n, &m);
	fft::init(n * 2);
	a[0] = 1;
	for (int i = 1; i <= n; ++i) c[i] = ifac[i + 2];
	fft::dft(c);
	for (int i = 1; i <= m; ++i) {
		for (int j = 1; j <= n; ++j) {
			b[j] = mul(a[j], j * (j + 1) / 2 + 1);
			a[j] = mul(a[j], ifac[j]);
		}
		fft::dft(a);
		for (int j = 0; j < fft::l; ++j) a[j] = mul(a[j], c[j]);
		fft::idft(a);
		for (int j = 1; j <= n; ++j) a[j] = add(b[j], mul(a[j], fac[j + 2]));
		a[0] = 1;
		for (int j = n + 1; j < fft::l; ++j) a[j] = 0;
	}
	for (int i = 0; i <= n; ++i)
		ans = add(ans, mul(comb(n, i), a[i]));
	printf("%d", ans);
}


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

using namespace std;

int A,B,C,X,Y;
int ans;

void input(){
  cin >> A >> B >> C >> X >> Y;
}

void solve(){
  int a,b,c;
  if (A+B>2*C){
    if ((2*C>=A)&&(2*C>=B)){
      int tmp=min(X,Y);
      c=tmp*2;
      a=X-tmp;
      b=Y-tmp;
      ans=A*a+B*b+C*c;
    }
    if ((2*C<A)&&(2*C>=B)){
      c=2*X;
      a=0;
      b=max(Y-X,0);
      ans=A*a+B*b+C*c;
    } 
    if ((2*C>=A)&&(2*C<B)){
      c=2*Y;
      a=max(X-Y,0);
      b=0;
      ans=A*a+B*b+C*c;
    } 
    if ((2*C<A)&&(2*C<B)){
      int tmp=max(X,Y);
      c=tmp*2;
      a=0;
      b=0;
      ans=A*a+B*b+C*c;
    }

  }
  if (A+B<=2*C){
    a=X;
    b=Y;
    c=0;
    ans=A*a+B*b+C*c;
  }
}

int main(){
  input();
  solve();
  cout << ans << endl;
  return 0;
}
  


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


void trace(int A[], int N)
{
	for (int i = 0; i < N; i++)
	{
		if (i != N - 1) {
			printf("%d ",A[i]);
		}
		else {
			printf("%d\n", A[i]);
		}
	}
}

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

}


int main(void)
{
	int N;
	int A[100];

	scanf("%d", &N);
	for (int i = 0; i < N; i++)
	{
		scanf("%d",&A[i]);
	}
	trace(A, N);
	sort(A, N);
}


Measured memory_bytes: 3216
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.util.*

fun main(args: Array<String>) {
    val sc = FastScanner(System.`in`)

    val h = sc.nextInt()
    val w = sc.nextInt()
    val c = Array(10) { Array(10) { sc.nextInt() } }

    val wall = Array(h) { Array(w) { sc.nextInt() } }

    for (k in 0 until 10) {
        for (i in 0 until 10) {
            for (j in 0 until 10) {
                c[i][j] = Math.min(c[i][j], c[i][k] + c[k][j])
            }
        }
    }

    println(wall.flatMap { it.asIterable() }.filter { it != -1 }.sumBy { c[it][1] })

}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}

Measured memory_bytes: 41804