akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <iomanip>
#include <set>
#include <map>
#include <stack>
#include <deque>
 
#define ll long long
#define cint const int
#define ld long double
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define add +
#define minus -
#define squer(a) sqrt(a)
#define mod % 
 
using namespace std;

ll n, m, k;

int main () {
	cin >> n >> m >> k;
	if (k > m + n) {
		cout << 0 << " " << 0;
		return 0;
	}
	if (n == k) {
		cout << 0 << " " << m;
		return 0;
	}
	if (n > k) {
		cout << n - k << " " << m;
		return 0;
	}
	if (n < k) {
		cout << 0 << " " << m - (k - n);
		return 0;
	}
	return 0;
}

Measured memory_bytes: 256
/*
 *  Lang    : C++
 *  Author  : little_angel
 */
#include <bits/stdc++.h>

using namespace std;
#define int long long
const int mod = 1e9 + 7;
int dp[100001];

void add(int &a, int b) {
    a += b;
    if (a >= mod)a -= mod;
    if (a < 0)a += mod;
}

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

    int n, k, ai;
    cin >> n >> k;
    dp[0] = 1;
    for (int child = 1; child <= n; ++child) {
        cin >> ai;
        vector<int> sum(k + 2);
        for (int used = k; used >= 0; --used) {
            int val = dp[used];
            int l = used + 1;
            int r = min(k, used + ai);
            add(sum[l], val);
            add(sum[r + 1], -val);
        }
        int pref = 0;
        for (int i = 0; i <= k; ++i) {
            add(pref, sum[i]);
            add(dp[i], pref);
        }
    }
    cout << dp[k] << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define INF64 4999999999999999999
#define ALL(n) n.begin(),n.end()

ll N, K,ans = INF64;
vector<pair<ll, ll>> s, k;
set<pair<ll, ll>> se;
int main(){
	cin >> N >> K;
	REP(i, N) {
		int a, b;
		cin >> a >> b;
		pair<ll, ll> P = make_pair(a, b);
		se.insert(P);
		s.push_back(P);
		k.push_back(P);
	}
	REP(i, N) {
		REP(j, N) {
			pair<ll, ll> P[2] = { make_pair(s[i].first, s[j].second) , make_pair(s[j].first, s[i].second) };
			REP(o, 2) {
				if (se.find(P[o]) == se.end()) {
					se.insert(P[o]);
					k.push_back(P[o]);
				}
			}
		}
	}
	REP(i, k.size()) {
		REP(j, k.size()) {
			int count = 0;
			REP(l, N) {
				if (k[i].first <= s[l].first and  k[j].first >= s[l].first and k[i].second <= s[l].second and  k[j].second >= s[l].second)count++;
			}
			if (count >= K) {
				ans = min(ans, abs(k[i].first - k[j].first) * abs(k[i].second - k[j].second));
			}
		}
	}
	cout << ans << endl;
}

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

using namespace std;

/**
 *  Name: Chris M. Perez
 *  University: Interamerican University Metro Campus
 *
**/

#define endl '\n'
#define MOD 10E9
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define gcd(x , y) __gcd(x , y)
#define all(x) (x).begin() , (x).end()
#define forn(i , a , b) for(int i=(a);i<(b);i++)
#define forrange(j , a , b) for(int j=(a);j<=(b);j++)
#define nestedforn(i , a , b , j , c , d) for(int i=(a);i<=(b);i++) for(int j=(c);j<=(d);j++)
#define sort_all(x) sort(all(x))
#define zeros_at_beginning(x) __builtin_clz(x)
#define zeros_at_end(x) __builtin_ctz(x)
#define ones(x) __builtin_popcount(x)
#define parity_even_or_odd_ones __builtin_parity(x)

typedef vector<int> vi;
typedef pair<int , int> pii;
typedef tuple<int , int , int> tiii;
typedef vector<pii> vpii;
typedef vector<tiii> vtiii;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef long long ll;
typedef long long int lli;

             
inline int input(){
  int n;
  scanf("%d" , &n);
  return n;
}
                                              
int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(10);
  cout << fixed;  

#ifdef LOCAL_DEFINE
  freopen("input.txt" , "rt" , stdin);
#endif

  int a; cin >> a;
  int b; cin >> b;
  int c; cin >> c;
  cout << ((a == b && b == c) ? "Yes" : "No") << endl;    
  
      
#ifdef LOCAL_DEFINE
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
#include<map>
using namespace std;
map<int,int> in;
int n,x;
int main(){
	scanf("%d",&n);
	while(n--){
		scanf("%d",&x);
		if(in[x]) return puts("NO"),0;
		in[x]=1;
	}
	puts("YES");
	return 0;
}

Measured memory_bytes: 9600
n,m = gets.split.map(&:to_i)
dp = (n+2).times.map{0}
dp[0] = 1
w = (n+2).times.map{true}
m.times.map{
  i = gets.to_i
  w[i] = false
}

mod = 10**9+7

n.times{|i|
  dp[i+1] += dp[i] if w[i+1]
  dp[i+1] %= mod
  dp[i+2] += dp[i] if w[i+2]
  dp[i+2] %= mod
}

p dp[n]


Measured memory_bytes: 4220
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
using namespace std;
typedef long long ll;
int main(void){
    ll k, n, a[16];
    cin >> n >> k;
    for (int i = 0; i < n; i++) cin >> a[i];
    
    ll mn = 1e18;
    for (int i = 0; i < pow(2, n - 1); i++) {
        int ic = i, t[16], cnt = 1;
        t[0] = 1;
        for (int j = 0; j < n - 1; j++) {
            t[j + 1] = ic% 2;  ic /= 2;
            if (t[j + 1] == 1) cnt++;
        }
        
        if (cnt == k) {
            int idx = 0, b[16];
            b[0] = a[0];
            for (int j = 1; j < n; j++) {
                if (t[j] == 1) {
                    if (b[idx] >= a[j]) b[j] = b[idx] + 1;
                    else b[j] = a[j];
                    idx = j;
                } 
                else {
                    if (b[idx] < a[j]) b[idx] = a[j] + 1;
                    b[j] = a[j];
                }
            }
            
            ll sum = 0;
            for (int j = 0; j < n; j++) {
                sum += b[j] - a[j];
            }
            mn = min(mn, sum);
            //cout << sum << endl;
        }
        
        
    }
    
    cout << mn << endl;
    
    
}


Measured memory_bytes: 512
N, K = map(int, input().split())
A = list(map(int, input().split()))
A = sorted(A)
p = 1000000007
frac = [1]
for i in range(N):
  frac.append(frac[i]*(i+1)%p)

def power(n, r, mod):
    if r == 0: return 1
    if r%2 == 0:
        return power(n*n % mod, r//2, mod) % mod
    if r%2 == 1:
        return n * power(n, r-1, mod) % mod

def comb(n, k, mod):
    a=frac[n]
    b=frac[k]
    c=frac[n-k]
    return (a * power(b, mod-2, mod) * power(c, mod-2, mod)) % mod
  

ans = 0  
for i in range(N- K +1):
  ans += ((A[N-1-i] - A[i])*comb(N-1-i, K-1, p))
  ans = ans % p
print(ans)

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

#define ll long long
#define ull unsigned long long

using namespace std;

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

	vector <int> v(N);
	for (int ii = 0; ii < M; ++ii){
		int a, b;
		cin >> a >> b;
		a--; b--;
		v[a]++;
		v[b]++;
	}

	bool ok = true;
	for (int ii = 0; ii < N; ++ii){
		if (v[ii]%2==1){
			ok = false;
			break;
		}
	}

	if (ok){
		cout << "YES" << endl;
	} else {	
		cout << "NO" << endl;
	}

	return 0;
}


Measured memory_bytes: 3792
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

typedef long long ll;

int main() {
    int h, a;
    cin >> h >> a;
    cout << ((h % a == 0) ? (h / a) : (h / a + 1)) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<string>
#include<cstdlib>
//#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long INF = 1LL << 40;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// ----------------------------------------------------------------------------


int main(){
  int sx,sy,tx,ty;
  cin >> sx >> sy >> tx >>ty;
  int x,y;
  x = tx-sx;
  y = ty-sy;
  for(int i=0; i<x; i++){
    cout << "R";
  }
  for(int i=0; i<y+1; i++){
    cout << "U";
  }
  for(int i=0; i<x+1; i++){
    cout << "L";
  }
  for(int i=0; i<y+1; i++){
    cout << "D";
  }
  cout << "R";
  for(int i=0; i<y; i++){
    cout << "U";
  }
  for(int i=0; i<x+1; i++){
    cout << "R";
  }
  for(int i=0; i<y+1; i++){
    cout << "D";
  }
  for(int i=0;i<x+1; i++){
    cout << "L";
  }
  cout << "U" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin >>s;
    int l=0,r=s.length()-1,c=0;
    while(l<=r)
    {
        if(s[l]!=s[r])
        {
            c++;
        }
        l++,r--;
    }
    cout <<c;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << x << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 10000

int way[7][2] = {};


void calc(char *p){

  int now = 1;

  for(int i=0;p[i]!='\0';i++){
    now = way[now][p[i]-'0'];
  }

  if(now == 6)
    puts("Yes");
  else
    puts("No");

}

int main(){
  char p[SIZE];

  way[1][0] = 2;
  way[1][1] = 3;
  way[2][1] = 4;
  way[3][0] = 2;
  way[4][0] = 5;
  way[4][1] = 6;
  way[5][0] = 6;
  way[5][1] = 3;
  way[6][1] = 2;
  way[6][0] = 3;
  
  while(1){
    scanf("%s",p);
    if(p[0]=='#') break;
    calc(p);
  }
  
  return 0;
}

Measured memory_bytes: 1116
//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin, output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error('\n↑入力 ↓出力');
  Main();
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  return {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}
  };
}
function myout(s){console.log(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
  var s = next();
  var isA = false;
  var isB = false;
  for(var i = 0; i < s.length; i++){
    if(s[i] == "A"){
      isA = true;
    }
    if(s[i] == "B"){
      isB = true;
    }
  }
  if(isA && isB){
    myout("Yes");
  }else{
    myout("No");
  }
}



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

char C;

int main() {
    cin >> C;

    string ans = "consonant";
    if (C == 'a') ans = "vowel";
    if (C == 'i') ans = "vowel";
    if (C == 'u') ans = "vowel";
    if (C == 'e') ans = "vowel";
    if (C == 'o') ans = "vowel";

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

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <climits>
#include <utility>
typedef long long ll;
using namespace std;

string buff;

void search(int l, char ls, int r, char rs){
  int mid = (l+r) / 2;
  cout << mid << endl;
  cin >> buff;
  if(buff[0]=='V'){
    return;
  }

  if((ls==buff[0]&&(mid-l)%2==1)||(ls!=buff[0]&&(mid-l)%2==0)){
    search(l,ls,mid,buff[0]);
  }
  else{
    search(mid,buff[0],r,rs);
  }

  return;
}

int main(void){
  int n;
  char ls, rs;
  cin >> n;

  cout << 0 << endl;
  cin >> buff;
  if(buff[0]=='V') return 0;
  else ls = buff[0];

  cout << n-1 << endl;
  cin >> buff;
  if(buff[0]=='V') return 0;
  else rs = buff[0];

  search(0,ls,n-1,rs);

  return 0;
}


Measured memory_bytes: 852
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
typedef long long ll;
typedef long double ld;
int main(){
    int a;
    REP(i,5){
        cin>>a;
        if(a==0){
            cout<<i+1;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 3584
#include<stdio.h>

int main(void){
    long long int i, N, T, A, t, a, rt, ra, r;
    
    scanf("%ld", &N);
    
    scanf("%ld", &t);
    scanf("%ld", &a);
    
    for(i = 1; i < N; i++){
        scanf("%ld", &T);
        scanf("%ld", &A);
        
        rt = (t + T - 1) / T;
        ra = (a + A - 1) / A;
        
        if(rt > ra) r = rt;
        else r = ra;
        
        t = r * T;
        a = r * A;
    }
    
    printf("%lld\n", t + a);
    
    return 0;
}

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

int N;

LL X[19][19] = {};

int main() {

 scanf("%d",&N);
 rep(i,N){
  double buf; scanf("%lf",&buf);
  LL a = buf * 1.0e9 + 0.5;
  int idx2 = 0, idx5 = 0;
  while(a%2==0){ idx2++; a/=2; }
  while(a%5==0){ idx5++; a/=5; }
  X[min(idx2,18)][min(idx5,18)]++;
 }

 LL ans=0;
 rep(x,19)rep(y,19)rep(xx,19)rep(yy,19){
  if(x+xx < 18) continue;
  if(y+yy < 18) continue;
  if(x==xx && y==yy)
   ans += X[x][y]*(X[x][y]-1);
  else
   ans += X[x][y]*X[xx][yy];
 }

 ans /= 2;
 printf("%lld\n",ans);
 
 return 0;
}

Measured memory_bytes: 3820
N = int(input())
A = list(map(int, input().split()))

fm = 1000
nm = (0, 0)

for a in A:
	nfm = max(fm, nm[0] * a + nm[1])
	nnm = max(nm, (fm//a, fm - fm//a*a))

	fm, nm = nfm, nnm

print(fm)


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

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

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const double PI = 3.1415926535;
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;


int main(){
  int n, m;
  cin >> n >> m;
  vector<string>a(n);
  rep(i, 0, n)cin >> a[i];
  sort(a.begin(),a.end());
  rep(i, 0, n)cout << a[i];
  cout << endl;
}

Measured memory_bytes: 3584
//Errichto's sol
#include <bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define eb emplace_back
#define mt make_tuple
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

ll n,a,b,c,d;
vi mul={2,3,5};
vll cost;
map<ll,ll>vis;
ll INF = 5e18;

void mins(ll &a, ll b){
	a = min(a,b);
	return;
}

ll f(ll goal){
	if(goal==0)return 0;
	if(goal==1)return d;
	if(vis.find(goal)!=vis.end())return vis[goal];
	ll best = INF;
	if(d<INF/goal)mins(best,d*goal);
	for(int i=0; i<3; i++){
		if(goal%mul[i]==0)mins(best, cost[i] + f(goal/mul[i]));
		else{
			ll down = goal/mul[i] * mul[i];
			mins(best, d*(goal-down) + cost[i] + f(down/mul[i]));
			ll up = down + mul[i];
			mins(best, d*(up-goal) + cost[i] + f(up/mul[i]));
		}
	}
	return vis[goal]=best; 
}

void solve(){
	vis.clear(); cost.clear();
	cin >> n >> a >> b >> c >> d;
	cost.eb(a); cost.eb(b); cost.eb(c);
	cout << f(n) << endl;
}

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


Measured memory_bytes: 4352
n = int(input())
a = list(map(int, input().split()))
q = int(input())
m = list(map(int, input().split()))

def test(i, s, target):
    if s == target:
        return 1
    if s > target or i == n:
        return 0
    if s + sum(a[i:]) < target:
        return 0

    return test(i+1, s, target) or test(i+1, s+a[i], target)

for target in m:
    ans = 'yes' if test(0, 0, target) else 'no'
    print(ans)


Measured memory_bytes: 5624
#include <cstdio>
#include <map>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)

constexpr int MAX_N = 100;

using P = std::pair<int, int>;
using ll = long long;

int N, W;
ll w[MAX_N], v[MAX_N];
std::map<P, ll> dp;

ll rec( int i, ll j )
{
  if( i == 0 || j <= 0 )
    return 0;

  if( dp.count( P(i,j) ) )
    return dp[P(i,j)];

  if( j-w[i-1] >= 0 )
    return dp[P(i,j)] = std::max( rec( i-1, j ), rec( i-1, j-w[i-1] )+v[i-1] );
  else
    return dp[P(i,j)] = rec( i-1, j );
}

int main()
{
  scanf( "%d%d", &N, &W );
  rep( i, N )
    scanf( "%lld%lld", w+i, v+i );

  printf( "%lld\n", rec( N, W ) );

  return 0;
}

Measured memory_bytes: 6144
from collections import deque

N = int(input())
P = list(map(int, input().split()))

d = deque(P)
# print(d)
idx = 1
c = 0
while d:
    p = d.popleft()
    if not d and p == idx:
        c += 1
        break
    if p == idx:
        p2 = d.popleft()
        d.appendleft(p)
        d.appendleft(p2)
        c += 1
    else:
        idx += 1
print(c)


Measured memory_bytes: 14196
<?php
/**
 * ABC129
 * B - Balance
 */

// $s = trim(fgets(STDIN));
// fscanf(STDIN, "%d %d", $a, $b);
// $n = array_map('intval', explode(' ', trim(fgets(STDIN))));

fscanf(STDIN, "%d", $n);
$w = array_map('intval', explode(' ', trim(fgets(STDIN))));

$diff_min = 99999999999;

for ($i = 0; $i < $n - 1; $i++) {
    $sum1 = 0;
    $sum2 = 0;
    for ($j = 0; $j <= $i; $j++) {
        $sum1 += $w[$j];
    }
    for ($j = $i + 1; $j < $n; $j++) {
        $sum2 += $w[$j];
    }
    $diff_min = min($diff_min, abs($sum1 - $sum2)); 
}

echo $diff_min, PHP_EOL;


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

int main()
{
    string s, t;
    vector<vector<int>> graph(27);
    cin >> s;
    cin >> t;
    int n_s = s.length();
    int n_t = t.length();
    ll ans = 0;
    for (int i = 0; i < n_s; i++)
    {
        int c = s[i] - 'a';
        graph[c].push_back(i);
    }
    // for (int i = 0; i < 27; i++)
    // {
    //     cout<<i<<endl;
    //     for (auto itr : graph[i])
    //     {
    //         cout<<itr<<" ";
    //     }
    //     cout<<endl;
    // }
    int now = -1;
    for (int i = 0; i < n_t; i++)
    {
        int c = t[i] - 'a';
        auto itr = upper_bound(graph[c].begin(), graph[c].end(), now);
        if (itr != graph[c].end())
        {
            ans += *itr - now;
            now = *itr;
            //cout<<"a "<<*itr<<" "<<now<<endl;
        }
        else
        {
            ans += n_s - 1 - now;
            now = -1;
            auto itr = upper_bound(graph[c].begin(), graph[c].end(), now);
            if (itr != graph[c].end())
            {
                ans += *itr - now;
                now = *itr;
                //cout<<"b "<<*itr<<" "<<now<<endl;
            }
            else
            {
                ans = -1;
                break;
            }
        }
    }

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

Measured memory_bytes: 1216
N = int(input())
a = [int(i) for i in input().split()]

a.sort()
a.reverse()


# i = 0, j = 1

ans = (a[2]+a[3]) / (a[0]-a[1])

# i = 0, j = 2

ans = max(ans, (a[1]+a[3]) / (a[0]-a[2]))


# i = 0, j >= 3

for j in range(3, N):
    ans = max(ans, (a[1]+a[2])/(a[0]-a[j]))

# i = 1, j = 2

ans = max(ans, (a[0]+a[3]) / (a[1]-a[2]))

# i = 1, j >= 3

for j in range(3, N):
    ans = max(ans, (a[0]+a[2])/(a[1]-a[j]))

# i >= 2

for i in range(2, N):
    for j in range(i+1, N):
        ans = max(ans, (a[0]+a[1])/(a[i]-a[j]))

print(ans)



Measured memory_bytes: 5644
#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.SN", "r", stdin );

	string str = "";
	int sum = 0;
	while (cin >> str ){
		str += 'E';
		int n = str.length();
		int curr = 0;
		rep (i, n ){
			if (isdigit(str[i] ) ){
				curr *= 10;
				curr += (int)(str[i] - '0' );
			}else{
				sum += curr;
				curr = 0;
			} // end if
		} // end rep
	} // end loop

	printf ("%d\n", sum );
		
	return 0;
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

int main(){
    ll N, M;
    cin >> N >> M;
    VL k(M);
    VVL s(M, VL(N));
    rep(i, 0, M){
        cin >> k[i];
        rep(j, 0, k[i]){
            ll ss;
            cin >> ss;
            ss--;
            s[i][j] = ss;
        }
    }
    VL p(M);
    rep(i, 0, M) cin >> p[i];

    ll ans = 0;
    rep(bit, 0, 1LL<<N){
        VB sw(N, false);
        rep(i, 0, N){
            if(bit & 1LL<<i){
                sw[i] = true;
            }
        }
        ll c = 0;
        rep(i, 0, M){
            ll tc = 0;
            rep(j, 0, k[i]){
                if(sw[s[i][j]]) tc++;
            }
            if(tc%2 == p[i]) c++;
        }
        if(c == M) ans++;
    }

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

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<string>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#include<complex>
#include<unordered_map>
#define deg(x) cout<<#x<<"="<<x<<endl;
#define fd(x) for(int i=0;i<x;i++)
#define fdd(a,x) for(int i=a;i<x;i++)
#define fx(x,n) for(int i=n-1;i>=x;i--)
#define mst(x) memset(x,0,sizeof(x));
#define fi first
#define se second
#define TB ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define ok "ok"
#define HH puts("");
#define ls rt<<1
#define rs rt<<1|1
#define pb(a,b) a.push_back(b);
#define FIN  freopen("1.in","r",stdin);
#define FOUT freopen("1.out","w",stdout);
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<string,int> pss;
typedef unsigned long long ull;
const ll mod=1e18;
const ll inf=1e18;
const double eps=1e-8;
const double pi=acos(-1);

int main(){
    TB
    ll h,w;
    cin>>h>>w;
    if(h==1||w==1){
        cout<<1<<'\n';
        return 0;
    }
    ll sum=w*(h/2);
    if(h&1){
        ll k=w/2;
        if(w&1) k++;
        sum+=k;
    }
    cout<<sum<<'\n';
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		int count = 0;
		for(int i = 0; i < n - 2; i++) {
			if(s.charAt(i) == 'A' && s.charAt(i+1) == 'B' && s.charAt(i+2) == 'C') {
				count++;
				i += 2;
			}
		}
		System.out.println(count);
		sc.close();
	}
}

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

int cnt_char(string s1, string s2) {
    set<char> set1, set2;
    int cnt = 0;
    for (int i=0;i<s1.size();i++) {
        set1.insert(s1[i]);
    }
    for (int i=0;i<s2.size();i++) {
        set2.insert(s2[i]);
    }
    for (auto it=set2.begin();it!=set2.end();it++) {
        if (set1.count(*it) > 0) {
            cnt++;
        }
    }
    return cnt;
}

int main() {
    int n;
    string s;
    int tmp = 0;
    cin >> n >> s;
    for (int i=0;i<n;i++) {
        tmp = max(tmp, cnt_char(s.substr(0, i+1), s.substr(i+1)));
    }
    cout << tmp << endl;
}


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

typedef long long LL;

const int N=5000,mod=1000000007;

int add(int a,int b,int p=mod){return a+b>=p?a+b-p:a+b;}
int sub(int a,int b,int p=mod){return a-b<0?a-b+p:a-b;}
int mul(int a,int b,int p=mod){return (LL)a*b%p;}
void sadd(int &a,int b,int p=mod){a=add(a,b,p);}
void ssub(int &a,int b,int p=mod){a=sub(a,b,p);}
void smul(int &a,int b,int p=mod){a=mul(a,b,p);}

int n,m;

void into(){
  scanf("%d%d",&n,&m);
}

int dp[N+9][N+9];

void Get_dp(){
  for (int i=1;i<=m;++i) dp[0][i]=1;
  for (int i=1;i<=n;++i){
	int sum=0;
	for (int j=1;j<=m;++j){
	  sadd(dp[i][j],mul(dp[i-1][j],j+1));
	  sadd(dp[i][j],sum);
	  sum=add(mul(sum,2),mul(dp[i-1][j],j));
	}
  }
}

void work(){
  Get_dp();
}

void outo(){
  printf("%d\n",dp[n][m]);
}

int main(){
  into();
  work();
  outo();
  return 0;
}

Measured memory_bytes: 101604
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		ArrayDeque<Integer> ans = new ArrayDeque<Integer>();

		while(sc.hasNext()){
			int n = sc.nextInt();
			int m = 100000;
			for(int j=0;j<n;j++){
				m *= 1.05;
				double s = (double)m/1000;
				int t = m/1000;
				if(s!=t)m=(t+1)*1000;
			}
			ans.push(m);
		}
		int num = ans.size();
		for(int i=0;i<num;i++){
			System.out.println(ans.pollLast());
		}
	}
}

Measured memory_bytes: 17156
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;

const int INF = 1e9;
const int mod = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1.0);

int main()
{
    int a,b;
    cin >> a >> b;
    int flag;
    if(a > 0) flag = 1;
    else if(a <= 0 && 0 <= b) flag = 0;
    else{
        if((b+a)%2) flag = 1;
        else flag = -1;
    }

    if(flag) cout << (flag == 1 ? "Positive" : "Negative") << endl;    
    else cout << "Zero" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
int main(int argc, char const* argv[]) {
    std::string s;
    int k;
    std::cin >> s >> k;

    std::vector<std::string> ss;
    int size = s.size();
    for (int i = 0; i < size; ++i) {
        for (int j = 0; j < std::min(k, size - i); ++j) {
            ss.push_back(s.substr(i, j + 1));
        }
    }
    std::sort(ss.begin(), ss.end());
    std::unique(ss.begin(), ss.end());
    std::cout << ss[k - 1] << std::endl;
    return 0;
}


Measured memory_bytes: 1660
#include <stdio.h>

int	main()
{
	char	S[27];
	int	flag, i, n;

	i = 0;
	n = -1;
	flag = 0;
	scanf("%s\n", S);
	while (S[i])
	{
		if (i > 0)
			n = i - 1;
		while (n >= 0)
		{
			if (S[i] == S[n])
				flag = 1;
			n--;
		}
		i++;
	}
	if (flag)
		printf("no\n");
	else
		printf("yes\n");
	return (0);
}

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

/**
 * 課題C3
 *
 * @author ken2
 */
public class Main {

	/** 天気 */
	private static final String[] WEATHER = {"Sunny", "Cloudy", "Rainy"};

	/**
	 * メイン処理

	 * @param args 起動引数
	 */
	public static void main(String[] args) {

		// 標準入力から今日の天気を取得
		String today = scanTodayWeather(System.in);

		// 標準出力へ明日の天気を出力
		String tomorrow = predictTomorrowWeather(today);
		System.out.println(tomorrow);
	}

	/**
	 * 今日の天気を取得
	 *
	 * @param in 入力ストリーム
	 * @return 今日の天気
	 */
	private static String scanTodayWeather(InputStream in) {
		String today = null;
		try {
			InputStreamReader isr = new InputStreamReader(in);
			BufferedReader br = new BufferedReader(isr);
			today = br.readLine();
			br.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return today;
	}

	/**
	 * 今日の天気から明日の天気を予測
	 * ・晴れ→曇り
	 * ・曇り→雨
	 * ・雨→晴れ
	 *
	 * @param today 今日の天気
	 * @return 明日の天気
	 */
	private static String predictTomorrowWeather(String today) {
		String tomorrow = null;
		for (int i=0; i < WEATHER.length; i++) {
			if (today.equals(WEATHER[i])) {
				int p = i < 2 ? i + 1 : 0;
				tomorrow = WEATHER[p];
			}
		}
		return tomorrow;
	}
}


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

int main() {
	int A, B, C;
	cin >> A >> B >> C;
	if (A == 5 && B == 5 && C == 7 ||
		A == 5 && B == 7 && C == 5 ||
		A == 7 && B == 5 && C == 5)
	{
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <bitset>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long int ll;
bool c[5050];
void make(){
    c[0] = true;
    for(int i=1;i<5050;i++) c[i] = false;
}
void orc(int a){
    bool t[5050];
    for(int i=0; i<5050;i++) t[i] = c[i];
    for(int i=0; i<5050-a; i++) if(i+a < 5050) c[i+a] |= t[i];
}

int main(){
    ll n,k,sum=0;
    cin >> n >> k;
    vector<ll> a(n);
    for(int i=0;i<n;i++){cin >> a[i]; sum += a[i];}
    if(sum < k){cout << n << endl; return 0;}
    sort(a.begin(),a.end());
    if(a[0]>=k){cout << 0 << endl; return 0;}
    int ok = 0, ng = n;
    
    while(1 < ng - ok){
        int i = (ng + ok) / 2 - 1;
        if(i<0) i = 0;
        make();
        for(int j=0;j<n;j++){
            if(! (a[j] >= k || j==i)){
                orc(a[j]);
            }
        }
        bool flag = true;
        for(int j=k-a[i];j<k;j++) if(c[j]==1){
                flag = false;
                break;
        }
        if(flag){
            ok = i+1;
        }
        else{
            ng = i+1;
        }
    }

    cout << ok << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define PI                acos(-1)
#define pb                push_back
#define mp                make_pair
#define all(a)            (a).begin(), (a).end()
#define clr(a,h)          memset(a, (h), sizeof(a))
#define forr(i, b, e)     for(ll i = b; i < e; i++)
#define forg(i, b, e, m)  for(ll i = b; i < e; i+=m)
#define F first
#define S second

using namespace std;
using namespace __gnu_pbds;

typedef long long       ll;
typedef pair<ll, ll>  ii;
typedef vector<ll>     vi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
const ll INF = ll(1e18);
#define tam 320000
#define tamlog 61
#define ptr nodo*

typedef pair<ii,ll> iii;
int main()
{
    std::ios::sync_with_stdio(false); cin.tie(0);    
    int n,valor;
    cin>>n;
    map<int,int> mapa;
    forr(i,0,n)
    {
        cin>>valor;
        mapa[valor]++;
    }
    int c=0;
    for(auto ite=mapa.begin();ite!=mapa.end();ite++)
    {
        if (ite->S%2==0)
            c++;
    }
    c%=2;
    //cout<<c<<endl;
        cout<<mapa.size()-c<<endl;

}
// PLUS ULTRA!

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

using namespace std;

template <long long Mod> struct ModInt {
  long long v;
  constexpr ModInt(const long long x = 0) {
    v = x % Mod;
    if (v < 0) {
      v += Mod;
    }
  }
  constexpr ModInt operator+(const ModInt rhs) const {
    return ModInt(*this) += rhs;
  }
  constexpr ModInt operator-(const ModInt rhs) const {
    return ModInt(*this) -= rhs;
  }
  constexpr ModInt operator*(const ModInt rhs) const {
    return ModInt(*this) *= rhs;
  }
  constexpr ModInt operator/(const ModInt rhs) const {
    return ModInt(*this) /= rhs;
  }
  const ModInt &operator+=(const ModInt rhs) {
    v += rhs.v;
    if (v >= Mod) {
      v -= Mod;
    }
    return *this;
  }
  constexpr ModInt &operator-=(const ModInt rhs) {
    if (v < rhs.v) {
      v += Mod;
    }
    v -= rhs.v;
    return *this;
  }
  constexpr ModInt &operator*=(const ModInt rhs) {
    v = v * rhs.v % Mod;
    return *this;
  }
  constexpr ModInt &operator/=(ModInt rhs) {
    long long exp = Mod - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
  friend ostream &operator<<(ostream &s, ModInt<Mod> m) {
    s << m.v;
    return s;
  }
  friend istream &operator>>(istream &s, ModInt<Mod> m) {
    s >> m.v;
    return s;
  }
};

const int mod = 998244353;
using modint = ModInt<mod>;

int main() {
  int N, S;
  cin >> N >> S;
  vector<int> A(N);
  for (auto &a : A) {
    cin >> a;
  }
  vector<vector<modint>> dp(N + 1, vector<modint>(S + 1));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < S + 1; j++) {
      if (j == 0) {
        dp[i][j] += 1;
      }
      dp[i + 1][j] += dp[i][j];
      if (j + A[i] < S + 1) {
        dp[i + 1][j + A[i]] += dp[i][j];
      }
    }
  }
  modint ans = 0;
  for (int i = 1; i <= N; i++) {
    ans += dp[i][S];
  }
  cout << ans.v << endl;

  return 0;
}


Measured memory_bytes: 70784
from sys import stdin
n = int(stdin.readline())
a = []
b = []
for _ in xrange(n):
 x,y = map(int,stdin.readline().split())
 a.append(x)
 b.append(y)
x = a[0]
y = b[0]
for i in xrange(1,n):
 fir = a[i]
 sec = b[i]
 if fir>=x and sec >= y:
  x = fir;y=sec
 elif fir>=x:
  k = y/sec
  if y%sec:
   k+=1
  x = fir * k
  y = sec * k
 elif sec>=y:
  k = x/fir
  if x%fir:
   k += 1
  x = fir * k
  y = sec * k
 else:
  u = x/fir
  if x%fir:
   u+=1
  v = y/sec
  if y%sec:
   v+=1
  k = u
  if v > k:
   k = v
  x = fir * k
  y = sec * k



print x + y

Measured memory_bytes: 2816
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
	string s;
	cin >> s;
	int N = s.size();

	cout << s[0];
	cout << N-2;
	cout << s[N-1] <<endl;
    
	return 0;
}













Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f1(n) for(int i=0;i<n;++i)
#define f2(n) for(int i=1;i<=n;++i)
#define mp make_pair
using namespace std;
typedef long long ll;
typedef long double llf;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;
const int maxn = 2e5 + 5;
const int maxm = 18;
const ll Mod = 1e9 + 7;
const ll INF = 1e9 + 7;

ll a[maxn];

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

	ll n, m;
	cin >> n >> m;

	for (int i = 0; i < m; ++i) {
		ll aa;
		cin >> aa;
		n -= aa;
	}
	if (n < 0)cout << "-1\n";
	else cout << n << endl;


	return 0;
}

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

int n, k, a, x[500000], dp[500000][2], chain, maxn;
bool hakushi, ok;
vector<int>p;

int main() {
	while (true) {
		hakushi = false;
		for (int i = 0; i < 500000; i++) { x[i] = 0; dp[i][0] = 0; dp[i][1] = 0; }
		cin >> n >> k;
		if (n == 0 && k == 0) { break; }
		for (int i = 0; i < k; i++) {
			cin >> a;
			if (a == 0) { hakushi = true; }
			else { x[a] = 1; }
		}
		if (hakushi == false) {
			chain = 0; maxn = 0;
			for (int i = 1; i <= n; i++) {
				if (x[i] == 1) {
					chain++;
				}
				else {
					maxn = max(maxn, chain);
					chain = 0;
				}
			}
		}

		else {
			maxn = 0;
			for (int i = 1; i <= n; i++) {
				if (x[i] == 1) {
					dp[i][0] = max(dp[i][0], dp[i - 1][0] + 1);
					dp[i][1] = max(dp[i][1], dp[i - 1][1] + 1);
				}
				else {
					dp[i][0] = 0;
					dp[i][1] = max(dp[i][1], dp[i - 1][0] + 1);
				}
			}
			for (int i = 1; i <= n; i++) { maxn = max(maxn, max(dp[i][0], dp[i][1])); }
		}

		cout << maxn << endl;
	}
	return 0;
}

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

const int	MAX = 510000;
const int	MOD = 1000000007;

void	Primes(long M, vector<vector<int> > &P) {
	int i=2;
	P.push_back({1, 0});
	while (M !=1) {
		if (0==M%i) {
			if (i==P.back().at(0)) {
				P.back().at(1)++;
			} else {
				P.push_back({i, 1});
			}
			M /=i;
		} else i++;
	}
}

void	CombInit(vector<long> &fac, vector<long> &finv, vector<long> &inv) {
	fac.at(0) = fac.at(1) =1;
	finv.at(0) = finv.at(1) =1;
	inv.at(1) = 1;
	for (int i=2; i<MAX; i++) {
		fac.at(i) = fac.at(i-1) * i % MOD;
		inv.at(i) = MOD - inv.at(MOD%i) * (MOD / i) % MOD;
		finv.at(i) = finv.at(i-1) * inv.at(i) % MOD;
	}
}

long	Comb(long n, long k, vector<long> &fac, vector<long> &finv) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac.at(n) * (finv.at(k) * finv.at(n-k) % MOD) % MOD;
}

int	main() {
	int N;
	long M;
	cin >>N >>M;
	vector<vector<int> > P;
	Primes(M, P);
	long S=1;
	vector<long> fac(MAX), finv(MAX), inv(MAX);
	CombInit(fac, finv, inv);
	for (int i=1; i<P.size(); i++) {
		S *= Comb(N+P.at(i).at(1)-1, N-1, fac, finv);
		S %=1000000007;
	}
	cout <<S <<endl;
	return 0;
}


Measured memory_bytes: 12160
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)
 
const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);
 
using namespace std;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    ll N,L,T;
    cin >> N >> L >> T;
    vector<ll> X(N),W(N),ans(N);
    rep(i,N){
        cin >> X[i] >> W[i];
        // とりあえず直進させるとT秒後にありのいる場所がわかる
        if(W[i]==1)ans[i] = (X[i] + T) % L;
        else {
            ans[i] = (X[i] - T + (L*(ll)1e9) ) % L;
        }
    }
    sort(ALL(ans));
    ll count = 0;
    rep(i,N){
        if(W[i]==1)count -=( T - (L-X[i]) + L)/ L;
        else count += ( T - (X[i] + 1) + L) / L;
    }
    count = (count % N + N ) % N;
    vector<ll>res(N);
    rep(i,N){
        res[(i+count)%N] = ans[i];
    }
    rep(i,N)cout << res[i] << endl;
}

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

#define GO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int

const int maxr = 1e5 + 5;


int best(int x) {
	for (int i = 1; true; i++) {
		int value = (i * (i + 1)) / 2;
		if (value > x)
			return i - 1;
	}
}

int32_t main()
{
	GO;
	int n;
	cin >> n;
	int ans = 0;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0) {
			int count = 0;
			while (n % i == 0) {
				n /= i;
				count++;
			}
			ans += best(count);
		}
	}
	if (n > 1)
		ans ++;
	cout << ans << endl;
	return 0;
}

//!

Measured memory_bytes: 3604
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
using namespace std;

int main()
{
	int a[200]={0};
	char str[200];
	scanf("%s",str);
	int flag=0;
	for(int i=0;i<strlen(str);i++)
	{
		if(a[str[i]-'a']==0)
		{
			a[str[i]-'a']++;
		}
		else
		{
			flag=1;
			break;
		}
	}
	if(flag==1)
	{
		printf("no\n");
	}
	else
	{
		printf("yes\n");
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if (a <= 9 && b <= 9) {
            System.out.println(a * b);
        } else {
            System.out.println(-1);
        }
    }
}


Measured memory_bytes: 21844
let () =
    let main () =
        let n, k = Scanf.sscanf (read_line ()) "%d %d" (fun n k -> n, k) in
        if 2 * k - 1 > n then print_endline "-1" else (
            let m1, m2 = n / 2, n - n / 2 in
            let a = Array.make n 0 in
            let b = Array.make n 0 in
            let c = Array.init n (fun i -> i + k + 2 * n) in
            for i = 0 to m2 - 1 do
                a.(i * 2) <- i + k;
                b.(i * 2) <- i + k + n + m1
            done;
            for i = 0 to m1 - 1 do
                a.(i * 2 + 1) <- i + k + m2;
                b.(i * 2 + 1) <- i + k + n
            done;
            for i = 0 to n - 1 do
                Printf.printf "%d %d %d\n" a.(i) b.(i) c.(i)
            done
        )
    in
    main ()

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

int main() {
    int a, b, c; cin >> a >> b >> c;

    int ans = 0;
    int i = 0;
    while(ans < c) {
        i++;
        ans += a;
        if (i % 7 == 0 && i != 1) {
            ans += b;
        }
    }

    cout << i <<  endl;
}


Measured memory_bytes: 3100
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<map>
#include<queue>
#include<ostream>
#include<cstring>
using namespace std;
int main(){
	
    long long a,b,k,sum=0,ans=0;
    cin>>a>>b>>k;
    if(k<=a){
        sum=a-k;
        ans=b;
    }else if(k<=a+b){
        sum=0;
        ans=a+b-k;
    }else{
        sum=0;
        ans=0;
    }
    cout<<sum<<" "<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
n=int(input())
X=list(map(int,input().split()))
x=X[0]
def gcd(a,b):
    while b:
        a,b=b,a%b
    return a


for i in range(1,n):
    x=gcd(x,X[i])
if x!=1:
    print(x)
else:
    print(1)


Measured memory_bytes: 14228
#%%
import sys
def input():
    return sys.stdin.readline().rstrip()

def main():
    a = int(input())
    s = input()

    if a >= 3200:
        print(s)
    else:
        print('red')

# %%
if __name__ == '__main__':
    main()

# %%
# from atcoder_test import doTest
# doTest("abc138","a",main)

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

typedef long int lint;
typedef long long int llint;
typedef pair<int, int> pii;
typedef pair<int, string> pis;
typedef pair<long, long> pll;

#define EACH(i, c) for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOR(i, s, e) for (int i = (s); i < (int)(e); ++i)
#define REP(i, n) FOR(i, 0, n)
#define endl "\n"

const int INF = 100000000;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

template<typename T>
void print(const std::vector<T>& v, char sep=' ') {
  for (int i = 0; i < (int)v.size(); i++) {
    if (i != 0) cout << sep;
    cout << v[i];
  }
  cout << endl;
}

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

  lint a[3];
  REP(i, 3) cin >> a[i];

  sort(a, a + 3);
  if (a[2] % 2 == 0)  cout << "0";
  else cout << a[0] * a[1];
  cout << endl;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main(){
  int N, c, l, r;
  int count = 0;
  cin >> N;
  for(int i = 0; i < N; ++i){
    cin >> l >> r;
    c = r - l + 1;
    count += c;
  }
  
  cout << count << endl;
}

Measured memory_bytes: 256
l = raw_input().split()
N = int(l[0])
M = int(l[1])

L = []
R = []

for i in range(M):
    l = raw_input().split()
    L.append(int(l[0]))
    R.append(int(l[1]))

l = max(L)
r = min(R)
# print(l, r)
if l > r:
    print(0)
else:
    print(r - l + 1)


Measured memory_bytes: 12164
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>

using namespace std;

int main(int argc, char *argv[]) {
  // read inputs
  long N, A, B, C, D;
  scanf("%ld %ld %ld %ld %ld", &N, &A, &B, &C, &D);

  // solve
  const long diff = B - A, Nm1 = N - 1;
  if (C == 0) {
    if (diff <= D * Nm1 || diff >= -D * Nm1) {
      printf("YES\n");
    } else {
      printf("NO\n");
    }
  } else {
    const long kl = floor(0.5 * (Nm1 + ((double)diff) / C)), ku = kl + 1;
    const long lower = C * (2 * kl - Nm1);
    const long upper = C * (2 * ku - Nm1);
    if ((kl >= -Nm1 && kl <= Nm1 && lower + kl * (D - C) >= diff) ||
        (ku >= -Nm1 && ku <= Nm1 && upper - (Nm1 - ku) * (D - C) <= diff) ||
        (C * Nm1 <= abs(diff) && D * Nm1 >= abs(diff))) {
      printf("YES\n");
    } else {
      printf("NO\n");
    }
  }

  return 0;
}


Measured memory_bytes: 128
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        a: u16,
        b: u16,
    }
    println!("{}", a * b - a - b + 1);
}


Measured memory_bytes: 2072