akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            new Program().Solve();
        }

        public void Solve()
        {
            var sc = new Scanner();
            int A = sc.NextInt();
            int B = sc.NextInt();

            if (A >= 13)
            {
                Console.WriteLine(B);
            }

            if (6 <= A && A <= 12)
            {
                Console.WriteLine(B/2);
            }

            if (A <= 5)
            {
                Console.WriteLine("0");
            }
        }
    }
}




class Scanner
{
    public Scanner()
    {
        _stream = new StreamReader(Console.OpenStandardInput());
        _pos = 0;
        _line = new string[0];
    }

    const char Separator = ' ';
    private readonly StreamReader _stream;
    private int _pos;
    private string[] _line;

    #region スペース区切りで取得

    public string Next()
    {
        if (_pos >= _line.Length)
        {
            _line = _stream.ReadLine().Split(Separator);
            _pos = 0;
        }

        return _line[_pos++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }

    #endregion

    #region 型変換

    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }

        return result;
    }

    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }

        return result;
    }

    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }

        return result;
    }

    #endregion

    #region 配列取得

    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = _stream.ReadLine().Split(Separator);

        _pos = _line.Length;
        return _line;
    }

    public int[] IntArray()
    {
        return ToIntArray(Array());
    }

    public long[] LongArray()
    {
        return ToLongArray(Array());
    }

    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }

    #endregion
}


Measured memory_bytes: 11092
#include <stdio.h>
#define N_MAX 300010
#define ll long long
#define CONST 998244353

ll C[N_MAX];

ll ext_gcd(ll a, ll b, ll&x, ll&y){
    if(b == 0){
        x = 1; y = 0; return a;
    }
    ll q = a / b;
    ll g = ext_gcd(b, a-q*b, x, y);
    ll z = x - q * y;
    x = y; y = z;
    return g;
}

ll invmod(ll a, ll m){
    ll x, y;
    ext_gcd(a, m, x, y);
    x %= m;
    if(x < 0) x += m;
    return x % CONST;
}


int main(void){
    ll N, A, B, K;
    scanf("%lld", &N);
    scanf("%lld", &A);
    scanf("%lld", &B);
    scanf("%lld", &K);

    C[0] = 1;
    for(ll i = 1; i <= N; i++){
        C[i] = ((C[i - 1] * (N - i + 1)) % CONST * invmod(i, CONST)) % CONST;
        //printf("%lld %lld\n", i, C[i]);
    }

    ll sum = 0;
    for(ll n1 = 0; n1 <= N; n1++){
        if((K - A * n1) < 0){
            break;
        }
        if((K - A * n1) % B != 0){
            continue;
        }
        ll n2 = (K - A * n1) / B;
        if(n2 > N){
            continue;
        }
        sum += C[n1] * C[n2];
        sum = sum % CONST;
    }

    printf("%lld\n", sum);
}


Measured memory_bytes: 3192
import Control.Applicative
import Data.List

ints :: String -> [Int]
ints s = map read $ words s

getLines :: IO [[Int]]
getLines = do
  [a, b] <- ints <$> getLine
  if a == 0 && b == 0
    then return []
    else do
      rest <- getLines
      return ([a, b] : rest)

calc :: Int -> Int -> String
calc w h = intercalate "\n" $ c
  where
    a = take w $ cycle "#."
    b = take w $ cycle ".#"
    c = take h $ cycle [a, b]

main :: IO ()
main = do
  xs <- getLines
  putStrLn $ intercalate "\n\n" [calc w h | ys <- xs, let [h, w] = ys]
  putStrLn ""

Measured memory_bytes: 5112
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100//000000000
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<int, int>
#define PP pair<P,P>
#define T tuple<int,int,int>
#define pr(x) cout << x << endl;
using namespace std;

int n,m,r,ans;
int d[210][210];
vector<int> ress;

void solve(vector<int> list, vector<int> vis){
  if(list.size()==r){
    int tmp=0;
    rep(i,r-1){
      //cout << i << endl;
      tmp+=d[list[i]][list[i+1]];
    }
    //cout << tmp << endl;
    ans=min(ans,tmp);
    return;
  }
  rep(i,vis.size()){
    vector<int> nvis=vis;
    vector<int> nlist=list;
    nlist.push_back(ress[nvis[i]]);
    nvis.erase(nvis.begin()+i);
    solve(nlist,nvis);
  }
}

int main(){
  cin >> n >> m >> r;
  rep(i,r){
    int tr; cin >> tr;
    ress.push_back(--tr);
  }
  vector<vector<int> > ki(n);
  int cost[210][210];

  rep(i,m){
    int a,b,c; cin >> a >> b >> c;
    a--; b--;
    ki[a].push_back(b);
    ki[b].push_back(a);
    cost[a][b]=cost[b][a]=c;
  }

  rep(i,r-1){
    for(int j=i+1; j<r; j++){
      priority_queue<P> q;
      q.emplace(0,ress[i]);
      vector<int> mc(n,INF);
      mc[ress[i]]=0;
      while(!q.empty()){
        int now=q.top().second;
        int nowc=q.top().first;
        q.pop();
        for(int x : ki[now]){
          int newcost=nowc+cost[now][x];
          if(newcost<mc[x]){
            q.emplace(newcost,x);
            mc[x]=newcost;
          }
        }
      }
      d[ress[i]][ress[j]]=d[ress[j]][ress[i]]=mc[ress[j]];
    }
  }
  ans=INF;
  vector<int> vist(r);
  rep(i,r) vist[i]=i;
  vector<int> emp;
  solve(emp,vist);
  cout << ans << endl;
return 0;
}

Measured memory_bytes: 4052
#include<stdio.h>
#include<string.h>
int main(){
   char s[10];
   scanf("%s",s);
   char t[strlen(s)+1];
   scanf("%s",t);
   int i,judg=0;
   for(i=0;i<strlen(s);i++){
      if(s[i]==t[i]){
      }else{
         judg++;
         break;
      }
   }
   if(judg==0){
      printf("Yes");
   }else{
      printf("No");
   }
   return 0;
}


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

int main() {
  long long n, m;
  cin >> n >> m;

  if (n>=2 && m>=2) {
      cout << n*m - (n-2)*2 - (m-2)*2 - 4 << endl;
  }
  else if (n==1 && m==1) {
      cout << 1 << endl;
  }
  else if (n==1 && m>=2) {
      cout << m-2 << endl;
  }
  else {
      cout << n-2 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

h1, m1, h2, m2, k = LI()

h = (h2 - h1 - 1) * 60 
m = (60 - m1) + m2
print(h + m - k)



Measured memory_bytes: 65380
n,k = map(int,input().split())
li = list(map(int,input().split()))
li = list(map(lambda x:(x+1)/2,li))

wk = 0
nn = n-k

for i in range(0,k):
    wk += li[i]
kwk = wk
for j in range(nn):
    wk = wk - li[j]
    wk = wk + li[j+k]
    kwk = max(wk,kwk)
 
print(kwk)

Measured memory_bytes: 25060
N, M = map(int, input().split())

s = []
e = []
for _ in range(M):
    ab = list(map(int, input().split()))
    if ab[0] == 1:
        s.append(ab[1])
    if ab[1] == N:
        e.append(ab[0])

s = set(s)
e = set(e)

t = s & e

if len(t) == 0:
    print("IMPOSSIBLE")
else:
    print("POSSIBLE")

Measured memory_bytes: 71896
#include<bits/stdc++.h>
using namespace std;
#define M 1000000007
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define gcd __gcd
#define in(a) scanf("%d",&a)
#define in2(a,b) scanf("%d%d",&a,&b)
#define in3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define read(v,n) for(h=0;h<n;h++)in(v[h]);
#define sc(ch) scanf("%c",&ch)
#define sstr(str) scanf("%s",str)
#define pr(n) printf("%d ",n)
#define out(n) printf("%d\n",n)
#define cf(n) printf("%I64d\n",n)
#define yes printf("YES\n")
#define no printf("NO\n")
#define lin printf("\n")
#define dbg(v,n) for(h=0;h<n;h++)pr(v[h]); lin
#define ck printf("continue\n")
#define ii pair<int,int>
#define vi vector<int>
#define vii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define viii vector<pair<pair<int,int>,int> >
#define vvii vector<vector<pair<int,int> > >
#define all(vec) vec.begin(),vec.end()
#define asc(vec) sort(vec.begin(),vec.end())
#define lp(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) for(i=0;i<n;i++)
#define lower(v,k) lower_bound(v.begin(),v.end(),k)-v.begin()
#define upper(v,k) upper_bound(v.begin(),v.end(),k)-v.begin()
#define N 100005
typedef long long int ll;
int par[N],lev[N],tot[N];
void makeset(int n)
{
    fill(par,par+n,-1);
    fill(tot,tot+n,1);
    return;
}
int findset(int x)
{
    int y=x;
    while(par[y]>=0)
        y=par[y];
    if(x!=y)
        par[x]=y;
    return y;
}
void combine(int a,int b)
{
    a=findset(a);
    b=findset(b);
    if(a!=b)
    {
        if(lev[a]<lev[b])
            par[a]=b,tot[b]+=tot[a];
        else if(lev[a]>lev[b])
            par[b]=a,tot[a]+=tot[b];
        else
            lev[b]++,par[a]=b,tot[b]+=tot[a];
    }
    return ;
}
int main()
{
    int i,n,m,a,b,c;
    in2(n,m);
    makeset(n);
    while(m--)
    {
        in3(a,b,c);
        combine(a-1,b-1);
    }
    a=0;
    for(i=0;i<n;i++)
        if(par[i]<0)a++;
    out(a);
}


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

using namespace std;
set <int> s;

int  main(){
	for (int i = 0; i < 3; i++){
		int x;
		scanf("%d", &x);
		s.insert(x);
	}
	printf("%d\n", (int)s.size());
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;


map<string,int> mp;
vector<string> a,b;

void replace(string& s,const string& target,const string& replacement){
    ll idx = 0;
    while((idx = s.find(target,idx)) != string::npos){
        s.replace(idx,target.length(),replacement);
        idx += replacement.length();
    }
}
void rec(string& s,int dep){
    if(s.length() > 10) return;
    if(mp.count(s)){
        if(mp[s] < dep) return;
    }
    mp[s] = dep;
    
    int n = (int)a.size();
    for(int i = 0; i < n;i++){
        string t = s;
        replace(t,a[i],b[i]);
        rec(t,dep+1);
    }
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int n;
    while(cin >> n,n){
        mp.clear();
        a.resize(n); b.resize(n);
        for(int i = 0; i < n;i++) cin >> a[i] >> b[i];
        string sigma,ganma; cin >> sigma >> ganma;
        rec(sigma,0);
        
        if(mp.count(ganma)){
            cout << mp[ganma] << endl;
        }else{
            cout << -1 << endl;
        }
    }
    return 0;
}



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

using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr int inf = 1<<30;
constexpr int mo = 1e9+7;
constexpr ll infl = 1ll<<60;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int h,w;
    cin>>h>>w;
    int cur = 0;
    vector<tuple<int,int,int,int>> ret;
    pair<int,int> p;
    vector<vector<int>> v(h,vector<int>(w));
    for(int i=0;i<h;++i)for(int j=0;j<w;++j)cin>>v[i][j];
    for(int i=0;i<h;++i)if(i%2 == 0)for(int j=0;j<w;++j){
        if(v[i][j]%2 == 1){
            if(cur == 0)p = {i,j};
            else ret.emplace_back(p.first,p.second,i,j);
            cur ^=1;
        } else if(cur == 1){
            ret.emplace_back(p.first,p.second,i,j);
            p = {i,j};
        }
        
    }else {
        for(int j=w-1;j>=0;j--){
        if(v[i][j]%2 == 1){
            if(cur == 0)p = {i,j};
            else ret.emplace_back(p.first,p.second,i,j);
            cur ^=1;
        } else if(cur == 1){
            ret.emplace_back(p.first,p.second,i,j);
            p = {i,j};
        }
        
        }
    }
    cout << ret.size() << endl;
    for(auto a : ret){
        int x,y,z,w;
        tie(x,y,z,w) = a;
        cout << x+1 << " " << y+1 << " " << z+1 << " " << w+1 << endl;
    }
    return 0;
}

Measured memory_bytes: 6308
process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines = []
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});

reader.on('line', (line) => {
  lines.push(line);
});

reader.on('close', () => {
  var n = Number(lines[0]);
  var info = lines[1].split(' ');
  var info = info.map(function(str) { return Number(str)});
  var sum = 0;
  var ans = 0;
  
  for(i=0; i<n; i++){
    sum += info[i];
  }
  var ave = Math.round(sum / n);

  for(i=0; i<n; i++){
    var sa = (info[i] - ave) * (info[i] -ave);
    
    ans += sa
  }
  console.log(ans);
  
 
});

Measured memory_bytes: 11596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll, ll> P;
using VP = vector<P>;
using VVP = vector<VP>;
using VI = vector<ll>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;
const int inf = 1e9 + 7;
const ll INF = 1LL << 61;
const ll mod = 1e9 + 7;

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

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int i, j;
    ll n, k;
    cin >> n >> k;
    multiset<P> s;
    for (i = 0; i < n; i++) {
        ll a, b;
        cin >> a >> b;
        s.insert(P(a, b));
    }
    for (auto it = s.begin(); it != s.end(); ++it) {
        if (k > it->second)
            k -= it->second;
        else {
            cout << it->first << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 9896
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
 
using namespace std;
 
int main(){
  string S;
  int Q;
  int T;
  int F;
  string C;
  
  cin >> S >> Q;
  
  bool dir = true;
  for(int i=0;i<Q;i++){
    cin >> T;
    if(T == 1){
      dir = !dir;
      //reverse(S.begin(), S.end());
    }else{
      cin >> F >> C;
      if(((F == 1)&&dir) || ((F == 2)&&!dir)){
        S.insert(0, C);
      }else{
        S.append(1, C[0]);
      }
    }
  }
  if(!dir){
    reverse(S.begin(), S.end());
  }
  
  cout << S << endl;
}

Measured memory_bytes: 900
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        String[] in = s.nextLine().split(" ");
        int where = Integer.parseInt(in[1])-1;
        String t = s.nextLine();
        String r = "";
        int i=0;
        for(char c:t.toCharArray()){
            if(i == where){
                r += String.valueOf(c).toLowerCase();
            }else {
                r += c;
            }
            i++;
        }
        System.out.println(r);
    }
}

Measured memory_bytes: 21716
#include<stdio.h>

int main(void){
    int n,i,f,j;

    scanf("%d",&n);

    for(i = 1;i <= n;i++){
        f = 0;
        if(i % 3 == 0)
            f = 1;
        j = i;
        while(j > 0){
            if(j % 10 == 3){
                f = 1;break;
            }
            j /= 10;
        }
        if(f == 1)
            printf(" %d",i);
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 600
#!/usr/bin/env python3

MOD = 10**9
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

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

t = 0
a = 0
if C%B==0: t = C // B
else: t = C // B + 1

if A%D==0: a = A // D
else: a = A // D + 1

if t > a: print('No')
else: print('Yes')


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}


int N,M;
int A[222222];
int S[222222];

map<pint,int>uku;

vector<int> G[1000000];
vector<pair<int, int> > bridge;
vector<int> articulation;
int ord[1000000], low[1000000];
bool vis[1000000];

tuple<int,int,int>ans;
int sumall;

int X[222222],Y[222222],Z[222222];

void dfs(int v, int p, int &k)
{

    S[v]=A[v];
	vis[v] = true;

	ord[v] = k++;
	low[v] = ord[v];

	bool isArticulation = false;
	int ct = 0;

	for (int i = 0; i < G[v].size(); i++){
		if (!vis[G[v][i]]){
			ct++;
			dfs(G[v][i], v, k);
			S[v]+=S[G[v][i]];
			low[v] = min(low[v], low[G[v][i]]);
			if (~p && ord[v] <= low[G[v][i]]) isArticulation = true;
			if (ord[v] < low[G[v][i]]){
                int x=v;
                int y=G[v][i];
                int Sy=(S[y]-uku[minmax(x,y)])/2;
                int Sx=sumall-uku[minmax(x,y)]-Sy;
                if(x>y)swap(x,y);
                chmin(ans,make_tuple(abs(Sx-Sy),x,y));
            }
		}
		else if (G[v][i] != p){
			low[v] = min(low[v], ord[G[v][i]]);
		}
	}

	if (p == -1 && ct > 1) isArticulation = true;
	if (isArticulation) articulation.push_back(v);
}


signed main(){
    cin>>N>>M;
    ans=make_tuple(LLONG_MAX,-1,-1);
    rep(i,M){
        int a,b,c;
        cin>>a>>b>>c;
        a--;b--;
        if(a>b)swap(a,b);



        X[i]=a;Y[i]=b;Z[i]=c;
        uku[{a,b}]=c;
        G[a].pb(b);G[b].pb(a);
        A[a]+=c;
        A[b]+=c;
        sumall+=c;
    }


    rep(i,M){
        chmin(ans,make_tuple(sumall-Z[i],X[i],Y[i]));
    }
    int K;
    dfs(0,-1,K);
    cout<<get<1>(ans)+1<<" "<<get<2>(ans)+1<<endl;
    return 0;
}



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

int main(){
  long long a,b;
  int k;
  cin >> a >> b >> k;
  for(int i=0;i<k;i++){
    if(i%2==0){
      if(a%2) a--;
      a/=2;
      b+=a;
    }
    else{
      if(b%2) b--;
      b/=2;
      a+=b;
    }
  }
  cout << a << " " << b << endl;
}

Measured memory_bytes: 3624
#include <array>
#include <vector>
#include <deque>
#include <set>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iterator>
#include <limits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cstdint>
#include <cassert>

using namespace std;

#define FOR(i, start, end) for(int i = (start); i < (end); ++i)
#define REP(i, n) FOR(i, 0, n)

int read_problem()
{
    int n;
    scanf("%d\n", &n);
    return n;
}

#if 0
constexpr int SQRTN_MAX = 31622; // sqrt(1e9) = 31622.77...

array<bool, SQRTN_MAX+1> is_prime;

void init_prime_table()
{
    fill(is_prime.begin(), is_prime.end(), true);
    is_prime[0] = is_prime[1] = false;

    for(int i = 2; i <= SQRTN_MAX; ++i) {
        if(!is_prime[i]) continue;

        for(int j = 2*i; j <= SQRTN_MAX; j += i) {
            is_prime[j] = false;
        }
    }
}
#endif

vector<int> factor(int n)
{
    vector<int> result;

    int sqrtn = static_cast<int>(sqrt(n));
    for(int i = 2; i <= sqrtn; ++i) {
        while(n % i == 0) {
            result.push_back(i);
            n /= i;
        }
    }
    if(n != 1)
        result.push_back(n);

    return result;
}

int main()
{
    int n = read_problem();

    vector<int> facs = factor(n);
    printf("%d:", n);
    for(int p : facs) {
        printf(" %d", p);
    }
    puts("");

    return 0;
}

Measured memory_bytes: 2752
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		while(sc.hasNext()){
			String[] str=sc.next().split(",");
			double xa=Double.parseDouble(str[0]);
			double ya=Double.parseDouble(str[1]);
			double xb=Double.parseDouble(str[2]);
			double yb=Double.parseDouble(str[3]);
			double xc=Double.parseDouble(str[4]);
			double yc=Double.parseDouble(str[5]);
			double xd=Double.parseDouble(str[6]);
			double yd=Double.parseDouble(str[7]);
			boolean flag=true;
			double z1=(xc-xb)*(ya-yb)-(yc-yb)*(xa-xb);
			double z2=(xb-xd)*(ya-yd)-(yb-yd)*(xa-xd);
			double z3=(xc-xb)*(ya-yb)-(yc-yb)*(xa-xb);
			if(z1>0&&z2>0&&z3>0||z1<0&&z2<0&&z3<0){
				flag=false;
			}
			z1=(xd-xc)*(yb-yc)-(yd-yc)*(xb-xc);
			z2=(xc-xa)*(yb-ya)-(yc-ya)*(xb-xa);
			z3=(xd-xc)*(yb-yc)-(yd-yc)*(xb-xc);
			if(z1>0&&z2>0&&z3>0||z1<0&&z2<0&&z3<0){
				flag=false;
			}
			z1=(xa-xd)*(yc-yd)-(ya-yd)*(xc-xd);
			z2=(xd-xb)*(yc-yb)-(yd-yb)*(xc-xb);
			z3=(xa-xd)*(yc-yd)-(ya-yd)*(xc-xd);
			if(z1>0&&z2>0&&z3>0||z1<0&&z2<0&&z3<0){
				flag=false;
			}
			z1=(xb-xa)*(yd-ya)-(yb-ya)*(xd-xa);
			z2=(xa-xc)*(yd-yc)-(ya-yc)*(xd-xc);
			z3=(xb-xa)*(yd-ya)-(yb-ya)*(xd-xa);
			if(z1>0&&z2>0&&z3>0||z1<0&&z2<0&&z3<0){
				flag=false;
			}
			System.out.println(flag?"YES":"NO");
		}
	}
}

Measured memory_bytes: 17148
#include<iostream>
#include<bits/stdc++.h>
#include<algorithm>
#include<limits>
#define INF 100000000
#define MOD 1000000007
#define N 100001
#define ll long long
using namespace std;

map<pair<int,int>,int> myMap;
int main()
{
    int n;
    cin >> n;
    for(int i = 1;i <= n;i++)
    {
        int lastDigit = i%10;
        int x = i;
        int firstDigit = 0;
        while(x)
        {
            firstDigit = x%10;
            x /= 10;
        }
        myMap[make_pair(firstDigit,lastDigit)]++;
    }
    int ans = 0;
    for(int i = 1;i <= n;i++)
    {
        int lastDigit = i%10;
        int x = i;
        int firstDigit = 0;
        while(x)
        {
            firstDigit = x%10;
            x /= 10;
        }
        ans += myMap[make_pair(lastDigit,firstDigit)];
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int y = sc.nextInt();
        for(int yen10000 = 0; yen10000 <= n; yen10000++) {
            for(int yen5000 = 0; yen5000 <= n - yen10000; yen5000++) {
                int diff = y - (yen10000 * 10000) - (yen5000 * 5000);
                if(diff == (n - yen10000 - yen5000) * 1000) {
                    System.out.println(yen10000 + " " + yen5000 + " " + diff / 1000);
                    return;
                }
            }
        }
        System.out.println("-1 -1 -1");
    }
}


Measured memory_bytes: 24148
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main() {
  string s,t="";
  cin >> s;
  for(int i=0; i<s.size(); i++) {
    if(s[i]=='0') {
      t.push_back('0');
    }
    else if(s[i]=='1') {
      t.push_back('1');
    }
    else {
      if(t!="") {
        t.pop_back();
      }
    }
  }
  cout << t << endl;
}

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

struct UnionFind {
  vector< int > data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
};

int main()
{
	int N, M;
	cin >> N >> M;
	UnionFind uf( N );
	for( int i = 0; i < M; i++ ) {
		int A, B;
		cin >> A >> B;
		A--;
		B--;
		uf.unite( A, B );
	}

	int ans = 0;
	for( int i = 0; i < N; i++ ) {
		ans = max( ans, uf.size( i ) );
	}

	cout << ans << endl;
}


Measured memory_bytes: 4024
import java.util.Scanner;

public class Main{
	public static void main(String args[]){
    	Scanner in = new Scanner(System.in);
      	int n = in.nextInt();
      	int cnt = 0;
      	for(int i = 1 ; i <= n ; i++){
        	int x = in.nextInt();
         	 if(i%2 != 0){
           		 if(x%2 != 0)
             	 cnt++;
          }
        }
      System.out.println(cnt);
          
    }
}

Measured memory_bytes: 35856
#include <bits/stdc++.h>
using namespace std;
 
const int INF = 1<<28;
const int MAXN = 101;
const int MAXD = 101;
const int MAXE = 101;
 
int D, N;
int dp[MAXD][MAXE];
int a[MAXN], b[MAXN], c[MAXN];
 
int main() {
  while(cin >> D >> N && (D|N)) {
    for(int i = 0; i < N; ++i)
      cin >> a[i] >> b[i] >> c[i];
    fill(dp[0], dp[MAXD], INF);
    dp[0][0] = 0;
    for(int d = 0; d <= D; ++d) {
      for(int e = 0; e < MAXE; ++e) {
        for(int i = 0; i < N; ++i) {
          if(e < c[i]) continue;
          int nd = min(d + a[i], D);
          int ne = min(e + b[i], MAXE-1);
          dp[nd][ne] = min(dp[nd][ne], dp[d][e] + 1);
        }
      }
    }
    int res = INF;
    for(int e = 0; e < MAXE; ++e) {
      res = min(res, dp[D][e]);
    }
    if(res == INF) cout << "NA" <<endl;
    else cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 1204
n, k = map(int, input().split())
s = str(input())

if s[k-1] == 'A':
    print(s[:k-1] + 'a' + s[k:])

elif s[k-1] == 'B':
    print(s[:k-1] + 'b' + s[k:])

else:
    print(s[:k-1] + 'c' + s[k:])

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	int n,a = 0,b = 0,ba = 0,ans = 0;
	cin >> n;
	for(int i = 0;i < n;i++){
		string s;
		cin >> s;
		for(int j = 0;j < s.length() - 1;j++){
			if(s[j]== 'A' && s[j + 1] == 'B') ans++;
		}
		if(s[0] == 'B' && s[s.length() - 1] == 'A') ba++;
		else if(s[0] == 'B') b++;
		else if(s[s.length() - 1] == 'A') a++;
	}
	if(a) ans += ba + min(a,b);
	else if(b) ans += ba;
	else ans += max(0ll,ba - 1);
	cout << ans << endl;
}


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

int ord(int n) {
  int ord = 0;
  while (n % 2 == 0) { n /= 2; ord++; }
  return ord;
}

int main() {
  int N;
  cin >> N;
  int ans;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    ans += ord(a);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<stdio.h>
#include<sstream>
#include<map>
#include<vector>
#include<queue>
using namespace std;
#define maxn 100005
int b[maxn];
int main()
{
    int haha,n;
  string s;
  cin>>haha>>n>>s;
  int l,r;
  int sum=0,max1=0,flag=0;
  for(int a=1;a<s.size();a++)
  {
      if(s[a]=='C'&&s[a-1]=='A')

        {sum++;
        b[a]=sum;
        b[a-1]=max1;
        flag=1;
        }
      max1=sum;
      if(flag==0)b[a]=max1;
     //cout<<max1;
     flag=0;
  }
 // cout<<b[0]<<b[7];
  while(n--)
  {
      cin>>l>>r;
      cout<<b[r-1]-b[l-1]<<endl;
  }

}










Measured memory_bytes: 1408
import java.io.*;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
		int[] nums = Arrays.stream(stdin.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
		int time = Integer.parseInt(stdin.readLine());
		Arrays.sort(nums);
		nums[2] *= (int)Math.pow(2, time);
		System.out.println(Arrays.stream(nums).sum());
	}

}

Measured memory_bytes: 26324
#include <iostream>

using namespace std;

int main()
{
    int a,b,c;
    char y;
    cin>>a>>b;
    c=a+b+1;
    for(int i=0;i<c;i++)
    {
        cin>>y;
        if(i==a&&y!='-')
        {
            cout<<"No";
            return 0;
        }
        if(i!=a&&y!='0'&&y!='1'&&y!='2'&&y!='3'&&y!='4'&&y!='5'&&y!='6'&&y!='7'&&y!='8'&&y!='9')
        {
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
    return 0;
}


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

const int INF = 1e9;
int main () {
  int N;
  cin >> N;

  vector<int> v;
  v.push_back(1);
  for(int x = 6; x <= N; x *= 6) {
    v.push_back(x);
  }
  for(int x = 9; x <= N; x *= 9) {
    v.push_back(x);
  }

  int M = v.size();
  vector<vector<int>> dp(M+1, vector<int>(N+1, INF));
  dp[0][0] = 0;
  for(int i = 0; i < M; i++) {
    for(int j = 0; j <= N; j++) {
      dp[i+1][j] = dp[i][j];
      if(j-v[i] >= 0) dp[i+1][j] = min(dp[i+1][j], dp[i+1][j-v[i]] + 1);
    }
  }

  cout << dp[M][N] << endl;

  return 0;
}


Measured memory_bytes: 5760
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7

arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = INT()
print(arr[k - 1])

Measured memory_bytes: 5968
#include <bits/stdc++.h>
using namespace std;
int S[105],cnt,n, num,A,B;
bool cmp(int a,int b)
{
    return a>b;
}
int main() {
    
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>S[i];
    }
    sort(&S[0],&S[n],cmp);
    
    for(int i=0;i<n;i++)
    {
        if(i%2==0)
        {
            A=A+S[i];
        }
        else
        {
            B=B+S[i];
        }
    }
    cout<<A-B;
    
    
}
    
    
    
       

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
c = []
w = []
for i in range(n):
  t = a[i]//400
  if t < 8 and t not in c:
    c.append(t)
  if t>=8:
    w.append(t)

if len(c)==0 and len(w) >0:
  print(1, len(w))
else:
  print(len(c), len(c)+len(w))

Measured memory_bytes: 3064
N = int(input())
b = list(map(int, input().split()))
b = [x for x in reversed(b)]
ans = []
for _ in range(N):
    for i, bb in enumerate(b):
        #print(len(b) - i, bb)
        if (len(b) - i) == bb:
            b.pop(i)
            ans.insert(0, bb)
            break
        elif (len(b) - i) < bb:
            print(-1)
            exit()
for a in ans:
    print(a)

Measured memory_bytes: 3064
MOD = 10**9 + 7
n = int(input())
a = list(map(int,input().split()))

ka = [[0]*3 for _ in range(n+1)]

for i in range(n):
    for j in range(3):
        ka[i+1][j] = ka[i][j]
        
    for j in range(3):
        if ka[i][j] == a[i]:
            ka[i+1][j] += 1
            break
    ka[i+1].sort(reverse = True)
    
ans = 1
for i in range(n):
    mlt = 0
    for j in range(3):
        if ka[i][j] == a[i]:
            mlt += 1
            
    ans = ans * mlt % MOD
        
print(ans)

Measured memory_bytes: 63428
S = list(input())
S.sort()
import bisect
a_uni = ord('a')

Search = S
for i in range(26):
    char = chr(a_uni+i)

    if Search and Search[0] == char:
        ind = bisect.bisect_right(S,char)
        Search = S[ind:]
        continue
    print(char)
    exit()
print('None')




Measured memory_bytes: 10900
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <numeric>
#include <iomanip>
#define M_PI acos(-1)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1000000007;
const int MAX_V = 201;
int now = 0;

const int MAX = 200000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
struct edge {
	int t;
	ll cost;
	edge(int _t, ll _cost) : t(_t)
		, cost(_cost) {
	}
};
bool isPrime(int n) {

	if (n == 1) return false;
	for (ll i = 2; i * i <= n; i++)
	{
		if (n % i == 0) return false;
	}
	return true;
}
int anyDigitSum(int n) {
	int res = 0;
	while (n > 0)
	{
		res += n % 10;
		n /= 10;
	}
	return res;
}
ll f(double n) {

	n *= n;
	n += 4.0;
	return n / 8.0;
}
ll calc(ll a, ll b, ll c) {
	int half = a / 2;
	if (a % 2 == 0) {
		return 0;
	}
	else {
		return b * c;
	}

}
void Solve() {
	int n,p;
	cin >> n >> p;
	int t[2];
	t[0] = 0;
	t[1] = 0;
	for (size_t i = 0; i < n; i++)
	{
		int a;
		cin >> a;
		t[a % 2]++;
	}
	ll table[55][55];
	table[0][0] = 1;
	for (size_t i = 1; i <= 50; i++)
	{
		table[0][i] = 0;
	}
	for (size_t i = 1; i <= 50; i++)
	{
		table[i][0] = 1;
		for (size_t j = 1; j <= 50; j++)
		{
			table[i][j] = table[i - 1][j] + table[i - 1][j - 1];
		}
	}

	ll res = 0;
	int zc = t[0];
	int oc = t[1];
	for (size_t i = 0; i <= zc; i++)
	{
		ll firs = table[zc][i];
		for (size_t j = (p % 2); j <= oc; j += 2)
		{
			res += firs * table[oc][j];
		}
	}



	cout << res << endl;
}
int main() {
	Solve();
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define INF 10000001
int v,e,r,d[1000],cnt;
class edge{
    public:
    int from,to,cost;
};

int main(void){
   cin>>v>>e>>r;
   edge x[e];
   for(int i=0;i<e;i++)cin>>x[i].from>>x[i].to>>x[i].cost;
      
   
   for(int i=0;i<v;i++)d[i]=INF;
   d[r]=0;
   while(1){
       bool update=false;
       for(int i=0;i<e;i++){
           if(d[x[i].from]<INF&&d[x[i].from]+x[i].cost<d[x[i].to]){
               d[x[i].to]=d[x[i].from]+x[i].cost;
               update=true;
           }
       }
       if(update==false)break;
       if(cnt==v-1){
           cout<<"NEGATIVE CYCLE\n";
           return 0;
       }
       cnt++;
   }
    for(int i=0;i<v;i++){
        if(d[i]==INF)cout<<"INF\n";
        else cout<<d[i]<<endl;
    }
}

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

using namespace std;

#define TC ll t; cin >> t; while(t--)
typedef long long ll;

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ll n,k;
    cin >> n >> k;
    n%=k;
    cout << min(n,k-n) << endl;
    return 0;
}


Measured memory_bytes: 3624
#include<iostream>
#include<cstdio>
using namespace std;
#define int long long
const int N=2002020;
int n,p,cnt[N],h[N]; char s[N];
void solve2(){
	long long ans=0;
	for(int i=1;i<=n;i++)
		if((s[i]-'0')%2==0)ans+=i;
	cout<<ans<<endl;
}
void solve5(){
	long long ans=0;
	for(int i=1;i<=n;i++)
		if((s[i]-'0')%5==0)ans+=i;
	cout<<ans<<endl;
}
int read(){
	int x=0,f=1; char ch=getchar();
	while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
#undef int
int main()
{
	#define int long long
	n=read(); p=read();
	scanf("%s",s+1);
	if(p==2){solve2();return 0;}
	if(p==5){solve5();return 0;}
	int ans=0,nw=1; ++cnt[0];
	for(int i=n;i>=1;i--){
		h[i]=(1ll*nw*(s[i]-'0')%p+h[i+1])%p;
		ans+=cnt[h[i]]; cnt[h[i]]++; nw=10ll*nw%p;
	} cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 5588
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb push_back 
#define mod 1e9+7

int main(){
      ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0);    
     int n;
      cin>>n;
    string s,t;
     cin>>s>>t;
    for(int i=0; i<n ;i++){
          cout<<s[i]<<t[i];
    }
  
    }

// a  A  z  Z  q  Q  !  1 


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

const int MAX = 1e5 + 10;
bool flag[MAX];

int main() {
  // 入力
  int N;
  cin >> N;
  int a[N];
  for (int i = 0; i < N; i++) cin >> a[i];

  for (int i = 0; i < N; i++) flag[a[i]] = true;

  int k = 0;
  for (int i = 0; i < MAX; i++) if (flag[i]) k++;

  // 解答
  cout << (k & 1 ? k : k - 1) << endl;

  return 0;
}


Measured memory_bytes: 768
#coding: utf-8

import re

K, T = map(int, input().split())
a = list(map(int, input().split()))

count = 0
n = None #
for j in range(K):
    m = 0
    t = None
    for i,c in enumerate(a):
        if c > m and (n is None or i != n):
            m = c
            t = i
    if t is None:
        count += 1
        t = n
    a[t] -= 1
    n = t
print(count)


Measured memory_bytes: 3316
#include "bits/stdc++.h"
#define rep(i,a,n) for(int i=a;i<n;i++)
using namespace std;
using ll=long long;
const int M=100010;


int main(){
	int R,G,B,N,ans=0;

	cin>>R>>G>>B>>N;
	if(R==1){
		rep(j,0,N/G+2){
			rep(k,0,N/B+2){
				if(j*G+B*k<=N)ans++;
			}
		}
	} else if(G==1){
		rep(i,0,N/R+2){
			rep(k,0,N/B+2){
				if(i*R+k*B<=N)ans++;
			}
		}
	} else if(B==1){
		rep(i,0,N/R+2){
			rep(j,0,N/G+2){
				if(i*R+j*G<=N)ans++;
			}
		}
	} else {
		rep(i,0,N/R+2){
			rep(j,0,N/G+2){
				rep(k,0,N/B+2){
					if(i*R+j*G+k*B==N)ans++;
				}
			}
		}
	}
	cout<<ans<<endl;
}

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

int main()
{
    int n,sum = 0,k=0;
    cin>>n;

    int ar[100],br[100],cr[100];

    for(int i=1;i<=n;i++){
        cin>>ar[i];
    }
    for(int i=1;i<=n;i++){
        cin>>br[i];
    }
    for(int i=1;i<=n-1;i++){
        cin>>cr[i];
    }
    for(int i=1;i<=n;i++){
            if((ar[i] - k) == 1){
                sum = sum + cr[k];
            }
         k = ar[i];
        sum = sum+br[k];
    }
    cout<<sum<<endl;
}


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

using namespace std;

//using Matrix = vector< vector<int> >;
typedef long long ll;
typedef pair<int, int> P;
//const int INF = 1e9 + 10;
//const ll INF = 1e18 + 10LL;
const ll INF = 1 << 18;
int dx[5] = {0, 0, 1, -1, 0}, dy[5] = {1, -1, 0, 0, 0};
const double EPS = 1e-10;
bool cmp(P a, P b) { return a.second < b.second; } //End sort (Interval scheduling problem)
ll MOD = 1e9 + 7;

ll L, R;

int main(void){
	cin>>L>>R;

	if (R - L + 1 >= 2019) cout<< 0 <<endl;
	else {
		ll minv = INF;

		for (ll i = L; i <= R; i++) {
			for (ll j = i + 1; j <= R; j++) {
				minv = min(minv, (i * j) % 2019);
			}
		}
		printf("%lld\n", minv);
	}
	
	return 0;
}

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

int main(){
    int h, w;
    cin >> h >> w;
    vector<string> pic(h);
    for(int i = 0; i < h; i++){
        cin >> pic[i];
    }
    for(int i = 0; i < h; i++){
        cout << pic[i] << endl;
        cout << pic[i] << endl;
    }
}

Measured memory_bytes: 3612
#include <cstdio>
bool A[200001];
inline char tc(){
  static char fl[100],*A=fl,*B=fl;
  return A==B&&(B=(A=fl)+fread(fl,1,100,stdin),A==B)?EOF:*A++;  
}
inline int read(){
  int a=0;static char c;
  while((c=tc())<48||c>57);
  while(c>=48&&c<=57)a=a*10+c-48,c=tc();
  return a;
}
int main(){
  int n,m,a,b;n=read();m=read();
  while(m--){a=read();b=read();
    if(a==1){
      if(A[b])return puts("POSSIBLE"),0;
      A[b]=1;
    }
    if(b==n){
      if(A[a])return puts("POSSIBLE"),0;
      A[a]=1;
    }
  }
  puts("IMPOSSIBLE");
  return 0;
}

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

using ll = long long;

signed main(){
	string s;
	cin >> s;

	if((s[3] == s[2]) && (s[5]==s[4])){
		cout << "Yes\n";
	}
	else{
		cout << "No\n";
	}
	return 0;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().split_whitespace().map(|s| s.to_string()).collect::<Vec<String>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn dfs(graph: &[Vec<usize>], root: usize, memo: &mut [i64]) -> i64 {
    if let Some(d) = graph[root]
        .iter()
        .map(|&r| {
            if memo[r] == -1 {
                memo[r] = dfs(graph, r, memo) + 1;
            }
            memo[r]
        })
        .max()
    {
        d
    } else {
        0
    }
}

fn main() {
    let (n, m) = scan!(usize, usize);
    let routes = scan!(usize, usize;m);
    let mut ins = vec![0; n + 1];

    let mut graph = vec![vec![]; n + 1];
    for r in routes.iter() {
        graph[r.0].push(r.1);
        ins[r.1] += 1
    }

    let mut memo = vec![-1; n + 1];
    println!(
        "{}",
        (1..n + 1)
            .filter(|&i| ins[i] == 0)
            .map(|i| {
                memo[i] = 0;
                dfs(&graph, i, &mut memo)
            })
            .max()
            .unwrap()
    )
}


Measured memory_bytes: 34812
import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)

N = int(input())
A = list(map(int, input().split()))
sum=A[N-1]
for i in range(N-1):
    sum+=A[i]*(-1)**(i+1)
x_n=sum/2
x=A[N-1]-x_n
print(int(2*x), end=" ")
for i in range(1,N-1):
    x=A[i-1]-x
    print(int(2*x), end=" ")
print(int(2*x_n))

Measured memory_bytes: 14128
n=input().split()
if int(n[0])+int(n[1]) <= int(n[1])+int(n[2]):
  if int(n[0])+int(n[1]) <= int(n[2])+int(n[0]):
    print(int(n[0])+int(n[1]))
  else:
    print(int(n[2])+int(n[0]))
else:
  if int(n[1])+int(n[2]) <= int(n[2])+int(n[0]):
    print(int(n[1])+int(n[2]))
  else:
    print(int(n[2])+int(n[0]))

Measured memory_bytes: 3188
#include<iostream>
using namespace std;
int main()
{
    long long n,m,p,i;
    cin>>n>>m;
    p=min(n,m);
    if(p==n)
    {
        for(i=1;i<=m;i++)
        {
            cout<<n;
        }
        cout<<endl;
    }
    else
    {
        for(i=1;i<=n;i++)
        {
            cout<<m;
        }
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
  double l;
  cin >> l;
  double ans = l / 3;
  ans = ans * ans * ans;
  cout.precision(30);
  cout.setf(ios::fixed, ios::floatfield);
  cout << ans << '\n';
  return 0;
}

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

struct Data{
	int r,k,l;
};

int main() {
	string S;
	cin>>S;
	int n=S.length();
	vector<Data> d(n);

	for(int i=0;i<n;i++){
		if(S[i]=='R'){
			d[i].k=0;
		}else{
			d[i].k=1;
		}
	}
	d[0].r=0;
	for (int i = 1; i < n; i++) {
    if (S[i] == 'R') {
      d[i].r = i;
    } else {
      d[i].r = d[i - 1].r;
    }
  }
   d[n - 1].l = n - 1;
   for (int i = n - 2; i >= 0; i--) {
    if (S[i] == 'L') {
      d[i].l = i;
    } else {
      d[i].l = d[i + 1].l;
    }
  }
int cnt[n]{};
  for (int i = 0; i < n; i++) {
    int g;
    if (d[i].k == 0) {
      g = d[i].l - i;
      if (g % 2 == 0) {
        cnt[d[i].l]++;
      } else {
        cnt[d[i].l - 1]++;
      }
    } else {
      g = i - d[i].r;
      if (g % 2 == 0) {
        cnt[d[i].r]++;
      } else {
        cnt[d[i].r + 1]++;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    if (i == n - 1) {
      cout << cnt[i] << "\n";
    } else {
      cout << cnt[i] << " ";
    }
  }
  return 0;
}

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

using ll = long long;
using K = long double;

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

int n;
vector<int> a;

int gcd(int a, int b) {
	while (a && b) {
		if (a > b) a %= b; else b %= a;
	}
	return a + b;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	cin >> n;
	int m = n;
	
	if (n == 3) {
		cout << "2 5 63\n";
		return 0;
	}
	
	vector<int> a, b, c;
	
	for (int i = 1; i <= 30000; ++i) {
		if (i % 6 == 0) {
			c.push_back(i);
			continue;
		}
		if (i % 2 == 0) {
			a.push_back(i);
		}
		if (i % 3 == 0) {
			b.push_back(i);
		}
	}
	
	//cout << "2: " << SIZE(a) << endl;
	//cout << "3: " << SIZE(b) << endl;
	//cout << "6: " << SIZE(c) << endl;
	
	reverse(ALL(a));
	reverse(ALL(b));
	reverse(ALL(c));
	
	vector<int> result;
	
	if (n > 15000) {	
		while (n >= 2 && SIZE(a) >= 2) {
			result.push_back(a.back()); a.pop_back();
			result.push_back(a.back()); a.pop_back();
			n -= 2;
		}
		
		while (n >= 2 && SIZE(b) >= 2) {
			result.push_back(b.back()); b.pop_back();
			result.push_back(b.back()); b.pop_back();
			n -= 2;
		}
	} else {
		while (n >= 4 && SIZE(a) >= 2 && SIZE(b) >= 2) {
			result.push_back(a.back()); a.pop_back();
			result.push_back(a.back()); a.pop_back();
			result.push_back(b.back()); b.pop_back();
			result.push_back(b.back()); b.pop_back();
			n -= 4;
		}
	}
	
	REP(i, min(n, SIZE(c))) result.push_back(c[i]);
	
	assert(SIZE(result) == m);
	int sum = 0;
	REP(i, SIZE(result)) sum += result[i];
	int g = 0;
	REP(i, SIZE(result)) {
		assert(gcd(sum-result[i], result[i]) > 1);
		g = gcd(g, result[i]);
	}
	assert(g == 1);
	
	for (auto& e : result) {
		cout << e << ' ';
	}
	cout << '\n';
	
	return 0;
}


Measured memory_bytes: 640