akhauriyash/Code-Regression huggingface dataset:
s = input().rstrip()
N = int(s)

ans = 0
i = 1
order = len(str(N))

params = {}

for i in range(1, N + 1):
    Akey = str(i)[-1] + str(i)[0] 
    if params.get(Akey) is not None:
        params[Akey] = params[Akey] + 1
    else:
        params[Akey] = 1

for i in range(1, N + 1):
    Bkey = str(i)[0] + str(i)[-1] 
    count = params.get(Bkey)
    if count is not None:
        ans =  ans + count;

print(ans)


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


int main() {
    int n;
    cin>>n;
    int a[n],b[n],c[n-1];
    rep(i,n)cin>>a[i];
    rep(i,n)cin>>b[i];
    rep(i,n-1)cin>>c[i];
    int ans=0;
    rep(i,n-1){
        ans+=b[a[i]-1];
        if(a[i]+1==a[i+1])ans+=c[a[i]-1];
    }
    cout << ans+b[a[n-1]-1] <<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    if (a >= 1 && a <= 9 && b >= 1 && b <= 9)
      System.out.println(a * b);
    else
      System.out.println(-1);
  }
}

Measured memory_bytes: 23124
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
using lint=int64_t;
using namespace std;

bool has(string s,string t)
{
	lint als[26]={};
	lint alt[26]={};

	for(int i=0;i<s.size();i++)
		als[s[i]-'a']++;
	for(int i=0;i<t.size();i++)
		alt[t[i]-'a']++;
	
	for(int i=0;i<26;i++)
	{
		if(alt[i]>0 && als[i]==0)
			return false;
	}
	return true;
}

int main()
{
	string s,t;

	cin >> s >> t;

	if(has(s,t)==false)
	{
		cout << -1 << endl;
		return 0;
	}

	map<char,vector<lint>> ms;
	map<char,vector<lint>> mt;

	for(lint i=0;i<s.size();i++)
		ms[s[i]].push_back(i);
	for(lint i=0;i<t.size();i++)
		mt[t[i]].push_back(i);
	
	lint place[100010]={};
	lint cur=-1;
	for(lint i=0;i<t.size();i++)
	{
		auto itr=lower_bound(ms[t[i]].begin(),ms[t[i]].end(),cur+1);
		if(itr==ms[t[i]].end())
			itr=ms[t[i]].begin();
		place[i]=*itr;
		cur=*itr;
	}

	lint ans=0;
	for(int i=0;i<t.size()-1;i++)
	{
		if(place[i]>=place[i+1])
			ans+=(lint)s.size();
	}
	ans+=place[t.size()-1]+1;
	cout << ans << endl;
/*
	for(int i=0;i<t.size();i++)
		cout << place[i] << " ";
	cout << endl;
*/
return 0;
}



Measured memory_bytes: 3444
#include <stdio.h>

int main() {

	int X,A,B;

	scanf("%d",&X);
	scanf("%d",&A);
	scanf("%d",&B);

	X-=A;

	while(1){
		if(X-B<0){break;}
		X-=B;
	}

	printf("%d\n",X);

	return 0;
}

Measured memory_bytes: 128
def splitsharp():
    print("#"*20)

num = int(input())
building = [[[0 for i in range(10)]for j in range(3)]for k in range(4)]
for i in range(num):
    infos = [int(e) for e in input().split()]
    building[infos[0]-1][infos[1]-1][infos[2]-1] = building[infos[0]-1][infos[1]-1][infos[2]-1] + infos[3]
for i in range(4):
    for j in range(3):
        floor =[]
        s = ""
        for k in range(10):
            floor.append(" ")
            floor.append(str(building[i][j][k]))
        s = "".join(floor)
        print(s)
    if(i==3):
        exit()
    splitsharp()


Measured memory_bytes: 5608
#include<iostream>
using namespace std;
int main(){
	//バックトラック法
	while(1){
		int n,s,i,j,a,b,c=0;;
		cin>>n>>s;
		if(n==0&&s==0)break;
		for(i=0;i<(1<<10);i++){//1<<10は2^10
			a=0;b=0;
			for(j=0;j<=9;j++){
				if((i>>j)&1!=0){//iの2^jの桁が1→ok
					a+=j;b++;//bはたし算の項の数
				}
			}
			if(a==s&&b==n){
				c++;
			}
		}
		cout<<c<<endl;
	}
    return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>

int main()
{
 int n,sn=0,t,r;
 scanf("%d",&t);
 n=t;
 while(t>0)
 {
 sn+=t%10;
 t=t/10;
 }

 if(n%sn==0)
 {
     printf("Yes");
 }
 else
 {
     printf("No");
 }
    return 0;
}

Measured memory_bytes: 128
x,y = map(int,input().split())
a=[1,3,5,7,8,10,12];b=[4,6,9,11];c=[2]
if x in a and y in a:
  print('Yes')
elif x in b and y in b:
  print('Yes')
elif x in c and y in c:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3060
#coding: utf-8

while True:
    a,b = (int(i) for i in input().split())
    if a == b == 0:
        break

    c = 0
    for i in range(1,a-1):
        for j in range(i+1, a):
            for k in range(j+1, a+1):
                if i + j + k == b:
                    c+=1
    print(c)


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

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
#define pii pair<int, int>
#define int int64_t
#define re(s) reverse((s).begin(), (s).end())
#define setout(n, x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10);
const long long mod = 1e9 + 7;

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

   int k, x;
   cin >> k >> x;

   k *= 500;

   if (k >= x)
   {
      cout << "Yes" << '\n';
   }
   else
   {
      cout << "No" << '\n';
   }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,s,n) for(int i = s; i < n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using Graph = vector<vector<int>>;
const int INF = 1000000007;
int main(){
  string s;
  cin >> s;
  int n = (int)s.size() - 1;
  ll ans = 0;
  rep(i,(1 << n)){
    ll tmp = 0;
    string t;
    t.push_back(s[0]);
    rep(j,n){
      if((1 << j) & i){
        tmp += stoll(t);
        t.clear();
      }
      t.push_back(s[j + 1]);
    }
    if(!t.empty())tmp += stoll(t);
    ans += tmp;
  } 
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3644
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

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



int main() {
    double d;
    
    scanf("%lf", &d);
    
    printf("%.11lf\n", max((double)((int)d + 1), d * sqrt(2.0)));
}


Measured memory_bytes: 3220
#include <iostream>
#include <vector>
#include <stack>
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <cmath>
#include <iomanip>

using namespace std;


int main() {
    int H, A;
    cin >> H >> A;

    int answer = H/A;
    if(H%A!=0)
        answer++;
    cout << answer <<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MAX 1007
#define INF 100000007

using namespace std;

typedef pair<int,int> di;
typedef pair<int, di> pii;
int n;
void dfs(string ans, int mx){
    if(ans.size() == n) cout << ans << endl;
    else{
        for(int i = 'a'; i <= mx; i++){
            dfs(ans+(char)i, (i==mx)? mx+1: mx);
        }
    }
}
int main(){
    cin >> n;
    dfs("", 'a');
    return 0;
}


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

#define ipair pair<int,int>
#define rep(i,n) for(i=0;i<n;i++)
#define repj(i,j,n) for(i=j;i<n;i++)

#define PB(a,i) (a).push_back(i)
#define ALL(a) (a).begin(),(a).end()
#define SIZE(a,n) (a).resize(n)

#define OK(i) cout<<"OK "<<i<<endl
#define Yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define NO cout<<"NO"<<endl

using namespace std;

typedef long long int lli;
typedef long long ll;
typedef vector<int> vi;
typedef vector< vector<int> > Matrix;



int main() {
	int n, d, ans, i, j, k, y, z;
	Matrix x;

	cin >> n >> d;
	SIZE(x, n);
	rep(i, n) {
		SIZE(x[i], d);
		rep(j, d) {
			cin >> x[i][j];
		}
	}
	ans = 0;
	rep(i, n) {
		repj(j,i+1, n) {
			y = 0;
			rep(k, d) {
				y += abs(x[i][k] - x[j][k])*abs(x[i][k] - x[j][k]);
			}
			z = sqrt(y);
			if (z*z == y)ans++;
		}
	}

	cout << ans;

	return 0;
}


Measured memory_bytes: 256
import std.algorithm, std.conv, std.range, std.stdio, std.string;

void readV(T...)(ref T t){auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(typeof(v));r.popFront;}}
void readA(T)(size_t n,ref T t){t=new T(n);auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(ElementType!T);r.popFront;}}
void readM(T...)(size_t n,ref T t){foreach(ref v;t)v=new typeof(v)(n);foreach(i;0..n){auto r=readln.splitter;foreach(ref v;t){v[i]=r.front.to!(ElementType!(typeof(v)));r.popFront;}}}
void readS(T)(size_t n,ref T t){t=new T(n);foreach(ref v;t){auto r=readln.splitter;foreach(ref j;v.tupleof){j=r.front.to!(typeof(j));r.popFront;}}}

void main()
{
  auto c = new int[][](3, 3); foreach (i; 0..3) readA(3, c[i]);
  writeln(c[1][1] == c[1][0]-c[0][0]+c[0][1] &&
          c[1][2] == c[1][0]-c[0][0]+c[0][2] &&
          c[2][1] == c[2][0]-c[0][0]+c[0][1] &&
          c[2][2] == c[2][0]-c[0][0]+c[0][2] ? "Yes" : "No");
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int a,b,c,d,e,f,g,cnt=0;
    scanf("%d",&a);
    b=a/1000;
    c=a%100;
    d=c/10;
    e=a%1000;
    f=e/100;
    g=c%10;

    if(b==2){
        cnt++;
    }
    if(d==2){
        cnt++;
    }
    if(f==2){
        cnt++;
    }
    if(g==2){
        cnt++;
    }
    printf("%d\n",cnt);
    return 0;
}

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

int main(){
  vector<char> a(10);
  cin >> a.at(0);
  cin >> a.at(1);
  cin >> a.at(2);
  cin >> a.at(3);
  cin >> a.at(4);
  cin >> a.at(5);
  cin >> a.at(6);
  cin >> a.at(7);
  cin >> a.at(8);
  cin >> a.at(9);
  
  vector<int> A(10);
  A.at(0) = a.at(0)- '0';
  A.at(1) = a.at(1)- '0';
  A.at(2) = a.at(2)- '0';
  A.at(3) = a.at(3)- '0';
  A.at(4) = a.at(5)- '0';
  A.at(5) = a.at(6)- '0';
  A.at(6) = a.at(8)- '0';
  A.at(7) = a.at(9)- '0';
  
  int C,D;
  C = A.at(0)*1000+A.at(1)*100+A.at(2)*10+A.at(3);
  D = A.at(4)*10+A.at(5);
  if(C<2019){
    cout << "Heisei";
  }else if(C == 2019 &&  D<= 4){
    cout << "Heisei" << endl;
  }else{
    cout << "TBD" << endl;
  }
  return 0;
}

      

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;using ll=long long;using uint=unsigned int;using pii=pair<int,int>;using pll=pair<ll,ll>;using ull = unsigned long long;using ld=long double;template<typename T>void _(const char*s,T h){cerr<<s<<" = "<<h<<"\n";}template<typename T,typename...Ts>void _(const char*s,T h,Ts...t){int b=0;while(((b+=*s=='(')-=*s==')')!=0||*s!=',')cerr<<*s++;cerr<<" = "<<h<<",";_(s+1,t...);}// break continue pop_back 998244353
#define int ll
#define pii pll
#define f first
#define s second
#define pb emplace_back
#define forn(i,n) for(int i=0;i<(n);++i)
#define sz(a)((int)(a).size())
#define sqr(x) ((x)*(x))
struct init{init(){cin.tie(0);iostream::sync_with_stdio(0);cout<<fixed<<setprecision(10);cerr<<fixed<<setprecision(5);}~init(){
#ifdef LOCAL
#define dbg(...) _(#__VA_ARGS__,__VA_ARGS__)
cerr<<"Time elapsed: "<<(double)clock()/CLOCKS_PER_SEC<<"s.\n";
#else
#define dbg(...) 
#endif
}}init;template<typename T,typename U>void upx(T&x,U y){if(x<y)x=y;}template<typename T,typename U>void upn(T&x,U y){if(x>y)x=y;}mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());const int D=4,dx[]={+1,0,-1,0},dy[]={0,+1,0,-1};
const int N=1e5+5;
vector<int> g[N];
int a[N];
void no(){
    cout<<"NO\n";
    exit(0);    
}
void dfs(int v,int p=0){
    int sum=0,big=0,lf=1;
    for(int to:g[v]){
        if(to^p){
            dfs(to,v);
            lf=0;
            sum+=a[to];
            upx(big,a[to]);
        }
    }
    if(!lf){
        int f=max(0ll,big-sum/2);
        if(f>a[v])no();
        int x=(a[v]-f)*2-(sum-f);
        a[v]=x+f;
        if(x<0||a[v]<0||a[v]>sum)no();
    }
}
int32_t main(){
    int n;
    cin>>n;
    for(int i=1;i<=n;++i)cin>>a[i];
    forn(i,n-1){
        int x,y;
        cin>>x>>y;
        g[x].pb(y);
        g[y].pb(x);
    }
    int s=-1;
    for(int i=1;i<=n;++i)if(sz(g[i])>1)s=i;
    if(s==-1){
        if(a[1]==a[2])cout<<"YES\n";
        else cout<<"NO\n";
    }else{
        dbg(s);
        dfs(s);
        if(a[s])cout<<"NO\n";
        else cout<<"YES\n";
    }
    return 0;
}

Measured memory_bytes: 16904
#include <stdio.h>
#include <cmath>
#include <stdlib.h>
#include <algorithm>
#include <functional>
#include <array>
#include <vector>

int main()
{
    long long int k,a,b;
    scanf("%lld",&k);
    scanf("%lld",&a);
    scanf("%lld",&b);
    
    long long int bis = 1;
    bool isNotTap = (b - a > 2);
    for(int i = 0;i < k;i++)
    {
        if(bis >= a && isNotTap && i + 1 < k)
        {
            bis += (b - a);
            i++;
            continue;
        }
        bis++;
    }
    printf("%lld", bis);
    
    return 0;
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define vv vector
#define pp pair
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define fastio                    \
	ios_base::sync_with_stdio(0); \
	cin.tie(0);
typedef pair<ll, ll> pll;
typedef vv<ll> vll;
typedef vv<pll> vpll;
#define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
//adds two more functions to set
//(1)*(set.find_by_order(k))[kth element in the sorted set]
//(2)set.order_of_key(k)[count of elements strictly less than k]
#define LG(args...)                               \
	{                                             \
		string _s = #args;                        \
		replace(_s.begin(), _s.end(), ',', ' ');  \
		stringstream _ss(_s);                     \
		err(istream_iterator<string>(_ss), args); \
		cerr << endl;                             \
	}
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << "(" << *it << ":" << a << ") ";
	err(++it, args...);
}
//:::::::::::::::::::::::::::::::::::::::::::::
const ll INF = 9e18;
const ll MOD = 1e9 + 7;
// #define dbg

int main(){
	fastio;
	ll n,k;
	cin>>n>>k;
	vll v(n);
	for(auto& i: v){
		cin>>i;
	}
	sort(all(v));
	ll a=0;
	for(ll i=0; i<k; i++){
		a+=v[i];
	}
	cout<<a;
}

Measured memory_bytes: 3624
module simple;import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, std.bitmanip, core.stdc.string;

immutable long MOD = 998244353;

void main() {
    auto N = readln.chomp.to!int;
    auto A = readln.split.map!(to!int).array;
    auto B = readln.split.map!(to!int).array;

    auto C = A.dup.sort().array;
    auto D = B.dup.sort().array;
    if (N.iota.map!(i => C[i] > D[i]).any) {
        writeln("No");
        return;
    }

    auto X = N.iota.map!(i => tuple(i, A[i])).array;
    auto Y = N.iota.map!(i => tuple(i, B[i])).array;
    X.sort!"a[1] < b[1]";
    Y.sort!"a[1] < b[1]";
    auto next = new int[](N);
    auto uf = new UnionFind(N);

    foreach (i; 0..N-1) {
        if (X[i][1] <= Y[i+1][1] && X[i+1][1] <= Y[i][1]) {
            writeln("Yes");
            return;
        }
    }

    foreach (i; 0..N) {
        uf.unite(X[i][0], Y[i][0]);
    }

    if (uf.table.map!(a => a < 0).sum > 1) {
        writeln("Yes");
    } else {

        writeln("No");
    }
}

class UnionFind {
    import std.algorithm : swap;

    int n;
    int[] table;

    this(int n) {
        this.n = n;
        table = new int[](n);
        table[] = -1;
    }

    int find(int x) {
        return table[x] < 0 ? x : (table[x] = find(table[x]));
    }

    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return;
        if (table[x] > table[y]) swap(x, y);
        table[x] += table[y];
        table[y] = x;
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }
}

Measured memory_bytes: 12304
#include <iostream>

using namespace std;

int main()
{
	for (;;)
	{
		int x, y;
		cin >> x >> y;
		if (x == 0 && y == 0)
		{
			break;
		}
		else if (x > y)
		{
			swap(x, y);
		}

		cout << x << " " << y << endl;
	}
}


Measured memory_bytes: 3080
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;


public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt();
		Set<String> s = new HashSet<String>();
		int cnt = 0;
		s.add(""+a+b+c);
		boolean f = false;
		
		while(true) {
			if(a % 2== 1 || b % 2== 1||c % 2== 1)	break;
			int aa = (b+c)/2, bb = (a+c)/2, cc = (a+b)/2;
			a = aa; b = bb; c = cc;
			if(s.contains(""+a+b+c)) {
				f = true;
				break;
			}
			cnt ++;
		}
		
		if(f)
			System.out.println(-1);
		else
			System.out.println(cnt);
		
	}
}


Measured memory_bytes: 20820
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

// 084c

int main(){
    int n;
    cin >> n;
    int c[505], s[505], f[505];
    rep(i, n-1) cin >> c[i] >> s[i] >> f[i];

    int tmp = 0;
    rep(i, n-1){
        tmp = 0;
        for(int j=i; j<n-1; j++){
            if (j==i){
                tmp = s[j]+c[j];
                continue;
            }
            if (tmp <= s[j]){
                tmp = s[j] + c[j];
            }else{
                int k = (tmp-s[j]+f[j]-1)/f[j];
                tmp = s[j] + f[j]*k + c[j];
            }
        }
        cout << tmp << endl;
    }
    cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>

int main()
{
  int k, s;
  std::cin >> k >> s;
  int count = 0;
  for (int x = 0; x <= k; ++x)
  {
    for (int y = 0; y <= k; ++y)
    {
      int z = s - x - y;
      if (0 <= z && z <= k)
      {
        ++count;
      }
    }
  }
  std::cout << count << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
typedef pair<int,int> P;
typedef long long ll;
const int INF = 1001001001;
const ll INFL = 1e17;
const int MOD = 1e9+7;


int main(){
    int n,k;
    cin >> n >> k;
    vector<int> p(n);
    rep(i,n) cin >> p[i];
    int now = 0;
    for(int i=0; i<k; i++) now += p[i];
    int ans = now;
    for(int i=k; i<n; i++){
        now = now-p[i-k]+p[i];
        ans = max(ans,now);
    }
    double output = ans;
    output = output/2.0 + 1.0/2.0*k;
    printf("%.12lf\n",output);
    return 0;
}

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

using namespace std;

#define vi vector<int>
#define vvi vector<vi>
#define rpt(i,x) for (int i = 0; i < x; i++)
#define fti(i,f,t) for (int i = f; i <= t; i++)
#define fte(i,f,t) for (int i = f; i < t; i++)
#define rptws(i,x,s) for (int i = 0; i < x; i += s)
#define llrpt(i,x) for (long long i = 0; i < x; i++)
#define llfti(i,f,t) for (long long i = f; i <= t; i++)
#define llfte(i,f,t) for (long long i = f; i < t; i++)


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

	fti(i, 1, n) {
		int ans = 0;
		llfti(x, 1, i) {
			llfti(y, 1, i) {
				long long b = x + y;
				long long c = i - (x*x) - (y*y) - (x*y);

				//cout<<i<<": "<<b<<" "<<c<<"\n";

				if (c > 0) {
					double ans1 = ((-1.0 * b) + (double)sqrt(b*b + 4.0 * c)) / 2.0;
					double ans2 = ((-1.0 * b) - (double)sqrt(b*b + 4.0 * c)) / 2.0;

					if (ans1 == (int)ans1 && ans1 >= 1.0 && ans1 == ans2) {
						//cout<<"from 1"<<"\n";
						ans++;
					}
					else if (ans1 == (int)ans1 && ans1 >= 1.0) {
						//cout<<"from 2: "<<ans1<<"\n";
						ans++;
					} 
					else if (ans2 == (int)ans2 && ans2 >= 1.0) {
						//cout<<"from 3: "<<ans2<<"\n";
						ans++;
					} 

				}
				else break;
				
			}
		} 
		cout<<ans<<"\n";
	}
}



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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

vector<ll> fib;

vector<vector<ll>> dfs(ll n){
  if(n==1){
    return vector<vector<ll>>(1,vector<ll>(1,0));
  }
  vector<vector<ll>> pre=dfs(n-1);
  vector<vector<ll>> res(n,vector<ll>(n,0));
  vector<ll> vs;
  rep(i,n-1)rep(j,n-1)res[i][j]=pre[i][j];
  rep(i,n-1)vs.push_back(i);
  ll mx=-1;
  do{
    ll sum=0;
    rep(i,n-2){
      sum+=res[vs[i]][vs[i+1]];
    }
    maxch(mx,sum);
  }while(next_permutation(all(vs)));
  mx++;

  rep(i,n-1){
    res[i][n-1]=res[n-1][i]=fib[i]*mx;
  }
  return res;
}

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

  fib.resize(10);
  fib[0]=1; fib[1]=2;
  repl(i,2,10){
    ll mn=-1;
    repl(j,fib[i-1]+1,10000){
      map<ll,bool> used;
      bool ok=true;
      rep(k,i){
        used[fib[k]]=true;
        rep(l,k)used[fib[k]+fib[l]]=true;
      }
      if(used[j])ok=false;
      used[j]=true;
      rep(k,i){
        if(used[fib[k]+j])ok=false;
        used[fib[k]+j]=true;
      }
      if(ok){
        mn=j; break;
      }
    }
    fib[i]=mn;
  }

  ll N;
  cin>>N;
  vector<vector<ll>> res=dfs(N);

  rep(i,N){
    rep(j,N){
      cout<<res[i][j]<<" ";
    }
    cout<<endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define i_7 (ll)(1E9+7)
#define i_5 (ll)(1E9+5)
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
long double EPS=1E-8;
////////////////////////////////////////
#define N 5004

ll kai[N];
ll kai2[N];
ll po(ll i,ll p){
    if(p==0)return 1;
    else if(p==1)return mod(i);
    else if(p%2==0)return po(mod(mod(i)*mod(i)),p/2);
    else  return mod(mod(i)*po(i,p-1));
}
void calc(){
    kai[0]=1;
    kai2[0]=1;
    rep(i,1,N-1){
        kai[i]=mod(kai[i-1]*i);
    }
    kai2[N-1]=po(kai[N-1],i_5);
    for(int i=N-2;i>=0;i--){
        kai2[i]=mod(kai2[i+1]*(i+1));
    }
}
ll comb(ll n,ll k){
    if(n<k)return 0;
    else if(n==0)return 1;
    else return mod(mod(kai[n]*kai2[n-k])*kai2[k]);
}
ll bunbo(ll n){
    return po(n,i_5);
}
int main(){
    calc();
    ll n,k;cin>>n>>k;
    ll ans=0;
    for(ll i=k;i>=1;i--){
        ll sum=mod(comb(k,i)*po(i,n));
        if((k-i)%2==0)ans+=sum;
        else ans-=sum;
        //cout<<sum<<endl;
        ans=mod(ans);
    }
    cout<<ans<<endl;
    
    return 0;
}



Measured memory_bytes: 3184
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    ll N;
    cin >> N;
    // 商がA、余りもA
    // → N = A*m + Aの形(A<m)
    ll ans = 0;
    for(ll i=1;i*i<=N;i++){
        if((N-i)/i > i && (N-i)%i == 0){
            ans += (N-i)/i; 
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main(int argc, char* argv[])
{
	int N,i,j,k;
	cin>>N;
	vector<int> W(N);
	int MinV=0;
	for (i=0;i<N;i++){
		cin>>W[i];
		MinV+=W[i];
	}

	for (i=0;i<N-1;i++){
		for (j=i+1;j<N;j++){
			int v1=0;
			for (k=0;k<=j;k++){
				v1+=W[k];
			}
			int v2=0;
			for (k=j+1;k<N;k++){
				v2+=W[k];
			}
			int v=v1-v2;
			if (v<0){
				v=-v;
			}
			if (MinV>v){
				MinV=v;
			}
		}
	}
	cout<<MinV<<endl;

	return 0;
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
char c;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>c;
    if(islower(c))
        cout<<'a';
    else
        cout<<'A';
    return 0;
}


Measured memory_bytes: 3648
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)

struct INIT{
    INIT(){
        std::ios::sync_with_stdio(false);
        std::cin.tie(0);
        cout << fixed << setprecision(13);
    }
}INIT;

int n;
string s;
bool dp[3][1010];

int main(){
    cin >> n;
    cin >> s;
    REP(i, n){
        int d = s[i] - '0';
        for(int j = 99;j >= 0;j--){
            dp[2][j * 10 + d] |= dp[1][j];
        }
        for(int j = 9;j >= 0;j--){
            dp[1][j * 10 + d] |= dp[0][j];
        }
        dp[0][d] = true;
    }
    int cnt = 0;
    REP(i, 1010)cnt += dp[2][i];
    cout << cnt << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 100000000;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() {
    ll n, a;
    cin >> n;
    map<ll, ll> num;
    rep1(i, n){
        cin >> a;
        num[a]++;
    }
    ll ans = 0;
    for (auto i: num){
        if (i.first > i.second) ans += i.second;
        else ans += i.second - i.first;
    }
    cout << ans << endl;
    //printf("%.12f", ans);
}

Measured memory_bytes: 9616
#include<bits/stdc++.h>
using namespace std;
int main(){
  int w,a,b,c=0;
  cin>>w>>a>>b;
  if(a>b && a-b-w>=0){
    c=a-b;
    cout<<c-w<<'\n';
  }
  else if(b>a && b-a-w>=0){
    c=b-a;
    cout<<c-w<<'\n';
  }
  if(a-b-w<0 && a>b){
    cout<<0<<'\n';
  }
  if(b-a-w<0 && b>a){
    cout<<0<<'\n';
  }
  if(a==b){
    cout<<0<<'\n';
  }
  return 0;
}
  
  
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = ll(1e9)+1;
const ll mod = ll(1e9)+7;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()

ll gcd(ll a,ll b){
    if(a < b)swap(a, b);
    if(b == 0) return a;
    return gcd(b,a%b);
}

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

ll factorial(ll n){
    ll t = 1;
    rep1(i, n){
        t *= i;
        t %= mod;
    }
    return t;
}

ll powerof(ll a, ll b){
    a %= mod;
    if(b == 0){
        return 1;
    }
    ll ans = powerof(a, b / 2);
    ans = ans * ans % mod;
    if(b % 2 == 1){
        ans = ans * a % mod;
    }
    return ans;
}

ll combination(ll a, ll b){
    if((a == b) || (b == 0)){
        return 1;
    }
    if(a < b) return 0;
    ll ret = 1;
    for(ll i = 0; i < b; i++) {
        ret *= (a - i);
        ret %= mod;
        ret *= powerof(i + 1, mod - 2);
        ret %= mod;
    }
    return ret;
}

int main(){
    ll n,a,b,ans = 1;
    cin >> n >> a >> b;
    ans = powerof(2, n);
    --ans;
    ans -= combination(n, a);
    ans -= combination(n, b);
    pf((ans + mod * 2) % mod);
    return 0;
}


Measured memory_bytes: 256
S = list(input())

def f(s):
    n = len(s)//2
    for i in range(n):
        if s[i] != s[-i - 1]:
            return False
    return True

N = len(S)

if f(S[:(N - 1) // 2]) and f(S[(N + 3) // 2 - 1:]) and f(S):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String[] s = scanner.nextLine().split(" ");
        int n = Integer.parseInt(s[0]);
        int a = Integer.parseInt(s[1]);
        int b = Integer.parseInt(s[2]);

        int sum = 0;
        for (int i = 1; i <= n; i++) {
            int p = i % 10;
            for (int j = i / 10; j > 0; j /= 10) {
                p += j % 10;
            }
            if (a <= p && p <= b) {
                sum += i;
            }
        }

        System.out.println(sum);
        scanner.close();
    }
}


Measured memory_bytes: 26972
import sys
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    A, B = map(int, readline().split())
    if A+B>=10:
        print('error')
    else:
        print(A+B)

if __name__ == '__main__':
    main()

Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    double r = scan.nextDouble();

    System.out.println(String.format("%.6f", Math.PI * r * r) + " " + String.format("%.6f", 2 * Math.PI * r));

  }
}


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

int main()
{
	int n, m;
	cin >> n >> m;
	string s;
	cin >> s;

	vector<int> dp(n + 1, 1000000);
	dp[n] = 0;
	for (int i = n - 1; 0 <= i; --i) {
		if (s[i] == '1') {
			continue;
		}

		int next = i + m;
		if (n < next) {
			next = n;
		}
		while (next != i)
		{
			if (dp[next] != 1000000) {
				dp[i] = dp[next] + 1;
				break;
			}
			--next;
		}
		if (dp[i] == 1000000) {
			cout << -1 << endl;
			return 0;
		}
	}

	int count = 0;
	int prev = dp[0];
	for (auto& i : dp) {
		if (i == 1000000) {
			++count;
			continue;
		}
		if (prev != i) {
			cout << count << " ";
			count = 0;
		}
		prev = i;
		++count;
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

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

    string S;
    cin >> S;
    vector<int> V(S.size() + 1, 0);
    int ans = 0;
    for (int i = 0; i < S.size(); ++i) {
        if (S.at(i) == 'A' || S.at(i) == 'C' || S.at(i) == 'G' || S.at(i) == 'T') {
            V.at(i + 1) = V.at(i) + 1;
            ans = max(ans, V.at(i + 1));
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
using System;
using System.IO;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using Debug = System.Diagnostics.Debug;
using System.Runtime.CompilerServices;
using static System.Math;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;

static class P
{
    static void Main()
    {
        var nk = Console.ReadLine().Split().Select(int.Parse).ToArray();
        Console.WriteLine(nk[0] - nk[1]+ 1);
    }
}


Measured memory_bytes: 13396
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.TreeSet;

import javax.swing.*;


import static java.util.Arrays.binarySearch;
import static java.util.Arrays.copyOfRange;

public class Main {

    public static void main(String[] args) throws Exception {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;

        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);

        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }
}

class Task {

    private static int mod = 998244353;


    public void solve(int testNumber, InputReader in, PrintWriter out) {
        int n = in.nextInt();
        int s = in.nextInt();
        int[] a = new int[n + 1];
        for (int i = 1; i <= n; i++) {
            a[i] = in.nextInt();
        }
        long[][] dp = new long[n + 1][s + 1];
        long ans = 0;
        for (int i = 1; i <= n; i++) {
            for (int j = s; j > 0; j--) {
                if (j >= a[i]) {
                    dp[i][j] = (dp[i][j] + dp[i - 1][j - a[i]]) % mod;
                    if (j == a[i]) {
                        dp[i][j] = (dp[i][j] + i) % mod;
                    }
                    if (j == s) {
                        ans = (ans + dp[i][j] * (n - i + 1) % mod) % mod;
                    }
                    //out.println(ans + " " + i + " " + j);
                }
                dp[i][j] = (dp[i][j] + dp[i - 1][j]) % mod;
            }
        }
        out.println(ans);
    }

}



class InputReader {

    private final BufferedReader reader;
    private StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream));
        tokenizer = null;
    }

    public String nextLine() {
        try {
            return reader.readLine();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(nextLine());
        }
        return tokenizer.nextToken();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }

}


Measured memory_bytes: 126036
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }



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

  ll q, h, s, d, n;
  cin >> q >> h >> s >> d >> n;

  ll ans = 0;
  ll res = min({q * 4, h * 2, s});
  if (n & 1) {
    ans += res;
    n--;
  }
  res = min(res * 2, d);
  ans += n / 2 * res;
  cout << ans << '\n';




  
  return 0;
}

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

int main() {
	int N, Q;
	cin >> N >> Q;
	if (N == 1) {
		for (int i = 0; i < Q; i++) {
			int V, W;
			cin >> V >> W;
			cout << min(V, W) << endl;
		}
	}
	else {
		for (int i = 0; i < Q; i++) {
			int V, W;
			cin >> V >> W;
			while (V != W) {
				if (V > W) V = (V + N - 2) / N;
				else W = (W + N - 2) / N;
			}
			cout << V << endl;
		}
	}
}

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

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const int MOD = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;

int main()
{
	#ifndef ONLINE_JUDGE
	freopen(".in.txt", "r", stdin);
	freopen(".out.txt", "w", stdout);
	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll x; cin >> x;
	for(ll i = -5e3; i <= 5e3; i++)
	{
		ll b5 = pow(i, 5);
		ll a = pow(x + b5, 0.2);
		if((ll) pow(a, 5) == x + b5)
		{
			cout << a << ' ' << i;
			return 0;
		}
	}

	return 0;
}

Measured memory_bytes: 4228
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {1,-1,0,0,1,-1,1,-1};
ll dx[8] = {0,0,1,-1,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    rep(i,a.size()) cout << a[i] << " ";
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

vl color(777,-1);
ll n,m;

P dfs(ll u, ll c, vvl &G){
    color[u] = c;
    P res = {1,0};
    rep(v,n){
        if(G[u][v]){
            if(color[v] == c) return P(-1,-1);
            if(color[v] == -1){
                P tmp = dfs(v,1-c,G);
                if(tmp == P(-1,-1)) return tmp;
                else{
                    res.first += tmp.second;
                    res.second += tmp.first;
                }
            }
        }
    }
    return res;
}

int main(){
    cin >> n >> m;
    vvl G(n,vl(n,1));
    rep(i,m){
        ll a,b; cin >> a >> b; a--; b--;
        G[a][b] = 0;
        G[b][a] = 0;
    }
    rep(i,n) G[i][i] = 0;
    vpl siz;
    rep(i,n){
        if(color[i] == -1){
            P t = dfs(i,0,G);
            if(t == P(-1,-1)){
                puts("-1");
                return 0;
            }
            siz.emplace_back(t);
        }
    }
    vvl dp(siz.size()+1,vl(n+1,0));
    dp[0][0] = 1;
    rep(i,siz.size()){
        rep(j,n+1){
            if(!dp[i][j]) continue;
            dp[i+1][j+siz[i].first] = dp[i][j];
            dp[i+1][j+siz[i].second] = dp[i][j];
        }
    }
    ll ans = linf;
    rep(i,n+1){
        if(dp[siz.size()][i]){
            chmin(ans, i*(i-1)/2 + (n-i)*(n-i-1)/2);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 7936
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
      	if (a>9||b>9)
        {
			System.out.println("-1");
        }
      	else
        {
        	System.out.println(a*b);
        }
	}
}

Measured memory_bytes: 22868
import java.util.*;

public class Main{
  
  public static void main(String[] args){
    
  Scanner scanner = new Scanner (System.in);
  
  	int city = scanner.nextInt();
  	int road = scanner.nextInt();
    Integer[] list = new Integer[city];
    
    for (int indexCity=0; indexCity<city; indexCity++){
       list[indexCity]=0;
    }
    
  	for (int indexRoad=0; indexRoad<road; indexRoad++){
  	
    int city1=scanner.nextInt();
  	int city2=scanner.nextInt();
      
    int temp = list[city1-1];
    list[city1-1]=temp+1;
  	
    temp = list[city2-1];
    list[city2-1]=temp+1;
  	}
    
    for(int indexCity=0; indexCity<city; indexCity++){
      System.out.println(list[indexCity]);
    }
  }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define deb(x) cout<<#x<<" " <<x<<"\n";
#define pi 3.1415926535897932384626433832795
#define mod 1000000007
#define all(x) x.begin(), x.end()
#define cr7 ios_base::sync_with_stdio(false);cin.tie(NULL);
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (((a)*(b))/gcd((a),(b)))
int main()
{
    cr7
#ifndef ONLINE_JUDGE
    freopen("input1.txt", "r", stdin);
    freopen("output1.txt", "w", stdout);
#endif
    ll k, a, b;
    cin >> k >> a >> b;
    ll diff = b / k;
    if (diff * k >= a && diff * k <= b) {
        cout << "OK\n";
    } else {
        cout << "NG\n";
    }
    return 0;
}

Measured memory_bytes: 3652
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
#define all(v) v.begin(), v.end()
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    int N,T;
    cin>>N>>T;
    vi c(N);
    vi t(N);
    rep(i,N) {
        cin>>c[i]>>t[i];
    }
    vi a;
    rep(i,N) {
        if(t[i]<=T) {
            a.pb(c[i]);
        }
    }
    if(a.size()==0) cout<<"TLE"<<endl;
    else {
        sort(all(a));
        cout<<a[0]<<endl;
    }
}

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

int main() {
  int n,k;
  cin>>n>>k;
  string s;
  cin>>s;
  int a=s.size();
  int ans=0;
  for (int i=0;i<(a-1);++i) {
    char w=s.at(i);
    char e=s.at(i+1);
    if (w!=e) {
      ans+=1;
    }
  }
  int p=ans-(2*k);
  int o;
  if (p>0) {
    o=n-1-p;
  } else {
    o=n-1;
  }
  cout<<o<<endl;
}



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

#define LL long long
LL n,ans=0,a[100100],p,l,idx;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    sort(a+1,a+n+1);
    for(int i=n;i>=1;i--){
        if(a[i]==a[i-1]){
            p=a[i];
            idx=i;
            break;
        }
    }
    for(int i=idx-2;i>=1;i--){
        if(a[i]==a[i-1]){
            l=a[i];
            break;
        }
    }
    cout<<p*l<<endl;
}


Measured memory_bytes: 4400
def gcd(a,b):
    if b==0:
        return a
    return gcd(b,a%b)

def getlcm(a,b):
    return (a*b)/gcd(a,b)
    
n=int(raw_input(''))
x=int(raw_input(''))
lcm=x

for i in range(1,n,1):
    x=int(raw_input(''))
    lcm=getlcm(lcm,x)
print lcm

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


int main() {
    int D, G;
    cin >> D >> G;
    vector<int> p(D), c(D);
    rep(i, D) cin >> p[i] >> c[i];

    int ans = 100000;
    for (int bit = 0; bit < (1 << D); bit++) {
        int score = 0, cnt = 0;
        // 基本スコア＋コンプリートボーナス
        rep(i, D) {
            if (bit & (1 << i)) {
                score += 100 * (i + 1) * p[i] + c[i];
                cnt += p[i];
            }
        }
        if (score >= G) {
            ans = min(ans, cnt);
            continue;
        }

        // 残りの基本スコアを高い方から順に取得
        for (int i = D - 1; 0 <= i; i--) {
            if (bit & (1 << i)) continue;
            int base = 100 * (i + 1);
            if (score + base * p[i] + c[i] >= G) {
                rep(_, p[i]) {
                    score += base;
                    cnt++;
                    if (score >= G) break;
                }
                break;
            } else {
                score += base * p[i] + c[i];
                cnt += p[i];
            }
        }
        ans = min(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main(void){
    double n , m , a[105] , vote=0;
    int ans=0;
    cin>>n>>m;
    for(int i=0;i<n;i++){
        cin>>a[i];
        vote+=a[i];
    }
    
    for(int i=0;i<n;i++){
        if(a[i] >= vote/(4*m)){
            ans++;
        }
    }
    
    if(ans < m){
        cout<<"No\n";
    } else {
        cout<<"Yes\n";
    }
}


Measured memory_bytes: 256
#include<iostream>
#include <cmath>
using namespace std;
int main()
{
long long int c,a,b,i;
cin>>a>>b;

for(i=0;i<1000000000;i++){
    if((abs(a-i))==(abs(b-i))){
        c++;
        break;
    }
    else{
        c=0;
    }
}
if(c==1){
    cout<<""<<i<<endl;
}
else{cout<<"IMPOSSIBLE"<<endl;}



}


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

#define Fast ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO freopen("in.txt", "r", stdin)
#define FC freopen("out.txt", "w", stdout)
#define aise cout<<"aise"<<endl
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mp make_pair
#define ll long long
#define all(x) x.begin(), x.end()
#define mset(v, a) memset(v, a, sizeof(v))
#define pll pair< ll, ll >
#define pdd pair< double, double >
#define ff first
#define ss second
#define pi acos(-1.0)
#define mxN 2010
#define inf 1e14
#define MOD 1000000007

ll ch(ll x)
{

    ll s = 0;
    while(1)
    {

        if(x%2) break;
        x/=2;
        s++;
    }
    return s;
}

int main()
{

    ll n, ans=inf;
    cin >> n;
    while(n--)
    {

        ll x;
        cin >> x;
        ans = min(ans, ch(x));
    }
    cout << ans;
}


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

class Pos{
public:
  int x, y, z;
  Pos(int a, int b, int c) : x(a), y(b), z(c){}
};

bool operator<(const Pos& l, const Pos& r) { return l.x < r.x; }

int main(){
  int x, y, z, k; cin >> x >> y >> z >> k;
  vector<long long> A(x), B(y), C(z);

  for(int i=0; i<A.size(); ++i) cin >> A[i];
  for(int i=0; i<B.size(); ++i) cin >> B[i];
  for(int i=0; i<C.size(); ++i) cin >> C[i];

  sort(A.begin(), A.end(), greater<long long>());
  sort(B.begin(), B.end(), greater<long long>());
  sort(C.begin(), C.end(), greater<long long>());

  priority_queue<pair<long long, Pos>> pq;
  pq.push(make_pair(A[0] + B[0] + C[0], Pos(0, 0, 0)));
  int hash = 0;
  set<int> done;
  done.insert(hash);

  for(int ix=0; ix<k; ++ix){
    auto now = pq.top();
    pq.pop();

    cout << now.first << endl;

    auto sec = now.second;

    for(int i=0; i<3; ++i){
      int apos = sec.x, bpos = sec.y, cpos = sec.z;
      if(apos < A.size()-1 && i == 0) ++apos;
      if(bpos < B.size()-1 && i == 1) ++bpos;
      if(cpos < C.size()-1 && i == 2) ++cpos;

      hash = (apos << 20) + (bpos << 10) + cpos;
      if(done.find(hash) == done.end()){
        done.insert(hash);
        pq.push(make_pair(A[apos] + B[bpos] + C[cpos], Pos(apos, bpos, cpos)));
      }
    }
  }
}


Measured memory_bytes: 768