akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int n , m;
int main() {
	cin>>n>>m;
	priority_queue<long long>pq;
	for(int i = 0; i< n; i++){
		long long x;cin>>x;
		pq.push(x);
	}
	while(m--){
		long long x = pq.top()/2;
		pq.pop();pq.push(x);
	}
	long long ans = 0;
	for(int i = 0; i <n;i++){
		ans+=pq.top();
		pq.pop();
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 1400
import sys
n = int(input())
a = list(map(int,input().split()))

dp = [sys.maxsize]*(n)
dp[0] = 0
for i in range(n):
  for j in range(i+1,i+2+1):
    if j<n :
      dp[j] = min(dp[j],dp[i]+abs(a[i]-a[j]))
                  
                  
print(dp[n-1])

Measured memory_bytes: 52208
import math

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

t = H * 60 + M

xh = A * math.sin(t % 720 / 720 * 2 * math.pi)
yh = A * math.cos(t % 720 / 720 * 2 * math.pi)
xm = B * math.sin(t % 60 / 60 * 2 * math.pi)
ym = B * math.cos(t % 60 / 60 * 2 * math.pi)

print(math.dist((xh, yh), (xm, ym)))


Measured memory_bytes: 9512
#include<iostream>
#include<string>
using namespace std;
int main()
{
	int count, i;
	count = 0;
	string S;
	cin >> S;
	for (i = 0; i < S.length(); i++)
	{
		if (S[i] ==  '0')
			count += 1;
	}
	cout << ((count <((double)S.length() / 2)) ? (2 * count) : (2 * (S.length() - count)));

	return 0;
}

Measured memory_bytes: 512
def main():
        
    N_satu, M_satu, K_fun = map(int, input().split())

    A_fun = list(map(int, input().split()))
    B_fun = list(map(int, input().split()))

    SumOf_A = [0]
    SumOf_B = [0]

    for i in range(N_satu):
        next_val = SumOf_A[i] + A_fun[i]
        SumOf_A.append(next_val)

    for i in range(M_satu):
        next_val = SumOf_B[i] + B_fun[i]
        SumOf_B.append(next_val)

    index_b = M_satu
    max_cnt = 0

    for i in range(N_satu + 1):
        if (SumOf_A[i] > K_fun):
            break
        
        while (SumOf_A[i] + SumOf_B[index_b] > K_fun):
            index_b -= 1
        
        max_cnt = max(max_cnt, i + index_b)
        

    print(max_cnt)


if __name__ == '__main__':
    main()


Measured memory_bytes: 47448
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=1<<16,INF=1<<30;
const double eps=1e-9;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N,Q;cin>>N>>Q;
    vector<double> x(N),y(N),z(N),r(N);
    vector<ll> l(N);
    
    for(int i=0;i<N;i++) cin>>x[i]>>y[i]>>z[i]>>r[i]>>l[i];
    
    while(Q--){
        double sx,sy,sz,dx,dy,dz;cin>>sx>>sy>>sz>>dx>>dy>>dz;
        ll sum=0;
        
        double vx=dx-sx,vy=dy-sy,vz=dz-sz;
        
        for(int i=0;i<N;i++){
            double A=x[i]-sx,B=y[i]-sy,C=z[i]-sz;
            
            double t=(vx*A+vy*B+vz*C)/(vx*vx+vy*vy+vz*vz);
            
            bool ok=false;
            
            if(0.0<=t&&t<=1.0){
                double dis=hypot(hypot(A-t*vx,B-t*vy),C-t*vz);
                if(dis<=r[i]+eps) ok=true;
            }
            
            if((x[i]-sx)*(x[i]-sx)+(y[i]-sy)*(y[i]-sy)+(z[i]-sz)*(z[i]-sz)<=r[i]*r[i]+eps) ok=true;
            if((x[i]-dx)*(x[i]-dx)+(y[i]-dy)*(y[i]-dy)+(z[i]-dz)*(z[i]-dz)<=r[i]*r[i]+eps) ok=true;
            //if((A-dx)*(A-dx)+(B-dy)*(B-dy)+(C-dz)*(C-dz)<=r[i]*r[i]) ok=true;
            
            if(ok) sum+=l[i];
        }
        
        cout<<sum<<endl;
    }
}





Measured memory_bytes: 3364
n, c, k = map(int, raw_input().split(' '))

t = [0 for i in range(n)]

for i in range(n):
	t[i] = input()

t.sort()

lowest = 0
res = 1

for i in range(n):
	if i - lowest >= c:
		lowest = i
		res += 1
	elif t[i] - t[lowest] > k:
		lowest = i
		res += 1

print res

Measured memory_bytes: 8956
#include<stdio.h>

int main()
{
	char s[3];
	scanf("%s", s);
	for (int i = 0; i < 3; i ++) {
		if (s[i] == '1') {
			s[i] = '9';
		} else if (s[i] == '9') {
			s[i] = '1';
		}
	}
	printf("%s", s);
	return 0;
}


Measured memory_bytes: 128
n=int(input());c,s,f=[0]*(n-1),[0]*(n-1),[0]*(n-1)
for i in range(n-1):c[i],s[i],f[i]=map(int,input().split())
for i in range(n-1):
  d=c[i]+s[i]
  for j in range(i+1,n-1):d=max(((d-s[j]-1)//f[j]+1)*f[j]+s[j],s[j])+c[j]
  print(d)
print(0)

Measured memory_bytes: 3064
#include <iostream>
#include <stdio.h>
#include <bits/stdc++.h>
#include <string>
using namespace std;

int main()
{
    int n;
    string s,t,res;
    cin >> n >> s >> t;
    for(int i=0;i<s.size();i++){res+=s.substr(i,1);res+=t.substr(i,1);}
    cout << res;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define i64 long long
#define maxn (int)(1e5)
#define pii pair<int,int>
#define L first 
#define R second
#define all(x) x.begin(),x.end()
using namespace std;


int main(){
	int A,B,K,d,cnt=0;
	cin>>A>>B>>K;
	
	for(d=min(A,B); d>=1; d--){
		if(A%d ==0 and B%d ==0) cnt++;
		if(cnt == K) break;
	}
	printf("%d\n",d);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
    int a[3], sum=0;
    string ans="YES";
    for(int i = 0; i < 3; i++)
    {
        cin >> a[i];
        if(a[i]==5 || a[i]==7) ;
        else
        {
            ans = "NO";
        }
        sum+= a[i];
    }
    if(sum!=17) ans = "NO";
    cout << ans << endl;
    
}


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

#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ii pair<int,int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>

using namespace std;

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	set<ll> st;
	cin>>n;
	for(int i=0;i<n;++i){
		ll x;cin>>x;
		st.insert(x);
	}
	if(st.size()==n)
		cout<<"YES\n";
	else
		cout<<"NO\n";
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) sort(all(v)); reverse(all(v))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template<typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template<typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template<typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template<typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template<typename T> inline T power(T x, i64 n) { T r = 1; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template<typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }

void solve() {
  int N; cin >> N;
  i64 x = 1, y = 1;
  rep(i, N) {
    i64 t, a; cin >> t >> a;
    i64 c = max((x + t - 1) / t, (y + a - 1) / a);
    x = t * c, y = a * c;
  }
  cout << x + y << '\n';
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=(1e5+10);
struct st
{
	int kt,d;
}a[maxn];
bool cmp(st x,st y)
{
	return (x.d>y.d);
}
int n,k;
ll cnt=0,tp=0,ans=0,now=0;
bool vis[maxn];
stack<int> s;
int main()
{
	cin>>n>>k;
	for(int i=0;i<n;i++)
	{
		cin>>a[i].kt>>a[i].d;
	}
	sort(a,a+n,cmp);
	for(int i=0;i<n;i++)
	{
		if(cnt<k)
		{
			if(!vis[a[i].kt])
			{
				++tp;
				vis[a[i].kt]=true; 
			}
			else
			{
				s.push(a[i].d);
			}
			++cnt;
			now+=a[i].d;
			ans=max(ans,now+tp*tp);
		}
		else
		{
			if(s.empty())
			{
				break;
			}
			if(vis[a[i].kt])
			{
				continue;
			}
			vis[a[i].kt]=true;
			now+=a[i].d;
			now-=s.top();
			s.pop();
			++tp;
			++cnt;
			ans=max(ans,now+tp*tp); 
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1280
#include<iostream>
using namespace std;
int n, a, b, c;
int main() {
	while (true) {
		cin >> n; if (n == 0) { break; }
		for (int i = 0; i < n; i++) {
			cin >> a >> b >> c;
			if (a + b + c >= 240) { goto A; }
			if (a + b >= 180) { goto A; }
			if (a == 100 || b == 100 || c == 100) { goto A; }
			if (a + b + c >= 210) { goto B; }
			if (a + b + c >= 150 && (a >= 80 || b >= 80)) { goto B; }
			goto C;
		A:; cout << 'A' << endl; goto D;
		B:; cout << 'B' << endl; goto D;
		C:; cout << 'C' << endl; goto D;
		D:;
		}
	}
}

Measured memory_bytes: 1152
using System;
using System.Collections;
using System.Numerics;

class Program {
    static void Main (string[] args) {
        string[] S = Console.ReadLine ().Split (' ');
        long N = long.Parse (S[0]);
        long M = long.Parse (S[1]);
        long ans = (1800 * M + 100 * N) * (long) Math.Pow (2, M);
        Console.WriteLine (ans);
    }
}

Measured memory_bytes: 11092
# 86
# ABC 075 C - Bridge

class UnionFindTree():
    def __init__(self, n):
        self.rank = [0] * n
        self.par = [x for x in range(n)]
        
    def find(self, x):
        if x == self.par[x]:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]
    
    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] > self.rank[y]:
            self.par[y] = x
        elif self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            self.rank[x] += 1
    
    def same(self, x, y):
        return (self.find(x) == self.find(y))

n, m = map(int, input().split())
ab_l = [[int(x)-1 for x in input().split()] for y in range(m)]

ans = 0

for i in range(m):
    UF = UnionFindTree(n)
    for j in range(m):
        if i != j:
            UF.unite(ab_l[j][0], ab_l[j][1])
    for j in range(1,n):
        if not UF.same(0, j):
            ans += 1
            break

print(ans)

Measured memory_bytes: 80516
n, x = map(int, input().split())
li = list(map(int, input().split()))
t = []
for i in li:
    t.append(abs(i - x))
divisors = []
for i in range(1, int(min(t) ** 0.5) + 1):
    if min(t) % i == 0:
        divisors.append(i)
        if i != min(t) // i:
            divisors.append(min(t) // i)
divisors.sort()
divisors = divisors[::-1]
for j in divisors:
    if all(k % j == 0 for k in t):
        print(j)
        exit()


Measured memory_bytes: 14252
#include<bits/stdc++.h>
using namespace std;
int az[26];
int main()
{
    string str;
    cin>>str;
    int ln;
    ln=str.size();
    int i;
    for(i=0;i<ln;i++){
        az[str[i]-'a']++;
    }
    int ck=0;
    for(i=0;i<26;i++){
        if(az[i]%2!=0){
            ck=1;
        }
    }
    if(ck==0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
from sys import stdin
from collections import deque
S=list(stdin.readline().strip())
d=deque(S)
# d=deque(list(stdin.readline().strip()))
N=list(map(int,stdin.readline().strip().split()))[0]
rev=False
for i in range(N):
    Q = list(stdin.readline().strip().split())
    if Q[0]=='1' :
        if rev==False:rev=True
        else:rev=False
    if Q[0]=='2':
        if Q[1]=='1':
            if rev==False:d.appendleft(Q[2])
            else:d.append(Q[2])
        if Q[1]=='2':
            if rev == False:
                d.append(Q[2])
            else:
                d.appendleft(Q[2])
# if rev==False:[print(x,end="") for x in d]
# else:[print(d[x],end="") for x in range(len(d)-1,-1,-1)]
if rev==False:[print(d.popleft(),end="") for x in range(len(d))]
else:[print(d.pop(),end="") for x in range(len(d))]

Measured memory_bytes: 11248
h, m =map(int,input().strip().split())

height=list(map(int,input().strip().split()) )
lst=[1]*h

for i in range(m):
    a,b=map(int,input().strip().split())
    if height[a-1]>height[b-1]:
        lst[b-1]=0
    elif height[a-1]<height[b-1]:
        lst[a-1]=0
    else:
        lst[b - 1] = 0
        lst[a - 1] = 0

print(lst.count(1))

Measured memory_bytes: 19980
#ifdef LOCAL
//#define _GLIBCXX_DEBUG
#endif
//#pragma GCC target("avx512f,avx512dq,avx512cd,avx512bw,avx512vl")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<char> Vc;
typedef vector<P> VP;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;
typedef vector<vector<char>> VVc;
typedef vector<vector<vector<ll>>> VVV;
typedef vector<vector<vector<vector<ll>>>> VVVV;

#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 rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e18+18;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define rEach(i, mp) for (auto i = mp.rbegin(); i != mp.rend(); ++i)
#ifdef LOCAL
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define dbgmint(n,arr) rep(i,n){cerr<<arr[i].x<<" ";}cerr<<endl;
#define dbgarrmint(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j].x<<" ";}cerr<<endl;}
#else
#define dbg(...)
#define dbgmap(...)
#define dbgarr(...)
#define dbgdp(...)
#define dbgmint(...)
#define dbgarrmint(...)
#endif
#define out(a) cout<<a<<endl
#define out2(a,b) cout<<a<<" "<<b<<endl
#define vout(v) rep(i,v.size()){cout<<v[i]<<" ";}cout<<endl
#define Uniq(v) v.erase(unique(v.begin(), v.end()), v.end())
#define fi first
#define se second

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

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,v.size())i>>v[j];return i;}

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int solve(){
    ll n;
    cin>>n;
    //n--;
    string ans;
    while(n){
        n--;
        ll x = n%26;
        ans += 'a'+x;
        n /= 26;
    }
    reverse(ALL(ans));
    cout<<ans<<endl;
    return  0;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);
    solve();
}


Measured memory_bytes: 3644
import itertools
from collections import Counter

n = int(input())

# 素因数分解した結果のリスト
# {1: [], 2: [2], 3: [3], 4: [2, 2], 5: [5]}
divs = {}
primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]

for i in range(1, n + 1):
    divs[i] = []
    x = i
    while x >= 2:
        for p in primes:
            if x % p == 0:
                x //= p
                divs[i].append(p)

# flatten
fdivs = list(itertools.chain.from_iterable(divs.values()))
counts = Counter(fdivs)

ans = 0
# 75==5*5*3
# https://juken-mikata.net/how-to/mathematics/number-of-divisor.html
# 4, 4, 2 選んだら75数になる
ge4 = len([c for c in counts.values() if c >= 4])
ge2 = len([c for c in counts.values() if c >= 2])
ans += ge4 * (ge4 - 1) / 2 * (ge2 - 2)

# 75==5*15
# 4, 14 選ぶ
ge14 = len([c for c in counts.values() if c >= 14])
ans += ge14 * (ge4 - 1)

# 75==25*3
# 24, 2 選ぶ
ge24 = len([c for c in counts.values() if c >= 24])
ans += ge24 * (ge2 - 1)

# 75 ==75*1
# 74 選ぶ
ge74 = len([c for c in counts.values() if c >= 74])
ans += ge74

print(int(ans))


Measured memory_bytes: 3444
#include <iostream>
#include <math.h>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

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

typedef long long lint;

using namespace std;

int main(){
  string S;
  cin>>S;
  cout<<700+100*count(ALL(S),'o')<<endl;
  return 0;
}


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

int main(){
   ll a,b,n;cin>>a>>b>>n;
   int count=0;
   for(int i=a;i<=b;i++){
      if(i%n==0){
         count++;
      }
   }
   cout<<count<<endl;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define SZ(x) ((int)x.size())
#define ALL(x) x.begin(),x.end()
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> T gcd(T a, T b){return !b?a:gcd(b,a%b);}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 303, mo = 998244353, inv2 =(mo+1)/2;
const ll MOD=7LL*mo*mo;
inline void add(int &x, int y){x=x+y<mo?x+y:x+y-mo;}
inline void sub(int &x, int y){x=x-y>=0?x-y:x-y+mo;}
inline int power(int a, int n) {
	int res=1;
	while (n) {
		if (n&1) res=1LL*res*a%mo;
		a=1LL*a*a%mo; n>>=1;
	}
	return res;
}
int res,n,f[N][N][N];char s[N];bool ok[N][N][N];
int main() {
	scanf("%s",s+1);n=strlen(s+1);
	f[0][0][0]=1;
	ok[0][0][0]=1;
	rep(i,1,n)rep(x,0,n)rep(y,0,n-x){
		ok[i][x][y]=ok[i-1][x][y];
		if(s[i]=='0'&&x)ok[i][x][y]|=ok[i-1][x-1][y+1];
		if(s[i]=='1'&&y)ok[i][x][y]|=ok[i-1][x+1][y-1];
		if(i>=2&&(s[i]=='0'||s[i-1]=='0')&&x)ok[i][x][y]|=ok[i-2][x-1][y];
		if(i>=2&&(s[i]=='1'||s[i-1]=='1')&&y)ok[i][x][y]|=ok[i-2][x][y-1];
	}
//	per(i,n-1,0)rep(x,0,n)rep(y,0,n-x)
//		ok[i][x][y]|=s[i+1]=='0'?ok[i+1][x+1][y]:ok[i+1][x][y+1];
	res=mo-1;
	rep(i,0,n)rep(x,0,n)rep(y,0,n-x)if(f[i][x][y]){
		if(ok[n-i][x][y])add(res,f[i][x][y]);//,cerr<<n-i<<' '<<x<<' '<<y<<' '<<f[i][x][y]<<endl;
		add(f[i+1][x][y],f[i][x][y]);
	//	if(i+x+y){
			if(s[n-i]=='1')add(f[i][x+1][y],f[i][x][y]);
			else add(f[i][x][y+1],f[i][x][y]);
	//	}
	}
	cout<<res;
	return 0;
}


Measured memory_bytes: 138936
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    S = input()
    K = int(input())
    ans = ''
    for s in S:
        if s=='a':
            ans += s
        else:
            if 123 - ord(s) <= K:
                ans += 'a'
                K -= 123 - ord(s)
            else:
                ans += s
    if K > 0:
        ans = ans[:-1] + (chr(ord(ans[-1]) + K%26))
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9332
#include<stdio.h>
typedef struct{int Parent,Rank;}UnionFind;
UnionFind uft[100000];
int Root(int x){return(uft[x].Parent!=x)?uft[x].Parent=Root(uft[x].Parent):x;}
void Unite(int x,int y){x=Root(x),y=Root(y);if(x!=y)uft[x].Parent=y,uft[y].Rank+=uft[x].Rank;}
int Size(int x){return uft[Root(x)].Rank;}
int Belong(int x,int y){return Root(x)==Root(y);}
int main(void)
{
  int A,B,C,D,N,M,K,i,j;
  j=scanf("%d %d %d",&N,&M,&K);
  int known[N];
  for(i=0;i<N;i++){uft[i].Parent=i;uft[i].Rank=1;known[i]=0;}
  while(M--)
  {
    j=scanf("%d %d",&A,&B);
    A--,B--;known[A]++,known[B]++;Unite(A,B);
  }
  while(K--)
  {
    j=scanf("%d %d",&C,&D);
    C--,D--;if(Belong(C,D))known[C]++,known[D]++;
  }
  for(i=0;i<N;i++){printf("%d ",Size(i)-known[i]-1);}
  return printf("\n"),0;
}

Measured memory_bytes: 2560
(stdin => {
  // Define Function
  const sortArray = f => (...args) => args.sort(f)
  const ascendNumber = (a, b) => a - b
  // Declare Variable
  const inputs = stdin.toString().trim().split('\n')
  const [a, b, c] = Array.from(inputs[0].split(' '), Number)

  // display
  console.log(sortArray(ascendNumber)(a, b, c).join(' '))

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


Measured memory_bytes: 15152
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>

#define DIV 1000000007
using namespace std;
using ll = long long;

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

    vector<int> R;
    vector<int> G;
    vector<int> B;

    vector<char> s(N);
    for (int i = 0; i < N; i++) {
        cin >> s[i];
        if (s[i] == 'R')
            R.push_back(i);
        if (s[i] == 'G')
            G.push_back(i);
        if (s[i] == 'B')
            B.push_back(i);
    }

    ll ans = 0;
    for (int i = 0; i < R.size(); i++) {
        for (int j = 0; j < G.size(); j++) {
            ans += B.size();
            if (R[i] < G[j]) {
                int sa = G[j] - R[i];
                if (binary_search(B.begin(), B.end(), G[j] + sa))
                    ans--;
                if (binary_search(B.begin(), B.end(), R[i] - sa))
                    ans--;
                if (sa%2==0&&binary_search(B.begin(), B.end(), R[i] + sa/2))
                    ans--;
            }

            if (G[j] < R[i]) {
                int sa = R[i] - G[j];
                if (binary_search(B.begin(), B.end(), R[i] + sa))
                    ans--;
                if (binary_search(B.begin(), B.end(), G[j] - sa))
                    ans--;
                if (sa % 2 == 0 && binary_search(B.begin(), B.end(), G[j] + sa / 2))
                    ans--;
            }

        }
    }

    cout << ans << endl;
}


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

#define REP(i, n) for(decltype(n) i = 0; i < n; i++)

#define ALL(c)   c.begin(), c.end()
#define SORT(c)  std::sort(ALL(c))
#define RSORT(c) std::sort(ALL(c), std::greater<decltype(c)::value_type>())

using namespace std;
using ll = long long;

const int MOD  = (int)1e9 + 7;
const int INF  = (int)1e9 + 1;
const ll  LINF = (ll)1e18 + 1;

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

    int N;
    std::cin >> N;

    vector<int> H(N);
    REP(i, N) {
        std::cin >> H[i];
    }

    int ans = 0;
    while(true) {
        bool continue_flag = false;
        REP(i, N) {
            if(!continue_flag) {
                if(H[i] != 0) {
                    ans++;
                    H[i]--;
                    continue_flag = true;
                }
            }
            else {
                if(H[i] != 0) {
                    H[i]--;
                }
                else {
                    continue_flag = false;
                }
            }
        }

        if(accumulate(ALL(H), 0) == 0) break;
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 256
def c_Otoshidama_C(N, Y):
    import math
    # a,b,cをそれぞれ1万円札/5千円札/千円札の枚数とする
    t = (Y - 1000 * N) // 1000  # 不定方程式 9a+4b=t を解く
    # 不定方程式の解はa=4k+q,b=-9k+rとなる。
    q = t % 4
    r = (t - 9 * q) // 4
    # 問題の条件から、left<=rightとなれば非負整数解a,b,cが存在する。
    left = max(math.ceil(-q / 4), math.ceil((q + r - N) / 5))
    right = math.floor(r / 9)
    if left <= right:
        k = left
        a = 4 * k + q
        b = -9 * k + r
        c = N - a - b
        return '{} {} {}'.format(a, b, c)
    else:
        return '-1 -1 -1'
    # 参考: http://ark4rk.hatenablog.com/entry/2018/01/08/201801

N,Y=[int(i) for i in input().split()]
print(c_Otoshidama_C(N, Y))

Measured memory_bytes: 3064
#include<algorithm>
#include<chrono>
#include<ctime>  
#include<climits>
#include<functional>
#include<numeric>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<random>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<vector>
#include<cassert>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<string>
// #include<bits/stdc++.h>
using namespace std;
 
struct Debug{
    int cnt = 0;
    bool on = false;
    char debug[10] = "debug";
    template<class T>
    Debug & operator<<(const T & v) {
        if(on && cnt++ == 0) cerr << "debug: ";
        if(on) cerr << v << ' ';
        return *this;
    }
    Debug & operator<<(ostream&(*pManip)(ostream&)) {
        if(on) cerr << (*pManip);
        cnt = 0;
        return *this;
    }
} debug;
#define rep(i, a, b) for(auto i = (a); i < (b); i++)
#define rrep(i, a, b) for(auto i = (a); i > (b); i--)
#define all(v) (v).begin(), (v).end()
#define print(v) {if(debug.on){for(auto x : v) debug << x; debug << endl;}}
#define printn(v, n) {if(debug.on){for(int _i = 0; _i < n; _i++) debug << *(v + _i); debug << endl;}}
#define pb push_back


typedef unsigned long long ull;
typedef long long ll;
 
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
typedef vector<long long> vll;

const int MAXN = 1e6 + 10;

int n;
int a[MAXN] = {0, 3,2,1};

int main(int argc, char * argv[]) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    // cout.tie(nullptr);
    if(argc > 1 && !strcmp(argv[1], debug.debug)) debug.on = true;

    int x, y;
    cin >> x >> y;
    int res = 0;
    if(x <= 3) res += a[x];
    if(y <= 3) res += a[y];
    if(x == 1 && y == 1) res += 4;
    cout << res * 100000 << endl;




    return 0;
}













Measured memory_bytes: 256
D, G = map(int, input().split())
score = []
for _ in range(D):
    temp = list(map(int,input().split()))
    score.append(temp)

total = 10000
for i in range(2**D):
    sum_score = 0
    flag = 0
    total_temp = 0
    for j in range(D):
        if i >> j & 1 :
            sum_score += score[j][0]*100*(j+1)+score[j][1]
            total_temp += score[j][0]
        else:
            flag = j
    if sum_score >= G and total >= total_temp:
        total = total_temp
    elif sum_score < G:
        for _ in range(score[flag][0]-1):
            sum_score += (flag+1)*100
            total_temp += 1
            if sum_score >= G and total >= total_temp:
                total = total_temp
                break
print(total)


Measured memory_bytes: 3064
#include <stdio.h>

int main(void){
    int a,b,add,times,res;
    
    scanf("%d %d", &a, &b);
    add = a + b;
    times = a * b;
    
    if(add > times){
        res = add;
    }else{
        res = times;
    }
    
    if(res < a - b){
        res = a - b;
    }
    
    printf("%d\n", res);
    return 0;
}

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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;

vll adj[MAXN]; ll visit[MAXN] = {};
int dx8[] = {0, 1, 1, 1, 0, -1, -1, -1}, dy8[] = {1, 1, 0, -1, -1, -1, 0, 1};
int dx4[] = {0, 1, 0, -1}, dy4[] = {1, 0, -1, 0};

// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, x, y, r, p;
string s, t;
// <------------- Implement Functions Here ----------> //



// <------------- Start of main() -------------------> //

void MAIN() {
	cin>>n>>y;
	vll cnt(3,0);

	if(n*1000 > y || n*10000 < y) {
		cout<<"-1 -1 -1\n";
	}	
	else {
		for(ll i=0;i<=n;i++) {
			for(ll j = 0;j<=n-i;j++) {
				ll k = n-i-j;
				//cout<<i<<" "<<j<<" "<<k;newl;
				if(i*1000 + j*5000 + k*10000 == y) {
					cout<<k<<" "<<j<<" "<<i;newl;
					return;
				}
			}
		}
		cout<<"-1 -1 -1\n";
	}
}

int main() {
	fastio; randomINT;
	//cin>>t;
	while (T--) {
		MAIN();
	}
	return 0;
}


Measured memory_bytes: 237948
#### import ####
import sys
import math
from collections import defaultdict

#### 設定 ####
sys.setrecursionlimit(10**7)
def input():
  return sys.stdin.readline()[:-1]

#### 定数 ####
mod = 10**9 + 7

#### 読み込み ####
def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
  read_all = [tuple(map(int, input().split())) for _ in range(N)]
  return map(list,zip(*read_all))

#################

N = I()

A = III()

num = 0
for i in range(N):
  if A[i] < 0:
    num += 1

if num%2==0:
  print(sum(map(abs, A)))
else:
  print(sum(map(abs, A))-2*min(map(abs, A)))

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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

template<class T>bool chmax(T & a, const T & b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

lli cnts[1000100];

vector<lli> yaku(lli N){

    vector<lli> rtn;
    for(lli i=1;i*i<=N;i++){
        if(N%i==0){
            rtn.push_back(i);
            if(i!=N/i)rtn.push_back(N/i);
        }
    }
    return rtn;
}
void func(long long N, std::vector<long long> A){

    SORT(A);

    REP(i,0,N){
        cnts[A[i]]++;
    }

    set<lli> s;
    lli cnt=0;

    REP(i,0,N){
        bool ok = true;
        vector<lli> y = yaku(A[i]);
        REP(i,0,y.size())
        {
            if(s.find(y[i])!=s.end()){
                ok=false;
                break;
            }
        }
        if(ok){
            s.insert(A[i]);
            if(cnts[A[i]]==1)cnt++;
        }
    }

    cout<<cnt<<endl;

}

int main(){
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    func(N, std::move(A));
    return 0;
}


Measured memory_bytes: 15764
#[allow(unused_imports)]
use itertools::Itertools;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

fn main() {
    input! {
        n: usize,
        a: [i64; n],
        q: usize,
        bc: [(i64, i64); q],
    }

    let mut m = std::collections::BTreeMap::new();
    let mut s = 0;
    for a in a {
        *m.entry(a).or_insert(0) += 1i64;
        s += a;
    }

    for (b, c) in bc {
        let x = *m.get(&b).unwrap_or(&0);
        s += x * (c - b);
        m.remove(&b);
        *m.entry(c).or_insert(0) += x;
        println!("{}", s);
    }
}


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

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;

#define deb(x) cerr<<#x<<":"<<x<<"\n";
#define dvi(x) for(ll i=0;i<x.size();i++)cerr<<#x<<"["<<i<<"]:"<<x[i]<<" ";
#define iter(v) for(auto it:v)
#define wt ll t;cin>>t;while(t--)
#define rl(x) ll x;cin>>x;
#define rvi(x,n) vi x(n);for(ll i=0;i<n;i++) cin>>x[i];
#define rs(x) string x;cin>>x;
#define wvi(x) for(ll i=0;i<x.size();i++) cout<<x[i]<<" ";cout<<endl;
#define ws(x) cout<<x<<endl;
#define all(v) v.begin(),v.end()
#define pb push_back
#define ppb pop_back
#define pll pair<ll, ll>
#define fo(i,n) for(ll i=0;i<n;i++)
#define forr(i,a,b) for(ll i=a;i<b;i++)
#define decsort(b) sort(all(b),greater<ll>())
#define yes cout<<"YES\n";
#define no cout<<"NO\n";
const ll N = 1e9+7;

map<long long, long long> factorize(long long n) {	//returns map containing factor and multiplicity, Eg: 60 = {{2,2},{3,1},{5,1}}
	map<long long, long long> ans;
	for (long long i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ans[i]++;
			n /= i;
		}
	}
	if (n > 1) {
		ans[n]++;
		n = 1;
	}
	return ans;
}

void FAST() {	//FAST Input Output, DONT use both scnaf,prllf / cin,cout , Use any ONE system
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}

long long binpow(long long a, long long b, long long m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

ll answer(ll sum,vvi a,ll n,ll m)
{
	ll cnt1=0,cnt0=0;
	for(ll i=0;i<n;i++)
		{
			for(ll j=0;j<m;j++)
			{
				if(i+j==sum || i+j==n+m-2-sum)
				{
					if(a[i][j])cnt1++;
					else cnt0++;
				}
			}
		}
	return min(cnt0,cnt1);
}

int main()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
	FAST();
 	rl(n)
	rvi(a,n)
	vi pre(n);
	pre[0]=a[0];
	for(ll i=1;i<n;i++)
	{
		pre[i]+=pre[i-1]+a[i];
		pre[i]%=N;
	}
	ll ans=0;
	for(ll i=1;i<n;i++)
	{
		ans+=(pre[i-1]*a[i])%N;
		ans%=N;
	}
	cout<<ans;
}

Measured memory_bytes: 6312
import java.util.*;
public class Main {
    static Scanner kbd = new Scanner(System.in);
    public static void main(String[] args) {
	while(kbd.hasNext()){
	    int n = kbd.nextInt();
	    int k = kbd.nextInt();
	    boolean answer = true;
	    int i;

	    if(n!=0 && k!=0){
		int[] blood = new int[k];
		for(i=0; i<blood.length; i++){
		    blood[i] = kbd.nextInt();
		}
		for(; n>0; n--){
		    for(i=0; i<blood.length; i++){
			blood[i] -= kbd.nextInt();
			if(blood[i]<0) answer = false;
		    }
		}
		if(answer) System.out.println("Yes");
		else System.out.println("No");
	    }
	}
    }
}
			  

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

Measured memory_bytes: 256
import sys

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

def graph_input(N, M):
    G = [[] for _ in range(N + 1)]
    for _ in range(M):
        a, b = map(int, readline().split())
        G[a].append(b)
        G[b].append(a)
    return G

N, M = map(int, readline().split())
G = graph_input(N, M)

# 極大パスを作ればよい。辺をひとつとったあと、双方向に伸ばす。

visited = [0] * (N + 1)
a = 1
b = G[a][0]
Pa = [a]
Pb = [b]
visited[a] = 1
visited[b] = 1
while True:
    v = Pa[-1]
    for w in G[v]:
        if visited[w]:
            continue
        visited[w] = 1
        Pa.append(w)
        break
    if v == Pa[-1]:
        break
while True:
    v = Pb[-1]
    for w in G[v]:
        if visited[w]:
            continue
        visited[w] = 1
        Pb.append(w)
        break
    if v == Pb[-1]:
        break

P = Pa[::-1] + Pb
print(len(P))
print(*P)

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


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


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int main(){
 int N,L;
 cin>>N>>L;
int min=1000000; 
int answer=0;
int count=0;
 vector<int>data(N);
 for(int i=0; i<N; i++){
   data.at(i)=L+i;
   count+=data.at(i);
   if(abs(data.at(i))<abs(min)){
       min=data.at(i);
       answer=i+1;
   }
 }
 cout<<count-min<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pi pair<int, int>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define PI acos(-1.0)
using namespace std;
int Dp[100100], n, m, a, b;
vector<vector<int>> G;

int DFS(int u)
{
    int &ret = Dp[u];
    if (ret != -1) return ret;

    ret = 0;
    for (auto i : G[u])
        ret = max(ret, 1 + DFS(i));

    return ret;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    memset(Dp, -1, sizeof Dp);

    cin >> n >> m;
    G.resize(n+1);
    G.clear();

    for (int i=0; i<m; i++){
        cin >> a >> b;
        G[a].pb(b);
    }

    int Answer = 0;
    for (int i=1; i<=n; i++)
        Answer = max(Answer, DFS(i));

    cout << Answer << '\n';
    return 0;
}


Measured memory_bytes: 7424
n=int(input())
w=list(map(int,input().split()))
w1=sum(w)
w2=0
ans=9999999999999
for i in range(n-1):
    w1-=w[i]
    w2+=w[i]
    if ans>abs(w1-w2):
        ans=abs(w1-w2)
print(ans)


Measured memory_bytes: 3060
//https://atcoder.jp/contests/abc134/tasks/abc134_e
//E - Sequence Decomposing
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
const ll LINF = 0x1fffffffffffffff;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
template<class T>bool chmax(T &a, const T &b) {if (a<b) { a=b; return 1; } return 0;}
template<class T>bool chmin(T &a, const T &b) {if (b<a) { a=b; return 1; } return 0;}
int main() {
  ll N; cin>>N;
  vector<ll> an(N);
  for(auto&& a:an) cin>>a;

  multiset<ll> lis;
  for(const auto& a:an){
    auto it = lis.lower_bound(a);
    if(it != lis.begin()){
      --it;
      lis.erase(it);
    }
    lis.insert(a);
  }
  //dump(lis);
  cout<<lis.size()<<endl;
  return 0;
}

Measured memory_bytes: 5760
#include <iostream>
#include <algorithm>
#include <map>

using namespace std;
using ll = long long;

#define rep(i,n) for(int i=0;i<(n);++i)
#define all(f,c,...) (([&](decltype((c)) cccc) { return (f)(begin(cccc), end(cccc), ## __VA_ARGS__); })(c))

int main() {
  int N; scanf("%d", &N);

  map<string, int> m;
  ll ans = 0;
  rep(i, N) {
    char s[10]; scanf("%s", &s);
    all(sort, s);
    ans += m[s];
    ++m[s];
  }
  printf("%lld\n", ans);

  return 0;
}


Measured memory_bytes: 11136
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
typedef pair<string,string> Ps;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};
struct pos{
	// 1 変数を入れる;
	int x,y,sx,sy,cost;
};
int main() {

	int n;
	cin>>n;
	cout<<(1000-n%1000)%1000<<endl;

	return 0;
}


Measured memory_bytes: 3640
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
var n=Arr.shift()-0;
for(var i=0;i<n;i++){
   var arr=Arr.shift().split(" ").map(Number);
   (function(x1, y1, x2, y2, x3, y3, x4, y4){
      var k1=(x2-x1!=0)?(y2-y1)/(x2-x1):Infinity;
      var k2=(x4-x3!=0)?(y4-y3)/(x4-x3):Infinity;
      k1=k1.toFixed(6);
      k2=k2.toFixed(6);
      console.log((k1==k2)?"YES":"NO");
   }).apply(null,arr);
}

Measured memory_bytes: 7644
using Yorukatsu050.Questions;
using Yorukatsu050.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace Yorukatsu050.Questions
{
    /// <summary>
    /// https://atcoder.jp/contests/abc116/tasks/abc116_c
    /// </summary>
    public class QuestionC : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var n = inputStream.ReadInt();
            var height = new[] { 0 }.Concat(inputStream.ReadIntArray()).ToArray();

            var count = 0;
            for (int i = 0; i + 1 < height.Length; i++)
            {
                if (height[i + 1] > height[i])
                {
                    count += height[i + 1] - height[i];
                }
            }

            yield return count;
        }
    }
}


namespace Yorukatsu050
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionC();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace Yorukatsu050.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace Yorukatsu050.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

Measured memory_bytes: 13396
#include "bits/stdc++.h"
using namespace std;

int main() {
	long long N, M, A[300][300], Top[300] = {}, COUNT[300] = {}, ANS = 1000;
	bool used[300] = {};
	cin >> N >> M;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++) cin >> A[i][j], A[i][j]--;
	}
	for (int i = 0; i < M; i++) {
		for (int j = 0; j < N; j++) {
			while (used[A[j][Top[j]]]) Top[j]++;
		}
		for (int j = 0; j < M; j++) COUNT[j] = 0;
		for (int j = 0; j < N; j++) COUNT[A[j][Top[j]]]++;
		long long MAXN = -1, MAXA = -1;
		for (int j = 0; j < M; j++) {
			if (MAXN < COUNT[j]) {
				MAXN = COUNT[j];
				MAXA = j;
			}
		}
		ANS = min(ANS, MAXN);
		used[MAXA] = true;
	}
	cout << ANS << endl;
}

Measured memory_bytes: 896
#include<stdio.h>
int main(){
  int n,m,i;
  scanf("%d%d",&n,&m);
  int a[m+1][2],b[n+1];
  for(i=1;i<=n;i++)
    b[i]=0;
  for(i=1;i<=m;i++){
    scanf("%d%d",&a[i][0],&a[i][1]);
    if(a[i][0]==1)
      b[a[i][1]]=1;
  }
  for(i=1;i<=m;i++){
    if(a[i][1]==n && b[a[i][0]]!=0){
      puts("POSSIBLE");
      return 0;
    }
  }
  puts("IMPOSSIBLE");
  return 0;  
}


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

int main(){
  int N,X,Y; cin >> N >> X >> Y;
  vector<int> count(N);
  for(int i=1; i<=N-1; i++){
    for(int j=i+1; j<=N; j++){
      count[min(j-i,abs(X-i)+1+abs(Y-j))]++;
    }
  }
  
  for(int k=1; k<=N-1; k++) cout << count[k] << endl;
}

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

using namespace std;

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const ll inf = 1e18+7;
const ll mod = 1e9+7;


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

    if(a+b==3)cout<<3<<endl;
    else if (a+b==4)cout<<2<<endl;
    else cout<<1<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mod 1000000007
// #define mod 998244353
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin >> s;
	int ans = 0;
	for (int i = 1; i < s.length(); i++)
	{
		if (s[i] != s[i - 1])
		{
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3736
S = input()
if S == 'SUN':
  print(7)
elif S == 'MON':
  print(6)
elif S == 'TUE':
  print(5)
elif S == 'WED':
  print(4)
elif S == 'THU':
  print(3)
elif S == 'FRI':
  print(2)
else:
  print(1)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

int main(){
    int a,b,k;cin>>a>>b>>k;
    int c=0;
    int ans=0;
    for(int i=100;i>0;i--){
        if(a%i==0&&b%i==0) c++;
        if(c==k){
            ans=i;
            break;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256