akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
const int maxn=500050,mod=1000000007;
#define MP make_pair
#define PB push_back
#define lson o<<1,l,mid
#define rson o<<1|1,mid+1,r
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define ROF(i,a,b) for(int i=(a);i>=(b);i--)
#define MEM(x,v) memset(x,v,sizeof(x))
inline ll read(){
	char ch=getchar();ll x=0,f=0;
	while(ch<'0' || ch>'9') f|=ch=='-',ch=getchar();
	while(ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();
	return f?-x:x;
}
int n,a[maxn],s[maxn],pre[maxn],ans,f[maxn];
vector<int> vec[1048576];
inline int qpow(int a,int b){
	int ans=1;
	for(;b;b>>=1,a=1ll*a*a%mod) if(b&1) ans=1ll*ans*a%mod;
	return ans;
}
int main(){
	n=read();
	pre[0]=1;
	FOR(i,1,n){
		vec[s[i]=s[i-1]^(a[i]=read())].PB(i);
		pre[i]=pre[i-1]+(s[i]==0);
	}
	FOR(_,1,1048575){
		int sum1=0,sum2=0;
		FOR(i,0,(int)vec[_].size()-1){
			f[i]=(1+1ll*pre[vec[_][i]-1]*sum1%mod-sum2+mod)%mod;
			if(!s[n] || vec[_][i]==n) ans=(ans+f[i])%mod;
			sum1=(sum1+f[i])%mod;
			sum2=(sum2+1ll*f[i]*pre[vec[_][i]])%mod;
		}
	}
	if(!s[n]) ans=(ans+qpow(2,vec[0].size()-1))%mod;
	printf("%d\n",ans);
}

Measured memory_bytes: 42228
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>

using std::cerr;
using std::cin;
using std::cout;
using std::endl;

int main(void){
  cout << std::fixed << std::setprecision(16);
  cin.tie(0);
  std::ios::sync_with_stdio(false);

  int n, m;
  cin >> n >> m;
  std::vector<int> a(m);
  for (auto &e: a) cin >> e;

  std::vector<bool> used(n+1, false);

  for (int i = m-1; i >= 0; i--) {
    if (!used[a[i]]) {
      cout << a[i] << endl;
      used[a[i]] = true;
    }
  }

  for (int i = 1; i <= n; ++i) {
    if (!used[i]) {
      cout << i << endl;
    }
  }


  return 0;
}



Measured memory_bytes: 3456
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<math.h>

#define ALL(a) (a).begin(),(a).end()
#define ll long long
#define vi vector<int>
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,k,n) for(int (i)=(k);(i)<(n);(i)++)

using namespace std;
  
int main(){
  char c;cin>>c;cout<<char(c+1)<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include<unordered_map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include<bitset>
#include<deque>
#include<string>
#include<list>
#include<iterator>
#include<sstream>
#include <algorithm>
# include <math.h>
#define lli long long int
#define lower(a) transform(a.begin(),a.end(),a.begin(),::tolower);

using namespace std;

const int N = 3e5 + 500;
const long long mod = 1e9 + 7;
const long long cmod = 998244353 ;
const long long inf = 1LL << 61;
const int M = 1e6 + 500;
const lli ths = 1LL << 40;
const int NN = 5e3 + 6;

void solve()
{
    lli n;
    cin>>n;
    lli a[n];
    for(int i = 0; i < n; i ++)
        cin>>a[i];
    sort(a, a + n);
    lli ans = 0;
    for(int i = 0; i < n - 2; i ++)
    {
        lli k = i + 2;
        for(int j = i + 1; j < n; j ++)
        {
            while(k < n && a[i] + a[j] > a[k])
                k ++;
            if(k > j)
                ans += k - j - 1;
        }
    }
    cout<<ans;
    return ;
}
/*
*/

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
    t = 1;
//    cin>>t;
    while(t --)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define DEC(i, a, b) for (int i = (a); i > (b); --i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
typedef long long ll;
const int INF = (int)1e9;
const int MOD = (int)1e9 + 7;
const ll LINF = (int)1e18;
const double EPS = 1e-9;

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

  int n;
  cin >> n;
  cout << 1110 - n << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <map>

using namespace std;

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

    map<int, int> m;
    for (int i = 0; i < n; i++) {
        int a;
        scanf("%d", &a);
        m[a]++;
    }

    int ans = 0;
    for (auto kv : m) {
        ans += kv.second % 2;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4992
#include <stdio.h>
 
int main(){
	
int n, a, b, sum = 0;
	
scanf("%d %d %d", &n, &a, &b);

for (int i = 1; i <= n; i++){
	int k = 0;
	int temp = i;
		
    for (int j = 0; j < 5; j++){
		k += temp % 10;
		temp /= 10;
	}
		
    if (k >= a && k <= b){
	sum += i;
	}
}
 
printf("%d\n", sum);
 
	return 0;
}

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

const int MAXN = 1e6 + 10;

long long a[MAXN], cnt[MAXN] = {}, csum[MAXN] = {};

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

    int n;
    cin >> n;
    for(int i = 0; i < n; i++) {
    	cin >> a[i];
    	cnt[a[i]]++;
    }
    for(int i = 1; i <= 1000; i++) {
    	csum[i] = csum[i - 1] + cnt[i];
    }
    sort(a, a + n);
   	n = unique(a, a + n) - a;
   	// printn(a, n);

    long long res = 0;
    for(int i = 0; i < n; i++) {
    	res += cnt[a[i]] * (cnt[a[i]] - 1) * (cnt[a[i]] - 2) / 6;
    	for(int j = i + 1; j < n; j++) {
    		res += (csum[min(a[i] + a[j] - 1, 1000LL)] - csum[max(a[i], a[j])]) * cnt[a[i]] * cnt[a[j]];
    		res += cnt[a[i]] * cnt[a[j]] * (cnt[a[j]] - 1) / 2;
    		if(a[i] + a[i] > a[j])
    			res += cnt[a[i]] * (cnt[a[i]] - 1) / 2 * cnt[a[j]];
    		// debug << i << j << res << endl;
    	}
    }
    cout << res << endl;

    return 0;
 
}























Measured memory_bytes: 4352
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int n,m;
  cin>>n>>m;
  vi a(m),b(m),c(m);
  rep(i,m){
    cin>>a[i]>>b[i]>>c[i];
    a[i]--;
    b[i]--;
    c[i]*=-1;
  }

  vector<ll> d(n,(ll)INF*INF);
  d[0]=0;
  rep(i,n-1)rep(j,m)
    d[b[j]] = min(d[b[j]], d[a[j]] + c[j]);
 
  vector<bool> negative(n,false);
  
  rep(i,n)rep(j,m){
    if(negative[a[j]])
      negative[b[j]] = true;
    if(d[b[j]] > d[a[j]] + c[j]){
      d[b[j]] = d[a[j]] + c[j];
      negative[b[j]] = true;
    }
  }
  if(negative[n-1])
    cout<<"inf"<<endl;
  else
    cout<<-d[n-1]<<endl;
}


Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
ans=[0]*2
for pat in range(2):
  cur=0
  isplus=pat
  for i in range(N):
    cur+=A[i]
    if isplus:
      if cur<=0:
        ans[pat]+=abs(cur-1)
        cur=1
    else:
      if cur>=0:
        ans[pat]+=abs(cur-(-1))
        cur=-1
    isplus^=1

print(min(ans))


Measured memory_bytes: 14332
#pragma GCC optimize ("O3")
#include <iostream>

inline void fastin(int &num) {
    bool neg = false;
    int c;
    num = 0;
    c = getchar_unlocked();
    if (c == '-') {
        neg = true;
        c = getchar_unlocked();
    }
    for (; (c > 47 && c < 58); c = getchar_unlocked()) num = num * 10 + c - 48;
    if (neg) num *= -1;
}

inline void fastout(int n) {
    int N = n, rev, count = 0;
    rev = N;
    if (N == 0) { putchar_unlocked('0'); putchar_unlocked('\n'); return ;}
    while ((rev % 10) == 0) { ++count; rev /= 10;}
    rev = 0;
    while (N != 0) { rev = (rev<<3) + (rev<<1) + N % 10; N /= 10;}
    while (rev != 0) { putchar_unlocked(rev % 10 + '0'); rev /= 10;}
    while (count--) putchar_unlocked('0');
}

int main(){    
    int n, m, Q; fastin(n); fastin(m); fastin(Q);
    int square[n + 5][n + 5] = {};
    for (int i = 0; i < m; ++i){
      int l, r;
      fastin(l); fastin(r); ++square[l][r];
    }

    for (int i = 1; i <= n; ++i){
        for (int j = 1; j <= n; ++j){
            square[i][j] += square[i][j - 1];
        }
    }

    for (int i = 1; i <= n; ++i){
        for (int j = 1; j <= n; ++j){
            square[i][j] += square[i - 1][j];
        }
    }

    for (int i = 0; i < Q; ++i){
        int p, q; fastin(p); fastin(q);
        fastout(square[q][q] + square[p - 1][p - 1] - square[p - 1][q] - square[q][p - 1]); putchar_unlocked('\n');
    }
    
    return 0;
}

Measured memory_bytes: 1920
#include <iostream>
#include <algorithm>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <string>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;

#define REP(i, N) for (int i = 0; i < (N); i++)
#define REPP(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((int)(x).size())

using namespace std;


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

    int x1,x2,y1,y2;
    int x3,x4y,y3,y4;
    cin >> x1 >> y1 >> x2 >> y2;
    pair<int,int> d1,d2,d3,d4;
    d1.first = x1;d1.second = y1;
    d2.first = x2;d2.second = y2;
    d3.first = d2.first+d1.second-d2.second;d3.second = d2.second+d2.first-d1.first;
    d4.first = d1.first+d1.second-d2.second;d4.second = d1.second+d2.first-d1.first;

    cout << d3.first << " " << d3.second << " " << d4.first << " " << d4.second<< endl;

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;

class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }

    Scanner cin;


    void calc()
    {
        cin = new Scanner();
        int N = cin.nextInt();
        long[] A= cin.ArrayLong(N,0);
        long[] max=new long[N];
        long[] L=new long[N];
        long[] R=new long[N];
        long max_i=0;
        for(int i=1;i<N;i++)
        {
          R[N-i-1]=cin.GCDLong(R[N-i],A[N-i]);
          L[i]=cin.GCDLong(L[i-1],A[i-1]);
        }
        for(int i=0;i<N;i++)
        {
            max[i]=cin.GCDLong(L[i],R[i]);
        }
        for(int i=0;i<N;i++)
        {
          if(max[i]>max_i)max_i=max[i];
        }
        Console.WriteLine(max_i);
        
    }


}



class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
    public long GCDLong(long a, long b)
    {
  
        while(a!=0)
        {
          long t=a;
          a=b%a;
          b= t;
        }
      
        return b;
        
    }
}

Measured memory_bytes: 33884
from collections import defaultdict, deque, Counter
from math import sqrt
def inpl(): return list(map(int, input().split()))

N = int(input())
yaku = []
ans = 0
S = int(sqrt(N))

for d in range(1, S+(S*S!=N)):
    a, b = divmod(N-d, d)
    if b == 0 and a >= 0:
      j, k = divmod(N, a)
      ans += a*(j==k)
print(ans)

Measured memory_bytes: 40300
$<.map{|i|a=i.chop.split(?,).map(&:to_i).sort;b=a.uniq.map{|j|a.count(j)};s,c=b.size,b.max;puts c>3?"four card":c>2?s>2?"three card":"full house":c>1?s>3?"one pair":"two pair":a[4]-a[0]<5||a[1]>9?:straight: :null}

Measured memory_bytes: 8588
S = input()

if 1 <= int(S[0:2]) <= 12 and 1 <= int(S[2:4]) <= 12:
    print('AMBIGUOUS')
elif not 1 <= int(S[0:2]) <= 12 and 1 <= int(S[2:4]) <= 12:
    print('YYMM')
elif 1 <= int(S[0:2]) <= 12 and not 1 <= int(S[2:4]) <= 12:
    print('MMYY')
else:
    print('NA')

Measured memory_bytes: 3064
iipt=lambda:int(input())
miipt=lambda:map(int,input().split(" "))
from math import sqrt
n,m=miipt()
r=0
for g in range(1, int(sqrt(m)+1)):
    if m%g==0 and m//g>=n:
        r=max(r, g)
    if m%g==0 and g>=n:
        r=max(r, m//g)
print(r)

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Competitive
{
    internal class Solution
    {
        public long[] A;

        public void Run()
        {
            var x = Input.ReadInt();
            {
                A = Input.ReadLongArray();
            }

            Console.WriteLine(A.Sum() - A.Length);
        }
    }

    // libs ----------
    

    // common ----------

    internal static class Input
    {
        public static string ReadString()
        {
            string line = Console.ReadLine();
            return line;
        }

        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();            
        }

        public static long ReadLong()
        {
            string line = Console.ReadLine();
            return long.Parse(line);
        }

        public static long[] ReadLongArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }
    
    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}

Measured memory_bytes: 13408
const input=require('fs').readFileSync('/dev/stdin', 'utf8').split(/[\s]/);const nin=()=>{const r = input[0];input.shift();return Number(r)};const nrin=(n)=>{const a:number[]=[];rep(n,()=>a.push(nin()));return a};const sin=()=>{const r = input[0];input.shift();return String(r)};const out=(...a)=>{console.log(...a)};const floor=(a)=>{return Math.floor(a)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const rep=(n, callback)=>{for(let i = 0;i < n; i++){callback()}};const strrep=(s, i, v)=>{return s.slice(0, i)+v+s.slice(i+1);};const permutation=({result=[],pre=[],post,n=post.length})=>{if(n>0){post.forEach((_,i)=>{const rest=[...post];const elem=rest.splice(i, 1);permutation({result, pre: [...pre,...elem],post:rest,n:n-1})})}else{result.push(pre)}return result};const sw=(s,a:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<a.length;i+=2){if(op==='=='){if(s==a[i])return a[i+1]}else if(op==='>='){if(s>=a[i])return a[i+1]}else if(op==='<='){if(s<=a[i])return a[i+1]}else if(op==='>'){if(s>a[i])return a[i+1]}else if(op==='<'){if(s<a[i])return a[i+1]}}return a[a.length-1];};const or=(a,...b)=>{for(let i=0;i<b.length;i++)if(a==b[i])return true;return false};const maxindex=(...a)=>{return a.indexOf(Math.max.apply(null,a))};const asc=(ar:number[])=>{return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{return ar.sort((a,b)=>{return b-a})};const ceil=a=>{return Math.ceil(a)};const srin=s=>{const a:string[]=[];rep(s,()=>a.push(sin()));return a};let ssinteger=-1;const ssin=()=>{ssinteger++;return input[0][ssinteger]};
const main = ()=>{
  let [a,b,c,d]=nrin(4)
  out(abs(a-c)<=d||(abs(a-b)<=d&&abs(b-c)<=d)?'Yes':'No')
}
main()

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

int main() {
  int A,B;
  cin >> A >> B;
  int count = 0;
  for (int i = 0; i < B - A + 1; i++) {
    int x = A + i;
    if (x % 10 == x /10000 && (x % 100 - x % 10) / 10 == x / 1000 - x / 10000 * 10) {
      count += 1;
    }
  } 
  cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int max_n=100005;
int n;
vector<int> G[max_n];
int col[max_n];
int main(){
    scanf("%d",&n);
    for(int i=1;i<n;i++){
        int u,v;
        scanf("%d%d",&u,&v);
        G[u].push_back(i);
        G[v].push_back(i);
    }
    int mx=0;
    for(int i=1;i<=n;i++)mx=max(mx,(int)G[i].size());
    for(int i=1;i<n;i++)col[i]=-1;
    for(int u=1;u<=n;u++){
        set<int> s;
        for(auto x:G[u]){
            if(col[x]!=-1)s.insert(col[x]);
        }
        int now=0;
        for(auto x:G[u]){
            if(col[x]!=-1)continue;
            else{
                while(s.count(now))now++;
                col[x]=now;
                s.insert(now);
            }
        }
    }
    printf("%d\n",mx);
    for(int i=1;i<n;i++)printf("%d\n",col[i]+1);
    return 0;
}

Measured memory_bytes: 7164
#include <iostream>

using namespace std;

int main()
{
    int a[100], n, i, j;
    
    cin>>n;
    
    for(i=0;i<n;i++){
        cin>>a[i];
        
    }
    for(j=0;j<n;j++){
        if(j!=0){
            cout<<" ";
        }
        cout<<a[n-j-1];
    }
cout<<endl;
    return 0;
}

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

int main() {
  char b;
  cin >> b;
  if (b == 'A') {
    cout << 'T' << endl;
  } else if (b == 'T') {
    cout << 'A' << endl;
  } else if (b == 'G') {
    cout << 'C' << endl;
  } else if (b == 'C') {
    cout << 'G' << endl;
  }
}

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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) ((int)(x).size())
#define pb push_back
#define fst first
#define snd second
#define PI (acos(-1))
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))

#define MAXN 1123456
#define MOD 1000000007

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<vi> vvi;

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

  int n;
  cin >> n;
  vi a(n), b(n);
  rep(i,0,n) cin >> a[i];
  rep(i,0,n) cin >> b[i];

  ll ans = 1e18; 
  rep(msk, 0, 1<<n) {
    if (__builtin_popcount(msk) != (n+1)/2) continue;
    vii e, o;
    rep(i,0,n) if(!(msk&(1<<i))) o.pb({i&1 ? a[i] : b[i], i}); else e.pb({i&1 ? b[i] : a[i], i});
    sort(all(e));
    sort(all(o));
    vi x;
    rep(i,0,n) if (i&1)x.pb(o[i/2].fst); else x.pb(e[i/2].fst);
    bool b=false;
    rep(i,1,n) {
      if (x[i] < x[i-1]) b=true;
    }
    if(b)continue;
    vi y;
    rep(i,0,n) if (i&1)y.pb(o[i/2].snd); else y.pb(e[i/2].snd);
    int swp = 0;
    rep(i,0,n) {
      rep(j,0,i) {
        if (y[j] > y[i]) ++swp;
      }
    }
    ans = min(ans, swp);
  }

  if (ans==1e18) ans = -1;

  cout << ans << endl;
}

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

int main() {
  int N, A; cin >> N >> A;
  int amari = N % 500;
  if (amari <= A) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
 
const int MAX_N = 100000;

int main() {
  int N, ansj;
  string s;
  int r[MAX_N], ans[MAX_N+1], flags, ansi;

  cin >> N >> s;
  for (int i=0; i<N; i++) {
    r[i] = (s[i] == 'o' ? 0x0 : 0xF);
  }
  ans[0] = 0x3;
  ans[1] = 0x5;
  for (int i=1; i<N; i++) {
    ans[i+1] = (ans[i] ^ ans[i-1] ^ r[i]);
  }
  flags = ~((0x3 ^ ans[N]) | (0x5 ^ (ans[N-1] ^ 0x3 ^ r[0])));

  ansi = -1;
  for(int i=0;i<4;i++){
    if(flags & (1<<i)){
      ansi = i;
      break;
    }
  }
  if(ansi != -1){
    for (int i=0; i<N; i++) {
      cout << ((ans[i] & (1<<ansi)) ? 'W' : 'S');
    }
    cout << endl;
  } else {
    cout << "-1" << endl;
  }
 
  return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
 
#define barsik ios::sync_with_stdio(false)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair <int, int> pii;
typedef std::unordered_set <int> u_si;
const double PI = acos(-1);
const long double EPS = 1e-9;
using namespace std;


void solve(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if(a > c){
        swap(a, c);
        swap(b, d);
    }
    if(b > c) cout << b - c - ((b > d) ? (b - d) : 0);
    else cout << 0;
}
int main(){
    int q = 1;
    //cin >> q;}
    while(q--) solve();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include<cstring>
#include<map>
#include<set>
#include<cstdlib>
#include<bitset>
using namespace std;
typedef long long ll;
ll n,k,p[5003],c[5003];
ll cir[5003]={0};
ll suan(ll st)
{
	ll now=p[st];
	ll j=0;
	while(now!=st)
	{
		cir[++j]=c[now];
		now=p[now];
	}
	cir[++j]=c[now];
	for(ll i=1;i<=j;i++) cir[i]+=cir[i-1];
	if(k<=j)
	{
		ll ans=cir[1];
		for(ll i=1;i<=k;i++) ans=max(ans,cir[i]);
		return ans;
	}
	else
	{
		ll ans=cir[1];
		for(ll i=1;i<=j;i++) ans=max(ans,cir[i]);
		ll macir=ans;
		ll qu=k%j,maqu=0;
		for(ll i=1;i<=qu;i++) maqu=max(maqu,cir[i]);
		ans=max(ans,k/j*cir[j]+maqu);
		if(k/j>0)
		{
			ans=max(ans,(k/j-1)*cir[j]+macir);
		}
		return ans;
	}
}
int main(void)
{
	scanf("%lld%lld",&n,&k);
	for(ll i=1;i<=n;i++) scanf("%lld",&p[i]);
	for(ll i=1;i<=n;i++) scanf("%lld",&c[i]);
	ll ans=-1000000000000000000;
	for(ll i=1;i<=n;i++)
	{
		ans=max(suan(i),ans);
	}
	printf("%lld\n",ans);
}

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

int main(){
	int n,o1,o2,o3;
	int a,b,c,d;

	cin >> n;

	a = n/1000;
	b = (n/100)%10;
	c = (n/10)%10;
	d = n%10;

	for(int i=1;i<=2;i++){
		for(int j=1;j<=2;j++){
			for(int k=1;k<=2;k++){
				if(a+b*(i==1?1:-1)+c*(j==1?1:-1)+d*(k==1?1:-1)==7){
					o1=i;
					o2=j;
					o3=k;
				}
			}
		}
	}

	cout << a << (o1==1?"+":"-") << b << (o2==1?"+":"-") << c << (o3==1?"+":"-") << d << "=7" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define LCIN(n) LL(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<LL,LL>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    LL from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};


int main(){
    CIN(A);CIN(B);CIN(C);
    COUT(max({A,B,C})-min({A,B,C}));
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <map>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

map<ll, ll> m;

ll sol(ll x) {
    if (m[x]) return m[x];
    if (x % 2) return m[x] = (sol(x / 2) * 2 + sol(x / 2 - 1)) % mod;
    else return m[x] = (sol(x / 2) + sol(x / 2 - 1) * 2) % mod;
}

int main() {
    ios::sync_with_stdio(false);
    ll n;
    m[0] = 1; m[1] = 2;
    cin >> n;
    cout << sol(n) << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e16+7;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int mod_pow(int x,int y) {
    int res = 1;
    while(y > 0) {
        if(y%2) {
            res = res*x%mod;
        }
        x = x*x%mod;
        y/=2;
    }
    return res;
}
int fac[2000005], finv[2000005], inv[2000005];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i <= 2000000; 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;
    }
}
int 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;
}
signed main() {
    int K;
    string S;
    cin >> K >> S;
    int N = K+S.size();
    int ans = 0;
    COMinit();
    for(int i = S.size(); i <= N; i++) {
        int cnt = 1;
        cnt *= mod_pow(25,i-S.size());
        cnt %= mod;
        cnt *= mod_pow(26,N-i);
        cnt %= mod;
        cnt *= COM(i-1,S.size()-1);
        cnt %= mod;
        ans += cnt;
        ans %= mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 51064
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

namespace CSharp
{
    class Program
    {
        static void Main(string[] args)
        {
            // 入力
            var input = Console.ReadLine().Split(' ');
            var monsterCount = int.Parse(input[0]);
            var specialAtk = int.Parse(input[1]);
            
            input = Console.ReadLine().Split(' ');
            long[] array = Array.ConvertAll<string,long>(input,delegate(string value){return long.Parse(value);});
            // 出力
            // モンスターの数より必殺技の数の方が多い場合は即戦闘終了
            if(monsterCount <= specialAtk)
            {
                Console.WriteLine(0);
                return;
            }
            var sort = array.OrderByDescending(x => x);
            var fight = sort.Skip(specialAtk).Take(array.Count() - specialAtk);
            long sum = 0;
            foreach (var item in fight)
            {
                sum += item;
            }
            Console.WriteLine(sum);
        }
    }
}

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

ll calc(ll a, ll b) {
    if (b == 0) return -a;
    return (a/b)*b*2 + calc(b, a%b);
}

int main(void){
    ll n,x;
    cin >> n >> x;
    ll a = max(n-x,x);
    ll b = min(n-x,x);
    cout << n + calc(a,b) << endl;
    return 0;
}


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

int main() {
  int a, b;
  cin >> a >> b;
  
  int ans = 0;
  int lol = 1;
  
  if(b == 1 ) { 
    cout << ans << endl; 
    return 0;
  }
  for(int i = 1; i < 30; i++) {
    lol = lol + a - 1;
    ans++;
    if(lol >= b) {
      cout << ans << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
using namespace std;
const ll MAX = 1e5+5;
ll dp[105][MAX];

int main(void)
{
	ll n, W;
	cin >> n >> W;
	ll v[n + 1], w[n + 1];

	for(int i = 0; i <= n; i++)
		dp[i][0] = 0;
	for(int i = 0; i <= W; i++)
		dp[0][i] = 0;

	for(int i = 1; i <= n; i++)
		cin >> w[i] >> v[i];

	for(int i = 1; i <= n; i++)
	{
		for(int j = 1; j <= W; j++)
		{
			if(j >= w[i])
				dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w[i]] + v[i]);
			else
				dp[i][j] = dp[i - 1][j];
		}
	}

	cout << dp[n][W] << endl;




	return 0;
}

Measured memory_bytes: 80128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y)
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repd(i, n) for (ll i = n-1; i >= 0; i--)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define repd2(i, s, n) for (ll i = n-1; i >= (s); i--)

int main() {
    string s;
    cin >> s;
    if (s=="RSR"){
        cout << 1 << endl;
    }
    else{
        cout << count(all(s), 'R') << endl;
    }
    return 0;
}

Measured memory_bytes: 3636
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef vector<vb> vvb;
typedef vector<vpii> vvpii;
const int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
const int MOD = 1000000007;
const double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
bool odd(const int &n) { return n & 1; }
bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int n;
  while (cin >> n, n) {
    int w, h;
    cin >> w >> h;
    vvi v(h, vi(w));
    while (n--) {
      int x, y;
      cin >> x >> y;
      x--;
      y--;
      v[y][x] = 1;
    }
    int s, t;
    cin >> s >> t;
    int m = 0;
    rep(i, h - t + 1) rep(j, w - s + 1) {
      int c = 0;
      loop(k, i, i + t) loop(l, j, j + s) c += v[k][l];
      cmax(m, c);
    }
    cout << m << endl;
  }
}

Measured memory_bytes: 3216
// AOJ Volume 0 Problem 0012

#include <stdio.h>

int main(void)
{
    int cars[1000];
    int n;
    int car_no;

    n = 0;
    
    while (scanf("%d", &car_no) != EOF){
    
        if (car_no == 0){
            printf("%d\n", cars[--n]);
        }
        else {
            cars[n++] = car_no;
        }
    }

    return (0);
}

Measured memory_bytes: 0
N,M = map(int,input().split())
List = []
like_dic = {}
like = 0
for i in range(N):
    List.append(input().split())
for i in range(N):
    for j in range(1,len(List[i])):
        if List[i][j] in like_dic:
            like_dic[List[i][j]] += 1
        else:
            like_dic[List[i][j]] = 1
for k in like_dic.keys():
    if like_dic[k] == N:
        like += 1
print(like)

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

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

fn main() {
  let s = read::<String>();
  let k = read::<i64>();
  let mut ans = '1';

  let s_char: Vec<char> = s.chars().collect();

  for i in 0..k {
    if s_char[i as usize] != '1' {
      ans = s_char[i as usize];
      break;
    }
  }

  println!("{}", ans);
}

Measured memory_bytes: 4352
#include <iostream>
#include <complex>
#include <vector>
#include <iomanip>
#include <queue>
using namespace std;

typedef complex<double> P;
#define EPS 1e-5
#define INF 1e7

typedef pair<int, double> Node;

class State
{
public:
	int n;
	double c;
	State(int n, double c)
		:n(n),c(c)
	{}

	bool operator<(const State& s) const
	{
		return c>s.c;
	}
};

//üª
struct L : public vector<P> {
  L(const P &a, const P &b) {
    push_back(a); push_back(b);
  }
};


//OÏ
double cross(const P& a, const P& b) {
  return imag(conj(a)*b);
}

double dist(const P& a, const P& b)
{
	return abs(a-b);
}

bool intersect(L& a, L& b)
{
	double t=max(a[0].imag(), a[1].imag());
	double l=min(a[0].imag(), a[1].imag());

	return (t+EPS>b[0].imag()&&b[0].imag()>l-EPS);
}

P crosspoint(const L &l, const L &m) {
  double A = cross(l[1] - l[0], m[1] - m[0]);
  double B = cross(l[1] - l[0], l[1] - m[0]);
  if (abs(A) < EPS && abs(B) < EPS) return m[0]; // same line
  return m[0] + B / A * (m[1] - m[0]);
}

int main()
{
	cout << setprecision(10) << setiosflags(ios::fixed);
	double vw,vc;
	int N;
	
	while(cin >> N, N)
	{
		vector<P> in;

		cin >> vw >> vc;
		for(int i=0; i<N; i++)
		{
			double x,y;
			cin >> x >> y;
			in.push_back(P(x,y));
		}

		vector<Node> node[4000];
		for(int i=0; i<N-1; i++)
		{
			node[i].push_back(make_pair(i+1, dist(in[i], in[i+1])/vw));
		}

		for(int i=0; i<N; i++)
		{
			L hz(P(-INF,in[i].imag()),P(INF,in[i].imag()));
			for(int j=i-2; j>=0; j--)
			{
				if(in[i].imag()+EPS > in[j+1].imag()) break;
				L tmp(in[j], in[j+1]);
				if(intersect(tmp,hz))
				{
					P xp=crosspoint(hz,tmp);
					in.push_back(xp);
					int p=in.size();
					node[j].push_back(make_pair(p, dist(in[j], xp)/vw));
					node[p].push_back(make_pair(j+1, dist(in[j+1], xp)/vw));
					node[p].push_back(make_pair(i, dist(in[i], xp)/vc));
					
					break;
				}
			}
			for(int j=i+1; j<N-1; j++)
			{
				if(in[i].imag()+EPS > in[j].imag()) break;

				L tmp(in[j], in[j+1]);
				if(intersect(tmp,hz))
				{
					P xp=crosspoint(hz,tmp);
					in.push_back(xp);
					int p=in.size();
					node[j].push_back(make_pair(p, dist(in[j], xp)/vw));
					node[p].push_back(make_pair(j+1, dist(in[j+1], xp)/vw));
					node[i].push_back(make_pair(p, dist(in[i], xp)/vc));
					
					break;
				}
			}
		}

		priority_queue<State> q;
		q.push(State(0,0));
		bool v[4000]={0};

		while(!q.empty())
		{
			State s=q.top(); q.pop();
			if(v[s.n]) continue;
			v[s.n]=1;

			if(s.n==N-1)
			{
				cout << s.c << endl;
				break;
			}

			for(int i=0; i<node[s.n].size(); i++)
			{
				Node next=node[s.n][i];
				if(v[next.first]) continue;

				q.push(State(next.first, s.c+next.second));
			}

		}


	}
}

Measured memory_bytes: 1188
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		// スペース区切りの整数の入力
		// 文字列の入力
		int[] d = new int[a];
		int e = 0;
		String h = sc.nextLine();
      String f = sc.nextLine();
		for(int i = 0; i < a; i++){
			if(f.substring(i,i + 1).equals("W")){
				d[i] = 1;
				
			}else{
				d[i] = 0;
              e++;
			}
		}
		int g = 0; 
		for(int i = 0; i < e; i++){
			g += d[i];
		}
		
		System.out.println(g);
		
		
	}
}

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

int main(void) {
    int A,B,C,X;cin>>A>>B>>C>>X;
    int cnt = 0;
    for (int i = 0; i <= A; i++) {
        for (int j = 0; j <= B; j++) {
            for (int k = 0; k <= C; k++) {
                if (i * 500 + j * 100 + k * 50 == X) cnt++;
            }
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 888
#include <stdio.h>
   struct yami
{
   double kinri;
   int fusai;

};
int main (void)
{
   int i,week;
   struct yami a;
   a.kinri=0.05;
   a.fusai=100000;
   scanf("%d",&week);
   for(i=0;i<week;i++)
   {
      a.fusai*=(1+a.kinri);
       if(a.fusai%1000!=0)
   {
      a.fusai/=1000;
      a.fusai+=1;
      a.fusai*=1000;
   }
   }
   printf("%d\n",a.fusai);
   return 0;
}

Measured memory_bytes: 592
N = int(input())

L = []
R = []

for i in range(N):
    x,l = map(int,input().split())
    L.append( x-l )
    R.append( x+l )

R,L = zip(*sorted(zip(R,L)))
cnt = 1
maxR = R[0]
for i in range(1,N):
    if maxR <= L[i]:
        cnt += 1
        maxR = R[i]
            
print(cnt)

Measured memory_bytes: 26008
a = list(input())
b = list(input())
c = list(input())
h = {'a':a ,'b':b, 'c': c}
t = 'a'
while True:
    if len(h[t]) == 0:
        print(t.capitalize())
        exit()
    d = h[t].pop(0)
    t = d


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

int main() {
  string s;
  cin >> s;
  int nedan = 700;
  for (int i = 0; i < 3; i++) {
    if (s.at(i) == 'o') {
      nedan += 100;
    }
  }
  cout << nedan << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
//#define double long double
#define endre getchar();getchar();return 0
#define moder (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1)*x;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x%mod;
		}
		x = x * x%mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)*mod_pow(kai(x - y), moder - 2, moder) % moder*mod_pow(kai(y), moder - 2, moder) % moder;
}
/*--------Library Zone!--------*/


signed main() {
	int a, b, c;
	cin >> a >> b >> c;
	rep(i, 50000000) {
		if (a % 2 || b % 2 || c % 2) {
			cout << i << endl;
			endre;
		}
		int a1 = b / 2 + c / 2, b1 = a / 2 + c / 2, c1 = a / 2 + b / 2;
		a = a1, b = b1, c = c1;
	}
	cout << -1 << endl;
	endre;
}

Measured memory_bytes: 256
/**********************
 * Author: Cloud_     *
 * Date:   19.04.2020 * 
 * Time:   17.53.32   *
 *                    *
***********************/
#include <bits/stdc++.h>
using namespace std;

#define gap " "
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ok cout<<"ok"<<endl
#define dbg(x) cout<<(#x)<<" is "<<x<<endl
#define fastio {ios_base::sync_with_stdio(false);cin.tie(NULL);}

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;

const int N=100009;

int main()
{
  //fastio; 
  double pi=2*acos(0.0),ans;
  int r;
  cin>>r;
  ans=2*pi*r;
  printf("%0.9lf\n", ans);
  return 0;
}

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

#define all(v) v.begin(), v.end()
#define rep(i, n) REP(i, 0, n)
#define REP(i, x, n) for (int i = x; i < n; i++)
#define REPE(i, x, n) for (int i = x; i <= n; i++)
#define OP(x) cout << x << endl;
template<typename T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<class T> void chmax(T& a, T b) { if(a > b) a = b; }
template<class T> void chmin(T& a, T b) { if(a < b) b = a; }
typedef long long ll;

int main() {
    string n; cin >> n;
    int in = stoi(n);
    int s = 0;
    rep(i, n.size()){
        s += n[i] - '0';
    }
    if(in % s == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
 
static const int MAX = 500;
static const int INFTY = (1<<21);
 
main(){
  int n, i, j, e, sum,k,a,V;
  int key,PI[MAX],v[MAX],u,c[MAX],M[MAX][MAX];
   
  scanf("%d", &n);
  for ( i = 0; i< n; i++ ){
    for ( j = 0; j < n; j++ ){
      M[i][j] = INFTY;
    }
  }
   
  for ( i = 0; i < n; i++ ){
    scanf("%d %d", &u, &k);
    for ( j = 0; j < k; j++ ){
      scanf("%d %d", &V, &a);
      M[u][V] = a;
    }
  }
  for(i=0;i<n;i++){
    c[i]=INFTY;
    PI[i]=-1;
    v[i]=0;
  }
  c[0]=0;
 
  while(1){
    key=INFTY;
    u=-1;
    for(i=0;i<n;i++){
      if(key>c[i] && !v[i]){
    u=i;
    key=c[i];
      }
    }
    if(u==-1)break;
    v[u]=1;
    for(j=0;j<n;j++){
      if(M[u][j]+c[u]<c[j] && !v[j]){
    PI[j]=u;
    c[j]=c[u]+M[u][j];
      }
    }
  }
   
  for ( i = 0; i < n; i++ ){
    printf("%d %d\n", i, (c[i]==INFTY?-1:c[i]));
  }
   
  return 0;
}

Measured memory_bytes: 800
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
using namespace std;

string grid[400];
bool used[400][400];

int move_h[4] = {-1, 1, 0, 0};
int move_w[4] = {0, 0, -1, 1};

int main(){
    int H;
    int W;
    cin >> H >> W;
    for(int i=0; i < H; i++){
        cin >> grid[i];
    }

    long long ans = 0;
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            if(used[i][j]){
                continue;
            }
            queue <pair <int, int> > q;
            q.push(make_pair(i, j));
            used[i][j] = true;
            long long black_num = 0;
            long long white_num = 0;
            while(!q.empty()){
                auto cur = q.front();
                q.pop();
                int cur_h = cur.first;
                int cur_w = cur.second;
                if(grid[cur_h][cur_w] == '.'){
                    white_num ++;
                } else {
                    black_num ++;
                }
                for(int i = 0; i < 4; i++){
                    int next_h = cur_h + move_h[i];
                    int next_w = cur_w + move_w[i];
                    if(0 <= next_h && next_h < H && 0 <= next_w && next_w < W
                        && !used[next_h][next_w] && grid[next_h][next_w] != grid[cur_h][cur_w]){
                        q.push(make_pair(next_h, next_w));
                        used[next_h][next_w] = true;

                    }
                }

            }
            ans += black_num * white_num;
        }
    }    

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

Measured memory_bytes: 640
#include <stdio.h>

int main(void)
{
	int n;
	int i;
	
	int a;
	int b;
	int c;
	
	scanf("%d", &n);
	
	for (i = 0; i < n; i++) {
		scanf("%d %d %d", &a, &b, &c);
		
		if ((c > a) && (c > b)) {
			if ((c * c) == (a * a) + (b * b)) {
				printf("YES\n");
			}
			else {
				printf("NO\n");
			}
		}
		
		else if ((b > a) && (b > c)) {
			if ((b * b) == (a * a) + (c * c)) {
				printf("YES\n");
			}
			else {
				printf("NO\n");
			}
		}
		else if ((a > b) && (a > c)) {
			if ((a * a) == (b * b) + (c * c)) {
				printf("YES\n");
			}
			else {
				printf("NO\n");
			}
		}
		else {
			printf("NO\n");
		}
	}
	
	return (0);
}

Measured memory_bytes: 580
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<ctime>
#include<utility>
#include<map>
#include<queue>
#include<set>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
int n;
map<ll,int> a;
queue<pii> q;
set<int> l[100010];
int f[100010];
int find(int x)
{
	return f[x]==x?x:f[x]=find(f[x]);
}
ll getid(int x,int y)
{
	if(x>y)
		swap(x,y);
	return ll(x)*n+y;
}
void link(int x,int y)
{
	l[x].insert(y);
	l[y].insert(x);
	ll v=getid(x,y);
	a[v]++;
	if(a[v]==3)
	{
		printf("NO\n");
		exit(0);
	}
	if(a[v]==2)
		q.push(pii(x,y));
}
int main()
{
	scanf("%d",&n);
	int i,x,y;
	for(i=1;i<=2*n-2;i++)
	{
		scanf("%d%d",&x,&y);
		link(x,y);
	}
	for(i=1;i<=n;i++)
		f[i]=i;
	for(i=1;i<n;i++)
	{
		while(1)
		{
			if(q.empty())
			{
				printf("NO\n");
				return 0;
			}
			x=q.front().first;
			y=q.front().second;
			x=find(x);
			y=find(y);
			q.pop();
			if(x!=y)
				break;
		}
		if(l[x].size()>l[y].size())
			swap(x,y);
		f[x]=y;
		a.erase(getid(x,y));
		l[y].erase(x);
		for(auto v:l[x])
		{
			v=find(v);
			if(v==y)
				continue;
			link(v,y);
			l[v].erase(x);
			a.erase(getid(x,v));
		}
		l[x].clear();
	}
	printf("YES\n");
	return 0;
}

Measured memory_bytes: 38656
#include<bits/stdc++.h>
#define mins(a,b) a=min(a,b)
#define maxs(a,b) a=max(a,b)
template < typename T > std::string to_string( const T& n )
  {
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
  }
using namespace std;

const long long INF=9000000000000000;
int main(){
int n,k;
string s;
cin>>n>>k>>s;
s[k-1]=s[k-1]+'a'-'A';
cout<<s<<endl;
}


Measured memory_bytes: 384
import sys
readline = sys.stdin.readline
write = sys.stdout.write
def solve():
    MOD = 10**9 + 7
    N = int(readline())
    S = []
    for i in range(N):
        s = readline().strip()
        if s == "-":
            N -= 1
            continue
        S.append(s == "D")
    memo = {}
    def dfs(i, a, b):
        if i == N:
            return (a == b == 0)
        key = (i, a, b)
        if key in memo:
            return memo[key]
        r = 0
        if S[i]:
            if a > 0:
                r += dfs(i+1, a, b) * a % MOD
            if a > 0 and b > 0:
                r += dfs(i+1, a-1, b-1) * a * b % MOD
        else:
            r += dfs(i+1, a+1, b+1)
            if b > 0:
                r += dfs(i+1, a, b) * b % MOD
        memo[key] = r = r % MOD
        return r
    write("%d\n" % dfs(0, 0, 0))
solve()


Measured memory_bytes: 6948