akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;

int main() {
	string a, b, c;
	int flag = 0;
	int sa = 0, sb = 0,sc = 0;

	cin >> a >> b >> c;
	
	while (1) {
	
		while (flag == 0) {
		
			if (a[sa] == 'a')flag = 0;
			else if (a[sa] == 'b')flag = 1;
			else if (a[sa] == 'c')flag = 2;
			 else if (a[sa] == '\0') {
				cout << 'A' << endl; return 0;
			}
			sa++;
		}
		while (flag == 1) {
			
			if (b[sb] == 'a')flag = 0;
			else if (b[sb] == 'b')flag = 1;
			else if (b[sb] == 'c')flag = 2;
			else if (b[sb] == '\0') {
				cout << 'B' << endl; return 0;
			}
			sb++;
		}
		while (flag == 2) {
			if (c[sc] == 'a')flag = 0;
			else if (c[sc] == 'b')flag = 1;
			else if (c[sc] == 'c')flag = 2;
			else if (c[sc] == '\0') {
				cout << 'C' << endl; return 0;
			}
			sc++;
		}
	}
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp> 
//using boost::multiprecision::cpp_int;
using namespace std;
#define ll long long int
#define F first
#define S second
//#define endl "\n"
//#define nl cout<<endl;
#define pb push_back
#define ull unsigned long long 
#define f(i,a,b) for(ll i=a;i<b;i++)
#define Knucklehead ios_base::sync_with_stdio(false);cin.tie(NULL);
//#define mod 100000007
#define mat vector<vector<ll>>
mat cn(ll n, ll m){return vector< vector<ll> >(n, vector<ll>(m));}
bool compare(char &s1,char &s2){return s1 > s2;} 
bool sortmahstyle(const pair<ll,ll> &a,  const pair<ll,ll> &b) 
{ 
    if(a.second > b.second )
        return true;
    if( a.second==b.second && a.first > b.second )
       return true;
    return false;
}
bool cmp(int n, pair<int, int> const& p)
{
    return (p.first < n);
}
//me
ll const mod = 1e9+7;//998244353;
ll const inf = 1e18;
ll const maxn = 5e2+1;

double fastpow(double a, ll b)
{
     double res = 1.0;
     while(b){
          if(b&1) res*=a;
          a*=a;
          b/=2;
     }
     return res;
}
void solve()
{    
     ll n,k; cin >> n >> k;
     double ans = 0;
     for(ll i=1; i<=n; i++){

          long double die = (double)1.0/n;
          ll num = i, cnt = 0;

          while(num<k){
               num*=2;
               cnt++;
          }
          double toss = fastpow(0.5, cnt);
          ans += die*toss;

     }
     cout << fixed << setprecision(9)<< ans << endl;
}

int main() {
Knucklehead 
//*
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
/**/ 
        
          ll t;
          /**/t=1;
          /*/cin>>t;/**/
          f(testcases,0,t){
               //cout << "Case #" <<testcases+1<<": ";
               solve();
          }
 
 
    return 0;
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

bool edge[8][8];

int main() {
  int n, m;
  cin >> n >> m;
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    edge[a][b] = edge[b][a] = 1;
  }

  int ans = 0;
  vector<int> vi;
  REP(i, 1, n) vi.eb(i);

  do {
    bool f = true;
    vector<int> tmp = vi;
    tmp.eb(0);
    reverse(all(tmp));
    rep(i, tmp.size() - 1) if (!edge[tmp[i]][tmp[i + 1]]) f = false;

    ans += f;
  } while (next_permutation(all(vi)));

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int main(){
  long long int N,ans,i,x;
  ans=1;
  scanf("%lld",&N);
  long int A[N+1];
  for(i=0;i<N;i++){
    scanf("%lld",&A[i]);
    if(A[i]==0){
      printf("0");
      return 0;
    }
  }
  for(i=0;i<N;i++){
    x=1000000000000000000/ans;
    if(x<A[i]){
      ans=-1;
      break;
    }
    ans=ans*A[i];
  }
 
  printf("%lld",ans);
  return 0;
}

Measured memory_bytes: 2512
package main

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

func main() {
	run()
}

func run() {
	setSpace()
	n := readN()
	hs := make([]int, n)
	for i := 0; i < n; i++ {
		hs[i] = readN()
	}
	dp := make([]int, n)
	dp[0] = 0
	dp[1] = abs(hs[0] - hs[1])

	for i := 2; i < n; i++ {
		var cost int
		costSingle := abs(hs[i-1]-hs[i]) + dp[i-1]
		costDouble := abs(hs[i-2]-hs[i]) + dp[i-2]
		if costSingle < costDouble {
			cost = costSingle
		} else {
			cost = costDouble
		}

		dp[i] = cost
	}
	fmt.Println(dp[n-1])
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}

// ------以下、ユーティリティ------

var sc = bufio.NewScanner(os.Stdin)

func setSpace() {
	sc.Split(bufio.ScanWords)
}

func read() string {
	sc.Scan()
	return sc.Text()
}

func readN() int {
	n, err := strconv.Atoi(read())
	if err != nil {
		panic(err)
	}
	return n
}


Measured memory_bytes: 2688
// https://atcoder.jp/contests/abc114/tasks/abc114_b
#include <bits/stdc++.h>
using namespace std;

int main(void){
  string S;
  cin >> S;
  int diff_min = 999;

  for (int i = 0; i < S.size() -2; i++){
    int diff = 753 - stoi(S.substr(i, 3));
    if (abs(diff) < diff_min)
      diff_min = abs(diff);
  }

  cout << diff_min << endl;
}

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

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int n,d;
cin>>n>>d;
cout<<ceil(n/float(2*d+1))<<endl;
//system("pause");
return 0;
}

Measured memory_bytes: 256
//
//  main.c
//  ITP1_9_D
//
//  Created by k16031kk on 2018/05/27.
//  Copyright © 2018年 AIT. All rights reserved.
//

#include <stdio.h>
#include <string.h>

int main(int argc, const char * argv[]) {
    // insert code here...
    char str[1000];
    int q;
    scanf("%s", str);
    scanf("%d", &q);
    
    for(int i=0; i<q; i++) {//q回命令実行
        int a=0, b=0;
        char order[10];
        scanf("%s", order);
        
        if(strcmp(order,"print")==0) {//printと入力
            scanf("%d %d", &a, &b);
            for(int i=a; i<=b; i++) {
                printf("%c", str[i]);
            }
            printf("\n");
        }
        else if(strcmp(order,"reverse")==0) {//reverseと入力
            scanf("%d %d", &a, &b);
            for(int i=a; i<=a+(b-a)/2; i++) {
                char tmp=str[i];
                str[i]=str[a+b-i];
                str[a+b-i]=tmp;
            }
        }
        else if(strcmp(order,"replace")==0) {//replaceと入力
            char ch[1000]={};
            scanf("%d %d", &a, &b);
            scanf("%s", ch);
            int i, j;
            for(i=a, j=0; i<=b; i++, j++) {
                str[i]=0;
                str[i]=ch[j];
            }
        }
    }
    
    return 0;
}



Measured memory_bytes: 2104
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <tuple>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T3;

int main(){
	int n,m;
	cin >> n >> m;
	vector<P> a(n);
	for(int i = 0;i < n;i++){
		int x,y;
		cin >> x >> y;
		a[i] = P(x,y);
	}

	vector<P> b(m);
	for(int i = 0;i < m;i++){
		int x,y;
		cin >> x >> y;
		b[i] = P(x,y);
	}

	for(int i = 0;i < n;i++){
		int d = 1000000000;
		int num;
		for(int j = 0;j < m;j++){
			if(abs(b[j].first - a[i].first) + abs(b[j].second - a[i].second) < d){
				d = abs(b[j].first - a[i].first) + abs(b[j].second - a[i].second);
				num = j + 1;
			}
		}
		cout << num << endl;
	}
}


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

#define fi first
#define lc (x<<1)
#define se second
#define U unsigned
#define rc (x<<1|1)
#define Re register
#define LL long long
#define MP std::make_pair
#define CLR(i,a) memset(i,a,sizeof(i))
#define FOR(i,a,b) for(Re int i = a;i <= b;++i)
#define ROF(i,a,b) for(Re int i = a;i >= b;--i)
#define SFOR(i,a,b,c) for(Re int i = a;i <= b;i+=c)
#define SROF(i,a,b,c) for(Re int i = a;i >= b;i-=c)
#define DEBUG(x) std::cerr << #x << '=' << x << std::endl

#define int LL
int n;
inline int get(int k){ // k(k+1) <= 2*n
    int L = 1,R = n,ans;
    while(L <= R){
        int mid = (L + R) >> 1;
        if(mid*(mid+1) <= 2*n) ans = mid,L = mid+1;
        else R = mid-1;
    }
    return ans;
}

std::vector<int> x;

signed main(){
    //freopen("q.out","w",stdout);
    scanf("%lld",&n);
    int k = get(n);
    if(k*(k+1)==2*n){
        FOR(i,1,k) putchar(')');
        FOR(i,1,k) putchar('(');
        putchar('\n');
        return 0;
    }
    //DEBUG(k);DEBUG((k+1)*(k+2)/2);
    int d = ((k+1)*(k+2))/2 - n;
    k++;
    FOR(i,1,k){
        if(i == k-d+1) putchar('(');
        else putchar(')');
    }
    putchar(')');
    FOR(i,2,k) putchar('(');
    putchar('\n');
    return 0;
}


Measured memory_bytes: 3140
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define per(i,n) for (int i = (n)-1; i >=0; --i)
using namespace std;
using ll = long long;
using vi = vector<int>;
using vv = vector<vi>;

int main(){
    int a,b,c,x;
    cin>>a>>b>>c>>x;
    
    int ans = 0;
    
    for(int i=0; i<=min(a, x/500); i++){
        for(int j=0; j<=min(b, (x-(500*i))/100); j++){
            if((x-500*i-100*j)/50<=c)ans++;
        }
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <bits/stdc++.h>
#include <cmath>

using namespace std;

int main(void)
{
	int A = 0;
  	int B = 0;
  	int H = 0;
  	int M = 0;
  
  cin >> A >> B >> H >> M;
  double theta_A = 2*M_PI* (H+ M/60.0) /12;
  double theta_B = 2*M_PI* M/60.0;
  cout << fixed << setprecision(20);
  
  double c2= A*A + B*B - 2*A*B*cos(theta_A-theta_B);
  
  cout << sqrt(c2) << endl;
}

Measured memory_bytes: 4292
n, m = map(int, input().split())
s = []
c = []
for i in range(m):
    S, C = map(int, input().split())
    s.append(S)
    c.append(C)

for i in range(10 ** (n + 1)):
    tmp = str(i)
    if len(tmp) == n and all([tmp[s[j] - 1] == str(c[j]) for j in range(m)]):
        print(tmp)
        exit()

print(-1)

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

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

ll ryuca[100];
int main(){
  ll n;cin>>n;
  ryuca[0]=2;
  ryuca[1]=1;
  FOR(i,2,n+1){
    ryuca[i]=ryuca[i-1]+ryuca[i-2];
  }
  cout<<ryuca[n]<<endl;
  return 0;
}

Measured memory_bytes: 256
//Tue Dec 22 22:01:34 JST 2009
#include<cstdio>
#include<set>
#include<iostream>
#include<queue>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define mp make_pair
int dx[]={0,1,1,0,-1,-1};
int dy[]={-1,-1,0,1,1,0};
#define CONNECT true
#define UNCONNECT false
#define CANMOVE true
#define CANNOTMOVE false
int gx,gy;

class state{
public:
  int len;
  int x[8],y[8];
  int cnt;
  bool is_connected(int me,int you){
    if ( x[me]==x[you]){
      if ( y[me]-1 == y[you] || y[me]+1 == y[you] || y[me]==y[you])return CONNECT;
    }else if ( x[me]+1 == x[you]){
      if (y[me] ==y[you] || y[me]-1==y[you])return CONNECT;
    }else if ( x[me]-1==x[you]){
      if (y[me] ==y[you] || y[me]+1 == y[you])return CONNECT;
    }

    return UNCONNECT;
  }

  bool can_good_pos(int cur){
    rep(i,cur-1){
      if ( is_connected(cur,i)==CONNECT)return false;//©ªÌOÈOÌâÂÆÂÈªÁÄ¢éÌÅ¾ßB
    }
    if (cur==0 ||  is_connected(cur,cur-1)==CONNECT)return true;//©ªÆOÌâÂÆÂÈªÁÄ¢éÌÅ¨
    return false;
  }
  bool make_next(int now,set<state>&S,bool flag,set<pair<int,int> > & NG);

  
  bool operator<(const state & a)const{
    rep(i,len){
      if ( x[i]!=a.x[i])return x[i]<a.x[i];
      if ( y[i]!=a.y[i])return y[i]<a.y[i];
    }
    return false;
  }
  
};
state Q[200000];
int qp,qt;


  bool state::make_next(int now,set<state>&S,bool flag,set<pair<int,int> > & NG){
    if ( now == len){
      if ( S.find((*this))==S.end()){
	cnt++;
	if ( x[0]==gx && y[0]==gy)return true;
	S.insert(*this);
	Q[qt++]=(*this);
	cnt--;
      }
      return false;
    }

    //don't move
    
    if (can_good_pos(now) ){
      if (make_next(now+1,S,CANMOVE,NG))return true;
    }

    if ( flag == CANNOTMOVE)return false;//OÌª®¢Ä½ç©ªÍ®¯È¢

    rep(i,6){
      x[now]+=dx[i];
      y[now]+=dy[i];
      if (NG.find(mp(x[now],y[now])) == NG.end() && can_good_pos(now)){
	if (make_next(now+1,S,CANNOTMOVE,NG))return true;//©ªª®¢½çÌÍ®¯È¢B
      }
      x[now]-=dx[i];
      y[now]-=dy[i];
    }
    return false;
  }



int bfs(state ini,int dx,int dy,set<pair<int,int> > &NG){
  set<state> S;
  Q[qt++]=ini;
  S.insert(ini);
  while(qp<qt){
    if (20<Q[qp].cnt+(max(Q[qp].x[0],dx)-min(Q[qp].x[0],dy)+max(Q[qp].y[0],dy)-min(Q[qp].y[0],dy))/2){qp++;continue;}
    if ( Q[qp].x[0]==dx && Q[qp].y[0]==dy){
      return Q[qp].cnt;
    }
    if ( Q[qp].make_next(0,S,CANMOVE,NG)){
      return Q[qp].cnt;
    }
    qp++;
  }
  return -1;
}


main(){
  int n,m,dx,dy;
  while(scanf("%d",&n)!=-1 && n){
    state ini;
    set<pair<int,int> > NG;
    
    ini.len=n;
    ini.cnt=0;
    rep(i,n)scanf("%d%d",&ini.x[i],&ini.y[i]);
    scanf("%d",&m);
    rep(i,m){
      int f,s;
      scanf("%d%d",&f,&s);
      NG.insert(mp(f,s));
    }
    scanf("%d%d",&dx,&dy);
    gx=dx;gy=dy;
    qp=0;qt=0;
    cout << bfs(ini,dx,dy,NG)<<endl;
  }
  return false;
}

Measured memory_bytes: 18000
// IO library
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>

// container library
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

// namespace
using namespace std;

// typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VB> VVB;

// conversion
#define INT(c) static_cast<int>(c)
#define CHAR(n) static_cast<char>(n)
#define LL(n) static_cast<ll>(n)

// container
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define SORT(c) sort((c).begin(), (c).end())
#define GSORT(c) sort((c).begin(), (c).end(), greater<decltype((c).front())>())
#define SZ(x) (INT((x).size()))
#define MEMSET(c, v) memset((c), v, sizeof(c))

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define NREP(i, n) FOR(i, 1, n + 1)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n, 0)
#define RNREP(i, n) RFOR(i, n, 1)

// constant
// const ll MOD = 1e9 + 7;
// const int INF = 1<<25;
// const ll INF = 1LL<<50;
// const int dx[4] = {0, -1, 1, 0};
// const int dy[4] = {-1, 0, 0, 1};
// const int dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
// const int dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};

// debug
#define test(x) cout << #x << " = " << x << endl

// answer output
#define Yes(c) cout << ((c) ? "Yes" : "No") << endl;
#define YES(c) cout << ((c) ? "YES" : "NO") << endl;
#define yes(c) cout << ((c) ? "yes" : "no") << endl;

#define possible(c) cout << ((c) ? "possible" : "impossible") << endl;
#define POSSIBLE(c) cout << ((c) ? "POSSIBLE" : "INPOSSIBLE") << endl;


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


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

  int N;
  cin >> N;
  cout << N * 800 - N / 15 * 200 << endl;
  return 0;
}

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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;

#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(n) begin(n),end(n)

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 (b<a) { a=b; return 1; } return 0; }

#define DEBUG

int main()
{
	ios::sync_with_stdio(false); cin.tie(0);
	int x,t;
	cin >> x >> t;

	int ans = x - t;
	if(ans < 0) cout << 0 << endl;
	else cout << x - t << endl;
	return 0;
}

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

using namespace std;

int n,D1,D2,sign1[700][700],sign2[700][700];
int dir[4][2]={{1,-1},{1,1},{-1,1},{-1,-1}},ct[4];
vector<pair<int,int> > V1,V2;
int main()
{
	cin >> n >> D1 >> D2;
	for(int j=0;j*j<=D1;j++)
	{
		int t=D1-j*j;
		int x=sqrt(t);
		while((x+1)*(x+1)<=t) x++;
		while(x*x>t) x--;
		if(x*x==t) V1.push_back(make_pair(j,x));
	}
	for(int j=0;j*j<=D2;j++)
	{
		int t=D2-j*j;
		int x=sqrt(t);
		while((x+1)*(x+1)<=t) x++;
		while(x*x>t) x--;
		if(x*x==t) V2.push_back(make_pair(j,x));
	}
	memset(sign1,-1,sizeof sign1);
	memset(sign2,-1,sizeof sign2);
	queue <int> q;
	for(int i=0;i<2*n;i++) for(int j=0;j<2*n;j++)
		if(sign1[i][j]==-1)
		{
			q.push(i); q.push(j);
			sign1[i][j]=0; while(!q.empty())
			{
				int sx=q.front(); q.pop();
				int sy=q.front(); q.pop();
				for(int t=0;t<V1.size();t++) for(int k=0;k<4;k++)
				{
					int vx=sx+V1[t].first*dir[k][0];
					int vy=sy+V1[t].second*dir[k][1];
					if(vx<0||vy<0||vx>2*n||vy>2*n) continue;
					if(sign1[vx][vy]!=-1) continue;
					sign1[vx][vy]=sign1[sx][sy]^1; q.push(vx); q.push(vy);
				}
			}
		}

	for(int i=0;i<2*n;i++) for(int j=0;j<2*n;j++)
		if(sign2[i][j]==-1)
		{
			q.push(i); q.push(j);
			sign2[i][j]=0; while(!q.empty())
			{
				int sx=q.front(); q.pop();
				int sy=q.front(); q.pop();
				for(int t=0;t<V2.size();t++) for(int k=0;k<4;k++)
				{
					int vx=sx+V2[t].first*dir[k][0];
					int vy=sy+V2[t].second*dir[k][1];
					if(vx<0||vy<0||vx>2*n||vy>2*n) continue;
					if(sign2[vx][vy]!=-1) continue;
					sign2[vx][vy]=sign2[sx][sy]^1; q.push(vx); q.push(vy);
				}
			}
		}

	for(int i=0;i<2*n;i++) for(int j=0;j<2*n;j++) 
		ct[sign1[i][j]*2+sign2[i][j]]++;
	for(int z=0;z<=3;z++) if(ct[z]>=n*n)
	{
		int cnt=0; for(int i=0;i<2*n&&cnt<n*n;i++) 
			for(int j=0;j<2*n&&cnt<n*n;j++)
				if(sign1[i][j]*2+sign2[i][j]==z) 
					printf("%d %d\n",i,j),cnt++;
		if(cnt!=n*n) assert(0); 
		return 0;
	}
	return 0;
}

Measured memory_bytes: 5504
import java.util.Scanner;

public class Main
{

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int i = 1;
		while(true){
			if(sc.nextInt() == 0){
				System.out.println(i);
				return;
			}
			i++;
		}
	}

}


Measured memory_bytes: 26928
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;

constexpr ll MOD = (ll)1e9 + 7;
constexpr ll MOD2 = 998244353;
constexpr ll HIGHINF = (ll)1e18;
constexpr ll LOWINF = (ll)1e15;
constexpr long double PI = 3.1415926535897932384626433;

template<typename T> vector<T> make_v(size_t N,T init){return vector<T>(N,init);}
template<typename... T> auto make_v(size_t N,T... t){return vector<decltype(make_v(t...))>(N,make_v(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max<T>(a,b);}
template <class T> void chmin(T& a, const T b){a=min<T>(a,b);}
void YN(bool flg) {cout << ((flg) ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << ((flg) ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << ((flg) ? "yes" : "no") << endl;}


int main() {
	int N; cin >> N;
	V<ll> A(N); for(int i = 0; i < N; ++i) cin >> A[i];
	V<ll> B(N,0);
	for(int i = 0; i < N; ++i) B[0] += A[i]*(i%2?-1:1);
	B[0] /= 2;
	for(int i = 1; i < N; ++i) B[i] = A[i-1] - B[i-1];
	for(int i = 0; i < N; ++i) B[i] *= 2LL;
	for(int i = 0; i < N; ++i) cout << B[i] << " ";
	cout << endl;

	




    return 0;
}


Measured memory_bytes: 2944
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <deque>
#include <numeric>
using namespace std;

#define INF 1e9+7;

int S(int n) {
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}

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

    cout << ((N%S(N)==0)?"Yes":"No") << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <set>
#include <algorithm>
#include <functional>

using namespace std;


int main(void){
    int H,W,N;
    scanf("%d%d%d",&H,&W,&N);
    vector<vector<int> > syogai;
    syogai.resize(W);
    for(int i=0;i<W;i++)syogai[i].push_back(H);
    set<pair<int,int> > po;
    for(int i=0;i<W;i++)po.insert(make_pair(H,i));
    for(int i=0;i<N;i++){
        int x,y;
        scanf("%d%d",&x,&y);
        x--;y--;
        syogai[y].push_back(x);
        po.insert(make_pair(x,y));
    }
    for(int i=0;i<W;i++)sort(syogai[i].begin(),syogai[i].end());
    int x=0,y=0;
    int ans=1145141919;
    while(1){
        //printf("%d %d\n",x,y);
        if(po.find(make_pair(x+1,y))!=po.end()){
            ans=min(ans,x+1);
            //if(ans==1)printf("%d%d\n",x,y);
            break;
        }
        else x++;
        if(po.find(make_pair(x,y+1))==po.end()){
            ans=min( ans, syogai[y][ lower_bound(syogai[y].begin() , syogai[y].end() , x )-syogai[y].begin() ] );
            //if(ans==1)printf("%d%d\n",x,y);
            if(y+1==W)break;
            else y++;
        }
        //if(ans==1)printf("%d%d\n",x,y);
    }
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 30336
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

pocket = [A,B,C,D,E]

a = 10 - A % 10
b = 10 - B % 10
c = 10 - C % 10
d = 10 - D % 10
e = 10 - E % 10

def func(x):
    if x == 10 :
        x = 0
    return x

a = func(a)
b = func(b)
c = func(c)
d = func(d)
e = func(e)
    
    
get = [a,b,c,d,e]

z = 0
k = 0 # 指摘するlist。こいつを最後に持っていく。
for i in  range(5):
    if z < get[i]:
        z = get[i]
        k = i
        
A_ = A + a
B_ = B + b
C_ = C + c
D_ = D + d
E_ = E + e

pocket_ = [A_, B_, C_, D_, E_]

print(sum(pocket_) - pocket_[k] + pocket[k])

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    string s;
    cin >> s;
    int n = s.size();
    vector<int> ans(n);
    int p = 0;
    int r = 0;
    for (int i = 0; i < n-1; ++i) {
        if(s[i] == 'R' && s[i+1] == 'L'){
            int l = i+1;
            while(l < n && s[l+1] == 'L') l++;
            for (int j = r; j <= l; ++j) {
                if(j%2 == i%2) ans[i]++;
                else ans[i+1]++;
            }
            r = l+1;
            i = l;
        }
    }
    for (int i = 0; i < n; ++i) {
        if(i) printf(" ");
        printf("%d", ans[i]);
    }
    puts("");
    return 0;
}

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

using namespace std;

#define PB push_back
#define f first
#define s second
#define what_is(x) cerr << #x << " is " << x << endl;

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

const int INF = 1000000007;
const ll MOD = 1000000007;

const int N = 1000005;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n, x, t;
    cin >> n >> x >> t;
    cout << t * ((n+x-1)/x);
    return 0;
}


Measured memory_bytes: 3688
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<queue>
#define int long long
#define mod (int)(1000000007)
using namespace std;
int test[213456]; string uiop[213456];
signed main() {
	int n, a, b = 0, c = 1234567890, ans = 0; string s, t, u;
	cin >> s;
	for (int h = 0; h < s.size(); h++) {
		cout << 'x';
	}
	cout << endl;
}

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

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

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

long long INF=LLONG_MAX;

int a[3];

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	int n,m,pos,val;
	cin >> n >> m;
	a[0] = a[1] = a[2] = -1;
	for(int i = 0; i < m; i++){
		int x,y;
		cin >> x >> y;
		x--;
		if(n>1&&x==0&&y==0){
			cout << -1 << endl;
			return 0;
		}
		if(a[x]!=-1&&a[x]!=y){
			cout << -1 << endl;
			return 0;
		}
		a[x]=y;
	}
	if(n==1){
		if(a[0]==-1)a[0]=0;
	}else{
		if(a[0]==-1)a[0]=1;
		if(n>1&&a[1]==-1)a[1]=0;
		if(n>2&&a[2]==-1)a[2]=0;
	}
	for(int i=0; i<n; i++)cout << a[i];
}	


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

const long M = 1046527;
const long NIL = -1;
const long L = 14;

string H[M];

long getChar(char ch){
	if (ch == 'A') return 1;
	else if (ch == 'C') return 2;
	else if (ch == 'G') return 3;
	else if (ch == 'T') return 4;
	else return 0;
}

long getKey(string str){
	long sum = 0, p = 1, i;
	for (long i = 0; i < str.size(); i++){
		sum += p * (getChar(str[i]));
		p *= 5;
	}
	return sum;
}

long h1(long key){return key % M;}
long h2(long key){return 1 + (key % (M - 1));}

long find(string str){
	long long key, h;
	key = getKey(str);
	for (long i = 0; ; i++){
		h = (h1(key) + i * h2(key)) % M;
		if (H[h] == str) return 1;
		else if (H[h].size() == 0) return 0;
	}
	return 0;
}

long insert(string str){
	long long key, h;
	key = getKey(str);
	for (long i = 0; ; i++){
		h = (h1(key) + i * h2(key)) % M;
		if (H[h] == str) return 1;
		else if (H[h].size() == 0){
			H[h] = str;
			return 0;
		}
	}
}

int main(){
	long n, h;
	string str, com(9, 'a');
	cin >> n;
	for (long i = 0; i < n; i++){
		cin >> com >> str;
		if (com[0] == 'i') insert(str);
		else {
			if (find(str)) cout << "yes" << endl;
			else cout << "no" << endl;
		}
	}
	return 0;
}

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

using namespace std;

const int N = 1e5 + 5;
pair<int, int> r[N];

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d %d", &r[i].first, &r[i].second);
  }
  sort(r, r+n);
  multiset<int> lef, rig;
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    lef.insert(r[i].first);
    rig.insert(r[i].second);
  }
  for (int i = 0; i < n; ++i) {
    lef.erase(lef.find(r[i].first));
    rig.erase(rig.find(r[i].second));
    ans = max(ans, r[i].second - r[i].first + 1 + max(0, *rig.begin() - *lef.rbegin() + 1));
    lef.insert(r[i].first);
    rig.insert(r[i].second);
  }
  int rmost = 1e9 + 7;
  for (int i = 0; i + 1 < n; ++i) {
    rmost = min(rmost, r[i].second);
    lef.erase(lef.find(r[i].first));
    rig.erase(rig.find(r[i].second));
    ans = max(ans, max(0, rmost - r[i].first + 1) + max(0, *rig.begin() - *lef.rbegin() + 1));
  }
  printf("%d\n", ans);
  return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<double> t(N), v(N);
  for (int i = 0; i < N; i++) cin >> t[i];
  for (int i = 0; i < N; i++) cin >> v[i];

  t.insert(t.begin(), 0);
  for (int i = 0; i < N; i++) t[i+1] += t[i];
  t.insert(t.begin(), 0);
  t.insert(t.end(), t.back());

  v.insert(v.begin(), 0);
  v.insert(v.end(), 0);

  double prevSpeed = 0, ans = 0;
  for (double time = 0.5; time <= t.back(); time += 0.5) {
    double speed = 100;
    for (int i = 0; i <= N+1; i++) {
      if (time < t[i])
        speed = min(speed, v[i] + (t[i] - time));
      else if (time > t[i+1])
        speed = min(speed, v[i] + (time - t[i+1]));
      else
        speed = min(speed, v[i]);
    }
    ans += 0.25 * (prevSpeed + speed);
    prevSpeed = speed;
  }
  cout << fixed << setprecision(3) << ans << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <vector>

#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define STRS(i,str) for(int i=0;(str)[i];i++)
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define MAX3(a,b,c) ((a)>(b)?(a)>(c)?(a):(c):(b)>(c)?(b):(c))
#define MIN3(a,b,c) ((a)<(b)?(a)<(c)?(a):(c):(b)<(c)?(b):(c))
#define MED(a,b,c) ((a)<(b)?(a)>(c)?(a):(b)<(c)?(b):(c):(a)>(c)?(b)<(c)?(c):(b):(a))
#define RANGE(a,b) ((a)>(b)?(a)-(b):(b)-(a))
#define RANGE3(a,b,c) ((a)>(b)?(b)>(c)?(a)-(c):(c)>(a)?(c)-(b):(a)-(b):(b)>(c)?(c)>(a)?(b)-(a):(b)-(c):(c)-(a))
#define MAXI(a,b) if(a<b)a=b;
#define MINI(a,b) if(a>b)a=b;
#define BEGINFOR(a,b,c,d,e,f,g,h,i) a;goto i##_6;i##_2:c;goto i##_6;i##_3:h;goto i##_7;i##_4:d;goto i##_8;i##_5:f;goto i##_8;i##_6:if(b)goto i##_4;else goto i##_9;i##_7:if(g)goto i##_5;else goto i##_1;i##_8:if(e)goto i##_2;else goto i##_3;i##_9:
#define CONTINUE(i) goto i##_3
#define BREAK(i) goto i##_1
#define ENDFOR(i) goto i##_3;i##_1:

using ull = unsigned long long;

int main(void) {
	char a, b, c, d;
	a = getchar() - '0';
	b = getchar() - '0';
	c = getchar() - '0';
	d = getchar() - '0';
	if (a + b + c + d == 7) {
		putchar(a + '0');
		putchar('+');
		putchar(b + '0');
		putchar('+');
		putchar(c + '0');
		putchar('+');
		putchar(d + '0');
		puts("=7");
	} else if (a + b + c - d == 7) {
		putchar(a + '0');
		putchar('+');
		putchar(b + '0');
		putchar('+');
		putchar(c + '0');
		putchar('-');
		putchar(d + '0');
		puts("=7");
	} else if (a + b - c + d == 7) {
		putchar(a + '0');
		putchar('+');
		putchar(b + '0');
		putchar('-');
		putchar(c + '0');
		putchar('+');
		putchar(d + '0');
		puts("=7");
	}
	else if (a + b - c - d == 7) {
		putchar(a + '0');
		putchar('+');
		putchar(b + '0');
		putchar('-');
		putchar(c + '0');
		putchar('-');
		putchar(d + '0');
		puts("=7");
	}else if (a - b + c + d == 7) {
		putchar(a + '0');
		putchar('-');
		putchar(b + '0');
		putchar('+');
		putchar(c + '0');
		putchar('+');
		putchar(d + '0');
		puts("=7");
	}
	else if (a - b + c - d == 7) {
		putchar(a + '0');
		putchar('-');
		putchar(b + '0');
		putchar('+');
		putchar(c + '0');
		putchar('-');
		putchar(d + '0');
		puts("=7");
	}
	else if (a - b - c + d == 7) {
		putchar(a + '0');
		putchar('-');
		putchar(b + '0');
		putchar('-');
		putchar(c + '0');
		putchar('+');
		putchar(d + '0');
		puts("=7");
	}
	else if (a - b - c - d == 7) {
		putchar(a + '0');
		putchar('-');
		putchar(b + '0');
		putchar('-');
		putchar(c + '0');
		putchar('-');
		putchar(d + '0');
		puts("=7");
	}
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    int i,j,k,m,n;
    int x,a,b;
    cin>>x>>a>>b;
    if(b-a<=0)
        cout<<"delicious"<<endl;
    else if(x>=b-a)
        cout<<"safe"<<endl;
    else if(b-a>x)
        cout<<"dangerous"<<endl;
 
    return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
max = max(a)
min = min(a)
cost_min = n * (max - min)**2
for m in range(min, max+1):
    cost = 0
    for x in a:
        cost += (x - m)**2
    if cost < cost_min:
        cost_min = cost
print(cost_min)

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

int main(){
    unsigned long long a,b,x;
    cin >> a >> b >> x;

    // unsigned long long val[b-a];
    // unsigned long long res;
    unsigned long long counter = 0;

    // for (unsigned long long i = 0; i < b-a; i++){
    //     if(i==0) val[i] = a;
    //     else val[i] = a + i;
    //     res = val[i] % x;
    //     if(res == 0) counter ++;
    // }
    
    if (a-1 != -1) counter = b / x - (a-1) / x;
    else counter = b / x + 1;

    cout << counter << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define sz(x) (int)(x).size()
using namespace std;

int binpow(int a, int b) {
    if (b == 0)
        return 1;
    int res = binpow(a, b / 2);
    if (b % 2)
        return res * res * a;
    else
        return res * res;
}

ll gcd(ll a,ll b)
{
    if (b==0) return a;
    return gcd(b,a%b);
}
string to_upper(string a)
{
    for (int i=0;i<(int)a.size();++i) if (a[i]>='a' && a[i]<='z') a[i]-='a'-'A';
    return a;
}
 
string to_lower(string a)
{
    for (int i=0;i<(int)a.size();++i) if (a[i]>='A' && a[i]<='Z') a[i]+='a'-'A';
    return a;
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n;
    cin>>n;
    for (int i=1;i<10;++i)
    {
        for (int j=1;j<10;++j)
        {
            if (n==i*j)
            {
                cout<<"Yes";
                return 0;
            }
        }
    }
    cout<<"No";
    return 0;
}

Measured memory_bytes: 256
// clang-format

#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;

using lli = long long int;

void solve(long long A, long long B) {
  int a[3] = {};
  a[A-1] = a[B-1] = 1;
  rep(i,3)if(!a[i]) cout << i + 1 << endl;
}

int main() {
  int a;
  long long A;
  scanf("%lld", &A);
  long long B;
  scanf("%lld", &B);
  solve(A, B);
  return 0;
}


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

long long N;
void func(long long cur,int use ,long long &ans){
  if(cur>N) return;
  if(use == 0b111) ans++;
  
  func(cur*10+3,use | 0b001,ans);
  func(cur*10+5,use | 0b010,ans);
  func(cur*10+7,use | 0b100,ans);
}
int main(){
  cin >>N;
  long long res=0;
  func(0,0,res);
  cout << res << endl;
}

Measured memory_bytes: 256
N=int(input())
T=[int(i) for i in input().split()]
M=int(input())
P=[0 for i in range(M)]
X=[0 for i in range(M)]
for i in range(M):
    P[i],X[i]=map(int,input().split())
    P[i]-=1
S=sum(T)
for i in range(M):
    print(S-T[P[i]]+X[i])


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

int main(){
  long n;
  long cnt=0;
  cin >> n;
  long a[n],b[n],c[n];
  for(int i=0;i<n;i++) cin >> a[i];
  for(int i=0;i<n;i++) cin >> b[i];
  for(int i=0;i<n;i++) cin >> c[i];
  sort(a,a+n);
  sort(b,b+n);
  sort(c,c+n);
  for(int i=0;i<n;i++){
    long d = lower_bound(a,a+n,b[i])-a;
    long e = upper_bound(c,c+n,b[i])-c;
    cnt+=d*(n-e);
  }
  cout << cnt << endl;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  int qwe=0;
  bool w;
  if(s.at(0) == 'W'){
    w = 1;
  }else{
    w = 0;
  }
  for(int i=1; i<s.size(); i++){
    if(w){
      if(s.at(i) == 'B'){
        w=!w;
        qwe++;
      }
    }else{
      if(s.at(i) == 'W'){
        w=!w;
        qwe++;
      }
    }
  }
  cout << qwe << endl;
}

Measured memory_bytes: 512
#include <iostream> 
#include <cstdio> 
#include <fstream> 
#include <algorithm> 
#include <cmath> 
#include <deque> 
#include <vector> 
#include <queue> 
#include <string> 
#include <cstring> 
#include <map> 
#include <stack> 
#include <set>
using namespace std;
//int path[1010][1010] = {0};
const int &INF = 100000000;
void floyd (vector<vector<int> > &d, int NODE /* , vector<vector<int> > &path */ ) {
	//const int &NODE = distmap.size();
	//path.assign(NODE, vector<int>(NODE, -1));
	for (int k=1; k<=NODE; ++k)
		for (int i=1; i<=NODE; ++i)
			for (int j=1; j<=NODE; ++j)
				d[i][j] = min(d[i][k] + d[k][j], d[i][j]);
}

int tmp = 0, num = 0, pn = 0;
/*
void print (const int &beg, const int &end, const vector<vector<int> > &path) {
	if (path[beg][end] >= 0) {
		print(beg, path[beg][end], path);
		print(path[beg][end], end, path);
	}
}

void swap (int &a, int &b) {
	if (a > b) {
		tmp = a;
		a = b;
		b = tmp;
	}
}
void dopath (int &a, int &b, int &c) {
	swap (a, b);
}
 */
int main() {
	int n, m, a, b, c, beg, end;
	cin >> n >> m;
	vector<vector<int> > da(n+10, vector<int> (n+10, INF)), db(n+10, vector<int> (n+10, INF));
	for (int s = 0; s < m; s++) {
		cin >> a >> b >> c;
		da[a][b] = min(c, da[a][b]);
		da[b][a] = min(c, da[b][a]);
		db[a][b] = min(c, db[a][b]);
		db[b][a] = min(c, db[b][a]);
	}
	floyd(da, n);
	for (int s = 1; s <= n; s++)
		for (int fs = 1+s; fs <= n; fs++)
			if (db[s][fs] != INF && da[s][fs] != db[s][fs])
				num++;
	cout << num;
	return 0;
}


Measured memory_bytes: 384
N=int(input())
#N=100
nlist=list(range(1,N+1))
import math
def getmax(n):
    logscale=int(math.log10(n))
    kurai=int(n/(10**logscale))
    return kurai
def getmin(n):
    return int(n%10)

profile=[]
for n in nlist:
    profile.append([getmin(n),getmax(n)])
#print(profile)
counter=0
for i in range(1,10):
    for j in range(1,10):
        ij=profile.count([i,j])
        ji=profile.count([j,i])
        counter+=ij*ji

print(counter)

Measured memory_bytes: 31348
#include <iostream>
#include <vector>
using namespace std;
struct X{
	int id;
	bool pushFlag;
	X(int _id,bool _pushFlag){
		id=_id;
		pushFlag=_pushFlag;

	}
};
int main(int argc, char* argv[])
{
	int N;
	cin>>N;
	int i;
	vector<X> A;
	int a1;
	for (i=0;i<N;i++){
		cin>>a1;
		A.push_back(X(a1,false));
	}
	i=0;
	int aw=0;
	if (A[0].id==2){
		cout<<1<<endl;
		return 0;
	}
	A[0].pushFlag=true;
	aw++;
	i=A[0].id-1;
	while (true){
		if (A[i].id==2){
			aw++;
			cout<<aw<<endl;
			return 0;
		}
		if (A[i].pushFlag){
			cout<<-1<<endl;
			return 0;
		}
		A[i].pushFlag=true;
		aw++;
		i=A[i].id-1;
	}

	
	return 0;
}

Measured memory_bytes: 1400
n = gets.to_i
a = gets.to_i
b = gets.to_i
c = gets.to_i
d = gets.to_i
e = gets.to_i

array = [a,b,c,d,e].sort
min = 5

puts array[0] == 1 ? n -1 + min : n/array[0] + min

Measured memory_bytes: 1916
#include<stdio.h>
int main(void)
{
    int a,b,c;
  int d;
  
 
    // スペース区切りの整数の入力
    scanf("%d %d %d",&a,&b,&c);
 
    // 出力
  if(a-b<c){
    d = c -(a-b);
   
  }else{
    d = 0;
  }
   printf("%d",d);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    char s[10010];
    scanf("%d %s",&n,s);
    int len = strlen(s);
    for(int i=0;i<len;i++){
        int x=s[i]-'A';
        x= (x+n)%26;
        s[i] = 'A'+x;
        printf("%c",s[i]);
    }
    printf("\n");
}

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

struct employee {
    int id;
    int price;
    int quantity;

    int total_sales() const {
        return price * quantity;
    }
};

employee read_employee(std::istream& in) {
    employee e{};
    in >> e.id >> e.price >> e.quantity;
    return e;
}

int main() {
    while (std::cin) {
        std::vector<employee> employees;
        int num;
        std::cin >> num;
        if (num <= 0)
            continue;
        for (int i = 0; i < num; ++i) {
            if (!std::cin) {
                std::cerr << "malformed input\n";
                std::exit(1);
            }
            auto e = read_employee(std::cin);
            employees.push_back(e);
        }
        std::vector<int> checked_ids;
        bool na = true;
        for (auto const& employee: employees) {
            if (std::find(checked_ids.begin(), checked_ids.end(), employee.id) != checked_ids.end())
                continue;
            checked_ids.push_back(employee.id);
            int sum = 0;
            for (auto const& e: employees) {
                if (e.id == employee.id)
                    sum += e.total_sales();
            }
            if (sum >= 1000000) {
                std::cout << employee.id << '\n';
                na = false;
            }
        }
        if (na)
            std::cout << "NA\n";
    }
}



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

signed main() {
  int n, k; cin >> n >> k;
  int ans = 0;
  for(int i = 0; i < n; i++) {
    int x; cin >> x;
    ans += 2*min(abs(x), abs(x-k));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>
using namespace std;
long long n,k,ans=3999999996000000001,mn,mnl,num;
pair<int,int>p[55];
int main()
{
	cin>>n>>k;
	for(int i=0;i<n;i++)
	{
		cin>>p[i].first>>p[i].second;
	}
	sort(p,p+n);
	for(int i=0;i<n;i++)
	{
		for(int j=i+k-1;j<n;j++)
		{
			vector<int>v;
			for(int l=i;l<=j;l++)
			{
				v.push_back(p[l].second);
			}
			sort(v.begin(),v.end());
			mn=v[k-1]-v[0];
			for(int l=0;l<v.size();l++)
			{
				for(int o=l+k-1;o<v.size();o++)
				{
					mnl=v[o]-v[l];
					mn=min(mn,mnl);
				}
			}
			num=mn*(p[j].first-p[i].first);
			ans=min(ans,num);
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import math

def get_input():
    while True:
        try:
            yield ''.join(input())
        except EOFError:
            break

while True:
    q = int(input())
    if q == -1:
        break

    x = 0.0
    x_pre = q / 2.0
    while True:
        x =  x_pre - (x_pre**3 - q) / (3 * x_pre**2)
        if abs(x**3 - q) < 0.00001*q:
            print(x)
            break
        x_pre = x




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

#define DEBUG(x) cerr << #x << ": " << x << endl;
#define ll long long

const int MOD = 1e9+7;

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

    ll power = 1;
    for (int i = 1; i <= n; i++) {
        power = power * i % MOD;
    }

    cout << power << endl;

    return 0;
}

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

using namespace std;
const int maxn = 1e5 + 1000;
const int mod = 1e9 + 7;
int s[maxn],t[maxn];
string str;
int main() {
    std::ios::sync_with_stdio(false);
    int te;
    cin>>str;
    for(int i=0;str[i];i++){
        if(str[i]=='A') s[i+1]=s[i]+1;
        else s[i+1]=s[i]+2;
    }
    cin>>str;
    for(int i=0;str[i];i++){
        if(str[i]=='A') t[i+1]=t[i]+1;
        else t[i+1]=t[i]+2;
    }
    int n;
    int a,b,c,d;
    cin>>n;
    for(int i=0;i<n;i++) {
        cin>>a>>b>>c>>d;
        if(((s[b]-s[a-1])-(t[d]-t[c-1]))%3==0){
            cout<<"YES"<<endl;
        }
        else {
            cout<<"NO"<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 1616
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <ctype.h>
using namespace std;
int main(void){
int A,B;
cin>>A>>B;
char str[A+B];
cin>>str;
int c;
int ans=0;
for(int i=0;i<A+B+1;i++){
   c=isdigit(str[i]) ;
   if(c!=0) ans++;
}
int a=0,b=0;
if(ans==A+B) a=1;
if(str[A]=='-') b=1;
if(a==1&&b==1) cout<<"Yes";
else cout<<"No";
return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
	char S[6];
	scanf("%s", S);
	
	if(S[0] == 'S'){
		printf("Cloudy");
	}

	else if(S[0] == 'C'){
		printf("Rainy");
	}

	else{
		printf("Sunny");
	}

	
	return 0;
	
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String s = String.valueOf(n);
    int aa = s.length();
    int[] a = new int[aa];
    int ss = 0;
    for(int i = 0;i<aa;i++){
      a[i] = Integer.parseInt(s.substring(i,i+1));
      ss += a[i];
    }
    if(n % ss == 0){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 35584
#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue>
using namespace std;
typedef pair<int,int> P;
bool f[200][200];
int tbl[200][200];

int dx[] = {-1,-1,0,0,1,1};
int dy[] = {-1,0,-1,1,0,1};
int main(){
  int t,n;
  while(cin>>t>>n,t||n){
    memset(f,0,sizeof(f));
    memset(tbl,0,sizeof(tbl));
    queue<P> Q;
    for(int i=0;i<n;++i){
      int x,y;
      cin>>x>>y;
      x+=100;y+=100;
      f[x][y]=true;
    }
    int sx,sy;
    cin >> sx >> sy;
    sx+=100;sy+=100;
    Q.push(P(sx,sy));
    int cnt = 1;
    f[sx][sy] = true;
    while(!Q.empty()){
      P p = Q.front(); Q.pop();
      if(tbl[p.first][p.second]>=t) continue;
      for(int i=0;i<6;++i){
	int mx = p.first + dx[i];
	int my = p.second + dy[i];
	if(!f[mx][my] && !tbl[mx][my]){
	  ++cnt;
	  Q.push(P(mx,my));
	  tbl[mx][my] = tbl[p.first][p.second]+1;
	}
      }
    }
    cout << cnt << endl;
  }
  return 0;
}

Measured memory_bytes: 1420
// AtCoder template
// sabaより胡蝶しのぶさんの方が可愛いのではないか？
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < n; ++i)

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

    int x,y,a,b,c; cin >> x >> y >> a >> b >> c;
    vector<ll> p(a),q(b),r(c);
    rep(i,a) cin >> p[i];
    rep(i,b) cin >> q[i];
    rep(i,c) cin >> r[i];
    sort(p.begin(), p.end(), greater<ll>());
    sort(q.begin(), q.end(), greater<ll>());
    sort(r.begin(), r.end(), greater<ll>());

    priority_queue<ll, vector<ll>, greater<ll>> que;
    rep(i,x) que.emplace(p[i]);
    rep(i,y) que.emplace(q[i]);

    rep(i,c){
        if(que.top() >= r[i]) break;
        que.pop();
        que.push(r[i]);
    }
    
    ll ans = 0LL;
    while(!que.empty()){
        ans += que.top();
        que.pop();
    }
    cout << ans << endl;
}

Measured memory_bytes: 5368