akhauriyash/Code-Regression huggingface dataset:
#include<string>
#include<iostream>
#include <algorithm>
#include<vector>
#include<functional>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <numeric>
#include <math.h>
#define ll long long 
#define PI 3.14159265358979323846
#define rep(i,n) for(ll i=0;i<(ll)n;i++)
using namespace std;



int main() {
    ll A, ans, B1;
    double B;
    cin >> A >> B;
    B1 = (B+0.0000001) * 100;
    ans = A * B1;
    ans = ans / 100;
    cout << ans << endl;
    return 0;
 }


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

int main(){
  
  int a,b,c;
  cin >> a >> b >> c;
  
  if( a >= b && a >= c ){
    
  cout << a*10 + b + c << endl;
  
  }

  else if( b >= a && b >= c ){
    
  cout << b*10 + a + c << endl;
  
  }
  
  else if( c >= a && c >= b ){
    
  cout << c*10 + a + b << endl;
  
  }
  
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <map>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <cmath>
#include <queue>
#include <ctime>
#include <utility> // std::pair
#include <functional> // std::greater <int> ()
#define int long long
#define MAXN 500000 // check
#define inf 1000000000000000001
#define BASE 29 // hashings mod, can be rand'd
#define mod 998244353 // can be 1000000007
#define pi 3.1415926535897
#define pii pair <int, int>
#define fii first
#define see second

typedef long long ll;
typedef long double ld;
using namespace std;

int a, b;

// functions
void input(){
	cin >> a >> b;
	return;
}

void solve(){
	if((a+b)%2!=0) cout << "IMPOSSIBLE";
	else cout << (a+b)/2;
	return;
}

void output(){
	return;
}

signed main(){
/*
//  REMEMBER TO TURN OFF IFDEF IN PROBLEMS WITH FILE I/O
*/
#ifdef sheeep
	freopen("forces.inp", "r", stdin);
	freopen("forces.out", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
//	int t;
//	cin >> t;
//	for(int i=1; i<=t; i++){
		input();
		solve();
		output();
//	}
	return 0;
}
// Author: NamSPro

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

using namespace std;

typedef long long ll;

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

   string a,b,c;

   cin>>a>>b>>c;

   if(a.back() == b.front() && b.back() == c.front()){
       cout<<"YES"<<endl;
   } else{
       cout<<"NO"<<endl;
   }

    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = sorted(map(int, input().split()))
if A[0] == 0:
    print(0)
    exit()

ans = 1
for a in A:
    ans *= a
    if ans > 10 ** 18:
        print(-1)
        exit()

if ans > 10 ** 18:
    print(-1)
else:
    print(ans)


Measured memory_bytes: 88688
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <climits>
#include <bitset>
#include <list>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

#define mod ((ull)(1e9)+7)
#define MAX ((ull)(1e9)+1)

int main(){
	int a, b, c, d, e, k;
	cin >> a >> b >> c >> d >> e >> k;
	if(e-a>k) cout << ":(" << endl;
	else cout << "Yay!" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <functional>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define SQ(x) ((x)*(x))
#define Mod(x, mod) (((x)+(mod)%(mod))
#define MP make_pair
#define PB push_back
#define Fi first
#define Se second
#define INF (1<<29)
#define EPS 1e-10
#define MOD 1000000007

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

#define MAX 14

int dp[1<<MAX][MAX];

int N;
vector<string>s;

int dfs(int S, int u){
  if(S==(1<<N)-1) return 0;
  if(u==-1){
    int res = INF;
    rep(i,N) res = min(res, dfs(S | (1<<i), i) + (int)s[i].size());
    return res;
  }
  int &res = dp[S][u];
  if(res >= 0) return res;
  res = INF;
  //  cout << S << " " << u << endl;
  string us = s[u];
  for(int i=0;i<N;i++){
    if((S>>i)&1) continue;
    string c = s[i];
    for(int p=us.size()-min(us.size(),c.size())+1;p<=us.size();p++){
      int f = 1;
      for(int j=p;j<us.size();j++) if(us[j] != c[j-p]){ f = 0; break;}
      if(f) res = min(res, dfs(S | (1<<i), i) + (int)c.size()-(int)us.size()+p);	

      /*      if(us.substr(p) == c.substr(0, us.size()-p)){
	res = min(res, dfs(S | (1<<i), i) + (int)c.size()-(int)us.size()+p);
	break;
	}*/
    }
  }
  return res;
}

int main(){
  while(cin >> N, N){
    s.clear();
    rep(i,N){
      string in; cin >> in;
      s.push_back(in);
    }
    rep(i,s.size()){
      rep(j,s.size()) if(i!=j && s[j].find(s[i], 0) != string::npos){
	s.erase(s.begin()+i);
	i--;
	break;
      }
    }
    N = s.size();
    memset(dp, -1, sizeof(dp));
    cout << dfs(0, -1) << endl;
  }
  return 0;
}

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

int main () {
  ll x; cin >> x; ll ans = (x / 11) * 2, b = x % 11;
  if (b > 6) ans += 2;
  else if (b > 0) ans++;
  cout << ans << endl;
}                                                

Measured memory_bytes: 3640
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int n;
string word ="abcdefghijklmnopqrstuvwxyz";
int main(){
	map<char,int> data;
	int pos = 0;
	for(char i = 'a';i <= 'z';i++){
		data[i] = pos++;
	}
	// cout <<"pos = "<<pos<<endl;
	while(cin>>n,n){
		string str;
		cin>>str;
		vector<pii> d;
		for(int i = 0;i < n;i++){
			int a,b;
			cin>>a>>b;
			a--,b--;
			d.push_back(mp(a,b));
		}
		reverse(d.begin(), d.end());
		for(int i = 0;i < n;i++){
			int a,b;
			a = d[i].first;
			b = d[i].second;
			int dist =abs(a - b);
			char tmp1,tmp2;
			tmp1 = word[(data[str[a]] + dist)%pos];
			tmp2 = word[(data[str[b]] + dist)%pos];
			// cout <<tmp1<<" "<<tmp2<<endl;
			str[a] = tmp2;
			str[b] = tmp1;
			// cout <<tmp1<<" "<<tmp2<<endl;
		}
		cout <<str<<endl;
	}
	return 0;
}

Measured memory_bytes: 1216
#include<stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

int main(void)
{
  int n;


  scanf("%d",&n);
  char s[n][11];
   for(int i=0; i<n; i++){
       scanf("%s",&s[i]);}
   int sum=1;

  qsort(s,n,11,strcmp);

  for(int i=1;i<n;i++){
      if(strcmp(s[i],s[i-1])!=0) sum++;
    
  }
 
  
 
  printf("%d",sum);
return 0;
}


Measured memory_bytes: 5736
#include <bits/stdc++.h>
      
#define FOR(i,a,b) for( ll i = (a); i < (ll)(b); i++ )
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort( (x).begin(),(x).end() )
#define REVERSE(x) reverse( (x).begin(),(x).end() )
#define UNIQUE(x) (x).erase( unique( ALL( (x) ) ) , (x).end() )
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())
#define SHOW(x) cout << #x << " = " << x << endl
#define SHOWA(x,n) for( int yui = 0; yui < n; yui++ ){ cout << x[yui] << " "; } cout << endl

#define pb emplace_back
#define fi first
#define se second

using namespace std;

typedef long double ld;
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<vpl> gr;
typedef vector<vl> ml;
typedef vector<vd> md;
typedef vector<vi> mi;
     
const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ld EPS = 1e-12;
const ll MOD = 1e9+7;
     
template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> inline T sq( T a ){ return a * a; }

ll in(){ long long int x; scanf( "%lld" , &x ); return x; }
char yuyushiki[1000010]; string stin(){ scanf( "%s" , yuyushiki ); return yuyushiki; }

// head

ll n, a, b;
ll c[100010];

int main(){

  n = in();
  a = in();
  b = in();
  REP( i , n ){
    c[i] = in();
  }

  ll ans = 0;
  REP( i , n-1 ){
    ans += min( b , ( c[i+1] - c[i] ) * a );
  }

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


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

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

using namespace std;

struct Edge { int src,dst,bitmask; };
struct Data {
  int cur,weight,bitmask,step;
  bool operator < ( const Data &data ) const {
    return weight > data.weight;
  }
};

const int MAX_V = 101;
const int MAX_R = 101;
const int IINF = INT_MAX;
int V,E,M,S,T,R,bits[MAX_V];
vector<Edge> G[MAX_V];
int mini[MAX_V][MAX_R][1<<4];

void compute(){
  rep(i,V) rep(k,R+1) rep(j,(1<<4)) mini[i][k][j] = IINF;
  //rep(i,MAX_V) rep(k,MAX_R) rep(j,(1<<4)) mini[i][k][j] = IINF;
  mini[S][0][bits[S]] = 0;
  priority_queue<Data> Q;
  Q.push((Data){S,0,bits[S],0});
  while( !Q.empty() ){
    Data data = Q.top(); Q.pop();
    if( data.cur == T ) { cout << data.weight << endl; return; }
    rep(i,(int)G[data.cur].size()){
      Edge &v = G[data.cur][i];
      if( v.bitmask != -1 ) {
	if( ( v.bitmask & data.bitmask ) == 0 ) continue;
      }
      int bitmask = data.bitmask | bits[v.dst];
      if( data.step + 1 <= R && mini[v.dst][data.step+1][bitmask] > data.weight + 1 ) {
	mini[v.dst][data.step+1][bitmask] = data.weight + 1;
	Q.push((Data){v.dst,data.weight+1,bitmask,data.step+1});
      }
    }
    if( mini[S][0][data.bitmask] > data.weight + 1 ) {
      mini[S][0][data.bitmask] = data.weight + 1;
      Q.push((Data){S,data.weight+1,data.bitmask,0});
    }
  }
  cout << -1 << endl;
}

int main(){
  cin >> V >> E >> M >> S >> T >> R;
  rep(i,E){
    int s,t;
    cin >> s >> t;
    G[s].push_back((Edge){s,t,-1});
    G[t].push_back((Edge){t,s,-1});
  }
  rep(i,M) {
    int s,t,c;
    cin >> s >> t >> c;
    bits[c] |= (1<<i);
    G[s].push_back((Edge){s,t,(1<<i)});
    G[t].push_back((Edge){t,s,(1<<i)});
  }
  compute();
  return 0;
}

Measured memory_bytes: 1920
using System;
using System.Collections.Generic;
using System.Dynamic;
using System.Linq;

namespace atcorder
{
    class Program
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();
           if(S.Contains("A") && S.Contains("B"))
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
            
        }
    }
}

//文字配列の取得
//string[] strArray = Console.ReadLine().Split(' ').ToArray();
//string S = strArray[0];
//string T = strArray[1];

//文字列の取得
//string s = Console.ReadLine();

//数字配列の取得
//int[] intArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
//int H = intArray[0];
//int W = intArray[1];

//数字の取得
//int N = int.Parse(Console.ReadLine());

//リスト型(int)の取得
//List<int> A = new List<int>(Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray());

//出力
//Console.WriteLine(ans);
//Console.WriteLine("Yes");
//Console.WriteLine("No");
//Console.WriteLine(cnt);



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

typedef long long lli;

const lli INF = (1LL << 31) - 1;
const int MAX_N = 1 << 17;

class LazySegTree{
  int n;
  lli dat[2*MAX_N-1], lazy[2*MAX_N-1];

public:
  LazySegTree(int _n = MAX_N){ 
    n = 1;
    while(n < _n) n *= 2;
    fill(dat,dat+2*n-1,INF);
    fill(lazy,lazy+2*n-1,INF);
  }

  void lazy_evaluate(int k){
    dat[k] = min(dat[k], lazy[k]); //
    if(k < n - 1){
      lazy[2*k+1] = min(lazy[2*k+1], lazy[k]); //
      lazy[2*k+2] = min(lazy[2*k+2], lazy[k]); //
    }
    lazy[k] = INF; //
  }

  void update(lli v, int a, int b){ update(v, a, b, 0, 0, n);}
  void update(lli v, int a, int b, int k, int l, int r){
    lazy_evaluate(k);

    if(a <= l && r <= b){
      lazy[k] = dat[k] = v; //
      lazy_evaluate(k);
    } else if(a < r && l < b){
      update(v, a, b, k*2+1, l, (l+r)/2);
      update(v, a, b, k*2+2, (l+r)/2, r);
      dat[k] = min(dat[2*k+1], dat[2*k+2]); //
    }
  }

  lli query(int a, int b){ return query(a, b, 0, 0, n);}
  lli query(int a, int b, int k, int l, int r){
    lazy_evaluate(k);

    if(r <= a || b <= l) return INF;
    else if(a <= l && r <= b) return dat[k];
    else {
      int v1 = query(a, b, k*2+1, l, (l+r)/2);
      int v2 = query(a, b, k*2+2, (l+r)/2, r);
      dat[k] = min(dat[2*k+1], dat[2*k+2]); //
      return min(v1, v2); //
    }
  }
};

int main(){
  int n,m;
  /*
  while(cin >> n){
    LazySegTree rst;
    for(int i=0;i<n;i++){
      int a,b,v;
      cin >> a >> b >> v;
      rst.update(v,a,b);
    }
    cin >> m;
    for(int i=0;i<m;i++){
      int a,b;
      cin >> a >> b;
      cout << "query (" << a << "," << b << ") : " << rst.query(a,b) << endl;
    }
  }
  */
  cin >> n >> m;
  LazySegTree rst;
  for(int i=0;i<m;i++){
    lli a,b,c;
    cin >> a >> b >> c;
    if(a == 0) rst.update(c,b,b+1);
    else cout << rst.query(b,c+1) << endl;
  }
}

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

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef long double ld;

const ll mod = (ll)1e9 + 7;
const ll mxN = 200200;




int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(20);
	cout << fixed;

	ll n;
	cin>>n;
	vector<pll>A(n);
	for(int i=0;i<n;i++){
		cin>>A[i].fi;
		A[i].se=i+1;
	}
	sort(all(A));
	for(int i=0;i<n;i++)
		cout<<A[i].se<<" ";

}


Measured memory_bytes: 4784
s = input()
count = 0
for i in range(len(s)):
    # 0番目の文字がA
    if i == 0:
        if s[i] != 'A':
            break
    # 大文字が出現したとき
    elif s[i].isupper():
        # Cの条件を満たせばcountを増やす
        if 2 <= i < len(s) - 1 and s[i] == 'C':
            count += 1
        # そうでなければcountを0にし、ループ終了
        else:
            count = 0
            break
# カウントが1なら
if count == 1:
    print('AC')
else:
    print('WA')


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll r;
    cin >> r;
    printf("%.10f\n", 2 * r * 3.14159265358);
    return 0;
}


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

int main() {
  string s;
  cin >> s;
  bool f = false;
  f |= (s[0] == s[1] && s[1] == s[2]);
  f |= (s[1] == s[2] && s[2] == s[3]);
  puts(f ? "Yes" : "No");
  return 0;
}

Measured memory_bytes: 256
import math

class Vector:
    def __init__(self,x,y):
        self.x = x
        self.y = y
        
    def norm_2(self):
        return dot(self,self)
    
    def norm(self):
        return math.sqrt(self.norm_2())
    
def v_sum(v1,v2):
    return Vector(v1.x+v2.x,v1.y+v2.y) 
def scalar_multi(k,v):
    return Vector(k*v.x,k*v.y)
def v_diff(v1,v2):
    return v_sum(v1,scalar_multi(-1,v2))
    
def dot(vector1,vector2):
    return vector1.x*vector2.x+vector1.y*vector2.y

def cross(vector1,vector2):
    return vector1.x*vector2.y+vector1.y*vector2.x

x1,y1,x2,y2 = map(int,input().split())
p1 = Vector(x1,y1)
p2 = Vector(x2,y2)

d = v_diff(p2,p1)

q = int(input())
for i in range(q):
    x,y = map(int,input().split())
    v = v_diff(Vector(x,y),p1)
    h = scalar_multi(dot(v,d)/d.norm_2(),d)
    w = v_sum(scalar_multi(2,v_diff(h,v)),v)
    print('{} {}'.format(v_sum(w,p1).x,v_sum(w,p1).y))


Measured memory_bytes: 5692
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>


int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 1 << 21;
using pii = std::pair<int, int>;
#define SORT(v) std::sort(v.begin(), v.end())

int main(void) {
	long long n, k;
	std::cin >> n >> k;
	long long temp = 0,ans=0;
	ans = (n / k)*(n / k)*(n / k);
	if (k % 2 == 0) {
		temp = n / (k / 2) - n / k;
		ans += temp * temp*temp;
	}
	std::cout << ans << std::endl;
	return 0;
}

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

const int M=1000010;
const long long mod=998244353;

void ad(long long &a,long long b){a+=b;a%=mod;}
void mn(long long &a,long long b){a+=mod-b;a%=mod;}
void ml(long long &a,long long b){a*=b;a%=mod;}
long long sq(long long a){return a*a%mod;}
long long pw(long long a,long long n)
{
  return n==0?1ll:sq(pw(a,n/2))*(n%2==1?a:1ll)%mod;
}
long long iv(long long a){return pw(a,mod-2);}

int main()
{
  int n;
  scanf("%d",&n);
  vector<int> T(M,0);
  for(int i=0;i<n;i++){
    int a;
    scanf("%d",&a);
    T[a]++;
  }
  vector<bool> E(M,true);
  vector<long long> mu(M,1);
  for(int p=2;p<M;p++){
    if(E[p]){
      for(int k=p;k<M;k+=p){
	mu[k]*=-1;
	E[k]=false;
      }
      long long p2=(long long)p*p;
      for(long long k=p2;k<M;k+=p2){
	mu[k]=0;
      }
    }
  }
  vector<long long> f(M,0);
  for(int g=1;g<M;g++){
    long long p=iv(g);
    for(int j=1;g*j<M;j++){
      ad(f[g*j],(mu[j]+mod)%mod*p%mod);
    }
  }
  long long ans=0ll;
  for(int d=1;d<M;d++){
    long long S=0,L=0;
    for(int j=d;j<M;j+=d){
      ad(S,L*T[j]%mod*j%mod);
      ad(S,(long long)T[j]*(T[j]-1)/2%mod*j%mod*j%mod);
      ad(L,T[j]*j%mod);
    }
    ad(ans,f[d]*S%mod);
  }
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 21888
#include <bits/stdc++.h>
#define ll long long int
#define mp make_pair
#define pb push_back
#define ff first 
#define ss second
#define mod 1000000007
#define lim 100005
#define nfs_mw ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;


int main()
{
	// nfs_mw;
	int i,u,n,rsz,root; string s;
	cin>>s;
	n = s.size();
	
	if((s[0] == '0') || (s[n-1] == '1')){
		cout<<(-1)<<"\n";
		return 0;
	}

	for(i=0; i<n/2; i++) if(s[i] != s[n-i-2]) {
		cout<<(-1)<<"\n";
		return 0;
	}
	
	root = u = 1;
	rsz = n - 1;

	for(i=(n/2); i>0; i--)
		if(s[i-1] == '1'){
			rsz -= i;
			while(rsz--)
				cout<<root<<" "<<(++u)<<"\n";
			cout<<root<<" "<<(++u)<<"\n";
			root = u;
			rsz  = i-1;
		}
}

Measured memory_bytes: 1408
// 2011/04/06 Tazoe

#include <iostream>
using namespace std;

void DFS(char map[14][14], int i, int j)
{
	map[i][j] = '3';

	if(map[i][j+1]=='1')
		DFS(map, i, j+1);
	if(map[i+1][j]=='1')
		DFS(map, i+1, j);
	if(map[i][j-1]=='1')
		DFS(map, i, j-1);
	if(map[i-1][j]=='1')
		DFS(map, i-1, j);
}

int main()
{
	while(true){
		char map[14][14];
		for(int i=0; i<14; i++)
			for(int j=0; j<14; j++)
				map[i][j] = '2';

		cin >> map[1][1];
		if(cin.eof())
			break;

		for(int i=1; i<=12; i++)
			for(int j=1; j<=12; j++)
				if(i==1&&j==1)
					continue;
				else
					cin >> map[i][j];

		int cnt = 0;
		for(int i=1; i<=12; i++)
			for(int j=1; j<=12; j++)
				if(map[i][j]=='1'){
					cnt++;
					DFS(map, i, j);
				}

		cout << cnt << endl;
	}

	return 0;
}

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

int main() {
    int N;
    long sum = 0;
    cin>>N;
    vector<int> A(N,0), B(N,0);
    vector<long> C(N,0);
    REP(i, 0, N){
        cin >> A[i];
        A[i]--;
        B[A[i]]++;
    }
    REP(i, 0, N){
        long p = B[i];
        C[i] = p*(p-1)/2;
        sum += p*(p-1)/2;
    }
    REP(i, 0, N){
        long q = B[A[i]];
        long ans = sum - q*(q-1)/2 + (q-1)*(q-2)/2;
        cout << ans << endl;
    }
}

Measured memory_bytes: 5760
import std.stdio;
import std.conv, std.array, std.algorithm, std.string;
import std.math, std.random, std.range, std.datetime;
import std.bigint;

class Point{
	static int idcounter = 0;
	int id;
	long x, y;
	long r;
	real value;
	bool visited;
	real[int] distancemap;
	real distanceto(Point p){
		if(p.id in distancemap) return distancemap[p.id];
		else{
			real ans = sqrt(to!real(this.x - p.x) ^^ 2 + to!real(this.y - p.y) ^^ 2) - this.r - p.r;
			if(ans < 0) ans = 0;
			distancemap[p.id] = ans;
			return ans;
			}
		}
	this(long x, long y, long r){
		this.id = idcounter ++;
		this.x = x;
		this.y = y;
		this.r = r;
		}
	}

void main(){
	Point start, term;
	{
		long[] tmp = readln.chomp.split.map!(to!long).array;
		start = new Point(tmp[0], tmp[1], 0);
		term = new Point(tmp[2], tmp[3], 0);
		}
	int n = readln.chomp.to!int;
	Point[] ps = [start, term];
	for(int i = 0; i < n; i ++){
		long[] tmp = readln.chomp.split.map!(to!long).array;
		ps ~= new Point(tmp[0], tmp[1], tmp[2]);
		}
	
	start.value = 0.0;
	start.visited = true;
	Point newp = start;
	foreach(p; ps){
		p.value = start.distanceto(p);
		}
	
	while(!term.visited){
		foreach(p; ps){
			if(p.visited) continue;
			real v = newp.value + newp.distanceto(p);
			if(v < p.value) p.value = v;
			}
		Point minp = term;
		foreach(p; ps){
			if(p.visited) continue;
			if(p.value < minp.value) minp = p;
			}
		newp = minp;
		newp.visited = true;
		}
	
	writefln("%#.12f", term.value);
	
	}





Measured memory_bytes: 38396
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long LL;
template <typename F, typename S> std::ostream& operator<<(ostream& os, const pair<F,S>& p) {
    os << "(" << p.first << "," << p.second << ")"; return os; }
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "["; for(const T& a: v){ os << a << ", "; } os << "]"; return os; }
template <typename K, typename V> ostream& operator<<(ostream& os, const map<K,V>& m) {
    os << "{"; for(const auto& p: m){ os << p.first <<":"<< p.second << ", "; } os << "}"; return os; }


// 剰余演算クラス
struct ModInt{
    static const LL MOD = 1e+9 + 7;
    LL v;
    ModInt():v(0){}
    ModInt(LL op):v(op){}
    ModInt operator+(ModInt op) const{ return (v + op) % MOD; }
    ModInt operator-(ModInt op) const{ return (v - op + MOD) % MOD; }
    ModInt operator*(ModInt op) const{ return (v * op) % MOD; }
    ModInt operator/(ModInt op) const{ return (v * op.inverse()) % MOD; }
    ModInt operator%(LL op) = delete;
    ModInt operator+=(ModInt op){ return v = (v + op) % MOD; }
    ModInt operator-=(ModInt op){ return v = (v - op + MOD) % MOD; }
    ModInt operator*=(ModInt op){ return v = (v * op) % MOD; }
    ModInt operator/=(ModInt op){ return v = (v * op.inverse()) % MOD; }
    ModInt operator-() const{ return MOD - v; }
    bool operator==(ModInt op) const{ return v == op.v; }
    bool operator!=(ModInt op) const{ return v != op.v; }
    ModInt inverse() const{ return pow(MOD-2); }
    ModInt pow(LL n) const{
        if(n < 0) return pow(MOD-1 + n);
        if(n == 0) return 1;
        ModInt res = pow(n/2);
        return res * res * ((n&1)?ModInt(v): ModInt(1));
    }
    LL get() const{ return v; }
private:
    operator LL() const{ return v; }
};
istream& operator>>(istream& st, ModInt& m){ st>>m.v; return st; }
ostream& operator<<(ostream& st, const ModInt& m){ st<<m.v; return st; }


vector<ModInt> factorial(LL n){
    vector<ModInt> res(n, 1);
    for(LL i = 2; i < n; ++i) res[i] = res[i-1] * ModInt(i);
    return res;
}

ModInt permutation(LL n, LL m, vector<ModInt>& factorial){
    if(m < 0 || n < m) return 0;
    if(m == 0) return 1;
    return factorial.at(n) / factorial.at(n-m);
}

ModInt combination(LL n, LL m, vector<ModInt>& factorial){
    if(m < 0 || n < m) return 0;
    if(m == 0) return 1;
    return factorial.at(n) / factorial.at(n-m) / factorial.at(m);
}

ModInt combination2(LL n, LL m){
    if(m < 0 || n < m) return 0;
    if(m == 0) return 1;
    ModInt num = 1;
    ModInt den = 1;
    for(LL i = 1; i <= m; ++i){
        num *= ModInt(n+1-i);
        den *= ModInt(i);
    }
    return num / den;
}


int main(){
    LL n, k;
    cin >> n >> k;
    vector<ModInt> f = factorial(1000000);
    ModInt ans = 1; // k >= 2
    for(LL i = 1; i <= k && i <= n-1; ++i){
        ModInt cnt = combination(n, i, f);
        cnt *= combination(n-i+i-1, n-i-1, f);
        ans += cnt;
    }
    cout << ans.get() << endl;
    return 0;
}



Measured memory_bytes: 8064
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: u64
    }
    let mut ans = 0;
    for i in 1..=n {
        if i % 3 != 0 && i % 5 != 0 {
            ans += i;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2168
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define pi 3.141592653589793
using namespace std;



int main() {
    cout << setprecision(10);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    ll a[5];
    for (int i = 0; i < 5; i++) {
        cin >> a[i];
    }

    ll k;
    cin >> k;

    if (*max_element(a, a + 5) - *min_element(a, a + 5) > k) {
        cout << ":(";
    }

    else {
        cout << "Yay!";
    }



}




Measured memory_bytes: 256
import math

N = int(input())
sqrt_n = int(math.sqrt(N))
d0 = 1
d1 = 1
for i in range(1, sqrt_n + 2):
    if N % i == 0:
        d0 = i
        d1 = N // i
print( d0 - 1 + d1 - 1)


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

using namespace std;

#define ll long long
ll input(){
	ll x=0,f=0;char ch=getchar();
	while(ch<'0'||ch>'9') f|=ch=='-',ch=getchar();
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return f? -x:x;
}

#define ll long long
const int N=1e5+7;

vector <int> G[N];
int n,m;
stack <int> s;
int d[N],dis[N];
int Ans=0;

void bfs(){
	queue <int> q;
	for(int i=1;i<=n;i++){
		if(!d[i]) q.push(i);
	}
	while(!q.empty()){
		int u=q.front();q.pop();
		for(auto v:G[u]){
			d[v]--;
			if(d[v]==0)
				dis[v]=dis[u]+1,q.push(v);
		}
	}
}

int main(){
	n=input(),m=input();
	for(int i=1;i<=m;i++){
		int u=input(),v=input();
		G[u].push_back(v);
		d[v]++;
	}
	bfs();
	for(int i=1;i<=n;i++){
		Ans=max(Ans,dis[i]);
	}
	printf("%d\n",Ans);
}

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

int main() {
  int N;
  cin >> N;
  
  vector<int> a(N);
  
  for(int i=0; i<N; i++){
    cin >> a.at(i);
  }
  
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  
  int Alice=0, Bob=0;
  
  for(int i=0; i<N; i++){
    if(i%2==0){
      Alice += a.at(i);
    }
    else{
      Bob += a.at(i);
    }
  }
  
  cout << Alice - Bob << endl;
}


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

int main() {
  int N;
  string S;
  cin >> N >> S;

  set<string> SE;
  SE.insert(S);

  for (int i = 1; i < N; i++) {
    string s;
    cin >> s;
    if (s.front() != S.back()) goto NG;
    if (SE.count(s)) goto NG;
    SE.insert(s), S = s;
  }

  cout << "Yes" << "\n";
  return 0;
  NG: cout << "No" << "\n";
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int a[11][11];

int main(void)
{
	int n, d, i, j, k, ans = 0;

	scanf("%d %d", &n, &d);
	for (i = 1; i <= n; i++)
		for (j = 1; j <= d; j++)
			scanf("%d", &a[i][j]);

	for (i = 1; i < n; i++)
		for (j = i + 1; j <= n; j++)
		{
			double sum = 0;
			for (k = 1; k <= d; k++)
				sum += pow((double)a[i][k] - a[j][k], 2.0);
			
			if ((int)sum == (int)((int)sqrt(sum) * (int)sqrt(sum)))
				++ans;
		}

	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 128
#設定
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**7)

from collections import defaultdict
import queue

INF = float("inf")

#入力受け取り
def getlist():
	return list(map(int, input().split()))

class Graph(object):
	def __init__(self):
		self.graph = defaultdict(list)

	def __len__(self):
		return len(self.graph)

	def add_edge(self, a, b):
		self.graph[a].append(b)

	def get_nodes(self):
		return self.graph.keys()

class BFS(object):
	def __init__(self, graph, s, N):
		self.g = graph.graph
		self.Q = queue.Queue()
		self.Q.put(s)
		self.dist = [INF] * N
		self.dist[s] = 0
		self.visit = ["No"] * N
		self.visit[s] = "Yes"
		while not self.Q.empty():
			v = self.Q.get()
			for i in self.g[v]:
				if self.visit[i] == "No":
					self.dist[i] = self.dist[v] + 1
					self.Q.put(i)
					self.visit[i] = "Yes"

def DFS(G, MAX, MIN, visit, node):
	for i in G.graph[node]:
		if visit[i] != "Yes":
			visit[i] = "Yes"
			DFS(G, MAX, MIN, visit, i)
			MAX[node] = min(MAX[node], MAX[i] + 1)
			MIN[node] = max(MIN[node], MIN[i] - 1)

class BFS2(object):
	def __init__(self, graph, s, N, MAX, MIN):
		self.g = graph.graph
		self.Q = queue.Queue()
		self.Q.put(s)
		self.visit = ["No"] * N
		self.visit[s] = "Yes"
		while not self.Q.empty():
			v = self.Q.get()
			for i in self.g[v]:
				if self.visit[i] == "No":
					self.visit[i] = "Yes"
					self.Q.put(i)
					MAX[i] = min(MAX[i], MAX[v] + 1)
					MIN[i] = max(MIN[i], MIN[v] - 1)

#処理内容
def main():
	#入力、前処理
	N = int(input())
	G = Graph()
	for i in range(N - 1):
		a, b = getlist()
		a -= 1; b -= 1
		G.add_edge(a, b); G.add_edge(b, a)
	K = int(input())
	MAX = [INF] * N; MIN = [-INF] * N
	for i in range(K):
		V, P = getlist()
		V -= 1
		MAX[V] = P
		MIN[V] = P

	#BFS 偶奇判定
	BF = BFS(G, V, N)
	dist = BF.dist
	odd_even = [0, 0]
	for i in range(N):
		if MAX[i] != INF:
			if MAX[i] & 1 == dist[i] & 1:
				odd_even[0] += 1
			else:
				odd_even[1] += 1
	
	#例外処理
	if odd_even[0] * odd_even[1] > 0:
		print("No")
		return

	#DFS
	visit = ["No"] * N
	visit[V] = "Yes"
	DFS(G, MAX, MIN, visit, V)
	#BFS
	BF2 = BFS2(G, V, N, MAX, MIN)

	#判定
	judge = "Yes"
	for i in range(N):
		if MAX[i] < MIN[i]:
			judge = "No"
			break
	if judge == "No":
		print(judge)
		return

	print("Yes")
	for i in MAX:
		print(i)

if __name__ == '__main__':
	main()

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

int main()
{
    ll int n;
    cin>>n;
    ll int z=n/500;
    n=n%500;
    ll int z1=n/5;
   ll int z2=(z*1000)+(z1*5);
   cout<<z2<<endl;
  return 0;
}




Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	long answer = 0;

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		long h = sc.nextLong();
		long w = sc.nextLong();
		if(h ==1 || w==1) {
			System.out.println("1");
			return;
		}
		System.out.println(((h * w)+1)/2);

	}


}

Measured memory_bytes: 22996
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 or x in b and  y in b or x in c and  y in c:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld  = long double;
using pll = pair<ll, ll> ;
using pld = pair<ld, ld>;
const int INF=1e9+7;
const ll LINF=1LL<<60;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld EPS = 1e-9; //微調整用（EPSより小さいと0と判定など）
 
#define gcd __gcd //llは受け取ってくれない
int lcm(int a, int b){return a / gcd(a, b) * b;}
#define ALL(a) a.begin(),a.end() //sort(ALL(vec));
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#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())
#define PB push_back
#define SZ(x) ((int)(x).size) //size()がunsignedなのでエラー避けに

//最大値、最小値を更新する。aよりbのが大きい（小さい）か等しければaを更新してtrueを返す。そうでなければ何もせずfalseを返す chmax(nowmax,x);
template<typename T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<typename T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}
// ----- template end ---- //
 
// ------- library ------- //

ll GCD(ll a, ll b) {
  if (a < b) return GCD(b, a);
  if (b == 0) return a;
  else return GCD(b, a % b);
}
 
ll LCM(ll a, ll b) {
  if (a < b) return LCM(b, a);
  ll g = GCD(a, b);
  return a / g * b;
}


// ----- library end ----- //



int main() {

  ll tmp1, tmp2;
  cin >> tmp1 >> tmp2;

  ll N, M;
  string S, T; //0-indexed
  if (tmp1 >= tmp2){
    N = tmp1;
    M = tmp2;
    cin >> S >> T;
  }
  else{
    N = tmp2;
    M = tmp1;
    cin >> T >> S;
  }

  ll lcm_st = LCM(N, M);
  ll sgap = lcm_st / N;
  ll tgap = lcm_st / M;
//  cout << lcm_st << endl;

  if (S.at(0)!=T.at(0)){
    cout << -1 << endl;
    return 0;
  }

  REP(i, 1, M){
//    cout << i << endl;
    if (tgap*i % sgap != 0){
      continue;
    }
    else{
      //tgapがsgapの倍数…… つまりアルファベットが被っている
      if (S.at((i*tgap)/sgap)==T.at(i)){
        continue;
      }
      else{
        //場所の被ったアルファベットが異なる-->-1
        cout << -1 << endl;
        return 0;
      }
    }
  }

  //生き残った
  cout << lcm_st << endl;


  
// -- main() end -- //
}


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

int main(void){

    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int max;
    int in;
    cin >> max;
    //cout << max <<endl;
    int ans = n;
    //cout << ans <<endl;
    for(int i=0;i<n-1;i++){
        cin >> in;
        //cout << in << max;
        if(max>in){
            ans--;
        }
        else{
            max = in;
        }
       // cout << ans << endl;
    }
    cout << ans;

    return 0;
}

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

int A, B;

int main(void){
	
	scanf("%d %d", &A, &B);
    
    if(A % 3 == 0) printf("Possible\n");
    else if(B % 3 == 0) printf("Possible\n");
    else if((A + B) % 3 == 0) printf("Possible\n");
    else printf("Impossible\n");
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdlib>
using namespace std;
int main() {
	string S;
	string a;
	int s=0,N;

	cin >> S;
	int size = S.size();
	for (int i = 0; i < size; i++) {
		a = S[i];
		s += atoi(a.c_str());
	}
	N = atoi(S.c_str());
	if (N%s == 0) {
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
#include <bitset>
#include <functional>
using namespace std;
#define fast_io ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define MOD (long long int)(1e9+7)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  if(n <= 1e7){
    ret *= kaijo(n); ret %= MOD;
    ret *= gyaku_kaijo(r); ret %= MOD;
    ret *= gyaku_kaijo(n-r); ret %= MOD;
  }else{
    rep(i,r){
      ret *= n-i; ret %= MOD;
      ret *= mpow(r-i, MOD-2); ret %= MOD;
    }
  }
  return ret;
}

int main(void){
  fast_io
  cout<<fixed<<setprecision(15);
  ll h,w;cin>>h>>w;
  if(min(h,w) == 1){
    cout<<1<<endl;
    return 0;
  }
  if((h*w)%2 == 0){
    cout<<h*w/2<<endl;
  }else if(min(h,w) != 1){
    cout<<h*w/2+1<<endl;
  }else{
    cout<<1<<endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> PII;
const int N = 3e5+7;

int r[N],c[N];
map<PII,int> mp;

int main()
{
	int n,m,k,x,y;
	scanf("%d%d%d",&n,&m,&k);
	int xx=0,yy=0;
	for(int i=0;i<k;i++){
		scanf("%d%d",&x,&y);
		mp[make_pair(x,y)]=1;
		r[x]++,c[y]++;
		xx = max(xx,r[x]);
		yy = max(yy,c[y]);
	}
	vector<int> vx,vy;
	for(int i=1;i<=n;i++) if(r[i]==xx) vx.push_back(i);
	for(int i=1;i<=m;i++) if(c[i]==yy) vy.push_back(i);
	int flag=0;
	for(int i=0;i<vx.size();i++){
		for(int j=0;j<vy.size();j++){
			if(!mp[make_pair(vx[i],vy[j])]){
				flag=1; break;
			}
		}
		if(flag) break;
	}
	if(flag) cout<<xx+yy<<"\n";
	else cout<<xx+yy-1<<"\n";
	return 0;
}

Measured memory_bytes: 28568
(function main() {
  const n = Number(require('fs').readFileSync('/dev/stdin', 'utf8')) + 1;
  const root5 = Math.sqrt(5);
  console.log(Math.round(1/root5 * (Math.pow((1 + root5) / 2, n) - Math.pow((1 - root5) / 2, n))));
})();



Measured memory_bytes: 15128
mat=[]
l1=list(map(int,input().split()))
l2=list(map(int,input().split()))
l3=list(map(int,input().split()))
mat=[l1,l2,l3]
N=int(input())
for r in range(N):
    n=int(input())
    for i in range(3):
        for j in range(3):
            if mat[i][j]==n:
                mat[i][j]=-1
flag=False
for i in range(3):
    if mat[i][0]==-1 and mat[i][1]==-1 and mat[i][2]==-1:
        flag=True
        break
for i in range(3):
    if mat[0][i]==-1 and mat[1][i]==-1 and mat[2][i]==-1:
        flag=True
        break
if mat[0][0]==-1 and mat[1][1]==-1 and mat[2][2]==-1:
    flag=True
if mat[0][2]==-1 and mat[1][1]==-1 and mat[2][0]==-1:
    flag=True
if flag==True:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 38384
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
#include <cmath>
#include <complex>
#include <map>
using namespace std;

#define rep(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8

static const double PI=6*asin(0.5);
typedef complex<double> P;
typedef long long ll;


int a2,a5;
int n;

int main(){
	while(cin>>n,n!=0){
		a2=a5=0;
		while(n!=2){
			int tmp=n;
			while(tmp%2==0){
				tmp/=2;
				a2++;
			}
			while(tmp%5==0){
				tmp/=5;
				a5++;
			}
			n--;
		}
		cout<<min(a2,a5)<<endl;
		}
	return 0;
}

Measured memory_bytes: 1160
s = input()
s += 'a'
cnts = []
prev = s[0]
cnt = 1
for i,si in enumerate(s[1:]):
    if prev == si:
        cnt += 1
    else:
        cnts.append(cnt)
        cnt = 1
    prev = si


ans = 0
c_num = 0
if s[0] == '<':
    for i,c in enumerate(cnts):
        if i%2 == 0:
            ans += c*(c-1)//2
            c_num = c-1
        else:
            ans += c*(c-1)//2
            ans += max(c,c_num+1)
    if s[-2] == '<':
        ans += cnts[-1]
        # print(cnts[-1])
    print(ans)

if s[0] == '>':
    ans = cnts[0]*(cnts[0]+1)//2
    for i,c in enumerate(cnts[1:]):
        if i%2 == 0:
            ans += c*(c-1)//2
            c_num = c-1
        else:
            ans += c*(c-1)//2
            ans += max(c,c_num+1)
        
    if s[-2] == '<':
        ans += cnts[-1]
    print(ans)

# print(cnts)

Measured memory_bytes: 85392
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m=1e32,s,p,j,i,a[500];
    cin>>n;
    for(i=0;i<n;i++)cin>>a[i];
    sort(a,a+n);
    for(i=a[0];i<=a[n-1];i++)
    {
        s=0;
        for(j=0;j<n;j++)
        {
            p=(a[j]-i);
            s+=(p*p);
        }
        if(s<m)m=s;
    }
    cout<<m<<endl;
    return 0;
}

Measured memory_bytes: 256
package main

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

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	q := getNextInt(scanner)
	aa := make([][]*link, n)
	for i := 0; i < n; i++ {
		aa[i] = append(aa[i], newLink(0))
		aa[i][0].pr = aa[i][0]
		aa[i][0].nx = aa[i][0]
	}
	for i := 0; i < q; i++ {
		qt := getNextInt(scanner)
		switch qt {
		case 0:
			t := getNextInt(scanner)
			x := getNextInt(scanner)
			e := newLink(x)
			e.pr = aa[t][0].pr
			e.nx = aa[t][0]
			aa[t][0].pr.nx = e
			aa[t][0].pr = e
		case 1:
			t := getNextInt(scanner)
			e := aa[t][0].nx
			for e != aa[t][0] {
				if e.pr != aa[t][0] {
					fmt.Fprint(writer, " ")
				}
				fmt.Fprint(writer, e.x)
				e = e.nx
			}
			fmt.Fprintln(writer, "")
		case 2:
			s := getNextInt(scanner)
			t := getNextInt(scanner)
			if aa[s][0].pr == aa[s][0] {
				continue
			}
			aa[s][0].pr.nx = aa[t][0]
			aa[s][0].nx.pr = aa[t][0].pr
			aa[t][0].pr.nx = aa[s][0].nx
			aa[t][0].pr = aa[s][0].pr
			aa[s][0].pr = aa[s][0]
			aa[s][0].nx = aa[s][0]
		}
	}
}

func newLink(x int) *link {
	return &link{
		pr: nil,
		nx: nil,
		x:  x,
	}
}

type link struct {
	nx, pr *link
	x      int
}



Measured memory_bytes: 24708
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
typedef long long ll;
using namespace std;
int main()
{
  int n;
  cin>>n;
  int p[10010];
  rep(i,n)cin>>p[i];
  sort(p,p+n,greater<int>());
  ll sum=0;
  sum+=p[0]/2;
  for(int i=1;i<n;i++){
    sum+=p[i];
  }

  cout<<sum<<endl;
  return 0;
}


Measured memory_bytes: 3644
import java.util.Arrays;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Scanner;
 
 
public class Main{
	
	public static class Pair implements Comparable<Pair>{
		int w, v;
		
		public Pair(int w, int v) {
			super();
			this.w = w;
			this.v = v;
		}

		@Override
		public int compareTo(Pair o) {
			return this.w * o.v - this.v * o.w;
		}
	}
	
    public static void main(String[] args){
    	final Scanner sc = new Scanner(System.in);
    	
    	final int N = sc.nextInt();
    	final int W = sc.nextInt();
    	
    	PriorityQueue<Pair> queue = new PriorityQueue<Main.Pair>(); 
    	
    	double cur_w = 0, cur_v = 0;
    	
    	for(int i = 0; i < N; i++){
    		int w = sc.nextInt();
    		int v = sc.nextInt();
    		
    		if(w >= 0 && v <= 0){
    			continue;
    		}else if(w <= 0 && v >= 0){
    			cur_w += w;
    			cur_v += v;
    			continue;
    		}else if(w <= 0 && v <= 0){
    			cur_w += w;
    			cur_v += v;
    			
    			w = -w;
    			v = -v;
    		}
    		
    		queue.add(new Pair(w, v));
    	}
    	
    	
    	while(!queue.isEmpty()){
    		Pair p = queue.poll();
    		
    		final double rest = W - cur_w;
    		final double x = Math.max(0, Math.min(1, rest / p.w));
    		
    		//System.out.println(cur_w + " "+ rest + " "+ p.v + " " + p.w + " " + x);
    		
    		cur_w += x * p.w;
    		cur_v += x * p.v;
    	}
    	
    	System.out.printf("%f\n", cur_v);
    }
     
}

Measured memory_bytes: 43164
using System.Collections.Generic;
using System.Linq;
public class PictureMatching
    {
        private static int[] Item;

        public static void Main(string[] args)
        {
            Input();
            Method();
            System.Console.ReadLine();
        }

        private static void Input()
        {
            var num = int.Parse(System.Console.ReadLine());
            Item = new int[num];
            for (int i = 0; i < num; i++)
            {
                Item[i] = int.Parse(System.Console.ReadLine());
            }
        }

        private static void Method()
        {
            int max = Item[1] - Item[0];
            int minv = Item[0];
            for (int i = 1; i < Item.Length; i++)
            {
                int diff = Item[i] - minv;
                if (diff > max)
                {
                    max = diff;
                }
                if (minv > Item[i])
                {
                    minv = Item[i];
                }
            }
            System.Console.WriteLine(max);
        }

        private static int[] ToIntArray(string[] str)
        {
            IEnumerable<int> intArray = str.Select(x => int.Parse(x));
            return intArray.ToArray();
        }
    }

Measured memory_bytes: 11260
N,Y=map(int,input().split())
Y=Y//1000
error='-1 -1 -1'

for x in range(N+1):
    for y in range(N+1-x):
            z=N-x-y
            if 10*x+5*y+z==Y and z>=0:
                print(str(x)+' '+str(y)+' '+str(z))
                exit()
print(error)

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

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(x) (x).begin(),(x).end()

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

ll s[55];
ll p[55];

ll answer(ll num, ll level)
{
    if(level == 1)
    {
        if (2<=num && num <=4)
        {
            return num-1;
        }else if (num<=1)
        {
            return 0;
        }else
        {
            return 3;
        }
        
    }
    if(num < s[level-1]+2)
    {
        return answer(num-1, level-1);
    }else if (num ==s[level-1]+2)
    {
        return p[level-1]+1;
    }else
    {
        return answer(num-2-s[level-1], level-1)+1+p[level-1];
    }
}
int main()
{
    ll n;cin >> n;
    ll x;cin >> x;
    rep(i,n)
    {
        if(i==0)
        {
            s[i] = 1;
            p[i] = 1;
            continue;
        }
        s[i] = 2 * s[i - 1] + 3;
        p[i] = 2 * p[i - 1] + 1;
    }
    cout << answer(x,n) << endl;

}

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

int main() {
    int n;cin >> n;
    int k;cin >> k;
    vector<long long> h(n+k+5), dp(n+k+5, 1e9+5);
    for(int i=0;i<n;i++) cin >> h[i];
    dp[0] = 0;
    for(int i=0;i<n;i++){
        for(int j=1;j<=k;j++){
            dp[i+j] = min(dp[i+j], dp[i]+abs(h[i+j]-h[i]));
        }
    }
    cout << dp[n-1] << endl;
    return 0;
}


Measured memory_bytes: 1792