akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>

char in[100000], out[100000];

int main(void)
{
//    char in[10000];
    int n;
    int i, j;
//    char out[10000];
    char tmp[10];
    int p, m, l;
    
    
    while (1){
        scanf("%d", &n);
        if (n == 0){
            break;
        }
        
        scanf("%s", in);
        
        for (i = 0; i < n; i++){
            out[0] = '\0';
            p = 0;
            while (in[p] != '\0'){
                m = in[p] - '0';
                l = 0;
                while (m == in[p] - '0'){
                    p++;
                    l++;
                }
                sprintf(tmp, "%d%d", l, m);
//                printf("[%d%d]", l, m);
                strcat(out, tmp);
            }
//printf("[%s]\n", out);

            strcpy(in, out);
        }
        
        printf("%s\n", out);
    }
    return (0);
}

Measured memory_bytes: 708
#include <bits/stdc++.h>
using namespace std;
using vec_int = vector<int>;
using P = pair<int,int>;
using T = tuple<int,int,int>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int main(){
    //start:23:29
    int N, K; cin>>N>>K;
    vector<int> D(K);
    rep(i,K){
       cin>> D.at(i);
    }

    int money_to_pay = N;
    while(true){
        int flag = 1;
        string money_str = to_string(money_to_pay);
        rep(i, money_str.size()){
            rep(j, K){
                char zero_char = '0';
                if((int)(money_str.at(i))-(int)zero_char==D.at(j) ){
                    flag=0;
                    goto OUT; 
                }
            }
        }
        OUT:
        if(flag==0){
            money_to_pay++;
            continue;
        }else{
            cout<<money_to_pay<<endl;
            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++)
double dp[3004][3004];
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin>>n;
    vector<double> a(n);
    rep(i,n)cin>>a[i];
    rep(i,n+1)rep(j,n+1)dp[i][j]=0;
    dp[0][0]=1;
    for(int i=0;i<n;i++)for(int j=0;j<=i;j++){
        dp[i+1][j+1]+=dp[i][j]*a[i];
        dp[i+1][j]+=dp[i][j]*(1.0-a[i]);
    }
    double res=0;
    for(int j=(n+1)/2;j<=n;j++)res+=dp[n][j];
    cout<<fixed<<setprecision(10)<<res<<endl;
    return 0;
}


Measured memory_bytes: 70656
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define FOR(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v),end(v)
#define debug(x) std::cerr<<#x<<": "<<x<<"\n"
#define debug2(x,y) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<"\n"
#define debug3(x,y,z) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<", "<<#z<<": "<<z<<"\n"

using ll=long long;
using vi=std::vector<int>;
using vvi=std::vector<vi>;
using vll=std::vector<ll>;
using vvll=std::vector<vll>;
template<typename T> using vvec=std::vector<std::vector<T>>;
template<typename T>
auto make_v(size_t sz){return std::vector<T>(sz);}
template<typename T,typename... Ts>
auto make_v(size_t sz,Ts...ts){return std::vector<decltype(make_v<T>(ts...))>(sz,make_v<T>(ts...));}
template<typename T>
void fill_v(T&var,const T&x){var=x;}
template<typename V,typename T>
void fill_v(V&v,const T&x){for(auto&& w:v){fill_v(w,x);}}

template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<std::vector<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<std::deque<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s, const std::set<T>&v){
  s<<"\n";for(auto&& elm:v){s<<elm<<"\t";}s<<"\n";return s;}

inline void scan(int&a){scanf("%d",&a);}
inline void scan(ll&a){scanf("%lld",&a);}
inline void scan(char&a){scanf(" %c",&a);}
inline void scan(double&a){scanf("%lf",&a);}
template<typename T>
inline void scan(std::vector<T>&v){for(auto&& sv:v){scan(sv);}}
template<typename First,typename...Args>
inline void scan(First&f,Args&...args){scan(f);scan(args...);}
inline void scan(std::string&s){char BUF[3000000];scanf(" %s",BUF);s=std::string(BUF);}
inline void print(int a){printf("%d\n",a);}
inline void print(ll a){printf("%lld\n",a);}
inline void print(double a){printf("%.12f\n",a);}
inline void print(std::string s){std::cout<<s<<"\n";}

using namespace std;

int main() {
  int k, n;
  scan(k, n);
  vi a(n);
  scan(a);
  int max_diff = a[0] + k - a[n-1];
  rep (i, n-1) {
    max_diff = max(max_diff, a[i+1] - a[i]);
  }
  print(k - max_diff);

  return 0;
}


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

int gcd(int a, int b) {
	if (b == 0) return a;
	else return gcd(b, a % b);
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);	
	int n, sum = 0;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			for (int k = 1; k <= n; k++) {
				sum += gcd(gcd(i, j), k);
			}
		}
	}
	cout << sum << "\n";
	return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <limits>
#include <sstream>
#include <fstream>
#include <climits>
#include <map>
#include <numeric>
#include <functional>
#include <utility>

using namespace std;

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

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

  ll x = 0;
  if (n < b) {
    x = n;
  }
  else {
    x = (n / b) * b - 1;
  }

  ll xb = x / b;
  ll axb1 = a * x / b;
  ll axb2 = a * xb;
  cout << axb1 - axb2 << endl;
  
  return 0;
}


Measured memory_bytes: 3608
from collections import deque
n,u,v=map(int,input().split())
graph=[[] for i in range(n)]
for i in range(n-1):
  a,b=map(int,input().split())
  a-=1;b-=1
  graph[a].append(b)
  graph[b].append(a)
Q=deque([v-1])
Vert=[[0,0] for i in range(n)]
visited=[False]*n
visited[v-1]=True
while Q:
  V=Q.popleft()
  visited[V]=True
  for i in graph[V]:
    if visited[i]:continue
    if i == V:continue
    Vert[i][0]=Vert[V][0]+1
    Q.append(i)
visited=[False]*n
visited[u-1]=True
Q.append(u-1)
while Q:
  V=Q.popleft()
  visited[V]=True
  for i in graph[V]:
    if visited[i]:continue
    if i == V:continue
    Vert[i][1]=Vert[V][1]+1
    Q.append(i)
ans=0
for i in Vert:
  if i[0]>i[1]:
    if i[0]>ans:
      ans=i[0]
print(ans-1)

Measured memory_bytes: 38856
#include <iostream>
#include <iomanip>

using namespace std;
int main(void){
    // Your code here!
    double i;
    double k;
    int a1;
    int a2;
    double a3;
    
    cin >> i >> k ;
    
    a1 = i/k;
    a2 = (int)i%(int)k;
    a3 = i/k;
    
    cout << a1 << " " << a2 << " " << fixed << setprecision(5) << a3 << endl;
    
}



Measured memory_bytes: 3280
import java.util.*;

public class Main {

	public static void main(String[] args) {
	
	
		Scanner sc=new Scanner(System.in);
		 long a,b;
		a=sc.nextLong();
		b=sc.nextLong();
		long c;
		c=(b-a)+1;
		
		 if (a>0)
		{System.out.println("Positive");}
		
		 else if(a<=0 && b>=0)
		{System.out.println("Zero");}
		 
		 else  if(c%2==0)
		 {System.out.println("Positive");}
		 
		 else
		 {System.out.println("Negative");}
			
		
	
		
		sc.close();

	}

}


Measured memory_bytes: 35608
# -*- coding: utf-8 -*-
# AtCoder Beginner Contest


if __name__ == '__main__':
    n = int(input())
    a = list(map(int, input().split()))
    count = 0

    for ai in a:
        while True:
            if ai % 2 == 0:
                ai = ai / 2
                count += 1
            else:
                break

    print(count)


Measured memory_bytes: 4148
def main():
    import sys
    input = sys.stdin.readline
    
    n, k = map(int, input().split())
    arr = list(map(int, input().split()))
    
    ans = 0
    for i in range(n):
        for j in range(i + 1, n):
            if arr[j] < arr[i]:
                ans += k
        for j in range(n):
            if arr[j] < arr[i]:
                ans += (k * (k - 1) >> 1) % 1000000007
        ans %= 1000000007
    print(ans % 1000000007)
    
    return 0

main()

Measured memory_bytes: 42092
#include<bits/stdc++.h>
using namespace std;
const int M=1e9+7;
int n,x,y,z,i,ans,k,now,s,st,f[42][1<<17],ban;
int main(){
	scanf("%d%d%d%d",&n,&x,&y,&z);
	ans=1;
	for (i=1;i<=n;i++) ans=10ll*ans%M;
	ban=(1<<z-1)|(1<<y+z-1)|(1<<x+y+z-1),st=(1<<x+y+z)-1;
	f[0][0]=1;
	for (i=0;i<n;i++)
		for (s=0;s<=st;s++) if (f[i][s])
			for (k=1;k<=10;k++){
				now=((s<<k)|(1<<k-1))&st;
				if ((now&ban)!=ban) (f[i+1][now]+=f[i][s])%=M;
			}
	for (i=0;i<=st;i++) (ans-=f[n][i])%=M;
	printf("%d",(ans+M)%M);
}


Measured memory_bytes: 19328
#include <stdio.h>

int main()
{
    int h, w, i, j;
    scanf("%d%d", &h, &w);
    char a[100][101], top[103], bottom[103];
    for (i=0; i<h; i++)
    {
        scanf("%s", a[i]);
    }
    for (i=0; i<=w+1; i++)
    {
        top[i] = bottom[i] = '#';
        top[w+2]= bottom[w+2] = '\0';
    }
    printf("%s\n", top);
    for (i=0; i<h; i++)
    {
        printf("#%s#\n", a[i]);
    }
    printf("%s\n", bottom);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
#define maxs(x,y) x = max(x, y)
#define mins(x,y) x = min(x, y)
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    ll N;
    cin >> N;

    ll sumA = 0, sumB = 0;
    vector<ll> A(N);
    REP(i, N) {
        cin >> A[i];
        sumA += A[i];
    }

    vector<ll> B(N);
    REP(i, N) {
        cin >> B[i];
        sumB += B[i];
    }

    if (sumA < sumB) {
        cout << -1 << endl;
        return 0;
    }

    ll fusoku = 0;
    vector<ll> yuyo;
    ll cnt = 0;
    REP(i, N) {
        if (A[i] < B[i]) {
            fusoku += B[i] - A[i];
            cnt ++;
        }
        if (A[i] > B[i]) yuyo.push_back(A[i] - B[i]);
    }

    sort(RALL(yuyo));

    while(fusoku > 0) {
        fusoku -= yuyo[0];
        cnt++;
        yuyo.erase(yuyo.begin());
    }


    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 2428
using System;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        var input = "";
        int numinput = 0;
        var inputList = new List<int>();

        do
        {
            input = Console.ReadLine();
            numinput = int.Parse(input);
            if (numinput != 0)
            {
                inputList.Add(numinput);
            }
        } while (numinput != 0);

        for(int i = 0; i < inputList.Count; i++)
        {
            Console.WriteLine("Case " + (i + 1) + ": " + inputList[i]);
        }
    }
}


Measured memory_bytes: 18020
n, w = map(int, input().split())
li = [list(map(int, input().split())) for _ in range(n)]

dp = [[0]*(w+10) for _ in range(n+10)]
weight = [0] * (n+10)
value = [0] * (n+10)

for i in range(n):
    value[i] = li[i][0]
    weight[i] = li[i][1]
    
for i in range(n):
    for j in range(w+1):
        if j >= weight[i]:
            dp[i+1][j] = max(dp[i][j-weight[i]] + value[i], dp[i][j])
        else:
            dp[i+1][j] = dp[i][j]
        
print(dp[n][w])


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

using namespace std;

#define ll long long
#define pb push_back


int main () {

    ll n;
    cin >> n;

    map <string, int> l;

    l["AC"] = 0;
    l["WA"] = 0;
    l["TLE"] = 0;
    l["RE"] = 0;

    for (int i = 0; i < n; ++i) {
        string t;
        cin >> t;

        l[t]++;
    }

    cout << "AC x " << l["AC"] << "\n" << "WA x " << l["WA"] << "\n" << "TLE x " << l["TLE"] << "\n" << "RE x " << l["RE"] << "\n";
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;

#define int long long  
#define ll long long
#define vi vector <int>
#define vii vector <pair<int,int> >
#define vvi vector <vi>
#define rep(i,a,b) for (int i=a;i<b;i++)
#define repD(i,a,b) for (int i=a;i>b;i--)
#define pb push_back
#define pii pair <int,int>
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define MOD 1000000007
#define M_PI 3.14159265358979323846 

typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
///*X.find_by_order("index")
///X.order_of_key("key")

///----------------------------------------------------------------------------------

int f1(int x, int y, int x1, int y1, int mid) {
	return x + y - x1 - y1 - mid;
}

int f2(int x, int y, int x1, int y1, int mid) {
	return x - y - x1 + y1 - mid;
}


vi sum, diff;
int n;
pii pts[200005];

void solve()
{
	
	cin >> n;
	rep(i,0,n) cin >> pts[i].ff >> pts[i].ss, sum.pb(pts[i].ff + pts[i].ss), diff.pb(pts[i].ff - pts[i].ss);
	sort(all(sum));
	sort(all(diff));
	
	int ans = 0;
	rep(i,0,n) {
		int lo = 0, hi = 2*MOD, mid, best = 0;
		while(lo <= hi) {
			mid = (lo + hi) / 2;
			
			int q1 = sum.end() - lower_bound(all(sum), pts[i].ff + pts[i].ss + mid), q2 = diff.end() - lower_bound(all(diff), pts[i].ff - pts[i].ss + mid);
			if (q1 + q2 == 0)
				hi = mid - 1;
			else best = mid, lo = mid + 1;
		}
		ans = max(ans, best);
	}
	cout << ans << "\n";
}
	
signed main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	
	#ifdef local
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	clock_t TIMER = clock();
	#endif
	
	int t = 1;
	//cin >> t;
	rep(a,0,t)
	{
		//cout<<"Case #"<<a+1<<": ";
		solve();
		#ifdef local
		cout << "\n";
		#endif

	}
	
	#ifdef local
	{TIMER = clock() - TIMER;double time_taken = ((double)TIMER)/CLOCKS_PER_SEC;cerr<<fixed<<setprecision(5)<<"\n\nTime Taken : "<<time_taken<<" seconds\n";}
	#endif
}


Measured memory_bytes: 9792
#include <stdio.h>
#include <iostream>
using namespace std;
static const int MAX = 100;
int main()
{
    // for i = 0 to A.length-1
    // 2     mini = i
    // 3     for j = i to A.length-1
    // 4         if A[j] < A[mini]
    // 5             mini = j
    // 6     swap A[i] and A[mini]
    int N, A[MAX], elem, mini, sw = 0;
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        cin >> elem;
        A[i] = elem;
    }

    for (int k = 0; k < N; k++)
    {
        mini = k;
        for (int j = k; j < N; j++)
        {
            if (A[j] < A[mini])
            {
                mini = j;
            }
        }
        if (k != mini)
        {
            swap(A[k], A[mini]);
            sw++;
        }
    }
    for (int j = 0; j < N; j++)
    {
        if (j)
        {
            cout << " ";
        }
        cout << A[j];
    }
    cout << endl;

    cout << sw<<endl;
    return 0;
}


Measured memory_bytes: 3096
//S.G.N.//
#include <bits/stdc++.h>
using namespace std;
typedef vector< long long > vi;
typedef long long ll;
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define endl "\n"
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define fr(n) for(ll i=0;i<n;i++)
#define tr(a) for(auto it=a.begin();it!=a.end();it++)
#define N 998244353445 
#define PI 3.1415926535897932384
#define F first
#define S second
#define mp make_pair
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod 1000000007
void solve()
{
 ll n,w;
 cin>>n>>w;
 ll dp[n+1][100001];
 ll we[n];
 ll v[n];
 fr(n)
 cin>>we[i]>>v[i];
 fr(n+1)
 {

  rep(j,0,100001)
  {
    
if(j==0)
  dp[i][0]=0;
else{
    dp[i][j]=1000000000000;
    
  }
  
  }
 }
fr(n)
{
rep(j,1,100001)
{
  dp[i+1][j]=dp[i][j];
  if(j-v[i]>=0&&dp[i][j-v[i]]!=1000000000000){
    //cout<<dp[i][j-v[i]]+we[i]<<" "<<dp[i+1][j]<<" ";
    dp[i+1][j]=min(dp[i+1][j],dp[i][j-v[i]]+we[i]);
    //cout<<dp[i+1][j]<<" ";
  }
  //cout<<dp[i+1][j]<<" ";
}
//cout<<endl;
}
for(int i=100000;i>=0;i--)
{
  if(dp[n][i]<=w&&dp[n][i]!=1000000000000){
    cout<<i;
  
  break;
}
}
}
int main()
{
  
  #ifndef ONLINE_JUDGE
     * freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
  #endif
  FAST
  ll test;
test=1;
  //cin>>test;
  while(test--)
  {
    solve();
  }
  return 0;
}

Measured memory_bytes: 82504
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: i64,
        b: i64,
    }
    if b % a == 0 {
        println!("{}", a + b);
    } else {
        println!("{}", b - a);
    }
}


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

int main() {
  int input, a, b, c;
  cin >> input;
  a = input / 100;
  b = input / 10 - 10 * a;
  c = input - 100 * a - 10 * b;
  
  cout << a + b + c << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
// マクロ
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
// 型エイリアス
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vvs = vector<vs>;

int main() {
    int n, a;
    cin >> n >> a;
    cout << n*n - a << endl;
}

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

int main(){
    int h,w;
    cin>>h>>w;
    char s[h][w];
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>s[i][j];
        }
    }
    //入力
    int memo_i,memo_j;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
           if(s[i][j]=='.'){
               int count=0;
                for(int k=i-1;k<=i+1;k++){
                    for(int l=j-1;l<=j+1;l++){
                        if(k>=0 && l>=0 && k<h && l<w){
                            if(s[k][l]=='#'){
                                count++;
                            }
                        }
                    }
                    
                }   
                s[i][j]='0'+count;
           }
        }
    }
    //変換
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cout<<s[i][j];
        }
        cout<<endl;
    }

    return 0;
}

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

using namespace std;

#define LL long long
#define DD double
#define Pb push_back
#define Bp pop_back
#define Pf push_front
#define Fp pop_front
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define X first
#define Y second
#define mx1 10
#define mx2 110
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

typedef vector<LL> Vl;
typedef vector<DD> Vd;
typedef vector<bool> Vb;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef pair<DD, DD> Pdd;
typedef vector<Pll> Vpl;
typedef vector<Pdd> Vpd;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
typedef deque<LL> Dl;

LL _set(LL N, LL pos) {return N = N | (1 << pos);}
LL _reset(LL N, LL pos) {return N = N & ~(1 << pos);}
bool _check(LL N, LL pos) {return (bool)(N & (1 << pos));}
bool _upper(char a) {return a >= 'A' && a <= 'Z';}
bool _lower(char a) {return a >= 'a' && a <= 'z';}
bool _digit(char a) {return a >= '0' && a <= '9';}

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

///**************************DONE****************************///

int main()
{
    int a, b;
    cin >> a >> b;
    cout << a * b << '\n';
    return 0;
}


Measured memory_bytes: 3620
n, k = map(int, input().split())
s = input()
res = []

if s[0] == "0":
    res.append(0)
res.append(1)
for i in range(1, n):
    if s[i] == s[i - 1]:
        res[-1] += 1
    else:
        res.append(1)
if s[-1] == "0":
    res.append(0)

l = len(res)
su = [0] * (l + 1)
for i in range(l):
    su[i + 1] = su[i] + res[i]

mil = min(l, 2 * k + 1)

ans = 1
for i in range(0, l - mil + 1, 2):
    ans = max(ans, su[mil + i] - su[i])
print(ans)


Measured memory_bytes: 7884
#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <numeric>
#include <math.h>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())

using namespace std;
typedef long long ll;

int main() {
#ifdef RUN_LOCAL
  ifstream in("../input.txt");
  cin.rdbuf(in.rdbuf());
#endif

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

  int n;
  cin >> n;

  cout << std::setprecision(10) << 2 * n * M_PI << endl;



  return 0;
}


Measured memory_bytes: 3220
N = int(input())
A = list(map(int, input().split()))
count=0
for i in range(N):
  if(i==0):
    continue
  if(A[i-1]>A[i]):
    count = count + A[i-1]-A[i]
    A[i] = A[i-1]
print(count)

Measured memory_bytes: 32200
#!/usr/bin/env python3
import sys


def solve(N: int, K: int):
    ans = 0
    for n in range(1, N+1):
        b = 1
        while n * b < K:
            b <<= 1
        ans += 1 / (b * N)
    return ans

# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    print(solve(N, K))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()


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

int gcd(int a, int b)
{
	if (a<b) swap(a,b);
	while(b)
	{
		int temp = b;
		b = a%b;
		a = temp;
	}
	return a;
}

int main()
{
	int n, k, a, b, maxi = 0;
	scanf("%d%d", &n, &k);
	if (n == 1)
	{
		scanf("%d", &a);
		if (a != k)
			printf("IMPOSSIBLE\n");
		else
			printf("POSSIBLE\n");
		return 0;
	}
	scanf("%d%d", &a, &b);
	maxi = max(a,b);
	b = gcd(a,b);
	for (int i = 2; i<n; i++)
	{
		scanf("%d", &a);
		if (a>maxi) maxi = a;
		b = gcd(a,b);
	}
	if (maxi<k)
	{
		printf("IMPOSSIBLE\n");
		return 0;
	}
	if (k%b)
	{
		printf("IMPOSSIBLE\n");
	}
	else
	{
		printf("POSSIBLE\n");
	}
}

Measured memory_bytes: 256
from itertools import permutations as p
from collections import defaultdict as dd

n,m=map(int,input().split())
d=dd(list)
for _ in range(m):
    a,b=map(int,input().split())
    d[a].append(b)
    d[b].append(a)
d=dict(d)
ans=0

for i in p(range(2,n+1)):
    pos=1
    for j in i:
        if not j in d[pos]:
            break
        pos=j
    else:
        ans+=1

print(ans)

Measured memory_bytes: 39152
#include<cstdio>
#include<algorithm>
#include<functional>
using namespace std;
int main(void)
{
	int n,i,m,x[100000],y[100000],sum;
	scanf("%d %d",&n,&m);
	for(i=0;i<m;i++)	scanf("%d",&x[i]);
	sort(x,x+m);
	for(i=0;i<m-1;i++)	y[i]=x[i+1]-x[i];
	sort(y,y+m-1);
	sum=0;
	for(i=0;i<m-n;i++)	sum+=y[i];
	printf("%d\n",sum);
	return 0;
}

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

#define int long long
#define MOD 1000000007

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

    map<int, int> mp;
    for(int i = 2;i <= n;i++){

        int tmp = i;
        int k = 2;
        while(tmp > 1){
            if(tmp % k == 0){
                mp[k]++;
                tmp /= k;
            }else{
                k++;
            }
        }

    }

    int ans = 1;
    for(auto itr = mp.begin();itr != mp.end();itr++){
        ans *= (*itr).second + 1;
        ans %= MOD;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
/*input
3 100 1000
10 100 100
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}

ll a[maxn];

int main()
{
	IOS;
	ll n,z,w;
	cin>>n>>z>>w;
	REP(i,n) cin>>a[i];
	if(n==1){
		cout<<abs(a[0]-w)<<'\n';
	}
	else{
		cout<<max(abs(w-a[n-1]),abs(a[n-1]-a[n-2]))<<'\n';
	}
	return 0;
}


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

#define fastio ios::sync_with_stdio(); cin.tie(0); cout.tie(0);
#define pb push_back
#define ll long long
#define fi first
#define se second
#define maxn 200005

const int mod = 1e9+7 ;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vii;

int dp[maxn][150], pos[maxn][150];

signed main()
{
//	freopen(".inp","r",stdin);
//	freopen(".out","w",stdout);
	fastio;
	string str;	cin >> str;
	int n = str.length();
	for (int i = 0; i <= maxn; i++)
		for (int j = 0; j <= 200; j++)	dp[i][j] = mod;
	dp[n][str[n-1]] = 2;
	for (int j = 'a'; j <= 'z'; j++)
	{
		pos[n][j] = n+1;
		if (dp[n][j] == mod)	dp[n][j] = 1;
		dp[n+1][j] = 1;
	}
	pos[n][str[n-1]] = n;
	for (int i = n-1; i > 0; i--)
	{
		pos[i][str[i-1]] = i;
		for (int j = 'a'; j <= 'z'; j++)
		{
			dp[i][str[i-1]] = min(dp[i+1][j] + 1, dp[i][str[i-1]]);
		}
		for (int j = 'a'; j <= 'z'; j++)
		{
			if (j != str[i-1])
			{
				pos[i][j] = pos[i+1][j];
				dp[i][j] = dp[i+1][j];
			}
		}
	}
	int ans = mod;
	for (int i = 'a'; i <= 'z'; i++)
	{
		ans = min(ans, dp[1][i]);
	}
	int run = 1;
	while (run <= n)
	{
		for (int i = 'a'; i <= 'z'; i++)
		{
			if (dp[run][i] == ans)
			{
				ans--;
				cout << (char)i;
				run = pos[run][i];
				break;
			}
		}
		run++;
	}
}


Measured memory_bytes: 238116
from collections import defaultdict 
import sys
import math 

def get_array(): return list(map(int , sys.stdin.readline().strip().split()))
def get_ints(): return map(int, sys.stdin.readline().strip().split())
def input(): return sys.stdin.readline().strip()

n = int(input())

start = 0
for i in range(1,n+1):
	start = (start*10+7)%n
	if start==0:
		print(i)
		break
else:
	print(-1)


Measured memory_bytes: 9328
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define elif else if
int aa[100000],ab[100000];
string s;
int a,b,c=0;
signed main()
{
	cin>>a>>b;
	rep(i,b){
		cin>>aa[i];
	}
	sort(aa,aa+b);
	rep(i,b-1){
		ab[i]=aa[i+1]-aa[i];
	}
	sort(ab,ab+(b-1));
	rep(i,b-a){
		c=c+ab[i];
	}
	cout<<c;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define mod 1000000007
#define pb push_back
#define ll long long
using namespace std;
int main(){
	int n;
	cin>>n;
	if(n==3){
		cout<<2<<" "<<5<<" "<<63<<endl;
	}
	else{
		int thr = 2, eve = n-2;
		while( eve%3 == 1 || eve>15000){
			thr += 2;
			eve -= 2;
		}
		for(int i=0;i<thr;i++){
			cout<<6*i+3<<" ";
		}
		for(int i=1;i<=eve;i++){
			cout<<2*i<<" ";
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abc123_a
{
    class Program
    {
        public static int keisan(int x, int y)
        {
            int g = y - x;
            return g;
        }
        public static int hantei(int x, int y)
        {
            int count = 0;
            if(x > y)
            {
                count = count + 1;
            }
            return count;
        }
        static void Main(string[] args)
        {
            int a = int.Parse(Console.ReadLine());
            int b = int.Parse(Console.ReadLine());
            int c = int.Parse(Console.ReadLine());
            int d = int.Parse(Console.ReadLine());
            int e = int.Parse(Console.ReadLine());
            int k = int.Parse(Console.ReadLine());

            int sum = 0;

            sum += hantei(keisan(a, b), k) ;
            sum += hantei(keisan(a, c),k);
            sum += hantei(keisan(a, d),k);
            sum += hantei(keisan(a, e),k);
            sum += hantei(keisan(b, c),k);
            sum += hantei(keisan(b, d),k);
            sum += hantei(keisan(b, e),k);
            sum += hantei(keisan(c, d),k);
            sum += hantei(keisan(c, e),k);
            sum += hantei(keisan(d, e),k);

            if(sum > 0)
            {
                Console.WriteLine(":(");
            }
            else
            {
                Console.WriteLine("Yay!");
            }
            Console.Read();
        }
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;


int main(){
 ll n;
 cin>>n;
 vector<ll> a(n);
 for(ll i=0;i<n;i++)cin>>a[i];
 vector<ll> b = a;
 sort( b.begin() , b.end() );
 for(ll i=0;i<n;i++){
  if( a[i] == b[n-1] ){
   cout<<b[n-2]<<endl;
  }else{
   cout<<b[n-1]<<endl;
  }
 }
    return 0;
}


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

int main(){
    int N;
    cin >> N;
    vector<int> D(N);
    for(int i = 0; i < N; i++){
        cin >> D.at(i);
    }

    int count = 0;

    for(int i = 0; i < N-1; i++){
        for(int j = i+1; j < N; j++){
            count += D.at(i) * D.at(j);
        }
    }

    cout << count << endl;
}

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

using namespace std;


int dp[2][101][10001],a[100],b[100],c[100];

int main(){
  int n,d;

  cin>>n>>d;

  for(int i=0;i<n;i++)
    cin>>a[i]>>b[i]>>c[i];

  for(int i=0;i<=100;i++)
    for(int j=0;j<=10000;j++)
      dp[0][i][j]=dp[1][i][j]=-1e9;

  dp[0][0][0]=0;

  for(int i=0;i<n;i++){
    for(int j=0;j<=d;j++)
      for(int k=0;k<=10000;k++){
	
	if(j+c[i]<=d&&k+a[i]<=10000)
	  dp[(i+1)%2][j+c[i]][k+a[i]]=
	    max(dp[(i+1)%2][j+c[i]][k+a[i]],dp[i%2][j][k]+b[i]);

	if(j+c[i]<=d&&k+b[i]<=10000)
	  dp[(i+1)%2][j+c[i]][k+b[i]]=
	    max(dp[(i+1)%2][j+c[i]][k+b[i]],dp[i%2][j][k]+a[i]);

	
	dp[(i+1)%2][j][k]=max(dp[(i+1)%2][j][k],dp[i%2][j][k]);
	
      }

    for(int j=0;j<=100;j++)
      for(int k=0;k<=10000;k++)dp[i%2][j][k]=-1e9;
    
  }
  
  int ans=0;
  
  for(int i=0;i<=d;i++)
    for(int j=0;j<=10000;j++){
      ans=max(ans,min(j,dp[n%2][i][j]));
    }

  cout<<ans<<endl;
  return 0;

}

Measured memory_bytes: 10984
package main

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

var scanner *bufio.Scanner

func printIt() {
	n := nextInt()

	for i := 1; i <= n; i++ {
		x := i
		if x%3 == 0 {
			fmt.Print(" ")
			fmt.Print(x)
		} else {
			for {
				if x%10 == 3 {
					fmt.Print(" ")
					fmt.Print(i)
					break
				}
				x = x / 10
				if x == 0 {
					break
				}
			}
		}
	}
	fmt.Println()
}

func nextInt() int {
	scanner.Scan()
	num, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(1)
	}
	return num
}

func main() {
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	printIt()
}



Measured memory_bytes: 1116
def main():
    N, T = map(int, input().split())
    ans = 10000
    for i in range(N):
        c, t = map(int, input().split())
        if t <= T:
            ans = min(ans, c)
    if ans == 10000:
        print("TLE")
    else:
        print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);

		String s = sc.next();
		
		int counta = 0;
		int countb = 0;
		int countc = 0;

		for (int i = 0; i < 3; i++) {
			if(s.charAt(i) == 'a'){
				counta++;
			}
			
			if(s.charAt(i) == 'b'){
				countb++;
			}
			
			if(s.charAt(i) == 'c'){
				countc++;
			}		
		}
		
		if (counta == 1 && countb == 1 && countc == 1){
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 21844
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
#include<set>
#include<stack>
#include<queue>

#define reps(i,j,k) for(int i=(j);i<(k);i++)
#define rep(i,j) reps(i,0,j)
#define fs first
#define sc second
#define pb push_back
#define mk make_pair

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

template<class S,class T>
ostream &operator<<(ostream &out, const pair<S,T> p){
	return out << "(" << p.fs << ", " << p.sc << ")";
}

template<class T>
ostream &operator<<(ostream &out, const vector<T> &v){
	out << "{";
	rep(i,v.size()) out << v[i] << ", ";
	return out << "}" << endl;
}

int main(){
	string s;
	cin >> s;
	string ac = "AC";
	rep(i, s.length() - 1){
		bool f = false;
		rep(j, 3){
			if (j == 2) {
				f = true;
				break;
			}
			if(s[i+j] != ac[j]) break;
		}
		if (f){ cout <<"Yes" << endl;return 0;}
	}
	cout << "No" << endl;

	return 0;
}


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

int main() {
    int n, l, r;
    while (cin >> n >> l >> r, n) {
        int cnt = 0;
        vector<int> a(n);
        for (int &ai: a) cin >> ai;
        for (int x = l; x <= r; x++) {
            int idx = n;
            for (int i = 0; i < n; i++) if (x % a[i] == 0) { idx = i; break; }
            if (idx % 2 == 0) cnt += 1;
        }
        cout << cnt << endl;
    }
    return 0;
}


Measured memory_bytes: 3052
n, m, c = map(int, input().split())
list_b = [int(x) for x in input().split()]
list_a = [[int(y) for y in input().split()] for z in range(n)]

cnt = 0

for i in range(n):
    sum = c
    for j in range(m):
        sum += list_a[i][j] * list_b[j]
    if sum > 0:
        cnt += 1

print(cnt)

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

#define lb push_back
typedef long long ll;
using namespace std;
const int maxn = 1e6+5;


int main()
{
    int a, b, c; cin >> a >> b >> c;
    if((a+b+c)%17==0) cout << "YES" << endl;
    else cout << "NO" << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>

using namespace std;
int main()
{
	int N,a,b,c,d,num;
	while(~scanf("%d",&N)){
		num=1;
		a=N/1000;
		b=(N-a*1000)/100;
		c=(N-a*1000-b*100)/10;
		d=N-a*1000-b*100-c*10;
		if(a==b&&a==c||b==c&&b==d||a==b&&b==c&&c==d){
			printf("Yes\n");
			num=0;
		}
		if(num==1)
			printf("No\n");
	}
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/math/common_factor.hpp>

#define rep_ui(k,n)      for(ui  i = (k); i < (n); ++i)
#define rep_si(k,n)      for(int i = (k); i < (n); ++i)
#define rep_ul(k,n)      for(ul  i = (k); i < (n); ++i)
#define rep_sl(k,n)      for(ll  i = (k); i < (n); ++i)
#define rep_ui_down(k,n) for(ui  i = (k); i > (n); --i)
#define rep_si_down(k,n) for(int i = (k); i > (n); --i)
#define rep_ul_down(k,n) for(ul  i = (k); i > (n); --i)
#define rep_sl_down(k,n) for(ll  i = (k); i > (n); --i)

#define rep_uj(k,n)      for(ui  j = (k); j < (n); ++j)
#define rep_sj(k,n)      for(int j = (k); j < (n); ++j)
#define rep_uj_down(k,n) for(ui  j = (k); j > (n); --j)
#define rep_sj_down(k,n) for(int j = (k); j > (n); --j)

#define rep(k,n)         rep_ui(k,n)

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

template<class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vc)
{
  boost::for_each(vc, [&os, &vc](T value) {
    os << value;
    if (value != vc.back())
      os << ' ';
    });
  return os;
}

template<class T1, class T2>
inline
std::ostream&
operator<<(std::ostream& os, const std::pair<T1, T2>& p)
{
  return os << p.first << ' ' << p.second;
}

void solve(void)
{
  //using std::string;
  //using std::vector;
  //using std::map;
  //using std::pair;
  //string S{}; std::cin >> S;
  //ui N{}; std::cin >> N;
  
  ui X{}, A{}; std::cin >> X >> A;

  ui ans = X < A ? 0 : 10;
  std::cout << ans << '\n';

  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <array>
#include <iomanip>
using namespace std;

typedef long long ll;
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#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 SORT(s) sort((s).begin(),(s).end())

int main(){
    int n; cin >> n;
    double ans = 0;
    REP(i,n){
        double x;
        string u;
        cin >> x >> u;
        if(u=="BTC"){
            x += x*38*10000;
        }
        ans += x;
    }
    cout << ans << endl;

}


Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;
const int MOD = 1e9+7;
using ll = long long;
using vi = vector<int>;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(x) x.begin(), x.end()
int main() {
  ll a;
  cin >> a;
  ll ans = 999;
  while(a>99){
    ans = min(ans,abs(753-a%1000));
    a /= 10;
  }
  cout << ans;
} 


Measured memory_bytes: 3552
#include<iostream>
#include<cmath>
using namespace std;
int resolve(double x1, double y1, double r1, double x2, double y2, double r2){
	double d=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
	if(d<abs(r1-r2)){
	    if(r1>r2)   return 2;
	    else    return -2;
	}
	else if(d>=abs(r1-r2) && d<=(r1+r2))    return 1;
	else    return 0;
}
int main(){
	int N;
	cin>>N;
	while(N--){
		double x1,y1,r1, x2, y2, r2;
		cin>>x1>>y1>>r1>>x2>>y2>>r2;
		cout<<resolve(x1, y1, r1, x2, y2, r2);
		cout<<endl;
	}
	return 0;
}


Measured memory_bytes: 3192
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
#include <list>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

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;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
//最小公倍数
int lcm(int x, int y) { return x / gcd(x, y) * y; }
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    int N; cin >> N;
    vector<int> c(4,0);
    for(int i=0;i<N;i++){
        string S;
        cin >> S;
        if(S=="AC") c[0]++;
        if(S=="WA") c[1]++;
        if(S=="TLE") c[2]++;
        if(S=="RE") c[3]++;
    }
    cout << "AC x " << c[0] << endl;
    cout << "WA x " << c[1] << endl;
    cout << "TLE x " << c[2] << endl;
    cout << "RE x " << c[3] << endl;
    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9 + 7;
const int inf = 1e8;

int main() {
	int H,W;
	cin >> H >> W;
	string S;
	rep(i,H){
		rep(j,W){
			cin>>S;
			if(S =="snuke")
				cout<<char('A'+j)<<i+1;
		}
	}
}

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

bool ip(string s) {
	for (int i = 0; i < s.size(); i++)
		if (s[i] != s[s.size() - i - 1]) return 0;
	return 1;
}

main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	string s;
	cin >> s;
	if (ip(s) && ip(s.substr(0, (s.size() - 1) / 2)) && ip(s.substr((s.size() + 3) / 2 - 1))) cout << "Yes\n";
	else cout << "No\n";
}


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

using namespace std;

int main(int argc, char const *argv[]) {
    int n;
    std::cin >> n;
    std::vector<int> a(n);
    for (int i = 0; i < n; i++) std::cin >> a[i];
    sort(a.begin(), a.end(), [](const int& l, const int& r){return l > r;});
    unsigned long long sum = 0;
    for (int i = 2; i <= n; i++)
        sum += a[(i-1) >> 1];
    std::cout << sum << '\n';
}


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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////

ll As;
ll i, j, k;
int main(){
    fornum(i,0,3){
        ll a;
        scanf("%lld", &a);
        As += a;
    }
    if(As>=22){
        printf("bust");
    }else{
        printf("win");
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;

int main() {
    int N, H;
    cin >> N >> H;
    int maximum = 0;
    vector<int> v(N);
    for(int i = 0; i < N; i++) {
        int a;
        cin >> a >> v[i];
        maximum = max(maximum, a);
    }
    sort(v.begin(), v.end(), greater<int>());
    int ans = 0;
    for(int i = 0; i < N; i++) {
        if(H <= 0 || maximum >= v[i]) break;
        H -= v[i];
        ans++;
    }
    if(H > 0) ans += (H + maximum - 1) / maximum;
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 640
from collections import deque
h, w = map(int, input().split())
ss = [input() for _ in range(h)]
q = deque([(0, 0, 0)])
cost = 0
visited = [[False for _ in range(w)] for _ in range(h)]


def find():
    while len(q) > 0:
        y, x, cost = q.popleft()
        if (y, x) == (h - 1, w - 1):
            return cost
        if 0 <= y < h and 0 <= x < w and ss[y][x] != '#' and not visited[y][x]:
            visited[y][x] = True
            q.append((y + 1, x, cost + 1))
            q.append((y - 1, x, cost + 1))
            q.append((y, x + 1, cost + 1))
            q.append((y, x - 1, cost + 1))
    return -1


c = find()
if c < 0:
    print(-1)
else:
    dots = 0
    for i in range(h):
        for j in range(w):
            if ss[i][j] != '#':
                dots += 1
    print(dots - c - 1)


Measured memory_bytes: 9420
#include <iostream>
#include <vector>
#include <numeric>
using namespace std;

const int MAX_COST = 200 * 200 * 100;

int calc_cost(int a, int b) {
  return (a - b) * (a - b);
}

int max(int array[], int size) {
  int max = array[0];
  for (int i = 0; i < size; i++) {
    max = array[i] > max ? array[i] : max;
  }
  return max;
}

int min(int array[], int size) {
  int min = array[0];
  for (int i = 0; i < size; i++) {
    min = array[i] < min ? array[i] : min;
  }
  return min;
}

int main() {
  int num;
  cin >> num;
  int nums[num];
  for (int i = 0; i < num; i++) {
    cin >> nums[i];
  }

  int min_num = min(nums, num);
  int max_num = max(nums, num);

  int min_cost = MAX_COST;
  for (int override_num = min_num; override_num < max_num; override_num++) {
    int cost = 0;
    for (int i = 0; i < num; i++) {
      if (nums[i] != override_num) {
        cost += calc_cost(nums[i], override_num);
      }
    }
    min_cost = min_cost < cost ? min_cost : cost;
  }

  if (min_cost == MAX_COST) {
    min_cost = 0;
  }
  cout << min_cost << endl;

  //int override_num = accumulate(nums, (int*) &nums[num - 1]);
  //cout << override_num << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>
#include <list>

using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define reps(x,c) for(auto x:c)
#define all(x) begin(x), end(x)
#define pb(a) emplace_back(a) 
#define mp(a,b) make_pair((a),(b))
#define pl pair<ll,ll>
#define INF 2147483600
#define MOD 1000000007
#define fi first
#define se second
#define dbg(x) cout << #x"="<< (x) << endl
#define dbgv(x) cout<<#x<<endl;reps(y,x){cout<<y<<" ";}cout<<endl


int main(){
  string s;cin>>s;
  ll t_x,t_y;cin>>t_x>>t_y;
  vector<ll> x,y;
  bool flg_xy=true;

  ll temp=0,index=0;
  s+="E";
  rep(i,s.size()){
    if(s[i]=='F'){
      t_x--;
    }else{
      index=i;
      break;
    }
  }
  FOR(i,index,s.size()){
    temp++;
    if(s[i]!=s[i+1]){
      if(s[i]=='F'){
        if(flg_xy){
          x.pb(temp);
        }else{
          y.pb(temp);
        }
      }else{
        if(temp%2){
          flg_xy=!flg_xy;
        }
      }
      temp=0;
    }
  }
  x.pb(0);
  y.pb(0);
  sort(all(x),greater<ll>());
  sort(all(y),greater<ll>());

  rep(i,x.size()){
    if(abs(t_x-x[i])>abs(t_x+x[i])){
      t_x+=x[i];
    }else{
      t_x-=x[i];
    }
  }

  rep(i,y.size()){
    if(abs(t_y-y[i])>abs(t_y+y[i])){
      t_y+=y[i];
    }else{
      t_y-=y[i];
    }
  }
  if(t_x==0&&t_y==0){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256