akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define pb push_back
#define mkp make_pair
#define llu unsigned long long int
#define ll long long
#define ld long double
#define foi(a,n) for(int i = a; i < n; i++)
#define foj(a,n) for(int j = a; j < n; j++)
#define foin(a,n) for(int i = n; i >= a; i--)
#define fojn(a,n) for(int j = n; j >= a; j--)
#define isp2(x) x&&(!(x&(x-1)))
#define ee 1000000007
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define cases long long t;cin>>t;while(t--)

using namespace std;

int n;
int a[100002];
int dp[100002];
int mn(int i){
	if(i == n - 2){
		return abs(a[n-1] - a[n-2]);
	}
	if(i == n-1){
		return 0;
	}
	if(dp[i] != -1){
		return dp[i];
	}
	return dp[i] = min(mn(i+1) + abs(a[i] - a[i+1]), mn(i+2) + abs(a[i] - a[i+2]));
}

int main() {
    ll q, m, x, y, d;
    string s, h;
	cin >> n; 
	foi(0, n) {
		cin >> a[i];
		dp[i] = -1;
		dp[i+1] = -1;
	}
	
	a[n] = a[n-1];
	cout << mn(0);

}




Measured memory_bytes: 7452
#include <iostream>
using namespace std; 
int main() {  
  int a[3][6], time[3][2]={};
  for(int i=0; i<3; i++) { 
    for(int j=0; j<6; j++) {  
      cin >> a[i][j];  
      if(j==0) time[i][0]=a[i][j]*3600;  
      if(j==1) time[i][0]+=a[i][j]*60; 
      if(j==2) time[i][0]+=a[i][j];  
      if(j==3) time[i][1]=a[i][j]*3600;  
      if(j==4) time[i][1]+=a[i][j]*60;   
      if(j==5) time[i][1]+=a[i][j];  
    }   
    time[i][0] = time[i][1]-time[i][0]; 
  }  
  for(int i=0; i<3; i++) {  
    cout << time[i][0]/3600 << " " << (time[i][0]%3600)/60 << " " << time[i][0]%60 << endl; 
  } 
  return 0;
}


Measured memory_bytes: 1160
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//　ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const int mod=1000000007;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

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


// ll memo[2020][2020];
// int pascal_triangle(){
//   for(int i = 0; i < 2020; i++){
//     for(int j = 0; j < i+1; j++){
//       if(j == 0 || j == i) memo[i][j] = 1;
//       else{
// 	memo[i][j] = (memo[i-1][j-1]+memo[i-1][j]);
//       }
//     }
//   }
//   return 0;
// }


// int factrial(int n){
//   if(n == 0) return 1;
//   return n*factrial(n-1);
// }

// int divisor(int a){
//   int cnt = 0;
//   for(int i=1; i <= a; i++) if(a%i == 0) cnt++;
//   return cnt;
// }

// int comb(int n, int k){
//   return fact(n) / (fact(n-k)*fact(k));
// }

int a[55];

int main(){
  int N;
  cin >> N;
  rep(i,N){
    cin >> a[i];
  }
  int sum = 0;
  for(int i = 0; i < N; i++){
    for(int j = i+1; j < N; j++){
      sum += a[i]*a[j];
    }
  }
  cout << sum << endl;
}
  





Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int[][] map=new int[14][14];
		while(sc.hasNext()){
			String[] str=sc.next().split(",");
			int x=Integer.parseInt(str[0])+2;
			int y=Integer.parseInt(str[1])+2;
			int s=Integer.parseInt(str[2]);
			if(s==1){
				map[y-1][x]++;
				map[y][x-1]++;
				map[y][x]++;
				map[y][x+1]++;
				map[y+1][x]++;
			}
			if(s==2){
				for(int i=y-1;i<=y+1;i++){
					for(int j=x-1;j<=x+1;j++){
						map[i][j]++;
					}
				}
			}
			if(s==3){
				for(int i=y-1;i<=y+1;i++){
					for(int j=x-1;j<=x+1;j++){
						map[i][j]++;
					}
				}
				map[y-2][x]++;
				map[y][x-2]++;
				map[y][x+2]++;
				map[y+2][x]++;
			}
		}
		int count=0;
		int max=0;
		for(int i=2;i<12;i++){
			for(int j=2;j<12;j++){
				if(map[j][i]==0){
					count++;
				}
				if(map[j][i]>max){
					max=map[j][i];
				}
			}
		}
		System.out.println(count);
		System.out.println(max);
	}
}

Measured memory_bytes: 17164
#include <stdio.h>
 
#define N 100
 
int queue[N] = {};
int b = 0, e = 0;
int step[N] = {};

void ENQ(int);
int DEQ();
int isemp();
void clear();
void BFS(int[], int s, int n);

int main(int argc,char *argv)
{
    int n, i, j, k, l, m;
    int cnt = 0;
    int table[N*N] = {};
    scanf( "%d", &n );
 
    clear();
 
    for( i=0; i<n; ++i ) {
        scanf( "%d %d", &k, &l );
        for( j=0; j<l; ++j ) {
            scanf("%d", &m);
            table[((k-1)*N)+(m-1)] = 1;
        }
    }
 
    BFS( table, 1, n );
 
    for( i=0; i<n; ++i )
        printf("%d %d\n", i+1, step[i]);
 
    return 0;
}
void ENQ( int m ) {
    queue[b++] = m;
}
int DEQ() {
    return queue[e++];
}
int isemp() {
    return b == e;
}
 
void clear()
{
    int i;
    for( i=0; i<N; ++i ) {
        queue[i] = 0;
        step[i] = -1;
    }
    b = 0;
    e = 0;
}
 
void BFS( int table[], int s, int n )
{
    int u, v;
 
    ENQ( s - 1 );
    while( !isemp() ) {
        u = DEQ();
        if ( step[u] == -1 )
            step[u] = 0;
                     
        for( v=0; v<n; ++v ) {
            if ( table[u*N+v] == 1 && step[v] == -1 ) {
                step[v] = step[u] + 1;
                ENQ( v );
            }
        }
    }
}
 



Measured memory_bytes: 2024
#include<bits/stdc++.h>
#define eps 0.000000001
using namespace std;
typedef long double ld;
typedef pair<int,int> p;
typedef pair<ld,p> P;

int n;
ld px[200],py[200],pz[200],vx[200],vy[200],vz[200],r[200],vr[200];

ld getlen(ld x1,ld x2,ld y1,ld y2,ld z1,ld z2,ld r1,ld r2){
  ld dx=x2-x1,dy=y2-y1,dz=z2-z1;
  return sqrt(dx*dx+dy*dy+dz*dz)-(r1+r2);
}

ld check(int a,int b){
  ld mt=min(r[a]/vr[a],r[b]/vr[b]);
  ld L=0,R=mt,M;
  int s=0;
  while(s++<200){
    M=(L+R)/2;
    ld ax=px[a]+vx[a]*M,ay=py[a]+vy[a]*M,az=pz[a]+vz[a]*M,ar=r[a]-vr[a]*M;
    ld bx=px[b]+vx[b]*M,by=py[b]+vy[b]*M,bz=pz[b]+vz[b]*M,br=r[b]-vr[b]*M;
    ld M1=M+eps;
    ld ax1=px[a]+vx[a]*M1,ay1=py[a]+vy[a]*M1,az1=pz[a]+vz[a]*M1,ar1=r[a]-vr[a]*M1;
    ld bx1=px[b]+vx[b]*M1,by1=py[b]+vy[b]*M1,bz1=pz[b]+vz[b]*M1,br1=r[b]-vr[b]*M1;
    ld len=getlen(ax,bx,ay,by,az,bz,ar,br),len1=getlen(ax1,bx1,ay1,by1,az1,bz1,ar1,br1);
    if(len<len1||len<=0)R=M;
    else L=M;
  }
  ld ax=px[a]+vx[a]*R,ay=py[a]+vy[a]*R,az=pz[a]+vz[a]*R,ar=r[a]-vr[a]*R;
  ld bx=px[b]+vx[b]*R,by=py[b]+vy[b]*R,bz=pz[b]+vz[b]*R,br=r[b]-vr[b]*R;
  if(R==mt||L==0||getlen(ax,bx,ay,by,az,bz,ar,br)>0)return 1000;
  return R;
}

int main(){
  while(cin>>n,n){
    for(int i=0;i<n;i++)
      cin>>px[i]>>py[i]>>pz[i]>>vx[i]>>vy[i]>>vz[i]>>r[i]>>vr[i];
    priority_queue<P,vector<P>,greater<P> > q;
    for(int i=0;i<n;i++){
      for(int j=i+1;j<n;j++)
	q.push(P(check(i,j),p(i,j)));
      q.push(P(r[i]/vr[i],p(i,i)));
    }
    ld used[200]={};
    while(!q.empty()){
      ld t=q.top().first;
      int a=q.top().second.first,b=q.top().second.second;
      q.pop();
      if(used[a]||used[b])continue;
      used[a]=used[b]=t;
    }
    for(int i=0;i<n;i++)printf("%.10Lf\n",used[i]);
  }
  return 0;
}

Measured memory_bytes: 4548
// https://atcoder.jp/contests/abc068/tasks/abc068_b

import java.util.*;

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

        int N = sc.nextInt();
        //1以上100以下の整数の中で最も2で割れる回数が多いのは64(2^6)
        int ans = 64;

        //64以下の整数で、次に割れる回数が多いのは32(2^5)
        while( N < ans ) {
            ans /= 2;
        }

        System.out.println(ans);
    }
}

    


Measured memory_bytes: 22612
N=int(input())
A=[int(a) for a in input().split()]
ABS_SUM=sum(abs(a) for a in A)
ans=0
if 0 in A:
  ans=ABS_SUM
else:
  pal=sum(1 for a in A if a<0)
  if pal%2==0:
    ans=ABS_SUM
  else:
    ABS_MIN=min(abs(a) for a in A)
    ans=ABS_SUM-ABS_MIN*2
print(ans)

Measured memory_bytes: 14412
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(b);i>(a);--i)
#define eper(i,a,b) for(int i=((int)(a));i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF 2000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int n, sum;
int main() {
 ios::sync_with_stdio ( false );
 cin.tie ( 0 );
    cin >> n;
    string s = to_string(n);
    int tmp = n;
    while (tmp > 0) {
        sum += tmp % 10;
        tmp /= 10;
    }
    if (n % sum == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
# 配るdp
n = int(input())
h = list(map(int, input().split()))

# dp[i]で今までの計算結果を保存してる
dp = [float('inf')] * n
dp[0] = 0
for i in range(1, n):
    dp[i] = min(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]))
    if i > 1:
        dp[i] = min(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]))

print(dp[n - 1])


Measured memory_bytes: 52208
using System;

class C
{
	static void Main()
	{
		var h = Array.ConvertAll(Console.ReadLine().Split(), double.Parse);
		Console.WriteLine($"{h[0] * h[1] / 2} {(h[0] == 2 * h[2] && h[1] == 2 * h[3] ? 1 : 0)}");
	}
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define int long long
constexpr int gcd(int a, int b)
{
    return b ? gcd(b, a % b) : a;
}
constexpr int lcs(int a, int b) { return a / gcd(a, b)*b; }

int unity;

// 参考
// https://www.creativ.xyz/segment-tree-entrance-999/
// [a, b) クエリに対して ノード k [l, r) が解答する
int query(int a, int b, int k, int l, int r, vector<int> &segtree)
{
    if (r <= a || b <= l)
        return unity;
    if (a <= l && r <= b)
        return segtree[k];
    else
    {
        int c1 = query(a, b, 2 * k + 1, l, (l + r) / 2, segtree);
        int c2 = query(a, b, 2 * k + 2, (l + r) / 2, r, segtree);
        return gcd(c1, c2);
    }
}

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

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

    // 単位元
    unity = a[0];
    for (int i = 0; i < n; i++)
    {
        unity = lcs(a[i], unity);
    }

    // セグメントツリーが扱う数列のサイズは2の累乗だよ
    // n以上の最小の累乗を求めるよ
    int m = 1;
    while (m < n)
        m *= 2;

    // セグメントツリー作るよ 余った部分は単位元でうめるよ
    vector<int> segtree(m + m - 1, unity);
    // father: (i-1)/2
    // children: i*2, i*2+1
    // leaf: i+N-1

    // セグメントツリーの葉にa[i]を入れる一点更新をするよ
    for (int i = 0; i < n; i++)
    {
        int j = i + m - 1;
        segtree[j] = a[i];
        while (j > 0)
        {
            j = (j - 1) / 2;
            segtree[j] = gcd(segtree[j * 2 + 1], segtree[j * 2 + 2]);
        }
    }

    int ans = 1;
    for (int i = 0; i < n; i++)
    {
        // ある点より前，より後のGCDを求める
        int c1 = query(0, i, 0, 0, m, segtree);
        int c2 = query(i + 1, n, 0, 0, m, segtree);
        ans = max(gcd(c1, c2), ans);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3072
IDENTIFICATION DIVISION.
PROGRAM-ID. 122B.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 S   PIC X(11).
01 I   PIC 9(2).
01 CNT PIC 9(2).
01 MAX PIC 9(2).
01 OUT PIC Z9.
01 C   PIC X(1).
   88  ATC VALUE 'A' 'C' 'G' 'T'.
*>
PROCEDURE DIVISION.
  ACCEPT S.
  MOVE 0 TO CNT MAX.
  PERFORM VARYING I FROM 1 BY 1 
    UNTIL (I > 10) OR (S(I:1) = ' ')
    MOVE S(I:1) TO C
    IF ATC
      ADD 1 TO CNT
      IF (CNT > MAX)
        MOVE CNT TO MAX
      END-IF
    ELSE
      MOVE 0 TO CNT
    END-IF 
  END-PERFORM.  
*>
  MOVE MAX TO OUT.
  DISPLAY FUNCTION TRIM(OUT).
*>
  STOP RUN.


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long int
#define ve vector<int>
#define vl vector<long long int>
#define all(a) a.begin(),a.end()
using namespace std;

int main(){
  int x,y;
  cin>>x>>y;
  ll A=0;
  for(int i=1;i<=3;i++){
    if(x==i){
      A+=(400000-i*100000);
    }
    if(y==i){
      A+=(400000-i*100000);
    }
  }
  if(x==y&&x==1) A+=400000;
  cout<<A<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>

using namespace std;
using ll = long long;

#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)

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;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////

// a
int main() {
    int h, a; cin >> h >> a;
    cout << (h+a-1)/a << endl;
    return 0;
}

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

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

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

void Main(){
    int N,K; cin >> N >> K;

    double p[N]; REP(i,N) p[i] = 0;

    REP(i,N){
        int x = i+1;
        double q = 1;
        while(x < K){
            q *= 0.5;
            x <<= 1;
        }
        p[i] = q;
    }

    double ans = 0; REP(i,N) ans += p[i];
    ans /= N;
    cout << ans << en;
    return;
}

int main(void){
    cin.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t){
        Main();
    }
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cmath>

using namespace std;

int n;
long large=0;
long small=1000000000;

int main(){
  cin >>n;
  long a[n];
  for(int i=0;i<n;i++){
  cin >> a[i];
  large=max(a[i],large);
  small=min(a[i],small);
  }
   
  cout << large-small << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

const double PI = 3.14159;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    double R;
    cin >> R;
    cout << fixed << setprecision(10) << 2 * PI * R << endl;
    return 0;
}

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

int main() {
    unsigned long d = 0;
    int a, b, c, k;
    cin >> k;
    for (int a = 1; a <= k; a++){
        for (int b = 1; b <= k; b++){
            for (int c = 1; c <= k; c++){
                d += std::gcd(std::gcd(a, b), c);
            }
        }
    }
    cout << d;
}


Measured memory_bytes: 3636
function Main(input) {
    // 1行目がinput[0], 2行目がinput[1], …に入る
    N = Number(input.split("\n")[0]);
    d = new Array;
    check = new Array;
    j = 0;
    for(i = 0; i< N ; i++){
        d[i] = Number(input.split("\n")[i+1]);
        if(check.indexOf(d[i])==-1){
            check[j]=d[i];
            j +=1;
        }
    }

    console.log(check.length);
}
    


//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
n,m=map(int,input().split())
a=[list(input()) for i in range(n)]
b=[list(input()) for i in range(m)]
def all_true(i,j):
    global a,b
    for k in range(i,i+m):
        for l in range(j,j+m):
            if a[k][l]!=b[k-i][l-j]:
                return False
    return True
f=0
for i in range(n-m+1):
    for j in range(n-m+1):
        if all_true(i,j):
            f=1
            break
    if f==1:
        print("Yes")
        break
else:
    print("No")


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    cin>>n>>k;
    
    
int a[100010],dp[100010];

    for(int i=1;i<=n;i++)
        cin>>a[i];
    dp[1]=0;
    for(int i=2;i<=n;i++)
    {
        dp[i]=1001010100;
        for(int j=1;j<=k;j++)
        {
            if(i-j<=0)break;
            
            dp[i]=min(dp[i],dp[i-j]+abs(a[i-j]-a[i]));
        }
    }
    cout<<dp[n]<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <sstream>
#include <set>
#include <map>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
 
using namespace std;
 
#define ll long long
#define pi pair<int,int>
#define pll pair<ll,ll>
#define pii pair<int,pi>
#define X first
#define Y second
#define pb push_back
#define ab(x) ((x)<0?(-(x)):(x))
#define xx(x) ((x)*(x))
#define mp make_pair
#define vi vector<int>
#define vll vector<ll>
#define vs vector<string>
#define vpi vector<pi>
#define vpll vector<pll>
#define ALL(x) (x).begin(),(x).end()
#define Max (1<<30)
#define LLMax (1ll<<60)
template<class T>string ToString(T t){stringstream s;s<<t;return s.str();}
template<class T>void ToOther(T&t,string a){stringstream s(a);s>>t;}
 
char a[10005];
int main(){
	while(1){
		gets(a);
		string t=a;
		if(t==".")break;

		bool no=0;
		stack<char> st;
		for(int i=0;i<t.size();i++){
			if(t[i]=='('){
				st.push(')');
			}
			if(t[i]=='['){
				st.push(']');
			}

			if(t[i]==')'){
				if(st.size()==0 || st.top()!=t[i]){
					no=1;break;
				}
				st.pop();
			}
			if(t[i]==']'){
				if(st.size()==0 || st.top()!=t[i]){
					no=1;break;
				}st.pop();
			}
		}
		if(st.size())no=1;
		cout<<(no?"no":"yes")<<endl;
	}
}

Measured memory_bytes: 1176
#include <iostream>
#include <vector>
#include<iomanip>
#include <math.h>
using namespace std;

struct Circles {
	double x;
	double y;
	double r;
};

Circles countCircle(double x1,double y1, double x2, double y2, double x3, double y3){
	double a = ((y2 - y1)*(y3*y3 - y1 * y1 + x3 * x3 - x1 * x1) - (y3 - y1)*(y2*y2 - y1 * y1 + x2 * x2 - x1 * x1)) / (2.0*((x3 - x1)*(y2 - y1) - (x2 - x1)*(y3 - y1)));
	double b = ((x2 - x1)*(x3*x3 - x1 * x1 + y3 * y3 - y1 * y1) - (x3 - x1)*(x2*x2 - x1 * x1 + y2 * y2 - y1 * y1)) / (2.0*((y3 - y1)*(x2 - x1) - (y2 - y1)*(x3 - x1)));
	double r = sqrt((x1 - a)*(x1 - a) + (y1 - b)*(y1 - b));
	return Circles{ a,b,r };
}


int main() {
	vector<Circles> dst;
	int n;
	double x1, y1, x2, y2, x3, y3;
	cin >> n;
	while (n-->0) {
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
		dst.push_back(countCircle(x1, y1, x2, y2, x3, y3));
	}
	for (vector<Circles>::iterator it = dst.begin(); it < dst.end(); it++) {
		cout.setf(ios::fixed);
		cout << fixed << setprecision(3) << (*it).x << " " << (*it).y << " " << (*it).r << endl;
	}
	return 0;
}


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

int H;
int W;
int N;

int main()
{
    cin >> H >> W;
    cin >> N;
    int swi = 0;
    vector<int> temp;
    int cou = 0;
    for (int i = 1; i <= N; i++)
    {
        cin >> cou;

        for (int j = 0; j < cou; j++)
        {
            temp.push_back(i);
            if (temp.size() == W)
            {
                if (swi == 0)
                {
                    for (int k = 0; k < W; k++)
                    {
                        cout << temp[k] << " ";
                    }
                }
                else
                {
                    for (int k = W - 1; k >= 0; k--)
                    {
                        cout << temp[k] << " ";
                    }
                }
                cout << endl;
                temp.clear();
                swi = 1 - swi;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
from itertools import groupby, accumulate, product, permutations, combinations
def solve():
  N = int(input())
  A = [list(map(int, input().split())) for _ in range(N)]
  mod = 10**9+7
  dp = [[0]*(1<<N) for _ in range(N+1)]
  dp[N][-1] = 1
  for i in range(N-1,-1,-1):
    for com in combinations(range(N),i):
      S = 0
      for k in com:
        S += 1<<k
      for j in range(N):
        if not S>>j&1: #jがSに含まれないなら
          if A[i][j]==1:
            dp[i][S] += dp[i+1][S|(1<<j)]
            dp[i][S] %= mod
  return dp[0][0]
print(solve())

Measured memory_bytes: 428376
#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000000;
int main(){
    int X, A, B;
    cin >> X >> A >> B;
    if (B - A > X) cout << "dangerous" << endl;
    else if (B - A > 0) cout << "safe" << endl;
    else cout << "delicious" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
using namespace std;
pair<int,int> pairs[100001];
int main(){
int n,m;cin>>n>>m;
int i,j,k,l;
for(i=0;i<m;i++){
  //second is a[i]
cin>>pairs[i].second>>pairs[i].first;
}
int ans=0,tmp=0;
sort(pairs,pairs+m);

for(i=0;i<m;i++){
  if(pairs[i].second>=tmp){
  tmp=pairs[i].first;
  ans++;
  }
}
cout << ans << endl;
}


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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var l = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).OrderBy(x => x).ToArray();
            var sum = 0;
            for (int i = 0; i < l.Length; i+=2)
            {
                sum += l[i];
            }

            Console.WriteLine(sum);
        }
    }
}


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

int main(){
 int N;
 cin >> N;
 map<string,int> mp;
 string s;
 uint64_t count = 0;

 for(int i=0;i<N;i++){
   cin >> s;
   sort(s.begin(),s.end());
   count += mp[s];
   mp[s]++;
  }

cout << count;
}

Measured memory_bytes: 11136
#include<iostream>
using namespace std;
int main(){
  char b;
  cin >> b;
  if( b == 'A') cout << 'T' << endl;
  if( b == 'T') cout << 'A' << endl;
  if( b == 'C') cout << 'G' << endl;
  if( b == 'G') cout << 'C' << endl;
  
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
const int N=1e5+5;
int n,m,u[N],v[N],check[N],deg[N];
vector<pair<int,int> > ans;
vector<int> adj[N];
map<pair<int,int>,int> dir;
void dfs(int u,int p){
	check[u]=1;
	for(int v: adj[u]){
		if(check[v]==0){
			dfs(v,u);
		}
	}
	if(deg[u]%2==1){
		if(dir[{u,p}]==1){
			dir[{u,p}]=0;
			dir[{p,u}]=1;
			deg[u]--;
			deg[p]++;
		}else{
			dir[{u,p}]=1;
			dir[{p,u}]=0;
			deg[u]++;
			deg[p]--;
		}
	}
}
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		cin>>u[i]>>v[i];
		adj[u[i]].push_back(v[i]);
		adj[v[i]].push_back(u[i]);
		dir[{u[i],v[i]}]=1;
		deg[u[i]]++;
	}
	if(m%2==1){
		cout<<"-1";
		return 0;
	}
	dfs(1,1);
	for(int i=1;i<=m;i++){
		if(dir[{u[i],v[i]}]==1){
			cout<<u[i]<<" "<<v[i]<<endl;
		}else{
			cout<<v[i]<<" "<<u[i]<<endl;
		}
	}
}

Measured memory_bytes: 29828
#include <stdio.h>

int main(void){
   int n,k,i,s=1;

   scanf("%d%d",&n,&k);

   for(i=0;i<n;i++){
      if(s>k) s+=k;
      else  s*=2;
   }

   printf("%d\n",s);
   return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
    using namespace std;
     
    #define       pb(a)             push_back((a))
    #define       mp(a,b)           make_pair((a),(b))
    #define       REP(a,b)          for(ll i=(a);i<(b);i++)
    #define       REP2(a,b)         for(ll j=(a);j<(b);j++)
    #define       REPE(a,b,c,d)     REP(a,b)for(ll j=(c);j<(d);j++)
    #define       REPV(a,b,c)       for(ll (a)=b;(a)<(c);(a)++)
    #define       IREP(a,b)         for(ll i=(a);i>=(b);i--)
    #define       IREP2(a,b)        for(ll j=(a);j>=(b);j--)
    #define       IREPV(a,b,c)      for(ll (a)=b;(a)>=(c);(a)--)
    #define       all(v)            (v).begin(),(v).end()
    #define       Trvs(c)           for (auto &it :c)
    #define       INF               INT_MAX
    #define       sz(x)             x.size()
    #define       flash             ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    #define       F                 first
    #define       S                 second
    #define       MOD               1000000007

    using         ll     = long long;
    using         vll    = vector<ll>;
    using         vvll   = vector<vll>;
    using         pll    = pair<ll, ll>;
    using         vpll   = vector<pll>;
    using         vvpll  = vector<vpll>;
     


void solve(){
	ll n; cin >> n;
	map <ll,ll> mp;
	REP(0,n){
		ll x; cin >> x;
		if(!mp[x])mp[x]++;
		else {
			cout<<"NO";
			return;
		}
	}
	cout<<"YES";
}
	

     
    	
int main(){
    	flash
    	
    	// ll t;cin>>t;while(t--)
    	solve();
    	return 0;
    } 	

Measured memory_bytes: 12800
a = input()
b = ""
c=""
counterf=0
counter =0


for x in a:
    if x == "A":
        b+=x
        counterf +=1
    elif counterf >=1:
        b+=x
        
for x in b[::-1]:
    if x == "Z":
        c+=x
        counter+=1
    elif counter >=1:
        c+=x
print(len(c))

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

int main(){
    int S;
    double h,m,s;
    cin >> S;
    h = S/3600;
    m = (S%3600)/60;
    s = (S%3600)%60;
    
    cout << h <<":"<< m <<":"<< s<< endl;
    return 0;
}


Measured memory_bytes: 3252
import java.util.Scanner;

public class Main {
	static int[] boo = new int[100000];
	public static void main(String[] args)throws Exception{
		//BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		Scanner sc = new Scanner(System.in);
		
		int n = Integer.parseInt(sc.next());
		//String[] st = br.readLine().split(" ");
		//boolean[] boo = new boolean[100000];
		
		for (int i = 0; i < n; i++) {
			//boo[Integer.parseInt(st[i])%100000] = 1;
			boo[Integer.parseInt(sc.next())%100000] = 1;
		}
		
		int ans = 0;
		//n = Integer.parseInt(br.readLine());
		n = Integer.parseInt(sc.next());
		//st = br.readLine().split(" ");
		for (int i = 0; i < n; i++) {
//			ans += boo[Integer.parseInt(st[i])%100000] ;
			ans += boo[Integer.parseInt(sc.next())%100000] ;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 70888
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
#include <cmath>

typedef long long ll;
using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;
    int ans[m + 1];
    int k, a[32];
    for (int i = 0; i < m + 1; i++){
        ans[i] = 0;
    }

    for (int i = 0; i < n; i++){
        cin >> k; 
        for (int j = 0; j < k; j++) {
            cin >> a[j];
            ans[a[j]]++;
        }
    }

    int sum = 0;
    for(int i = 1; i <= m ; i++){
        if(ans[i] == n){
            sum++;
        }
     }
     cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        if(N==M){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 23252
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <climits>
#include <numeric>
#include <cmath>
#include <queue>
#include <sstream>
#include <string.h>

using namespace std;
typedef long long ll;

int main() {
  vector<int> xyzc(3);
  int k;
  for (int i = 0; i < 3; i++) {
    cin >> xyzc[i];
  }
  cin >> k;
  
  vector<vector<ll>> vec(3);
  for (int i = 0; i < 3; i++) {
    vec[i] = vector<ll>(xyzc[i]);
    for (int j = 0; j < xyzc[i]; j++) {
      cin >> vec[i][j];
    }
    sort(vec[i].rbegin(), vec[i].rend());
  }
  
  vector<ll> xy(xyzc[0] * xyzc[1]);
  for (int i = 0; i < xyzc[0]; i++) {
    for (int j = 0; j < xyzc[1]; j++) {
      xy[i * xyzc[1] + j] = vec[0][i] + vec[1][j];
    }
  }
  sort(xy.rbegin(), xy.rend());

  int u = min(xyzc[0] * xyzc[1], k);
  vector<ll> xyz(u * xyzc[2]);
  for (int i = 0; i < u; i++) {
    for (int j = 0; j < xyzc[2]; j++) {
      xyz[i * xyzc[2] + j] = xy[i] + vec[2][j];
    }
  }
  sort(xyz.rbegin(), xyz.rend());

  for (int i = 0; i < k; i++) {
    cout << xyz[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 31616
import sys
input = sys.stdin.readline
N = int(input())
A = list(map(int,input().split()))

'''
import random
N = 30
A = [0]*N
for i in range(1000):
    n = random.randint(1,N)
    for j in range(N):
        A[(n-1+j)%N] += j+1
        '''

M = N*(N+1)//2
sumA = sum(A)

if sumA % M != 0:
    print('NO')
    exit()

diff = [x-y for x,y in zip(A[1:] + [A[0]], A)]

all_cnt = 0
while min(diff) < 0:
    cnt = 0
    for i in range(N):
        if diff[i] < 0:
            t = -(diff[i]//(N-1))
            cnt += t
            diff[i] += t*N
    diff = [d-cnt for d in diff]
    all_cnt += cnt*M
    if all_cnt > sumA:
        print('NO')
        exit()

N2 = sumA - all_cnt
if N2 % (M*N) == 0:
    print('YES')
else:
    print('NO')



Measured memory_bytes: 99264
#include <iostream>
#include <algorithm>
#include <typeinfo>
#include <numeric>
#include "math.h"
#include <string>
#include <vector>
#include <iomanip>

#define pai 3.14159265358979323846264338327950288
using namespace std;

// Sheep and Wolves
int main() {

	int s, w;

	cin >> s >> w;

	if (s > w) {
		cout << "safe";

	}
	else {
		cout << "unsafe";
	
	}
	return 0;
}


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

#define     fast()              ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
#define     ll                  long long int
#define     test()              ll t; cin>>t; while(t--) 
#define     lp0(i,begin,end)    for(ll i=begin;i<end;i++)
#define     lp1(i,begin,end)    for(ll i=begin;i<=end;i++)
#define     rlp(i,begin,end)    for(ll i=end;i>=begin;i--)
#define     prec(n)             fixed<<setprecision(n)
#define     initial(a,i)        memset(a,i,sizeof(a))
#define     pb                  push_back
#define     PI                  3.1415926535897932384626433832795
#define     MOD                 1000000007
#define     F                   first
#define     S                   second
#define     all(a)              (a).begin(),(a).end()
#define     BPC(x)              __builtin_popcountll(x)
#define     gcd(a,b)            __gcd(a,b)

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

ll power(ll x,ll n)
{
    ll result = 1;
    while (n)
    {
        if (n & 1)
            result = result * x;
        n = n / 2;
        x = x * x;
    }
    return result;
}


// Solution Function
void solution(ll compte)
{
    // cout<<compte<<"\n";

    ll n;
    cin>>n;
    if(n==1)
    cout<<0<<"\n";
    else 
    cout<<"1\n";
}

// Driver Function
int main()
{
    ll compte = 1;
    //test()
    //{
        solution(compte);
        compte++;
    //}
    return 0;
}


Measured memory_bytes: 3632
#include <algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<stdlib.h>
#include<string.h>
#include<math.h>
using namespace std;

int getSame(string x,string y){
  int xn[26],yn[26];
  int ii,ret;
  ret = 0;
  for(ii=0;ii<26;ii++){
	xn[ii] = yn[ii] = 0;
  }
  for(char c: x){
	xn[c-'a']++;
  }
  for(char c: y){
	yn[c-'a']++;
  }

  for(ii=0;ii<26;ii++){
	if(xn[ii] != 0 && yn[ii] != 0){
	  ret++;
	}
  }

  return ret;
}

int main(){
  int n;
  string str,x,y;
  int max = 0;
  int ret;
  int ii,len;
  cin >> n >> str;
  len = str.length();

  for(ii=0;ii<len-1;ii++){
	x = str.substr(0,ii+1);
	y = str.substr(ii+1,len-ii-1);
	//cout << "x:" << x << endl << "y:" << y << endl;
	ret = getSame(x,y);
	if(ret > max){
	  max = ret;
	}
  }
  cout << max << endl;
  return 0;
}


Measured memory_bytes: 256
from functools import reduce
from fractions import gcd
from collections import defaultdict
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")


def main():
    N = int(input())
    d = defaultdict(int)
    for _ in range(N):
        s = input()[:-1]
        d[s] += 1
    d = sorted(d.items(), key=lambda x:x[1], reverse=True)
    k = d[0][1]
    d.sort()
    for t in d:
        if t[1] == k:
            print(t[0])
    
    


if __name__ == '__main__':
    main()

Measured memory_bytes: 122708
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef tree<ll,null_type,less<ll>,rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define endl "\n"
#define int ll
#define tr(container, it) \
for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define all( x ) x.begin(), x.end()
#define fast ios::sync_with_stdio(0);cin.tie(0);

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef unsigned long long ull;

const int inf = 1e9 + 5;
const long double PI = 3.141592653589793;

void solve(){
  int a;
  string s;
  cin>>a>>s;
  int b = (s[0]-'0')*100 + (s[2]-'0')*10 + (s[3]-'0');
  a*=b;
  cout<<a/100<<endl;
}  
signed main(){
  fast;
  int t;
  //cin>>t;
  t = 1;
  while(t--){
    solve();
  }
}
/*
░░░░░░░░░░▄▄░░░░░░░░░░░░░░░░░░░░░░░░░░░
░░░░░░░░░██▀█▄░░▄██▀░░░░▄██▄░░░░░░░░░░░
░░░░░░░░██▄▄▄████████▄▄█▀░▀█░░░░░░░░░░░
░░░░░░░▄██████████████████▄█░░░░░░░░░░░
░░░░░░▄██████████████████████░░░░░░░░░░
░░░░░▄████████▀░▀█████████████░░░░░░░░░
░░░░░███████▀░░░░▀████████████▄░░░░░░░░
░░░░██████▀░░░░░░░░▀███████████▄▄▄▀▀▄░░
░▄▀▀████▀░░░▄▄░░░░░░░░░████████░░░░░█░░
█░░░▀█▀█░░░░▀▀░░░░░░██░░███░██▀░░░░▄▀░░
█░░░░▀██▄░░░▄░░░▀░░░▄░░░███░██▄▄▄▀▀░░░░
░▀▄▄▄▄███▄░░▀▄▄▄▀▄▄▄▀░░░███░█░░░░░░░░░░
░░░░░░████▄░░░░░░░░░░░░▄██░█░░░░░░░░▄▀▀
░░░░░░███▀▀█▀▄▄▄▄▄▄▄▄▄▀█████░░░░░░▄▀░░▄
░░░░░░█▀░░█░▀▄▄▄▄▄▄▄▄▄▀░███░█▀▀▀▄▀░░▄▀░
░░░░░░░░░▄▀░░░░░░░░░░░░░▀█▀░░█░░░░█▀░░░
░░░░░░░░░█░░░█░░░░░░░░░░░░░░░█░░░░░█░░░
░░░░░░░░░█▄▄█░▀▄░░█▄░░░░░░░░█░░▄█░░█░░░
░░░░░░░░░▀▄▄▀░░█▀▀█░▀▀▀▀█▀▀█▀▀▀▀█░█░░░░
hOi!!
I'm TemMie
*/

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define Blue ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i,a,n) for(int i=a;i<n;++i)
typedef vector<int> vi;
typedef long long ll;
const int mod=1e9+7;
 
const int dx[]={1,-1,0,0},dy[]={0,0,1,-1};

void solve(){
	int n;
	cin>>n;
	string s;
	cin>>s;
	if(n&1){
		cout<<"No";
		return;
	}
	cout<<(s.substr(0,n/2)==s.substr(n/2,n/2)?"Yes":"No");
	
 
}
 
 
int main(){
	Blue;
	int test=1;
	//cin>>test;
	while(test--)
		solve();
	return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
#include<unistd.h>
using namespace std;
#define pb(x) push_back(x);
typedef long long  int ll;
ll mod = 998244353;
ll hmaxii=0;
vector<ll>values[2*100000+1];
ll MAXN = 2*100000+1;
ll spf[2*100000+1];
//vector<ll>values[];
ll diff,x,y,z;
ll flag=1;ll price[1001][1001];

ll gcd(ll a,ll b) { return b?gcd(b,a%b):a; }



void solution(){
    int n;
    cin>>n;
    int temp = n%10;
    string ans;
    cin>>ans;
    if(n>=ans.length()){
        cout<<ans<<endl;
    }
    else{
        ans = ans.substr(0,n);
        ans+="...";
        cout<<ans<<endl;
    }
}


int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //sieve();
    /*ll powe[64];
    powe[0]=1;
    ll i=1;
    while(i<64){
        powe[i] = powe[i-1]*2;
        i++;
    }*/
    ll t;
    //cin>>t;
    t=1;
    while(t--){
        solution();
    }
    return 0;
}


Measured memory_bytes: 8256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
int main() {
  int n;
  cin >> n;
  int a[200100];
  rep(i,n) cin >> a[i];
  int next = 1, ans = 0;
  rep(i,n){
    if(next==a[i]) next++;
    else ans++;
  }
  if(ans==n) ans = -1;
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include<iostream>

using namespace std;

int main()
{long long ans,n,i;
char a;
string s;
	cin >> n;
	cin>> s;
	a = s[0];
	ans = 1;
	for(i=1;i<n;i++)
	{
		if(a != s[i])
		{
			ans++;
			a = s[i];
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 512
#include <iostream>

using namespace std;

int n, h[100001], f, o[100001];

int main()
{
    cin >> n;
    for (int i = 1; i <= n; ++i)
        cin >> h[i];
    int c = 1;
    while (c)
    {
        int d = 0;
        for (int i = 1; i <= n; ++i)
            if (h[i - 1] <= h[i])
            {
                continue;
            }
            else if (h[i - 1] == h[i] + 1)
            {
                if (o[i - 1])
                {
                    f = 1;
                    c = 0;
                    break;
                }
                o[i - 1] = 1;
                d = 1;
                --h[i - 1];
            }
            else
            {
                c = 0;
                f = 1;
                break;
            }
        if (!d)
            break;
    }
    if (f)
        cout << "No" << endl;
    else
        cout << "Yes" << endl;
    return 0;
}

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

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (i==n-1?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ');}}

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<bool> vb;
typedef vector<ld> vld;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int n, m, p, r;
string s[100], t[100];

signed main() {
	cin >> n;
	rep(i,n) cin >> s[i];
	cin >> m;
	rep(i,m) cin >> t[i];
	rep(i,n) {
		p = 0;
		rep(j,n) if (s[i]==s[j]) p++;
		rep(j,m) if (s[i]==t[j]) p--;
		chmax(r,p);
	}
	cout << r << ln;
}

Measured memory_bytes: 256
#include <iostream> // プログラムの耳と口
#include <vector> // 超有能配列秘書
#include <algorithm> // みんな大好きソートと二分探索
#include <queue> // きゅーちゃん、だいすき
#include <string> // to_string
#include <functional> // 関数を変数に入れる子
#include <set> // 値の取得・挿入・削除を高速に
#include <map> // setの妹 これまた優秀
#include <random> // 乱択さん

#define DB cerr<<"D"<<endl
using namespace std; using ll=long long; using ld=long double; const int INF=1e9; const ll LINF=1e18; const double dINF = 1e18; const ld ldINF = 1e18; const double EPS = 1e-6;
template<typename T, typename U, typename O> void caut(T a, U b, O c){cout<<"("<<a<<","<<b<<","<<c<<") ";} template<typename T, typename U> void caut(T a, U b){cout<<"("<<a<<","<<b<<") ";} template<typename T> void caut(T a){cout<<"("<<a<<") ";};
using P=pair<ll,ll>;
const ll M = 1e9+7;
ll mod_pow(ll x, ll a) { ll an = 1; while(a > 0) { if (a&1) an = an * x % M; x = x * x % M; a >>= 1;} return an;}
ll adad(ll x) {return x*(x+1)/2;} // 1～xの総和
void add(ll& x, ll y) {x+=y; x%=M;}; void mul(ll& x, ll y) {x*=y; x%=M;}; template<typename T, typename U> void chmax(T& x, U y) {if (x<y) x=y;}; template<typename T, typename U> void chmin(T& x, U y) {if (x>y) x=y;}
bool vaild(int x, int y, int hh, int ww){return 0<=x&&x<hh&&0<=y&&y<ww;}

int main() {
  int n; cin>>n;
  ll an[n]={};
  for(int x=1;;x++) {
    int cal0 = x*x+1*1+1*1+x*1+1*1+1*x;
    if (cal0 > n) break;
    for(int y=1;;y++) {
      int cal1 = x*x+y*y+1*1+x*y+y*1+1*x;
      if (cal1 > n) break;
      for(int z=1;;z++) {
        int cal2 = x*x+y*y+z*z+x*y+y*z+z*x;
        if (cal2 > n) break;
        else an[cal2-1]++;
      }
    }
  }
  for(int i=0;i<n;i++) {
    cout<<an[i]<<endl;
  }
}

Measured memory_bytes: 3604
while (n, x = gets.split(" ").map(&:to_i)) != [0, 0]
  c = 0
  for i in 1..n-2
    for j in i+1..n-1
      for k in j+1..n
        if i + j + k == x
          c += 1
        end
      end
    end
  end
  puts c
end



Measured memory_bytes: 6852
#include <bits/stdc++.h>
#include <stdlib.h>
#include <string>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007
#define pi 3.141592653589793
ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    ll r=a%b;
    while(r!=0){
        a=b;
        b=r;
        r=a%b;
    }
    return b;
}

int main(){
    string s;ll k;
    char ans='1';
    ll i;
    cin >> s >> k;
    ll l=s.length();
    for(i=0;i<min(k,l);i++){
        if(s[i]!='1'){
            cout << s[i] <<endl;
            return 0;
        }
    }
    cout << 1 << endl;
    return 0;
}


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

int main() {
  int A, B, K;
  cin >> A >> B >> K;
  for (int i = min(A, B); i > 0; i--) {
    if (A % i == 0 && B % i == 0) {
      K--;
      if (K == 0) {
        cout << i << endl;
        break;
      }
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int maxN = 100 * 1000 + 9;
const int MOD = 1e9 + 7;
const double EPS = 1e-18;

int n;
vector<pair<int, ll> > g[maxN];

void read(){
  cin >> n;
  for(int i = 0; i < n - 1; i++){
    int u, v; ll w;  cin >> u >> v >> w;
    g[u].push_back(make_pair(v, w));
    g[v].push_back(make_pair(u, w));
  }
}

ll dist[maxN];

void bfs(){
  queue<int> que;
  fill_n(dist, n + 1, INF);
  que.push(1);
  dist[1] = 0;

  while(!que.empty()){
    int u = que.front();
    que.pop();

    for(int i = 0, L = g[u].size(); i < L; i++){
      int v = g[u][i].first;
      ll w = g[u][i].second;
      if(dist[v] > dist[u] + w){
        que.push(v);
        dist[v] = dist[u] + w;
      }
    }
  }
}

void solv(){
  bfs();
  for(int i = 1; i <= n; i++){
//    cerr << dist[i] << ' ';
    if(dist[i] & 1){
      cout << "0\n";
    } else {
      cout << "1\n";
    }
  }
//  cerr << '\n';
}

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

  read();
  solv();

  return 0;
}


Measured memory_bytes: 8704
import java.util.*;

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

        int h = sc.nextInt();
        int w = sc.nextInt();
        int[][] field = new int[h][w];

        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                field[i][j] = sc.nextInt();
            }
        }

        StringBuilder sb = new StringBuilder();
        int n = 0;

        for(int y = 0; y < h; y++){
            for(int x = 0; x < w - 1; x++){
                if(field[y][x] % 2 == 1){
                    field[y][x]--;
                    field[y][x + 1]++;
                    n++;
                    sb.append(y + 1).append(" ").append(x + 1).append(" ")
                      .append(y + 1).append(" ").append(x + 2).append("\n");
                }
            }
            if(y < h - 1 && field[y][w - 1] % 2 == 1){
                field[y][w - 1]--;
                field[y + 1][w - 1]++;
                n++;
                sb.append(y + 1).append("  ").append(w).append(" ")
                  .append(y + 2).append(" ").append(w).append("\n");
            }

        }

        System.out.print(sb.insert(0, "\n").insert(0, n).toString());

        /*
        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                System.out.print(field[i][j] + " ");
            }
            System.out.println();
        }
         */

    }
}


Measured memory_bytes: 96616
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
#define rep(i,n) for (ll i = 0; i < (ll)(n); ++i)
#define rrep(i,j,n) for(ll i = (ll)(j); i < (ll)(n); i++)
#define mrep(i,n) for (ll i = (ll)(n); i > 0; i--)
#define be(v) (v).begin(), (v).end()
#define dcout cout << fixed << setprecision(20) 
ll INF = 1LL << 60;
ll mod = 1e9 + 7;

int main() {
	ll a,v,b,w,t;
	cin >> a >> v >> b >> w >> t;
	ll s=v-w;
	s*=t;
	if(s>=abs(b-a)) cout << "YES" << endl;
	else cout << "NO" << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VL vector<long long>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second
typedef long long LL;
using namespace std;
const int MOD = 1e9+7;
const int SIZE = 2e5+10;
set<int>front[SIZE];
int deg[SIZE],a[SIZE],base[SIZE][2],iter[SIZE],p[SIZE];
int main(){
    MS1(a);
    DRI(n);
    REPP(i,1,n+1){
        RI(p[i]);
        deg[p[i]]++;
    }
    queue<int>qq;
    REPP(i,1,n+1){
        if(!deg[i])qq.push(i);
    }
    while(SZ(qq)){
        int x=qq.front();qq.pop();
        REP(i,SIZE){
            if(!front[x].count(i)){
                a[x]=i;
                break;
            }
        }
        front[p[x]].insert(a[x]);
        deg[p[x]]--;
        if(!deg[p[x]])qq.push(p[x]);
    }
    REPP(j,1,n+1){
        if(a[j]!=-1)continue;
        int it=0;
        REP(i,SIZE){
            if(!front[j].count(i)){
                base[j][it++]=i;
                if(it==2)break;
            }
        }
    }
    int st=-1;
    REPP(i,1,n+1){
        if(a[i]==-1){
            st=i;
            break;
        }
    }
    int now=st;
    REP(i,2){
        int v=base[now][i];
        do{
            now=p[now];
            if(base[now][0]==v)v=base[now][1];
            else v=base[now][0];
        }while(now!=st);
        if(v==base[now][i])return 0*puts("POSSIBLE");
    }
    return 0*puts("IMPOSSIBLE");
}


Measured memory_bytes: 22144