akhauriyash/Code-Regression huggingface dataset:
n = int(input())
a = list(map(int, input().split()))


def calc(val):
    # valには、１か−１を入れる。
    if (val * a[0] > 0):
        # 狙った符号のパターン
        temp = a[0]
        ans01 = 0

    else:
        # 違うパターン
        add = abs(a[0]) + 1
        ans01 = add
        temp = val

    for i in range(1, n):
        tar = temp + a[i]
        if (tar * temp < 0):
            temp = tar
        else:
            add = abs(tar) + 1
            ans01 += add
            if (temp > 0):
                temp = -1
            else:
                temp = 1

    return ans01


ans = min(calc(1), calc(-1))


print(ans)


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

using namespace std;
typedef  long long ll;

#define sint(a) scanf("%d",&a)
#define sint2(a,b) scanf("%d %d",&a,&b)
#define sll(a) scanf("%lld",&a)
#define sll2(a,b) scanf("%lld %lld",&a,&b)
#define mem(a,i) memset(a,i,sizeof(a))
const int maxn=1e6+5;
const int mod=1e9+7;
string name[100];
int t[100];
int main()
{
    int n;
    cin>>n;
    int sum=0;
    for(int i=0; i<n; i++)
    {
        cin>>name[i]>>t[i];
        sum+=t[i];
    }
    string ss;
    cin>>ss;
    int sum1=0;
    for(int i=0; i<n; i++)
    {
        if(name[i]==ss)
        {
            sum1+=t[i];
            break;
        }
        else
            sum1+=t[i];
    }
    printf("%d\n",sum-sum1);
    return 0;
}


Measured memory_bytes: 256
import math
from itertools import permutations
N=int(input())
XYlist=[]
indexlist=[i for i in range(N)]
for _ in range(N):
    XYlist.append(tuple(map(int,input().split())))
ans=0
num=0
for indexes in permutations(indexlist,N):
    for i in range(N-1):
        ans+=math.sqrt((XYlist[indexes[i]][0]-XYlist[indexes[i+1]][0])**2+
                       (XYlist[indexes[i]][1]-XYlist[indexes[i+1]][1])**2)
    num+=1
print(ans/num)

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

int main() {
  map<string, string> w{
    {"Sunny", "Cloudy"},
    {"Cloudy", "Rainy"},
    {"Rainy", "Sunny"}
  };
  string s;
  cin >> s;
  cout << w[s];
  return 0;
}


Measured memory_bytes: 256
/*
 ▓█████▄  ▄████▄  ▓██   ██▓ ██▓███   ██░ ██ ▓█████  ██▀███
▒██▀ ██▌▒██▀ ▀█   ▒██  ██▒▓██░  ██▒▓██░ ██▒▓█   ▀ ▓██ ▒ ██▒
 ░██   █▌▒▓█    ▄   ▒██ ██░▓██░ ██▓▒▒██▀▀██░▒███   ▓██ ░▄█ ▒
 ░▓█▄   ▌▒▓▓▄ ▄██▒  ░ ▐██▓░▒██▄█▓▒ ▒░▓█ ░██ ▒▓█  ▄ ▒██▀▀█▄
 ░▒████▓ ▒ ▓███▀ ░  ░ ██▒▓░▒██▒ ░  ░░▓█▒░██▓░▒████▒░██▓ ▒██▒
  ▒▒▓  ▒ ░ ░▒ ▒  ░   ██▒▒▒ ▒▓▒░ ░  ░ ▒ ░░▒░▒░░ ▒░ ░░ ▒▓ ░▒▓░
  ░ ▒  ▒   ░  ▒    ▓██ ░▒░ ░▒ ░      ▒ ░▒░ ░ ░ ░  ░  ░▒ ░ ▒░
  ░ ░  ░ ░         ▒ ▒ ░░  ░░        ░  ░░ ░   ░     ░░   ░
    ░    ░ ░       ░ ░               ░  ░  ░   ░  ░   ░
  ░      ░         ░ ░
*/
//focus less on how much problem you should solve within a fixed time and focus more on getting the problem solved and
//learning something from it
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define per(i,a,b) for(ll i=a; i>=b; i--)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vii vector <pair<ll,ll> >
#define sedes set <ll, greater <ll> >
#define seasc set <ll>
#define pb push_back
#define mkp make_pair
#define ff first
#define ss second
// #define MOD 1000000007
#define prec(n) fixed<<setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define umap unordered_map<ll, ll>
#define map map<ll, ll>
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define mems(a, i) memset(a, i, sizeof(a))
#define endl '\n'
#define all(v) v.begin(),v.end()
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define deba(a) cout << #a << " " <<a << endl;
ll MOD;
ll power(ll a, ll n)
{
	ll res = 1;
	while (n > 0)
	{
		if (n % 2 == 0)
			a = ((a % MOD) * (a % MOD)) % MOD, n /= 2;
		else
			res = ((res % MOD) * (a % MOD)) % MOD , n--;
	}
	return res;
}
int main()
{
	fast;
#ifndef ONLINE_JUDGE
	freopen("D:\\input.txt", "r", stdin);
	freopen("D:\\output.txt", "w", stdout);
#endif
	int t = 1;
	// cin >> t;
	while (t--)
	{
		ll n, x, m;
		cin >> n >> x >> MOD;

		ll bcy = x, cy = 0, ncy = 0, nbcy = 1;

		vi vis(MOD + 1, 0);
		vi idx(MOD + 1, 0);
		vi cys;
		ll br = -1;
		while (true)
		{
			ll y = power(x, 2) % MOD;
			// cout << y << " ";
			if (vis[y])
			{
				if (y == br)
					break;
				else if (br == -1)
					br = y;
				bcy -= y;
				cy += y;
				ncy++;
				nbcy--;
				cys.pb(y);
			}
			else
			{
				bcy += y;
				nbcy++;
				vis[y] = 1;
			}
			x = y;
		}

		// deba(bcy);
		// deba(cy);

		ll sum = 0, left = 0;
		ll sz = (n - nbcy) / ncy;
		ll j = (n - nbcy) % ncy;
		// deba(sz);
		// deba(j);
		rep(i, 0, j)
		left += cys[i];
		sum = bcy + (cy * sz) + left;
		cout << sum << endl;



	}
	return 0;
}

Measured memory_bytes: 5316
#include <bits/stdc++.h>
using namespace std;
int n,m;
char a[51][51];
int i,j;
bool s;
void check_U()
{
	if(i!=0&&a[i-1][j]=='#')
		s=true;
}
void check_D()
{
	check_U();
	if(i!=n-1&&a[i+1][j]=='#')
		s=true;
}
void check_L()
{
	check_D();
	if(j!=0&&a[i][j-1]=='#')
		s=true;
}
void check_R()
{
	check_L();
	if(j!=m-1&&a[i][j+1]=='#')
		s=true;
}
void check()
{
	check_R();
}
int main()
{
	scanf("%d %d",&n,&m);
	getchar();
	for(i=0;i<n;i++)
	{
		for(j=0;j<m;j++)
		{
			scanf("%c",&a[i][j]);
		}
		getchar();
	}
	for(i=0;i<n;i++)
	{
		for(j=0;j<m;j++)
		{
			if(a[i][j]=='.')
				continue;
			s=false;
			check();
			if(!s)
			{
				printf("No");
				return 0;
			}
		}
	}
	printf("Yes");
	return 0;
}

Measured memory_bytes: 256
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    H, W = map(int, readline().split())
    A = [list(map(int, readline().split())) for _ in range(H)]
    B = [list(map(int, readline().split())) for _ in range(H)]

    M = 0
    G = [[0] * W for _ in range(H)]
    for i in range(H):
        for j in range(W):
            G[i][j] = abs(A[i][j] - B[i][j])
            if M < G[i][j]:
                M = G[i][j]

    M = 20000
    dp = [[0] * W for _ in range(H)]
    dp[0][0] = 1 << (M + G[0][0]) | 1 << (M - G[0][0])

    for i in range(H):
        for j in range(W):
            if i + 1 < H:
                dp[i + 1][j] |= (dp[i][j] >> G[i + 1][j]) | (dp[i][j] << G[i + 1][j])
            if j + 1 < W:
                dp[i][j + 1] |= (dp[i][j] >> G[i][j + 1]) | (dp[i][j] << G[i][j + 1])

    ans = INF
    for i in range(2 * M + 2):
        if dp[H - 1][W - 1] >> i & 1 and ans > abs(i - M):
            ans = abs(i - M)

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 93700
import std.algorithm,
       std.string,
       std.array,
       std.range,
       std.stdio,
       std.conv;

void main() {
  ulong N = readln.chomp.to!ulong;
  ulong[2][] TAs = N.iota.map!(_ => readln.chomp.split.to!(ulong[2])).array;

  ulong gt, ga;

  foreach (idx, TA; TAs) {
    ulong t = TA[0],
          a = TA[1];

    if (gt <= t && ga <= a) {
      gt = t;
      ga = a;
    } else if (gt > t && ga > a) {
      ulong _a = (t + gt - 1) / t,
            _b = (a + ga - 1) / a;

      if (_a > _b) {
        gt = _a * t;
        ga = _a * a;
      } else {
        gt = _b * t;
        ga = _b * a;
      }
    } else {
      ulong tmp;

      if (ga > a) {
        tmp = (a + ga - 1) / a;
      } else {
        tmp = (t + gt - 1) / t;
      }

      gt = tmp * t;
      ga = tmp * a;
    }
  }

  writeln(gt + ga);
}


Measured memory_bytes: 508
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}
vector<int> G[100100];
int N; ll M;
ll d[100100];
int cnt[100100];
int cnta = 0;
ll c[100100]; 
bool check[100100];
void bfs() {
    queue<int> que;
    rep(i, N) {
        if(cnt[i] == 1) {
            que.push(i);
            check[i] = true;
        }
    }
    while(que.size()) {
        int p = que.front(); que.pop();
        d[p] = c[cnta];
        if(cnta == N - 1) break;
        M += d[p];
        cnta ++;
        int k = G[p][0];
        cnt[k] --;
        for(auto it = G[k].begin() ; it != G[k].end(); it++) {
            if(*it == p) {
                G[k].erase(it);
                break;
            }
        }
        if(check[k] == false && cnt[k] == 1) {
            que.push(k); check[k] = true;
        }
    }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N;
  rep(i, N - 1) {
      int a, b;cin >> a >> b; a --; b --;
      G[a].push_back(b);
      G[b].push_back(a);
  }
  rep(i, N) cin >> c[i];
  sort(c, c + N);
  rep(i, N) cnt[i] = G[i].size();
  rep(i, N) check[i] = false;
  bfs();
  cout << M << endl;
  rep(i, N) cout << d[i] << " ";
  cout << endl;
  return 0;
}


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

using ll = long long;

constexpr ll MOD = 1e9+7;
constexpr ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

ll toh[300*300+10];
ll tow[300*300+10];
ll dp[300*300+10];

int main(int argc, char **argv)
{
	ll H, W, D; cin >> H >> W >> D;
	REP(h, H)REP(w, W)
	{
		ll a; cin >> a;
		toh[a] = h;
		tow[a] = w;
	}

	memset(dp, 0, sizeof dp);

	for (ll i = D+1; i <= H*W; ++i)
	{
		ll k = i - D;
		dp[i] = dp[k] + abs(toh[i] - toh[k]) + abs(tow[i] - tow[k]);
	}

	ll Q; cin >> Q;
	REP(_, Q)
	{
		ll l, r; cin >> l >> r;
		std::cout << dp[r] - dp[l] << std::endl;
	}
}


Measured memory_bytes: 3200
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
 
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define C(i) cin>>i
#define C2(i,j) cin>>i>>j
#define C3(i,j,k) cin>>i>>j>>k
#define C4(i,j,k,m) cin>>i>>j>>k>>m
////////////////////////////////////////////////////////////

int main(){
  int n,k;
  cin >> n >> k;
  long long ans = 1;
  rep(i,0,n){
    if(i==0){
      ans *= k;
    }
    else{
      ans *= k-1;
    }
  }
  
  P(ans);
  ret 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let h: usize = read();
    let w: usize = read();
    let mut costs = vec![vec![0 as i32; 10]; 10];
    for from in 0..10 {
        for to in 0..10 {
            costs[from][to] = read();
        }
    }
    for k in 0..10 {
        for i in 0..10 {
            for j in 0..10 {
                costs[i][j] = std::cmp::min(costs[i][j], costs[i][k] + costs[k][j]);
            }
        }
    }
    let mut ans = 0;
    for _y in 0..h {
        for _x in 0..w {
            let v: i32 = read();
            if v == -1 {
                continue;
            }
            ans += costs[v as usize][1];
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
# python3.4.2用
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from decimal import *
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
INF = float('inf') #無限大
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(sys.stdin.readline()) #整数読み込み
def ifn(): return float(sys.stdin.readline()) #浮動小数点読み込み
def isn(): return sys.stdin.readline().split() #文字列読み込み
def imn(): return map(int, sys.stdin.readline().split()) #整数map取得
def imnn(): return map(lambda x:int(x)-1, sys.stdin.readline().split()) #整数-1map取得
def fmn(): return map(float, sys.stdin.readline().split()) #浮動小数点map取得
def iln(): return list(map(int, sys.stdin.readline().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, sys.stdin.readline().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def m_add(a,b): return (a+b) % MOD
def lprint(l): print(*l, sep='\n')
def sieves_of_e(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n+1, i): is_prime[j] = False
    return is_prime

N,A,B = imn()

min_v = A+B+((N-2)*A)
max_v = A+B+((N-2)*B)
print(max(0, max_v-min_v+1))


Measured memory_bytes: 5300
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch Test | diff Test.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address Test.cpp && ./a.out

/*

 5/19/2020

 23:27-

 */

const int MAX_N=1e6+1;
int S[MAX_N],T[MAX_N],C[MAX_N];
int N,CN;

void solve() {
  VV<II> xs(CN);
  REP(i,N) {
    int l=S[i],r=T[i],c=C[i];
    xs[c].emplace_back(l,r);
  }
  FORR(x,xs) sort(ALL(x));
  VV<II> ys(CN);
  REP(c,CN) REP(i,SZ(xs[c])) {
    int l=xs[c][i].first,r=xs[c][i].second;
    if(ys[c].empty()||ys[c].back().second<l) ys[c].emplace_back(l,r);
    else ys[c].back().second=r;
  }

  map<int,int> imos;
  REP(c,CN) FORR(p,ys[c]) {
    imos[p.first]++,imos[p.second]--;
  }
  int res=0,cur=0;
  FORR(kvp,imos) {
    cur+=kvp.second;
    SMAX(res,cur);
  }
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;

  cin>>N>>CN;
  REP(i,N) cin>>S[i]>>T[i]>>C[i],--S[i],C[i]--;
  solve();

  return 0;
}


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

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

 int main(){
  int h, w;

  cin >> h >> w;
  char a[h+2][w+2];

  rep(i,h+2) {
    rep(j,w+2) {  
     a[i][j] = '#';
    }
  }

  rep(i,h) {
    rep(j,w) {  
     cin >> a[i+1][j+1];  
    }
  }

  rep(i,h+2) {
    rep(j,w+2) {  
     cout << a[i][j];  
    }
    cout << endl;
   }
  cout << endl;

 return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end())
#define uniq(a)         SORT(a);(a).erase(unique((a).begin(), (a).end()), (a).end())
#define reverse(a)      reverse((a).begin(), (a).end())
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define Yes()           printf("Yes\n")
#define No()            printf("No\n")
#define YES()           printf("YES\n")
#define NO()            printf("NO\n")
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

using namespace std;
using ll = long long;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7

void solve() {
  string s; cin >> s;
  outl(s.substr(0, s.size() - 8));
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 888
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n, y = list(map(int, readline().split()))

    for n10 in range(n + 1):
        rest = n - n10
        for n5 in range(rest + 1):
            n1 = rest - n5
            m = n10 * 10000 + n5 * 5000 + n1 * 1000
            if m == y:
                print(n10, n5, n1)
                sys.exit()

    print(-1, -1, -1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
// B.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>

using namespace std;

int main(int argc, char *argv[]) {
	int n;
	cin >> n;
	vector<pair<string, pair<int, int>>> v;
	for (int i = 0; i < n; ++i) {
		string s;
		int p;
		cin >> s >> p;
		v.push_back(make_pair(s, make_pair(-p, i + 1)));
	}
	sort(v.begin(), v.end());
	for (int i = 0; i < n; ++i) {
		cout << v[i].second.second << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S;cin>>S;
  if(S.size()%2==0){
    int i;
    for(i=0;i<S.size();i++){
      if((i%2==0&&S.at(i)!='h')||(i%2==1&&S.at(i)!='i'))break;
    }
    if(i==S.size())cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pi 3.1415926535897932384626
using namespace std;
      
struct P{
  long long x,y;
  bool operator < (const P &a )const{
    //if(y!=a.y)
    return y<a.y;
  };
};

int a,b,c,d,i,k,n,m,e,dx[10]={1,0,-1,0,1,1,-1,-1},dy[10]={0,1,0,-1,1,-1,1,-1};
int o[500101];
int l[500101];
int j[500101];

long long x,y,z,mod=1000000007;
//string r;
char r[3];

P u[1];
queue<P> q;
stack<int> s;
//set<int> s;
map<int,int> p;

vector<int> v[3];


bool as(P a,P b)
{
  if(a.x!=b.x)
  return a.x<b.x;
  return a.y>b.y;
}

int main()
{
  scanf("%d %d",&a,&b);
  o[0]=b;
  for(int t=1;t<=a;t++)
  {
    scanf("%d",&l[t]);
    o[t]=min(o[t-1],abs(o[t-1]-l[t]));
  }
  for(int t=a;t>0;t--)
  if(l[t+1]>=l[t]/2) l[t]=l[t+1]+l[t];
  else l[t]=l[t+1];
  //for(int t=1;t<=a;t++)
  //printf("%d ",l[t]);
  //puts("");
  scanf("%d",&c);
  for(int t=1;t<=c;t++)
  {
    scanf("%d",&n);
    if(l[n+1]>=o[n-1]) puts("NO");
    else puts("YES");
  }
}
//3
//21




Measured memory_bytes: 5888
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
using namespace std;

int main(){
	
	char b;
	long long int c,s;
	
	cin>>s;
	while(1){
		cin>>b;
		if(b!='='){
			cin>>c;
		if(b=='+')
			s+=c;
		else if(b=='-')
			s-=c;
		else if(b=='*')
			s=s*c;
		else if(b=='/')
			s=s/c;
		}
		else{
			cout<<s<<endl;
			break;
		}
	}
	
}

Measured memory_bytes: 1156
#include<stdio.h>
#define INFTY (1 << 21)
#define SHIRO 0
#define NEZUMI 1
#define KURO 2
#define MAX 100
int n;
int M[MAX][MAX];

void Dijkstra();

int main(){
  int i, j;


  int s, t, u, v;

  scanf("%d",&n);

  for(i = 0 ; i < n ; i++){


    for(j = 0 ; j < n ; j++){




      M[i][j] = INFTY;
    }
  }

  for(i = 0 ; i < n ; i++){
    scanf("%d%d",&s,&t);

    for(j = 0 ; j < t ; j++){
      scanf("%d%d",&u,&v);
      M[s][u] = v;
    }
  }

  Dijkstra();

  return 0;
}

void Dijkstra(){
  int i=0;
  int min, s, v;
  int d[MAX];
  int iro[MAX];

  while(i<n){
    i++;
    d[i] = INFTY;
    iro[i] = SHIRO;
  }

  d[0] = 0;
  iro[0] = NEZUMI;

  while(1){
    min = INFTY;
    s = -1;
    for(i = 0 ; i < n ; i++){
      if(min > d[i] && iro[i] != KURO){
	s = i;
	min = d[i];
      }
    }

    if(s == -1) break;

    iro[s] = KURO;



    for(v = 0 ; v < n ; v++){
      if(iro[v] != KURO && M[s][v] != INFTY){
	if(d[s] + M[s][v] < d[v]){
    
	  d[v] = d[s] + M[s][v];
	  iro[v] = NEZUMI;
	}
      }
    }
  }

  for(i = 0 ; i < n ; i++){



    printf("%d ",i);

    if(d[i] == INFTY) printf("-1\n");



    else printf("%d\n",d[i]);
  }
}



Measured memory_bytes: 2112
#include<bits/stdc++.h>
using namespace std;
int a,b;
int main() {
    cin>>a>>b;
    if((a+b)%3==0 || a%3==0 || b%3==0)
    cout<<"Possible"<<endl;
    else
    cout<<"Impossible"<<endl;
    return 0;
}

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

int main(void)
{
    string s, t;

    cin >> s >> t;

    int cn = 0;
    for(int i = 0; i < s.size(); ++i)
    {
        if(s[i] != t[i]) ++cn;

    }

    cout << cn << endl;
    
    return 0;
}



Measured memory_bytes: 3820
object Main {
  def main(args: Array[String]): Unit = {
    val s = new Main()
    s.solve()
    s.out.flush()
  }
}

class Main {
  import java.io._
  import java.util.StringTokenizer

  import scala.collection.mutable
  import scala.util.Sorting
  import math.{abs, max, min}
  import mutable.{ArrayBuffer, ListBuffer}
  import scala.reflect.ClassTag

  val MOD = 1000000007
  val out = new PrintWriter(System.out)

  def solve(): Unit = {
    val N, M = ni()
    val S = ns(N)
    val T = ns(M)
    val g = gcd(N, M)
    val n = N / g
    val m = M / g
    val ok = 0 until g forall { i =>
      S(n * i) == T(m * i)
    }

    if (ok) {
      out.println(N.toLong * M / g)
    } else {
      out.println(-1)
    }
  }

  def gcd(a: Int, b: Int): Int = {
    if (b == 0) a
    else gcd(b, a % b)
  }

  class InputReader(val stream: InputStream) {
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer = _

    def next(): String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next().toInt
    def nextLong(): Long = next().toLong
    def nextChar(): Char = next().charAt(0)
  }
  val sc = new InputReader(System.in)
  def ni(): Int = sc.nextInt()
  def nl(): Long = sc.nextLong()
  def nc(): Char = sc.nextChar()
  def ns(): String = sc.next()
  def ns(n: Int): Array[Char] = ns().toCharArray
  def na(n: Int): Array[Int] = map(n)(_ => ni())
  def nal(n: Int): Array[Long] = map(n)(_ => nl())
  def nm(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))
  def rep(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = offset
    val N = n + offset
    while(i < N) { f(i); i += 1 }
  }
  def rep_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = n - 1 + offset
    while(i >= offset) { f(i); i -= 1 }
  }

  def map[@specialized A: ClassTag](n: Int)(f: Int => A): Array[A] = {
    val res = Array.ofDim[A](n)
    rep(n)(i => res(i) = f(i))
    res
  }

  def sumL(as: Array[Int]): Long = {
    var s = 0L
    rep(as.length)(i => s += as(i))
    s
  }
}

Measured memory_bytes: 29328
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define erep(i, n) for (int i = 0; i <= (n); i++)
#define erep1(i, n) for (int i = 1; i <= (n); i++)
using namespace std;
using ll = long long;
#define PI 3.141592653589793

int main() {
    double a, b, h, m;
    cin >> a >> b >> h >> m;
    double r, rh, rm;
    h += m / 60;
    rh = 30 * h;
    rm = 6 * m;
    if (rh > rm) r = rh - rm;
    else
        r = rm - rh;
    double radian = r * (PI / 180);
    double c2 = a * a + b * b - (a * b * cos(radian) * 2);
    double c = sqrt(c2);
    printf("%.15lf\n", c);
}

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

int main(){
  string s;
  int x,y;
  cin>>s>>x>>y;
  int N=s.size();
  int i;
  for(i=0;i<N;i++)if(s[i]=='T')break;
  x-=i;
  x=max(x,-x);
  y=max(y,-y);
  int j=i;
  int k=0;
  int out=0;
  for(i=j+1;i<N;i++)if(s[i]=='T')k++;
  std::vector<int> vx((k+1)/2),vy(k/2+1);
  int l=-1;
  int ix=0;
  int iy=0;
  int ka=0;
  for(i=j+1;i<N;i++){
    if(s[i]=='T'){
      if(l==1){
        vx[ix]=ka;
        ix++;
      }
      else{
        vy[iy]=ka;
        iy++;
      }
      l*=-1;
      ka=0;
    }
    else ka++;
  }
  if(s[N-1]=='F'){
    if(l==1){
      vx[ix]=ka;
      ix++;
    }
    else{
      vy[iy]=ka;
      iy++;
    }
  }
  sort(vx.begin(),vx.end());
  sort(vy.begin(),vy.end());
  int xc=0;
  for(int i=0;i<(k+1)/2;i++)xc+=vx[i];
  //cout<<54321<<" "<<xc<<endl;
  xc-=x;
  //cout<<54321<<" "<<xc<<endl;
  if(xc%2||xc<0)out++;
  else{
    xc/=2;
    vector<vector<bool>> hx((k+1)/2+1,vector<bool>(xc+1));
    hx[0][0]=true;
    for(int j=1;j<xc+1;j++)hx[0][j]=false;
    for(int i=1;i<(k+1)/2+1;i++){
      for(int j=0;j<(xc+1);j++){
         hx[i][j]=hx[i-1][j];
         if(j-vx[i]>=0)hx[i][j]=(hx[i][j]||hx[i-1][j-vx[i]]);
      }
    }
    if(hx[(k+1)/2][xc]==false)out++;
  }
  ////////
  int yc=0;
  for(int i=0;i<k/2+1;i++)yc+=vy[i];
  yc-=y;
  if(yc%2||yc<0)out++;
  else{
    yc/=2;
    vector<vector<bool>> hy(k/2+1+1,vector<bool>(yc+1));
    hy[0][0]=true;
    for(int j=1;j<yc+1;j++)hy[0][j]=false;
    for(int i=1;i<k/2+1+1;i++){
      for(int j=0;j<(yc+1);j++){
         hy[i][j]=hy[i-1][j];
         if(j-vy[i]>=0)hy[i][j]=(hy[i][j]||hy[i-1][j-vy[i]]);
      }
    }
    if(hy[k/2+1][yc]==false)out++;
  }
  //cout<<xc<<endl;
  //for(int i=0;i<(k+1)/2;i++)cout<<vx[i]<<" ";
  //cout<<endl;
  //for(int i=0;i<k/2+1;i++)cout<<vy[i]<<" ";
  //cout<<endl;
  //cout<<ka<<" "<<ix<<endl;
  if(out)cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <cstdio>
#include <map>
#include <array>
#include <cstring>

using namespace std;
typedef long long ll;

// map<array<int, 4>, double> dp;
double dp[301][301][301];

double calc(int n0, int n1, int n2, int n3){
    if(dp[n1][n2][n3] >= 0){
        return dp[n1][n2][n3];
    }
    // if(dp.count({n0, n1, n2, n3})){
    //     return dp.at({n0, n1, n2, n3});
    // }
    const int n = n0 + n1 + n2 + n3;
    double tmp = (double)n0 / n;
    if(n1 > 0){
        tmp += (double)n1 / n * (calc(n0 + 1, n1 - 1, n2, n3) + 1);
    }
    if(n2 > 0){
        tmp += (double)n2 / n * (calc(n0, n1 + 1, n2 - 1, n3) + 1);
    }
    if(n3 > 0){
        tmp += (double)n3 / n * (calc(n0, n1, n2 + 1, n3 - 1) + 1);
    }
    tmp /= (1 - (double)n0 / n);
    // dp[{n0, n1, n2, n3}] = tmp;
    dp[n1][n2][n3] = tmp;
    return tmp;
}

int main(){
    int n;
    cin >> n;
    vector<int> s(4, 0);
    for(int i = 0; i < n; ++i){
        int ai;
        cin >> ai;
        s.at(ai)++;
    }
    // dp[{n, 0, 0, 0}] = 0;
    memset(dp, -1, sizeof(dp[0][0][0]) * 301 * 301 * 301);
    dp[0][0][0] = 0;
    printf("%.012lf\n", calc(s.at(0), s.at(1), s.at(2), s.at(3)));
    return 0;
}

Measured memory_bytes: 213376
// ######      ###      #######    #######    ##     #     #####        ###     ##### //
// #     #    #   #          #        #       # #    #    #     #      #   #     ###  //
// #     #   #     #        #         #       #  #   #   #       #    #     #    ###  //
// ######   #########      #          #       #   #  #   #           #########    #   //
// #     #  #       #     #           #       #    # #   #    ####   #       #    #   //
// #     #  #       #    #            #       #     ##   #    #  #   #       #        //
// ######   #       #   #######    #######    #      #    #####  #   #       #    #   //

// #pragma GCC optimize(2)
// #pragma GCC optimize(3)
// #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
// #pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double lld;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> ppl;
#define ain(a,n) for(ll i=0;i<(n);++i)	cin>>(a)[i];
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define loop(i,n) for(ll i=0;i<(n);++i)
#define FOR(i,a,b) for(ll i=(a);i<=(b);++i)
#define FORD(i,a,b) for(ll i=(a);i>=(b);--i)
#define cases ll T=0;cin>>T;while(T--)
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define END "\n"
#define pb push_back
#define mp make_pair
#define go(c,itr) for(auto itr=(c).begin(); itr!=(c).end(); ++itr)
// #define back(c,itr) for(auto itr=(c).rbegin(); itr!=(c).rend(); ++itr)
#define PI 3.14159265359
#define inf 9e18
#define MOD 1000000007
#define MODU 998244353
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define MAXN 300005
const string alpha = "abcdefghijklmnopqrstuvwxyz";
const ll N = 200005;
const long double epsilon = 1e-9;
ll binexp(ll a, ll b, ll m) {
	a %= m;
	ll res = 1;
	while (b > 0) {
		if (b & 1)
			res = res * a % m;
		a = a * a % m;
		b >>= 1;
	}
	return res;
}
ll modinvfermat(ll a, ll m)
{
	return binexp(a, m - 2, m);
}
void task(bool flag)
{
	if (flag)
		cout << "YES\n";
	else
		cout << "NO\n";
}
ll lcm(ll a, ll b)
{
	return ((1LL * a * b) / (__gcd(a, b)));
}

signed main() {
// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif
	fast
	ll n;
	cin >> n;
	ll k = 1, val = 0;
	while (k <= n)
	{
		val = (val * 10) % n;
		val = (val + 7) % n;
		if (val == 0)
			break;
		++k;
	}
	if (k > n)
		k = -1;
	cout << k << END;



// #ifndef ONLINE_JUDGE
// 	cout << "\nTime Elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " sec\n";
// #endif
	return 0;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int mod=1000000007;
int p(int A,int B){
  if(!B)return 1;
  if(B%2)return p(A,B-1)*A%mod;
  int C=p(A,B/2);
  return C*C%mod;
}
int k[1000100];
int c(int A,int B){
  return k[A]*p(k[A-B]*k[B]%mod,mod-2)%mod;
}
signed main(){
  k[0]=1;
  for(int i=1;i<=1000000;i++)k[i]=k[i-1]*i%mod;
  int N,K,ans=0;
  cin>>N>>K;
  for(int i=max(N-K,1LL);i<=N;i++)
    ans=(ans+c(N-1,i-1)*c(N,i)%mod)%mod;
  cout<<ans<<endl;
}

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ASC(x) sort(ALL((x)))
#define DESC(x) sort(ALL((x)),greater<ll>())
#define pb push_back


vec fac(210000), finv(210000), inv(210000);

ll modpow(ll a, ll n, ll m)
{
    if(n == 0) return 1;
    ll t = modpow(a, n >> 1, m);
    t = t * t % m;
    if(n & 1) t = t * a % m;
    return t; 
}

void combinit()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    REP(i,2,210000) {
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
 
ll combmod(ll n, ll r)
{
    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;
    ll c = 1;
    REP(i,0,r) c = c * (n-i) % MOD;
    c = c * finv[r] % MOD;
    return c;
}

int main()
{
    ll n, a, b;
    cin >> n >> a >> b;

//    vec inv(200010, 0);
//    inv[1] = 1;
//    REP(i,2,200010) inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;

    combinit();

    ll nCa = 1, nCb = 1, c;
    REP(i,1,a+1) nCa = (nCa * (n-i+1) % MOD) * inv[i] % MOD;
    REP(i,1,b+1) nCb = (nCb * (n-i+1) % MOD) * inv[i] % MOD;
    c = (modpow(2, n, MOD) - 1- nCa - nCb) % MOD;
    c = (c < 0) ? c + MOD : c;
    PR(c); 

    return 0;
}

/*

nC1 + ... + nCn - nCa - nCb
= 2^n - 1 - nCa - nCb

*/

Measured memory_bytes: 5120
#include <vector>
#include <iostream>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector< vector<int> > A(2,vector<int>(N));
  for(int i = 0; i < 2; ++i){
    for(int j = 0; j < N; ++j){
      cin >> A[i][j];
    }
  }
  for(int i = 1; i < N; ++i){
    A[0][i] += A[0][i-1];
    A[1][N-1-i] += A[1][N-i];
  }
  int ans = 0;
  for(int i = 0; i < N; ++i){
    ans = max(ans,A[0][i]+A[1][i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
function main(input) {
    const args = input.split(" ");
    const No = args[0].split("");

    var Number;
    var ans = 753;

    for (var i = 0; i < parseInt(No.length - 2); i++) {
        Number = No.slice(i, i + 3).map(str => parseInt(str, 10));
        var new_ans = Number[0] * 100 + Number[1] * 10 + Number[2];
        if (Math.abs(753 - new_ans) < ans) {
            ans = Math.abs(753 - new_ans);
        }
    }
    console.log(ans);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

string str;
int pos=0;

int read_num(){
//	cout<<"num "<<pos<<endl;
	int res=0;
	while(isdigit(str[pos])){
		res*=10;
		res+=str[pos]-'0';
		pos++;
	}
//	cout<<"return :"<<res<<endl;
	return res;
}

int read_block(){
//	cout<<pos<<endl;
	vector<int> work;
	if(isdigit(str[pos])){
		int res=read_num()/2+1;
		pos++;
		return res;
	}
	while(pos<str.length() && str[pos]!=']'){
//		cout<<pos<<endl;
		if(str[pos]=='['){
			pos++;
			int got = read_block();
			work.push_back(got);
//			cout<<"push "<<got<<endl;
		}
		else{
			cout<<pos<<": error?"<<endl;
		}
	}
	sort(work.begin(),work.end());
	int res=0;
	for(int i=0;i<work.size()/2+1;i++){
		res+=work[i];
	}
//	cout<<pos<<": "<<res<<endl;
	pos++;
	return res;
}


int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>str;
		pos=0;
		pos++;
		cout<<read_block()<<endl;
	}
	return 0;
}

Measured memory_bytes: 1276
#include <iostream>
#include <fstream>
#include <sstream>
#include <string.h>
#include <algorithm>
#include <cmath>
#include <assert.h>
#include <stack>
#include <queue>
#include <list>
#include <vector>
#include <map>
#include <set>

//#define DEBUG 1

#define int long long
#define for0(i,n) for (int i=0; i<n; i++)
#define iter(c) for(auto it=c.begin(); it!=c.end(); it++)
#define vec(x) vector< x >
#define pb push_back
#define ms(a,z) memset(a,z,sizeof(a));
#define mp make_pair
#define X first
#define Y second
#define sqr(x) 1LL*(x)*(x)
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define all(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#ifdef int
#define read(x) scanf("%lld",&x);
#else
#define read(x) scanf("%d",&x);
#endif

#ifdef DEBUG
#define nl cout<<"\n";
#define pr(x) cout<<(x)<<" ";
#define prl(x) cout<<#x " = "<<x<<endl;
#define prp(x) cout<<"("<<(x).first<<" "<<(x).second<<") ";
#define printv(v) {for(int _=0; _<sz(v); _++) cout<<v[_]<<" "; cout<<"\n";}
#define printa(a,s) {for (int _=0; _<s; _++) cout<<a[_]<<" "; cout<<"\n";}
#define print2D(a,m,n) {for (int _=0; _<m; _++) {for (int __=0; __<n; __++) cout<<a[_][__]<<" "; cout<<"\n";} cout<<"\n";}
#define debug cout<<"ok at line "<<__LINE__<<endl;
#else
#define nl
#define pr(x)
#define prl(x)
#define prp(x)
#define printv(v)
#define printa(a,s)
#define print2D(a,m,n)
#define debug
#endif

using namespace std;

typedef long long ll;

const int INF = 2147483647;
const long long INFL = 9223372036854775807LL;
const double EPSILON = 0.00000001;
const long long MOD = 1000000007;

int32_t main()
{
    #ifdef DEBUG
    freopen("A.txt","r",stdin);
    //freopen("","w",stdout);
    #endif

    int n,m;
    read(n); read(m);
    set<int> adj1, adjn;
    for0(i,m) {
        int u,v; 
        read(u); read(v);
        if (u == 1) {
            adj1.insert(v);
        }
        if (v == n) {
            adjn.insert(u);
        }
    }
    
    if (n == 1) {
        cout<<"POSSIBLE"<<endl;
    }
    else if (adj1.find(n) != adj1.end()) {
        cout<<"POSSIBLE"<<endl;
    }
    else {
        bool found = false;
        iter(adj1) {
            if (adjn.find(*it) != adjn.end()) {
                cout<<"POSSIBLE"<<endl;
                found = true;
                break;
            }
        }
        if (!found)
            cout<<"IMPOSSIBLE"<<endl;
    }
    return 0;
}


Measured memory_bytes: 9600
count = 0
info = []
ans = []
while True:
  info.append(list(map(int, input().split())))
  if info[count][0] == -1 and info[count][1] == -1 and info[count][2] == -1:
    break
  count += 1
for i in info:
  if (i[0] + i[1]) < 30 or i[0] == -1 or i[1] == -1:
    ans.append("F")
  elif 80 <=(i[0] + i[1]):
    ans.append("A")
  elif 65 <= (i[0] + i[1]) < 80:
    ans.append("B")
  elif 50 <= (i[0] + i[1]) < 65:
    ans.append("C")
  elif 30 <= (i[0] + i[1]) < 50:
    if 50 <= i[2]: 
      ans.append("C")
    else:
      ans.append("D")
  else:
    ans.append("F")
ans.pop()
for j in ans:
  print(j)


Measured memory_bytes: 5608
#!/usr/bin python3
# -*- coding: utf-8 -*-

def main():
    N = int(input())
    d = list(map(int, input().split()))
    ret = 0
    for i in range(N):
        for j in range(i+1,N):
            ret += d[i]*d[j]
    print(ret)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9080
#include<cstdio>
#include<cmath>
#include<cstring>
#include<iostream>
#include<cstdlib>
#include<algorithm>
#include<map>
using namespace std;

int x, n[105], m, s[105];
int ans = 0;
int main()
{
	scanf("%d", &x);
	for(int i = 1; i <= x; i++)
	  scanf("%d", &s[i]);
	for(int j = 1; j <= x; j++)
		scanf("%d", &n[j]);
		int sum = 0 , MAX = 0;
	for(int i = 1; i <= x; i++)
	{
		for(int k = 1; k <= i; k++)
		   sum += s[k];
		for(int j = i; j <= x; j++)
		{
			sum += n[j];
		}
		if(sum > MAX) MAX = sum;
		sum = 0;
	}
	printf("%d\n", MAX);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e9
#define all(v) v.begin(), v.end()
#define rall(v) v.begin(), v.end(), std::greater<int>()
#define rep(i, n) for(int i = 0; i < n; i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define max(v) *max_element(v.begin(), v.end())
#define min(v) *min_element(v.begin(), v.end())
using namespace std;
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
 
    int n;
    cin>>n;
    int a[n];
    
    bool flag = true;
    rep(i, n){
        cin>>a[i];
    }
    sort(a, a+n);
    rep(i,n-1)
        if(a[i] == a[i+1])
            flag = false;

    if(flag){
        cout<<"YES"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }
    return 0;
}

Measured memory_bytes: 1024
from enum import Enum
from queue import Queue

import numpy as np

import collections
import bisect
import sys
import math

from scipy.sparse.csgraph import floyd_warshall

"""nを素因数分解"""
def factorize(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b = b + 1
    if n > 1:
        fct.append(n)
    return fct
 #最大公約数
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a


A,B = map(int,input().split())

G = gcd(A,B)

c = collections.Counter(factorize(G))
print(len(list(c.keys()))+1)


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

using namespace std;

#define ll long long

int main() {

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

	int x, y, z;
	cin >> x >> y >> z;
	cout << z << " " << x << " " << y << " " << "\n";

	return 0;
}


Measured memory_bytes: 256
class Unionfind():  # Unionfind
    def __init__(self, N):
        self.N = N
        self.parents = [-1] * N

    def find(self, x):  # グループの根
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):  # グループの併合
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):  # グループのサイズ
        return - self.parents[self.find(x)]


n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]

uf = Unionfind(n)
ans, cnt = [], n * (n - 1) // 2
for a, b in ab[::-1]:
    a -= 1; b -= 1
    ans.append(max(cnt, 0))
    if uf.find(a) != uf.find(b):
        cnt -= uf.size(a) * uf.size(b)
        uf.union(a, b)
print(*ans[::-1], sep='\n')


Measured memory_bytes: 101680
#pragma GCC optimize ("O3")
//こういうの意味あるのかな

//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

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


	int N = getint(), K = getint();
	int dp[101], h[101] = {};
	rep(i, K) dp[i] = 1e9;

	int H = getint();
	int kotae = 0;
	rep(i, N - 1) {
		h[i % K] = H;
		dp[i % K] = kotae;
		H = getint();
		kotae = 1e9;
		rep(j, K) chmin(kotae, dp[j] + abs(h[j] - H));
	}

	printf("%d", kotae);

	Would you please return 0;
}

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

#pragma GCC optimize("O2,no-stack-protector,unroll-loops,fast-math")

#define F first
#define S second
#define pb push_back
#define SZ(x) (ll)(x.size())
#define all(x) x.begin(),x.end()
#define MP make_pair

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll maxn=2e3+10, maxm=5e3+10, lg=31, mod=1e9+7, inf=1e18;

ll n,m,q,ys[maxn][maxn][2],rs[maxn][maxn];
char tab[maxn][maxn];

int main(){
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	
	cin>>n>>m>>q;
	for(int i=1;i<=n;i++)for(int j=1;j<=m;j++){
		cin>>tab[i][j];
		for(bool b:{0,1}) ys[i][j][b]=ys[i-1][j][b]+ys[i][j-1][b]-ys[i-1][j-1][b];
		rs[i][j]=rs[i-1][j]+rs[i][j-1]-rs[i-1][j-1];
		if(tab[i][j]=='1'){
			ys[i][j][0]+=(tab[i-1][j]-'0');
			ys[i][j][1]+=(tab[i][j-1]-'0');
			rs[i][j]++;
		}
	}
	while(q--){
		ll x,y,X,Y; cin>>x>>y>>X>>Y;
		cout<<rs[X][Y]-rs[X][y-1]-rs[x-1][Y]+rs[x-1][y-1]-(ys[X][Y][0]-ys[x][Y][0]-ys[X][y-1][0]+ys[x][y-1][0]+ys[X][Y][1]-ys[x-1][Y][1]-ys[X][y][1]+ys[x-1][y][1])<<'\n';
	}
	
	return 0;
}





Measured memory_bytes: 101784
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String s = scanner.next();

		String sub = s.substring(1, s.length()-1);
		//System.out.println(sub);
		int count = sub.length();

		System.out.println(s.substring(0,1) + count + s.substring(count+1, s.length()));
	}

}

Measured memory_bytes: 21844
N, M = [int(i) for i in input().split()]
H = [None] + [int(i) for i in input().split()]
P = [False] + [True] * N
for i in range(M):
    A, B = [int(i) for i in input().split()]
    if H[A] >= H[B]:
        P[B] = False
    if H[B] >= H[A]:
        P[A] = False
ans = 0
for i in P:
    if i:
        ans += 1
print(ans)

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

// #define multitest 1
#ifdef WIN32
#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__);
#define pc(...) PC(#__VA_ARGS__, __VA_ARGS__);
template <typename T, typename U>
ostream &operator<<(ostream &out, const pair<T, U> &p)
{
	out << '[' << p.first << ", " << p.second << ']';
	return out;
}
template <typename Arg>
void PC(const char *name, Arg &&arg)
{
	std::cerr << name << " { ";
	for (const auto &v : arg)
		cerr << v << ' ';
	cerr << " }\n";
}
template <typename Arg1>
void ZZ(const char *name, Arg1 &&arg1)
{
	std::cerr << name << " = " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void ZZ(const char *names, Arg1 &&arg1, Args &&... args)
{
	const char *comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}
#else
#define db(...)
#define pc(...)
#endif

using ll = long long;
#define f first
#define s second
#define pb push_back
const long long mod = 1000000007;
auto TimeStart = chrono::steady_clock::now();

const int nax = 2e5 + 10;

void solve()
{
	string s, t;
	cin >> s >> t;
	vector<bool> h(26), h1(26);
	for (auto c : s)
		h[c - 'a'] = true;
	for (auto c : t)
		h1[c - 'a'] = true;
	for (int i = 0; i < 26; ++i)
		if (h1[i])
			if (!h[i])
			{
				cout << -1;
				return;
			}
	ll len = 0;
	vector<vector<int>> NextOcc(s.size() + 1, vector<int>(26, mod));
	for (int i = s.size() - 1; i >= 0; --i)
	{
		for (int j = 0; j < 26; ++j)
			NextOcc[i][j] = NextOcc[i + 1][j];
		NextOcc[i][s[i] - 'a'] = i;
	}
	int curr = 0;
	for (int i = 0; i < t.size(); ++i)
	{
		int next = NextOcc[curr][t[i] - 'a'];
		db(t[i], len);
		db(curr, i, NextOcc[curr][t[i] - 'a']);
		if (next == mod)
		{
			--i;
			curr = 0;
			len += s.size();
		}
		else
		{
			curr = next + 1;
			if (curr == s.size())
			{
				curr = 0;
				len += s.size();
			}
			// db(t[i], len);
			// db(curr, i, NextOcc[curr][t[i] - 'a']);
		}
	}
	len += curr;
	cout << len;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int t = 1;
#ifdef multitest
	cin >> t;
#endif
	while (t--)
		solve();
#ifdef WIN32
	cerr << "\n\nTime elapsed: " << chrono::duration<double>(chrono::steady_clock::now() - TimeStart).count() << " seconds.\n";
#endif
	return 0;
}

Measured memory_bytes: 13776