akhauriyash/Code-Regression huggingface dataset:
def resolve():
    N = int(input())
    A = list(map(int, input().split()))
    minabs = float("inf")
    tmpx = 0
    tmpy = sum(A)
    for i in range(N-1):
        tmpx += A[i]
        tmpy -= A[i]
        if abs(tmpx - tmpy) < minabs:
            minabs = abs(tmpx - tmpy)
    print(minabs)

if '__main__' == __name__:
    resolve()

Measured memory_bytes: 76624
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true) {
			int a0 = sc.nextInt();
			int L = sc.nextInt();
			if(a0 == 0 && L == 0) break;
			
			String[] num = new String[30];/* 繰り返しは20以下のみ(ケースの条件) */
			num[0] = make6Digit(Integer.toString(a0), L);/* a0の保存 */

			//System.out.println("a0=" + num[0]);
			for(int i = 1; i < num.length; i++) {
				String max = makeMax(num[i-1], L);
				String min = makeReverse(max);
				num[i] = make6Digit(Integer.toString(
						Integer.parseInt(max) - Integer.parseInt(min)
						), L);
				//System.out.println("a" + i + ":" + max + "-" +  min + "=" + num[i]);
				
				boolean _break = false;
				for(int j = 0; j < i; j++){
					if(num[i].equals(num[j])) {
						System.out.println(j + " " + Integer.parseInt(num[i]) + " " + (i - j));
						_break = true;
						break;
					}
				}
				if(_break) break;
			}
		}
	}
	
	public static String makeMax(String num, int l) {
		num = make6Digit(num, l);/* 6桁にする */

		/* 降順ソート */
		Integer[] array = new Integer[num.length()];
		for(int i = 0; i < array.length; i++) {
			array[i] = Integer.parseInt(num.charAt(i) + "");
		}
		Arrays.sort(array, Comparator.reverseOrder());

		/* 連結 */
		String max = new String();
		for(int i = 0; i < array.length; i++)
			max += Integer.toString(array[i]);
		return max;
	}

	public static String makeReverse(String num) {
		return new String(new StringBuilder(num).reverse());
	}
	
	public static String make6Digit(String num, int l) {
		int add_0 = l - num.length();
		for(int i = 0; i < add_0; i++) {
			num = "0" + num;
		}
		return num;
	}
}



Measured memory_bytes: 30020
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> oset;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using ll = long long;

void test_case(){
	int k ; cin >> k;
	string s; cin >> s;
	if((int)s.size() > k){
		s = s.substr(0,k);
		cout<<s<<"...";
	}
	else{
		cout<<s;
	}
}
 
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int T=1;
	//~ cin >> T;
	while(T--){
		test_case();
	}
	return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
int main(){
  float a,b;
  int c;
  float d;
  int e;
  std::cin >> a >> b;

  c = (a + b)/2;
  d = (a + b)/2;

  e = c + (d - c)*2;

  std::cout << e << std::endl;
}


Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
constexpr int INF = 0x3f3f3f3f;
constexpr ll LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr double EPS = 1e-8;
constexpr int MOD = 1000000007;
// constexpr int MOD = 998244353;
constexpr int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
constexpr int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

#include <atcoder/dsu>
using namespace atcoder;

int main() {
  int n, q; cin >> n >> q;
  dsu uf(n);
  while (q--) {
    int t, u, v; cin >> t >> u >> v;
    if (t == 0) {
      uf.merge(u, v);
    } else if (t == 1) {
      cout << uf.same(u, v) << '\n';
    }
  }
  return 0;
}


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

//#define int long long
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* cpp template {{{ */

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define rep(i, n) REPS(i, 0, n)
#define REP0(i,n) for (ll i = 0; i <= (ll)(n); ++i)
#define REP1(i,n) for (ll i = 1; i <= (ll)(n); ++i)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << '\n';}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {rep(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) is >> x;
  //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいいです。
  return is;
}
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
  for(int i=0; i<vec.size(); i++){
    os << vec[i] << ( i+1 == vec.size() ? "" : " " );
  }
  return os;
}
/* }}} */

signed main() 
{
  int h,w;
  cin >> h >> w;
  string board[50];
  rep(i,h) cin >> board[i];
  rep(i,h) rep(j,w) 
  {
    if(board[i][j]=='#') continue;
    int tmp=0;
    rep(k,8)
    {
      int ni=i+dy[k], nj=j+dx[k];
      if(ni<0||ni>=h||nj<0||nj>=w) continue;
      else if(board[ni][nj]=='#') tmp++;
    }
    board[i][j]=char(tmp+'0');
  }
  rep(i,h) cout << board[i] << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <numeric>
#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
#define LL long long
#define Dev 1000000007

// sort(a.begin(), a.end(), std::greater<int>());
using namespace std;

int main()
{
    int n, m, x, y;
    cin >> n >> m >> x >> y;
    vector<int> a(n);
    vector<int> b(m);
    rep(i, n)
    {
        cin >> a[i];
    }
    rep(i, m)
    {
        cin >> b[i];
    }
    SORT(a);
    SORT(b);
    int xn = *(a.end()-1);
    int y1 = *(b.begin());
    if (max(x, xn) < min(y, y1))
        cout << "No War" << endl;
    else
        cout << "War" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <climits>
#include <cstring>
#include <string>
#include <map>
#include <set>
#include <vector>
#include <queue>


using namespace std;
#define INF 0x3f3f3f3f3f
#define ll long long
#define pr(x) (cerr << #x << ' ' << x << ' ')
#define prln(x) (cerr << #x << ' ' << x << endl)

const int maxn = 1e5 + 5;
int a[maxn];


int main()
{
	#ifdef LOCAL
		freopen("in.txt", "r", stdin);
	#endif // LOCAL
	int n, x;
	scanf("%d %d", &n, &x);
	// int min_val = INT_MAX;

	int pre;
	// int ans;
	for (int i = 1; i <= n; ++i) {
		scanf("%d", &a[i]);

		int t = abs(a[i] - x);
		if (i == 1) {
			pre = t;
			continue;
		}else {
			pre = __gcd(pre, t);
		}
	}
	cout << pre << endl;
	return 0;
}

Measured memory_bytes: 640
if __name__ == '__main__':
    arr = input().strip().split()
    res = []
    for i in range(len(arr)):
        if arr[i] not in '+-*':
            res.append(int(arr[i]))
        else:
            tmp1 = res.pop()
            tmp2 = res.pop()
            if arr[i] == '+':
                res.append(tmp1 + tmp2)
            elif arr[i] == '-':
                res.append(tmp2 - tmp1)
            else:
                res.append(tmp1 * tmp2)
    print(res[0])



Measured memory_bytes: 5604
W,H,x,y,r=input().split()
W,H,x,y,r=[int(W),int(H),int(x),int(y),int(r)]
result="Yes"
if x+r>W or x-r<0 :
    result="No"
if y+r>H or y-r<0 :
    result="No"
print(result)


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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define allsort(v) sort(v.begin(),v.end())
const int MAX_V = 300;
const int MAX_E = 300 * 300;
const ll INF = 1e10;
int par[MAX_V]; //親
int rnk[MAX_V]; //木の深さ
struct edge { int u, v; ll cost; };
edge es[MAX_E];
int V, E;//頂点,辺

int main() {
	cin.sync_with_stdio(false);
	ll d[300][300];
	cin >> V;
	rep(i, V) {
		rep(j, V)cin >> d[i][j];
	}
	rep(k, V) {
		rep(i, V) {
			rep(j, V) {
				ll x = d[i][j];
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
				if (d[i][j] != x) {
					cout << -1 << endl;
					return 0;
				}
			}
		}
	}
	ll sum = 0;
	rep(i, V) {
		rep(j, V)sum += d[i][j];
	}
	ll sum2=0;
	rep(k, V) {
		rep(i, V) {
			rep(j, V) {
				if (i == k || j == k)continue;
				if (d[i][j] == d[i][k] + d[k][j]) {
					sum2 += d[i][j];
					d[i][j] = INF;
				}
			}
		}
	}
	cout << (sum-sum2)/2 << endl;
	return 0;
}

Measured memory_bytes: 1024
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func main() {
	H := nextInt()
	W := nextInt()

	s1 := calc(H, W)
	s2 := calc(W, H)
	fmt.Println(min(s1, s2))
}

func calc(x, y int) int {
	ans := math.MaxInt64
	for i := 1; i < x; i++ {
		a := y * i
		b1 := (y / 2) * (x - i)
		b2 := (x - i) / 2 * y
		c1 := x*y - a - b1
		c2 := x*y - a - b2
		ans = min(ans, max(a, max(b1, c1))-min(a, min(b1, c1)))
		ans = min(ans, max(a, max(b2, c2))-min(a, min(b2, c2)))
	}

	return ans
}

// Input. ----------

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Split(bufio.ScanWords)
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}

	return i
}

func nextString() string {
	sc.Scan()
	if err := sc.Err(); err != nil {
		panic(err)
	}

	return sc.Text()
}

// ---------- Input.

// Util. ----------

func min(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}

func max(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}

// ---------- Util.


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;
#define all(v) v.begin(), v.end()
#define rep(i, from, to) for (ll i = from; i < ll(to); ++i)

vector<vi> ch;
vector<vi> adj;
void dfs(ll x, ll p){
    for (auto& a : adj[x]){
        if(a!=p){
            ch[x].push_back(a);
            dfs(a,x);
        }
    }
}
vector<vi> dp;
ll calc(ll x, ll t){
    if (dp[x][t] !=-1)return dp[x][t];
    if (ch[x].size() == 0){
        dp[x][t] = t;
        return t;
    }
    if (ch[x].size()==1){
        dp[x][t] = calc(ch[x][0],t);
        return dp[x][t];
    }
    ll totsum = 0;
    for(auto c : ch[x]){
        totsum += calc(c,1);
    }
    ll rans = totsum;
    for(auto c : ch[x]){
        rans = min(rans, totsum-calc(c,1)+calc(c,0));
    }
    dp[x][t] = rans;
    return rans;
}


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

    ll n;
    cin>>n;
    adj.resize(n);
    ch.resize(n);
    rep(i,0,n-1){
        ll x,y;
        cin>>x>>y;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    ll root = -1;
    rep(i,0,n){
        if (adj[i].size() > 2){
            root = i;
        }
    }
    if (root == -1) {
        cout<<1<<endl;
        return 0;
    }
    dfs(root,-1);

    ll oo = 1e9;
    dp.resize(n,vi(2,-1));

    cout<<calc(root,1)<<endl;




    return 0;
}


Measured memory_bytes: 20608
<?php
  list($n, $m) = explode(" ", trim(fgets(STDIN)));

  $ans = 0;

  if($m >= $n * 2){
    $ans = $n;
    $m = $m - $n * 2;
    
    $ans = $ans + intdiv($m, 4);
    
  }else{
    $ans = intdiv($m, 2);
  }

  echo $ans;
  


Measured memory_bytes: 16056
#include<bits/stdc++.h>
using namespace std;
int maxit(int a[][3],int n)
{
    int dp[n][3];
    for(int i=0;i<n;++i)
        for(int j=0;j<3;++j)
         dp[i][j]=0;
    dp[0][0]=a[0][0];
    dp[0][1]=a[0][1];
    dp[0][2]=a[0][2];
    for(int i=1;i<n;++i)
    {
        int max1=dp[i-1][1]+a[i][0];
        int max2=dp[i-1][2]+a[i][0];
        dp[i][0]=max(max1,max2);
        max1=dp[i-1][0]+a[i][1];
        max2=dp[i-1][2]+a[i][1];
        dp[i][1]=max(max1,max2);
        max1=dp[i-1][0]+a[i][2];
        max2=dp[i-1][1]+a[i][2];
        dp[i][2]=max(max1,max2);
    }
    return max(max(dp[n-1][0],dp[n-1][1]),dp[n-1][2]);

}
int main()
{
    int n;
    cin>>n;
    int a[n][3];
    for(int i=0;i<n;++i)
    {
        for(int j=0;j<3;++j)
            cin>>a[i][j];
    }
    cout<<maxit(a,n);
    return 0;
}


Measured memory_bytes: 2560
def main():
    s = list(input())
    wox = [i for i in s if i != "x"]
    if len(wox) == 0: return 0
    wowr = list(reversed(wox))
    for i in range(len(wox)//2+1):
        if wox[i] != wowr[i]:
            return -1
    sr = list(reversed(s))
    si = ri = 0
    ret = 0
    while si < len(s) and ri < len(sr):
        if s[si] == sr[ri]:
            si += 1
            ri += 1
        elif s[si] == "x":
            si += 1
            ret += 1
        else:
            ri += 1
            ret += 1
    return (ret + len(s) - min(si,ri))//2
print(main())

Measured memory_bytes: 6312
#include <bits/stdc++.h>
#define ll long long
#define dbg(x) cout<<#x<<"="<<x
#define nl cout<<"\n"
#define frn(i,n) for(int i = 0;i < n;i++)
#define fr(i,a,b) for(int i = a;i < b;i++)
#define pb push_back
#define trav(x,c) for(auto &x:c)
using namespace std;

int toint(string s) {
  int ans = 0;
  for(char x: s) ans = ans*10 + (x - '0');
  return ans;
}

int sum(int x) {
  int s = 0;
  while(x) {
    s += x%10;
    x /= 10;
  }
  return s;
} 

bool equal(string s) {
  for(int i = 0,j = s.size()/2;j < s.size();i++,j++) {
    if(s[i] != s[j]) return false;
  }
  return true;
}

int main() {
  int h,w;
  cin>>h>>w;
  string s[h];
  frn(i,h) cin>>s[i];
  frn(i,w+2) cout<<"#";nl;
  frn(i,h) {cout<<"#"<<s[i]<<"#";nl;}
  frn(i,w+2) cout<<"#";nl;
}

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

int n, m, k, cntx[300005], cnty[300005], ans;
vector <int> vx, vy;
set <pair<int, int> > st;

int main() {
    cin >> n >> m >> k;
    for (int i = 0, x, y; i < k; i++){
        cin >> x >> y;
        st.insert({x, y});
        cntx[x]++;
        cnty[y]++;
    }
    int mx = 0;
    for (int i = 1; i <= n; i++){
        if (cntx[i] > mx){
            mx = cntx[i];
            vx.clear();
            vx.push_back(i);
        }
        else if (cntx[i] == mx) vx.push_back(i);
    }
    ans += mx;
    mx = 0;
    for (int i = 1; i <= m; i++){
        if (cnty[i] > mx){
            mx = cnty[i];
            vy.clear();
            vy.push_back(i);
        }
        else if (cnty[i] == mx) vy.push_back(i);
    }
    ans += mx;
    for (int i:vx){
        for (int j:vy){
            if (!st.count({i, j})){
                cout << ans << "\n";
                return 0;
            }
        }
    }
    cout << ans-1 << "\n";
}


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

using namespace std;
using ll = long long;

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

int main() {
  int a, b;
  cin >> a >> b;
  int ans = 0;
  if (a >= 13)
    ans = b;
  else if (a >= 6)
    ans = b / 2;
  else
    ans = 0;
  cout << ans << endl;
  return 0;
}


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

int main() {
  int A , B , C , D;
  cin >> A >> B >> C >> D;
  
  int a = A + B;
  int c = C + D;
  
  if (a < c) {
    cout << "Right" << endl;
  }
  else if (a == c) {
    cout << "Balanced" << endl;
  }
  else if (a > c) {
    cout << "Left" << endl;
  }
}


Measured memory_bytes: 384
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>

const int N=105; 

using namespace std;

int n,res,L[N<<2]; 

int main(){
	cin>>n; 
	for(int i=1; i<=(n<<1); ++i) cin>>L[i];
	sort(L+1,L+(n<<1)+1); 
	for(int i=1; i<=(n<<1); i+=2) res+=min(L[i],L[i+1]); 
	cout<<res<<endl; 
	return 0; 
} 

Measured memory_bytes: 256
n, k, q = map(int, input().split())
aq = [int(input()) for i in range(q)]
point = [k for i in range(n)]
correct_ans = [0] * n

for i in range(q):
    correct_ans[aq[i] - 1] += 1
    
point = ['Yes'  if p - (q - ca) > 0 else 'No' for (p, ca) in zip(point, correct_ans)]

for p in point:
    print(p)

Measured memory_bytes: 9424
#!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A
"""
a,b,h = IR(3)
print(((a+b)*h)//2)
"""
#B
s = SR(3)
i = 0
while 1:
    if len(s[i]) == 0:
        if i == 0:print("A")
        if i == 1:print("B")
        if i == 2:print("C")
        quit()
    x = s[i].pop(0)
    if x == "a":i = 0
    if x == "b":i = 1
    if x == "c":i = 2
#C

#D
"""
h,w,n = LI()
dp = [0 for i in range(10)]
dp[0] = (h-2)*(w-2)
q = defaultdict(int)
for i in range(n):
    a,b = LI()
    a -= 1
    b -= 1
    for i in [-1,0,1]:
        for j in [-1,0,1]:
            if 0 < a+i < h-1 and 0 < b+j < w-1:
                q[(a+i)*w+b+j] += 1
                dp[q[(a+i)*w+b+j]] += 1
                dp[q[(a+i)*w+b+j]-1] -= 1
for i in dp:
    print(i)
"""
#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T


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

//define gcd and lcm (using 64bit)
ll gcd(ll a,ll b){
    if (a < b) {
        //^はxor(bitwise operator)。以下三行でswap(a,b)を行っている。
        a ^= b;
        b ^= a;
        a ^= b;
    }
    //only when b==0,this program finds that b means false and returns a.
    return b ? gcd(b, a % b) : a;
}

ll lcm(ll a,ll b){
    return a * b / gcd(a, b);
}


int main(){
    int n,d,ans=0;
    int a=0,c;
    double b=0;
    cin>>n>>d;
    vector<vector<int>> p(n,vector<int>(d));
    rep(i,n){
        rep(j,d) cin>>p[i][j];
    }
    rep(i,n){
        rep(j,i){
            rep(k,d){
                a+=(p[i][k]-p[j][k])*(p[i][k]-p[j][k]);
            }
            c=sqrt(a);
            b=sqrt(a);
            if(c==b) ans++;
            a=0;
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

int main(){
    string S;
    cin>>S;
    int tmp = 0;
    int tmpp = 0;
    if(S.at(2)==S.at(3)){
        tmp = 1;
    }
    if(S.at(4)==S.at(5)){
        tmpp = 1;
    }
    if(tmp*tmpp==1){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
A,B,K=map(int,input().split())

small=[n for n in range(A,min(A+K,B+1))]

large=[n for n in range(max(A,B-K+1),B+1)]

ans_set=set(small+large)
ans=list(ans_set)
ans.sort()
ans_str=list(map(str,ans))

print(' '.join(ans_str))


Measured memory_bytes: 3060
#Counterめちゃべんり！！ 辞書型のkey(),value(),items()をつかえるようにしよう
from collections import Counter

n = int(input())
a = list(map(int,input().split()))
aa = Counter(a)

ans = 0
for i,j in aa.items():
	if i > j:
		ans += j
	elif i < j:
		ans += j-i
print(ans)


Measured memory_bytes: 18676
import sys
import math

def input():
    return sys.stdin.readline().rstrip('\n')

N = int(input())
X = []
Y = []

for i in range(N):
    x,y = list(map(int,input().split()))
    X.append(x)
    Y.append(y)

def distance(i,j):
    return math.sqrt((X[i]-X[j])*(X[i]-X[j]) + (Y[i]-Y[j])*(Y[i]-Y[j]))

distance_sum = 0

for i in range(N):
    for j in range(N):
        distance_sum += distance(i,j)

print(distance_sum/N)


Measured memory_bytes: 38384
#include <iostream>
#include <cstdio>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <stdlib.h>
#include <functional>
#include <string>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <nmmintrin.h>
#include <chrono>
#define Scan(a) int a;scanf("%d", &a);
#define ScanS(a) char a[500];scanf("%s", a);
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#ifdef _MSC_VER
#define __builtin_popcount _mm_popcnt_u32
#define __builtin_popcountll _mm_popcnt_u64
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}
class Graph {
public:
	int vn;
	int sumcost = 0;
	vector<vector<pii>> g;

	Graph(int n) {
		vn = n;
		g.resize(n);
	}
	virtual void con(int a, int b, int w) = 0;
	int getWeight(int f, int t) {
		auto itr = lower_bound(ALL(g[f]), make_pair(t, INT_MIN));
		if (itr != g[f].end())
			return itr->second;
		return INT_MIN;
	}
	int Costsum() {
		return sumcost;
	}
	void scan(int edcount, bool oindexed, bool w) {
		REP(i, edcount) {
			int a, b, c = 1;
			scanf("%d %d", &a, &b);
			if (w)scanf("%d", &c);
			con(a - oindexed, b - oindexed, c);
		}
	}
};
class BiDGraph : public Graph {//無向
public:
	BiDGraph(int n) : Graph(n) {}

	void con(int a, int b, int w = 1) {
		g[a].push_back({ b,w });
		g[b].push_back({ a, w });
		sumcost++;
	}
};
signed main() {

	int n;
	cin >> n;

	map<int, int> cou;

	REP(i, n) {
		int a;
		scanf("%d", &a);
		cou[a]++;
	}

	int f = 0, s = 0;

	for (auto itr : cou) {
		if (itr.second >= 2) {
			if (f < itr.first) {
				if (itr.second >= 4)
					s = itr.first, f = itr.first;
				else {
					s = f;
					f = itr.first;
				}
			}
			else if (s < itr.first) {
				s = itr.first;
			}
		}
	}

	printf("%lld\n", 1LL*f*s);

	return 0;
}

Measured memory_bytes: 4992
using System;
using System.Linq;
using System.Collections.Generic;

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var xyzk = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        // var xyz = xyzk.Take(3).ToArray();
        var k = xyzk[3];
        var dss = new long[3][];
        for (int i = 0; i < dss.Length; i++)
        {
            dss[i] = Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray();
        }

        for (int i = 0; i < dss.Length; i++)
        {
            Array.Sort(dss[i]);
            Array.Reverse(dss[i]);
        }

        var topK = new long[k];
        var candidates = new SortedSet<Tuple<long, int>>();
        var rankedIn = new HashSet<int>();
        candidates.Add(Tuple.Create(dss.Sum(x => x[0]), 0));
        for (int i = 0; i < topK.Length; i++)
        {
            topK[i] = candidates.Max.Item1;
            var abc = candidates.Max.Item2;
            candidates.Remove(candidates.Max);
            rankedIn.Add(abc);
            for (int j = 0; j < dss.Length; j++)
            {
                var jj = abc >> 10 * j & (1 << 10) - 1;
                if (jj + 1 > dss[j].Length - 1)
                {
                    continue;
                }

                var abcNext = abc + (1 << 10 * j);
                if (rankedIn.Contains(abcNext))
                {
                    continue;
                }
                candidates.Add(Tuple.Create(topK[i] - dss[j][jj] + dss[j][jj + 1], abcNext));
            }
        }
        Console.WriteLine(string.Join("\n", topK));
    }
}


Measured memory_bytes: 21080
import math

def cross(a,b): #外積
  return a.real*b.imag-a.imag*b.real

def dot(a,b): #内積
  return a.real*b.real+a.imag*b.imag

def norm2(a,b): #大きさの2乗
  return (b.real-a.real)**2+(b.imag-a.imag)**2

def is_intersect(p0,p1,p2,p3): #交差しているのかを判定
  ta=cross(p1-p0,p2-p0)
  tb=cross(p1-p0,p3-p0)
  tc=cross(p3-p2,p0-p2)
  td=cross(p3-p2,p1-p2)

  if ta*tb<0 and tc*td<0:
    return True
  else:
    return False

def distance_option(p0,p1,p2):
  nn=norm2(p0,p1)
  #print(dot(p1-p0,p2-p0),nn)
  if 0<=dot(p1-p0,p2-p0)<=nn:
    return abs(cross(p1-p0,p2-p0))/math.sqrt(nn)
  else:
    return math.sqrt(min(norm2(p0,p2),norm2(p1,p2)))

def distance(p0,p1,p2,p3):
  if is_intersect(p0,p1,p2,p3):
    return 0
  else:
    #print(distance_option(p0,p1,p2),distance_option(p0,p1,p3),distance_option(p2,p3,p0),distance_option(p2,p3,p1))
    return min(distance_option(p0,p1,p2),distance_option(p0,p1,p3),distance_option(p2,p3,p0),distance_option(p2,p3,p1))

q=int(input())

for _ in [0]*q:
  x_y=map(int,input().split())
  p0,p1,p2,p3=[x+y*1j for x,y in zip(*[x_y]*2)]
  print("{:.10f}".format(distance(p0,p1,p2,p3)))


Measured memory_bytes: 5724
while n = gets
  s = n.split(" ").map(&:to_f)
  x = (s[2] * s[4] - s[1] * s[5]) / (s[0] * s[4] - s[1] * s[3])
  y = (s[2] - s[0] * x) / s[1]
  x = 0.0 if x.zero?
  y = 0.0 if y.zero?
  printf("%.3f %.3f\n", x, y)
end

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

#define FOR(i, m, n) for(int (i) = (m); (i) < (n); (i)++)
#define rep(i, n) FOR(i, 0, n)
#define co(n) cout << (n) << endl
#define cosp(n) cout << (n) << ' '
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
typedef long long ll;
typedef pair<int, int> P;

const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;

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

	FOR(i, 1, 10){
		if(!(n%i) && n/i < 10){
			co("Yes");
			return 0;
		}
	}

	co("No");

	return 0;
}


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

int main() {
    string sa, sb, sc, s;
    char tmp;
    int status;
    cin >> sa >> sb >> sc;
    tmp = sa[0];
    s = sa.erase(0, 1);
    while (true) {
        if (tmp == 'a') {
            tmp = sa[0];
            sa = sa.erase(0,1);
            s = sa;
            status = 0;
        } else if (tmp == 'b') {
            tmp = sb[0];
            sb = sb.erase(0,1);
            s = sb;            
            status = 1;
        } else if (tmp == 'c') {
            tmp = sc[0];
            sc = sc.erase(0,1);
            s = sc;
            status = 2;
        } else if (s == "") {
            break;
        }
        //cout << sa << endl;
        //cout << sb << endl;
        //cout << sc << endl;
    }
    if (status == 0) cout << "A" << endl;
    if (status == 1) cout << "B" << endl;
    if (status == 2) cout << "C" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <cctype>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const ll INFLL = 1001001001001001001;  // > 10^18
const int MOD = (int)1e9 + 7;
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

vector<int> enum_divisor (int n) {
    vector<int> res;
    for (int i = 1; i*i <= n; i++) {
        if (n % i == 0) {
            res.push_back(i);
            if (i != (n/i)) {
                res.push_back(n/i); 
            }
        }
    }
    return res;
}

int main() {
    
    int n; cin >>n;
    vector<int> a(n+1); REP(i,n) cin >> a[i+1];
    vector<int> count(n+1);
    vector<int> res;

    int rescount=0;
    for (int j = n; j >= 1; j--) {
        if (count[j] % 2 != a[j]) {
            res.push_back(j);
            rescount++;
            for (int i = 1; i*i <= j; i++) {
                if (j % i == 0) {
                    count[i]++;
                    if (i != (j/i)) {
                        count[j/i]++;
                    }
                }
            }
        } 
    }

    cout << rescount << endl;
    if (rescount > 0) {
        for (int i = 0; i < res.size(); i++) {
            cout << res[i];
            if (i < res.size() - 1) {
                cout << " ";
            } 
        }
        cout << endl;
    } 
    
    

    return 0;

}




Measured memory_bytes: 3064
#include <iostream>
#include <set>

using namespace std;

char M[101][101];

int main() {
    int H, W;
    cin >> H >> W;
    for (int h = 0; h < H; ++h) {
        cin >> M[h];
    }

    set<int> memo_h;
    set<int> memo_w;
    while (true) {
        bool compressed = false;
        for (int h = 0; h < H; ++h) {
            if (memo_h.find(h) != memo_h.end()) continue;
            int w = 0;
            for (; w < W; ++w) {
                if (M[h][w] == '#') break;
            }
            if (w == W) {
                memo_h.insert(h);
                compressed = true;
            }
        }
        for (int w = 0; w < W; ++w) {
            if (memo_w.find(w) != memo_w.end()) continue;
            int h = 0;
            for (; h < H; ++h) {
                if (M[h][w] == '#') break;
            }
            if (h == H) {
                memo_w.insert(w);
                compressed = true;
            }
        }
        if (!compressed) break;
    }

    for (int h = 0; h < H; ++h) {
        if (memo_h.find(h) != memo_h.end()) continue;
        for (int w = 0; w < W; ++w) {
            if (memo_w.find(w) != memo_w.end()) continue;
            cout << M[h][w];
        }
        cout << endl;
    }
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define N 100005
typedef struct pp{
  char name[100];
  int t;
}P;

P Q[N];
int hazime,owari,n;
void enqueue(P x){
  Q[owari] = x;
  owari=(owari+1)%N;
}
P dequeue(){
  P x=Q[hazime];
  hazime=(hazime+1)%N;
  return x;
}
int min(int a,int b){return a<b?a:b;}

int main(){
  int karuma=0,c;
  int i,q;
  P u;
  scanf("%d%d",&n,&q);
  for(i=1;i<=n;i++){
  scanf("%s",Q[i].name);
  scanf("%d",&Q[i].t);
 }
 hazime=1;owari=n+1;

 while(hazime!=owari){
   u=dequeue();
   c=min(q,u.t);
   u.t-=c;
   karuma+=c;
   if(u.t>0)enqueue(u);
   else{
     printf("%s %d\n",u.name,karuma);
   }
 }
 return 0;
}




Measured memory_bytes: 11864
n = int(input())
nums = list(map(int, input().split()))

a = nums[-1]
for i in range(n - 1):
    a += (-1)**i * nums[n - 2 - i]

res = dict()
res[n - 1] = a

for i in range(n - 1):
    res[n - 2 - i] = 2 * nums[n - 2 - i] - res[n - i - 1]
res = [res[i] for i in range(n)]
print(' '.join(map(str, res)))

Measured memory_bytes: 92516
//#include <algorithm>
//#include <cassert>
//#include <cfloat>
//#include <cmath>
//#include <cstdio>
//#include <cstdlib>
//#include <deque>
#include <iostream>
//#include <limits>
//#include <map>
//#include <queue>
//#include <set>
//#include <stack>
//#include <string>
//#include <tuple>
//#include <unordered_map>
//#include <unordered_set>
//#include <vector>
using namespace std;

#define MIN(x, y) ((x) < (y) ? (x) : (y))
#define MAX(x, y) ((x) > (y) ? (x) : (y))

#define DIVUP(x, y) (((x) + ((y) - 1)) / (y))
#define DIVOFF(x, y) (((x) + ((y) / 2)) / (y))
#define REMAINDER(x, y) ((x) % (y))

int N;

int dfs(long num, bool n3, bool n5, bool n7) {
  if (num > N) return 0;

  int count{};

  if (n3 && n5 && n7) {
    ++count;
  }

  num *= 10;
  count += dfs(num + 3, true, n5, n7);
  count += dfs(num + 5, n3, true, n7);
  count += dfs(num + 7, n3, n5, true);

  return count;
}

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

  int count = dfs(0L, false, false, false);

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


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

int main()
{
    int a, b;
    char op;
    while (1)
    {
        cin >> a >> op >> b;
        if (op == '?')
            break;
        switch (op)
        {
        case '+':
            cout << a + b << endl;
            break;
        case '-':
            cout << a - b << endl;
            break;
        case '*':
            cout << a * b << endl;
            break;
        case '/':
            cout << a / b << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 3076
using System;
using System.Linq;

namespace Contest
{
    

    class Program
    {

        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(" ");
            var n = int.Parse(input[0]);
            var k = int.Parse(input[1]);

            int[] p = Console.ReadLine().Split(" ").Select(int.Parse).OrderBy(x => x).ToArray();

            int ans = 0;
            for(int i = 0; i < k; i++)
            {
                ans += p[i];
            }

            Console.WriteLine(ans);

            
        }
    }
}




Measured memory_bytes: 28464
@{$_ x3}=1for A..D;for$i(1..<>-1){for$j(@_=glob'{A,B,C,D}'x3){(${$j=~/./;$'.$_}[$i]+="$j$_"!~/ABC|A.*C.*B|CAB/*$$j[$i-1])%=$%=1e9+7for A..D}}($\+=$$_[-1])%=$%for@_;print

Measured memory_bytes: 1024
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <iomanip>
#include<set>
#include <numeric>
#pragma region Macros
#define int long long
#define double long double
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,n) for(int i=1;i<=n;i++)
#define LAST(x) x[x.size()-1]
#define ALL(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
#define DIVCEIL(a,b) ((a+b-1)/b)
//int CHMAX

int intpow(int a, int n) {
	// a^nのint ver
	rep(i, n - 1)
		a *= a;
	return a;
}
int MODPOW(int a, int n, int mod) {
	// a^n mod
	int ans = 1;
	while (n > 0) {
		if (n & 1)
			ans = ans * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return ans;
}
int FACT(int a) {
	if (a == 0)
		return 1;
	else
		return a * FACT(a - 1);
}
int MODFACT(int a, int mod) {
	if (a == 0)
		return 1;
	else
		return (a * FACT(a - 1)) % mod;
}
int nPr(int n, int r) {
	int s = n - r + 1;
	int sum = 1;
	for (int i = s; i <= n; i++)
		sum *= i;
	return sum;
}
int MODnPr(int n, int r, int mod) {
	int s = n - r + 1;
	int sum = 1;
	for (int i = s; i <= n; i++) {
		sum *= i;
		sum = sum % MOD;
	}
	return sum;
}
//int nCr(int n, int r)
int nCr2(int n, int r) {
	return FACT(n) / (FACT(r) * FACT(n - r));
}
int GCD(int a, int b)
{
	if (a < b)
		swap(a, b);
	if (b == 0)
		return a;
	if (a % b == 0)
		return b;
	return GCD(b, a % b);
}
int LCM(int a, int b)
{
	return  a * b / GCD(a, b);
}
int NUMOFDIV(int n) {
	//約数の数（だっけ？）
	int ans = 0;
	REP(i, n) {
		if (n % i == 0)
			ans++;
	}
	return ans;
}
int CEIL1(int n) {
	//1桁目切り上げ
	return (n + 9) / 10 * 10;
}
int DIGIT(int n, int k) {
	//nのk桁目
	rep(i, k - 1)
		n /= 10;
	return n % 10;
}
int DIGITSUM(int n) {
	int sum = 0, dig;
	while (n) {
		dig = n % 10;
		sum += dig;
		n /= 10;
	}
	return sum;
}
int DIVTIME(int n, int k) {
	//nをkで何回割れるか的な
	int div = 0;
	while (n % k == 0) {
		div++;
		n /= k;
	}
	return div;
}
int binary(int n) {
	//10進数→2進数
	int ans = 0;
	for (int i = 0; n > 0; i++) {
		ans += n % 2 * intpow(10, i);
		n /= 2;
	}
	return ans;
}
double LOG(int a, int b) {
	return log(b) / log(a);
}
inline bool BETWEEN(int x, int min, int max) {
	if (min <= x && x <= max)
		return true;
	else
		return false;
}
inline bool between(int x, int min, int max) {
	if (min < x && x < max)
		return true;
	else
		return false;
}
inline bool PRIMEOR(int x) {
	if (x == 1)
		return false;
	if (x == 2)
		return true;
	if (x % 2 == 0)
		return false;
	double sqrtx = sqrt(x);
	for (int i = 3; i <= sqrtx; i += 2) {
		if (x % i == 0)
			return false;
	}
	return true;
}
bool SQRTOR(int n) {
	if (sqrt(n) == (int)sqrt(n))
		return true;
	else
		return false;
}
// 順位付け
using namespace std;
#pragma endregion

signed main() {
	int N, K;
	string S;
	cin >> N >> S >> K;
	char x = S[K - 1];
	rep(i, N) {
		if (S[i] != x)
			S[i] = '*';
	}
	cout << S << endl;

}

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

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int a, b, c;
    
    cin >> a >> b >> c;
    
    if ((a + b + c) >= 22)
    {
        cout << "bust";
    }
    else
    {
        cout << "win";
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define rev(v) reverse(v.begin(), v.end())
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
#define OK { cout << "OK" << endl; return 0; }
#define NG { cout << "NG" << endl; return 0; }
#define sz(v) ((int)(v).size())
#define uniq(a) sort(all(a));(a).resize(unique(all(a)) - a.begin());
#define dab(v) for(auto i:v)cout<<i<<' '; cout << endl;
#define vin(v) for (ll i = 0; i < v.size(); ++i) cin >> v[i];
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 (a>b) { a=b; return 1; } return 0; }
template<class T>void out(T a){cout << a << endl;}
template<class T>void die(T a){cout << a << endl; exit(0);}
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

#define SIZE 200005
#define MOD 1000000007
 
typedef pair <int,int> P;
 
ll inv[SIZE], fac[SIZE], finv[SIZE];
void make(){
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for(int i=2; i<SIZE; i++)
	{
		inv[i] = MOD - inv[MOD%i]*(MOD/i)%MOD;
		fac[i] = fac[i-1] * (ll) i % MOD;
		finv[i] = finv[i-1] * inv[i] % MOD;
	}
    return ;
}
ll comb(int a,int b){
	if(a < b) return 0;
	return fac[a] * (finv[b] * finv[a-b] % MOD) % MOD;
}



ll beki(int a, int n){
    if(n == 0) return 1;
    ll ans = beki(a, n / 2);
    ans = ans * ans;
    if(n % 2 == 1) ans = ans * a;
    return ans;
}




int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    //cout << fixed << setprecision(15);
    
    ll A,V,B,W,T; cin >> A>>V>>B>>W>>T;
    if(V <= W) NO;

    ll sa = V - W;
    ll wa = V + W;
    ll kyori = abs(A - B);
    if(T * sa >= kyori) YES
    else NO



    
}

Measured memory_bytes: 3652
#!python3.8
# -*- coding: utf-8 -*-
# abc173/abc173_b
import sys
from collections import Counter

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N = i2n()
    cntr = Counter()
    for _ in range(N):
        S = i2s()
        cntr[S] += 1
    print(f'AC x {cntr["AC"]}')
    print(f'WA x {cntr["WA"]}')
    print(f'TLE x {cntr["TLE"]}')
    print(f'RE x {cntr["RE"]}')
    return

main()


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

int n, a; 
int main() {
	cin >> n;
  	for(int i = 0; i < n; i++) {
    	cin >> a;
      	if(a % 2 == 0 && (a % 3 != 0 && a % 5 != 0)) {
        	cout << "DENIED";
          	return 0;
        }
    }
    cout << "APPROVED";
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#define MAXN 510

int n,m;
int a[MAXN][MAXN];

int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++){
		static char str[MAXN];
		scanf("%s",str+1);
		for(int j=1;j<=m;j++)
			if(str[j]=='#')
				a[i][j]=1;
	}
	for(int j=1;j<=m;j++) putchar('#');
	puts("");
	for(int i=2;i<n;i++){
		for(int j=1;j<=m;j++)
			if((j&1) || a[i][j]) putchar('#');
			else putchar('.');
		puts("");
	}
	for(int j=1;j<=m;j++) putchar('.');
	puts(""); puts("");
	for(int j=1;j<=m;j++) putchar('.');
	puts("");
	for(int i=2;i<n;i++){
		for(int j=1;j<=m;j++)
			if(((~j)&1) || a[i][j]) putchar('#');
			else putchar('.');
		puts("");
	}
	for(int j=1;j<=m;j++) putchar('#');
}


Measured memory_bytes: 1664
import sys
from collections import deque
input = lambda: sys.stdin.readline().rstrip()
Yes = lambda boolean: print('Yes') if boolean else print('No')
YES = lambda boolean: print('YES') if boolean else print('NO')
aint = lambda: int(input())
ints = lambda: list(map(int, input().split()))
is_even = lambda x: True if x%2==0 else False
zeros2d = lambda r,c: [[0 for col in range(c)] for row in range(r)]

n,m = ints()
a = ints()
s = sum(a)
print(max(-1,n-s))

Measured memory_bytes: 10100
#include <iostream>
using namespace std;
struct Card {
	char suit, value; 
}A[36];
//ascend
void bubble_sort(struct Card A[], int N)
{
	for (int i = 0; i < N; i++)
	{
		for (int j = N - 1; j >= i + 1; j--)//最后一个是i+1与i的交换
		{
			if (A[j].value < A[j - 1].value)
				swap(A[j], A[j - 1]);		
		}
	}
 }

//ascend
void selection_sort(struct Card A[], int N)
{
	for (int i = 0; i < N - 1; i++)
	{
		int minj = i;
		for(int j=i;j<N;j++)
			{
				if(A[j].value<A[minj].value) minj=j;
				 
			}
		if (minj != i)
			swap(A[i], A[minj]);
	}
}

void print(struct Card A[], int N)
{
	for (int i = 0; i < N; i++)
	{
		if (i) cout << " ";
		cout << A[i].suit << A[i].value;
	}
	cout << endl;
}

//比较冒泡与选择排序的结果
bool isStable(struct Card C1[], struct Card C2[], int N)
{
	for (int i = 0; i < N; i++)
	{
		if (C1[i].suit != C2[i].suit) return false;
	}
	return true;
}

int main()
{
	Card C1[40], C2[40];
	int N;
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> C1[i].suit >> C1[i].value;
	}
	for (int i = 0; i < N; i++)
	{
		C2[i] = C1[i];
	}
	bubble_sort(C1, N);
	selection_sort(C2, N);
	print(C1, N);
	cout << "Stable" << endl;
	print(C2, N);
	if (isStable(C1, C2, N))
		cout << "Stable" << endl;
	else cout << "Not stable" << endl;
	
	return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
int n,sum=0;
int main()
{
	cin>>n;
	int v[n+1],c[n+1];
	for(int i=1;i<=n;i++)
	{
		cin>>v[i]; 
	}
	for(int i=1;i<=n;i++)
	{
		cin>>c[i];
	}
	for(int i=1;i<=n;i++)
	{
		if(v[i]>c[i])
		{
			sum+=v[i]-c[i];
		}
	}
	cout<<sum<<endl;
	return 0;
} 

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

namespace AOJ
{
	class Program
	{
		static void Main(string[] args)
		{
			var map = new bool[9 + 2][];
			map[0] = map[10] = new bool[7];
			for (int i = 1; i < 10; i++)
			{
				map[i] = ("0" + Console.ReadLine() + (i % 2 == 0 ? "0" : "00")).Select(c => c == '1').ToArray();
			}

			Console.WriteLine(new string(f(map).ToArray()));
		}

		static IEnumerable<char> f(bool[][] map)
		{
			yield return 'R';
			int[] ax1 = new int[4] { 0, 0, 0, -1 };
			int[] ay1 = new int[4] { -1, 0, 1, 0 };
			int[] ax2 = new int[4] { 0, 1, 0, -1 };
			int[] ay2 = new int[4] { -2, 0, 2, 0 };
			int x = 2, y = 1, o = 0;
			while (!(x == 1 && y == 1))
			{
				var flg = false;
				for (int i = o; i < 4 + o; i++)
				{
					int p = i % 4;
					if (map[y + ay1[p]][x + ax1[p]])
					{
						o = (p + 3) % 4;
						yield return "URDL"[p];
						x += ax2[p];
						y += ay2[p];
						flg = true;
						break;
					}
				}
				if (!flg) break;
			}
		}
	}
}

Measured memory_bytes: 5564
#include<stdio.h>
int main(void)
{
	long long int a, b,num,ans;
	ans = 0;
	scanf("%lld%lld%lld", &a, &b, &num);
	if (a == 0) ans = b / num + 1;
	else
	{
		b = b / num + 1;
		a = (a - 1) / num +1;
		ans = b - a;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 128