akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <iomanip> //cout << fixed << setprecision() <<
using namespace std;
using ll = long long;
vector<vector<int>> v; //入力値
ll mint = 10000000000;
int c=0;

void monmo(int y,int n,int m,int x,vector<vector<int>> vv){
    vector<int> ten;
    int flag1=0;
    for(int i=0;i<m+1;i++){
        ten.push_back(0);
        ten[i]+=vv[y][i];
    }//flag1がたつと次の再帰に行く
    for(int i=0;i<m;i++){
        if(ten[i+1]<x)flag1=1;
    }
    if(flag1==1){
        for(int i=y;i<n-1;i++){
            vector<vector<int>> v2;
            v2=vv;
            for(int j=0;j<m+1;j++){
                v2[i+1][j]+=vv[y][j];
            }
            monmo(i+1,n,m,x,v2);
        }
    }
    else{
        if(mint>ten[0])mint=ten[0];
        c++;
    }
}

int main() {
    int n,m,x,num;
    cin>>n>>m>>x;
    for(int i=0;i<n;i++){
        v.emplace_back();
        for(int j=0;j<m+1;j++){
            cin>>num;
            v[i].push_back(num);
        }
    }
    for(int i=0;i<n;i++){
        monmo(i,n,m,x,v);
    }
    if(c==0)mint=-1;
    cout<<mint;
}

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

#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define MAX 101

using namespace std;

int field[MAX][MAX];
bool went[MAX][MAX];
int w, h;
int sx, sy, gx, gy;
int scol;
const int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

bool dfs(int x, int y) {
	if(field[y][x] == 0) return false;
	if(x == gx && y == gy) return true;
	int ncol = field[y][x];
	field[y][x] = 0;
	rep(i, 4) {
		int nx = x + dx[i];
		int ny = y + dy[i];
		if(0 < nx && nx <= w && 0 < ny && ny <= h && ncol == field[ny][nx]) {
			/*rep(j, h) {
				rep(k, w) cout << field[j][k] << " ";
				cout << endl;
			}*/
			if(dfs(nx, ny)) return true;
		}
	}
	return false;
}

int main() {
	while(cin >> w >> h, w || h) {
		memset(field, 0, sizeof(field));
		memset(went, false, sizeof(went));
		int n;
		cin >> sx >> sy >> gx >> gy;
		cin >> n;
		rep(i, n) {
			int c, d, x, y;
			cin >> c >> d >> x >> y;
			rep(i, (d ? 4 : 2)) rep(j, (d ? 2 : 4)) field[y + i][x + j] = c;
		}
		/*rep(j, h) {
			rep(k, w) cout << field[j][k] << " ";
			cout << endl;
		}*/
		if(dfs(sx, sy)) cout << "OK" << endl;
		else cout << "NG" << endl;
	}
	return 0;
}

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

int main(){
    int n,y;
    cin>>n>>y;
    int a=-1; int b=-1; int c=-1;
    for(int i=0;i<=n;i++){
        for(int j=0;j<=n-i;j++){
            for(int h=0;h<=n-j-i;h++){
                if((i*10000+j*5000+h*1000)==y && i+j+h==n){
                    a=i; b=j; c=h;
                    break;
                    
                } 
              

            }
            
        }
    }
    cout<<a<<" "<<b<<" "<<c<<endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
  int h, w, n;
  int r = 0;
  cin >> h;
  cin >> w;
  cin >> n;
  if (h > w) {
    if (n % h == 0) {
	    r = n / h;
    } else {
      	r = n / h + 1;
    }
  }else {
    if (n % w == 0) {
      r = n / w;
    } else {
      r = n / w + 1;
    }
  }
  cout << r << endl;
}

Measured memory_bytes: 256
#include <iomanip>
#include <iostream>
using namespace std;
int main(void) {
  cout << fixed << setprecision(12);
  double r;
  cin >> r;
  double pi = 3.141592653589793238462;
  printf("%.8lf %.8lf\n", pi * r * r, pi * 2 * r);

  return 0;
}



Measured memory_bytes: 3276
#include <math.h>

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define PI 3.14159265358979323846264338327950L
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0]))

float metric(vector<int>& a, vector<int>& b) {
  float sum = 0;

  rep(i, a.size()) { sum += (a[i] - b[i]) * (a[i] - b[i]); }
  return sqrt(sum);
}

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

  int last = L + N - 1;

  int a = 0;
  if (last <= 0)
    a = last;
  else if (L >= 0)
    a = L;
  else
    a = 0;
  int ans = (last + L) * (last - L + 1) / 2 - a;
  cout << ans << endl;
}


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

#define F first
#define S second
#define int long long
#define inf 1000000000

using namespace std;

signed main(){
    int k;
    cin >> k;
    int ans = 0;
    for (int i = 1; i <= k; i++){
        for (int j = 1; j <= k; j++){
            for (int z = 1; z <= k; z++){
                //cout << i << " " << j << " " << z << " : " << __gcd(__gcd(i, j), k) << endl;
                ans += __gcd(__gcd(i, j), z);
            }
        }
    }
    cout << ans << endl;
    return 0;
}























Measured memory_bytes: 3580
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        long n = scan.nextLong();
        long k = scan.nextLong();
        if(n >= k){
            n = n % k;
            if(n == 0){
                System.out.println(0);
                System.exit(0);
            }
            System.out.println(Math.min(Math.abs(n), Math.abs(n - k)));
        }else{
            System.out.println(Math.min(n, Math.abs(n - k)));
        }
    }
}

Measured memory_bytes: 23508
array = gets.split(" ").map(&:to_i)
p1 = array[0] - array[1]
p2 = array[1] - array[0]
if array[3].even? && p1 < 1000000000000000000
  puts p1
elsif array[3].odd? && p2 < 1000000000000000000
  puts p2
else
  puts 'Unfair'
end

Measured memory_bytes: 1788
# -*- coding: utf-8 -*-

def main():
    N, Y = [int(i) for i in input().split()]

    for a in range(N+1):
        for b in range(N+1-a):
            c = N-a-b
            if (a*10000 + b*5000 + c*1000) == Y:
                print(str(a)+ " " + str(b) + " " + str(c))
                return
    print("-1 -1 -1")

if __name__ == "__main__":
    main()


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

using namespace std;

typedef long long ll;
typedef long double ld;

const int N=100000+5;

int n;
ll h[N];
ll dp[N];

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>h[i];
        dp[i]=(1LL<<60);
    }
    dp[1]=0;
    for(int i=2;i<=n;i++)
    {
        for(int j=i-2;j<i;j++)
        {
            if(j>=1)
            {
                dp[i]=min(dp[i],dp[j]+abs(h[i]-h[j]));
            }
        }
    ///cout<<i<<" : "<<dp[i]<<"\n";
    }
    cout<<dp[n]<<"\n";
    return 0;
}
/**

**/


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define MAX 100

int main() {
  int n, w[MAX];
  cin >> n;

  for (int i = 0; i < n; ++i) {
    cin >> w[i];
  }

  int s1 = 0, s2 = 0;
  int minv;
  for (int t = 1; t < n; ++t) {
    s1 = s2 = 0;
    for (int i = 0; i < n; ++i) {
      if (t >= i) {
	s1 += w[i];
      } else {
	s2 += w[i];
      }
    }
    minv = (t == 1) ? abs(s1 - s2) : (minv > abs(s1 - s2) ? abs(s1 - s2) : minv);
  }

  cout << minv << endl;

  return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;
int INF = INT_MAX / 2;

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

int R, C;
string a[50];
int b[50][50][3];
int r[1000], c[1000];
vector<int> v[50][50];
bool vis[50][50];

bool dfs(int& t, int x, int y, int xt, int yt) {
	vis[y][x] = true;
	if (x == xt && y == yt)
		return true;
	for (int k = 0; k < 4; k++) {
		int _x = x + dx[k], _y = y + dy[k];
		if (_x < 0 || _x >= C || _y < 0 || _y >= R || a[_y][_x] == '#' || vis[_y][_x])
			continue;
		if (dfs(t, _x, _y, xt, yt)) {
			v[_y][_x].push_back(t++);
			return true;
		}
	}
	return false;
}

int main() {
	int M; cin >> R >> C >> M;
	for (int y = 0; y < R; y++)
		cin >> a[y];
	for (int k = 0; k < 3; k++)
		for (int y = 0; y < R; y++)
			for (int x = 0; x < C; x++)
				cin >> b[y][x][k];
	for (int i = 0; i < M; i++)
		cin >> r[i] >> c[i];
	int t = 0;
	for (int i = 0; i + 1 < M; i++) {
		fill(vis[0], vis[0] + 50 * 50, false);
		dfs(t, c[i + 1], r[i + 1], c[i], r[i]);
		v[r[i + 1]][c[i + 1]].push_back(t);
	}
	int sum = 0;
	for (int y = 0; y < R; y++)
		for (int x = 0; x < C; x++) {
			if (v[y][x].empty()) continue;
			sum += b[y][x][1] + b[y][x][2];
			for (int j = 0; j + 1 < v[y][x].size(); j++) {
				int dt = v[y][x][j + 1] - v[y][x][j];
				sum += min(b[y][x][0] * dt, b[y][x][1] + b[y][x][2]);
			}
		}
	cout << sum << endl;
}

Measured memory_bytes: 6552
// Dictionary.cs

using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Diagnostics;

class Dictionary {
	public static void Main() {

		int n = int.Parse(Console.ReadLine());
		var<string> hash = new HashSet<string>();

		for(int i = 0; i < n; i++) {
			
			string[] str = Console.ReadLine().Split(' ');

			if(str[0] == "insert") {

				hash.Add(str[1]);
				
			} else if(str[0] == "find") {

				if(hash.Contains(str[1])) {
					Console.WriteLine("yes");
				} else {
					Console.WriteLine("no");
				}
			
			}

		}

	}
}

Measured memory_bytes: 39516
#include<iostream>
#include<stdio.h>
#include<vector>//s1.erase(n)=文字列s1の、n文字目以降削除
#include<algorithm>//辞書順=next_permutation
#include<set>
#include<string>//char 小文字のほうが32大きい
#include<sstream>
#include<string.h>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swap=数値交換
#define rt "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())//標準=昇順
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define llcncn llint cnt=0
#define llasas llint ans=0
#define str string
#define please return
#define AC 0
#define ic_a int a;cin>>a;
#define ic_b int b;cin>>b;
#define ic_s string s;cin>>s;
#define Rapid_pleaseAC_fast cin.tie(0);ios::sync_with_stdio(false)
#define Pi 3.1415926535897932384626
#define nine 1000000000

using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<double> vdou;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<bool>> vvbool;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

unsigned GetDigit(unsigned num) {
	return std::to_string(num).length();
}

int tow(int n) {//2のn乗
	if (n == 0)return 1;
	int x = tow(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;//@domino
}

/*

 (char)toupper(a[n])=文字列のn文字目を大文字で出力

  pow(a,b)=aのb乗

  */


int main(void) {
	Rapid_pleaseAC_fast;

	int a, b, c, d;
	cin >> a >> b >> c >> d;
	a += b;
	c += d;

	if (a < c) {
		cout << "Right" << rt;
	}
	else if (a > c) {
		cout << "Left" << rt;
	}
	else {
		cout << "Balanced" << rt;
	}

	please AC;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
using namespace std;
int main()
{
	long long int k,max=-1000001,min=1000001,g=0,n,i;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>k;
		if(k>max)
		{
			max=k;
		}
		if(min>k)
		{
			min=k;
		}
		g=g+k;
	}
	cout<<min<<" "<<max<<" "<<g<<endl;
	
	return 0;
}

	
	

Measured memory_bytes: 3076
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			int n=sc.nextInt();
			if(n==0) break;
			int[] sosu = new int[2*n+1];
			int[] tansaku = new int[2*n+1];
			for(int i=0;i<=2*n;++i){
				if((i!=0&&i!=1)&&i%2!=0){
					tansaku[i]=1;
				}
			}
			int end=(int)Math.sqrt((double)2*n);
			sosu[0]=2;
			for(int i=3;i<=end;i+=2){
				if(tansaku[i]==1){
					for(int j=i+i;j<=2*n;j+=i){
						if(tansaku[j]==1) tansaku[j]=0;
					}
				}
			}
			int m=1;
			for(int i=3;i<=2*n;++i){
				if(tansaku[i]==1){
					sosu[m]=i;
					++m;
				}
			}
			int l=0,count=0;
			for(int i=0;i<m;++i){
				if(2*n<sosu[l]) break;
				if(n<sosu[l] && sosu[l]<=2*n) count++;
				l++;
			}
			System.out.println(count);
		}
	}
}


Measured memory_bytes: 60504
#include<stdio.h>
int main(void){
    int a, b;
    char ap;
    while(1){
        scanf("%d %c %d", &a, &ap, &b);
        if(ap=='?'){
            break;
        }
        else if(ap=='+'){
            printf("%d\n", a+b);
        }
        else if(ap=='-'){
            printf("%d\n", a-b);
        }
        else if(ap=='*'){
            printf("%d\n", a*b);
        }
        else if(ap=='/'){
            printf("%d\n", a/b);
        }
    }
    return 0;
}


Measured memory_bytes: 2100
// Problem : A - Five Variables
// Contest : AtCoder - AtCoder Beginner Contest 170
// URL : https://atcoder.jp/contests/abc170/tasks/abc170_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
#include<set>
#include<map>
#include<bitset>
#define rep(i,a,b)  for(i=a;i<b;i++)
#define Sort(a)	sort(a.begin(),a.end())
#define rev(a)	reverse(a.begin(),a.end())
#define all(a)	(a).begin(),(a).end()
#define vll vector<long long int>
#define lli long long int
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define db double
#define M 1000000007
#define pi 3.1415926535897932384626433832795028841971
#define INF 1e18

#define MAX 200005

using namespace std;
lli min(lli a,lli b){return a<b?a:b;}
lli min(lli a,lli b,lli c){a=min(a,b);a=min(a,c);return a;}
lli max(lli a,lli b){return a>b?a:b;}
lli max(lli a,lli b,lli c){a=max(a,b);a=max(a,c);return a;}
lli dsum(lli n){lli ans=0;while(n){ans+=(n%10);n/=10;}return ans;}
lli power(lli a,lli b){lli res=1;while(b){if(b&1) res=res*a;a=a*a;b>>=1;}return res;}
lli Ceil(lli a,lli b){lli res=a/b;if(a%b!=0)	res++;return res;}

template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }

lli dxx[]={1,1,0,-1,-1,-1,0,1};
lli dyy[]={0,1,1,1,0,-1,-1,-1};
lli dx[]={1,0,-1,0};
lli dy[]={0,1,0,-1};

struct pll{
	lli x,y;
};
bool comp(pll a,pll b){
	if(a.x==b.x)	return a.y<b.y;
	else	return a.x<b.x;
}
void solve(lli the)
{
	char ch;
	db aa,bb,cc,dd,xx;
	string s1,s2,s3,str;
    lli i,j,k,a,b,c,d,n,m,l,r,x,y,z,low,high,mid,sum=0,ans=0,temp,t;
    vll v(5);
    cin >> v;
    if(v[0]==0)	cout<<1;
    else if(v[1]==0)	cout<<2;
    else if(v[2]==0)	cout<<3;
    else if(v[3]==0)	cout<<4;
    else	cout<<5;
    
    
}













int main()
{
	long long int t=1,c=1;
	// scanf("%lld",&t);
	while(t--){
		solve(c);
		c++;
	}
	return 0;
}
/* UJJWAL KESHRI */

Measured memory_bytes: 3596
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] a = new int[3];
        for (int i = 0; i < 3; i++) {
            a[i] = sc.nextInt();
        }
        
        Arrays.sort(a);
        if (a[0] == a[1] && a[1] != a[2] || a[0] != a[1] && a[1] == a[2])
            System.out.println("Yes");
        else
            System.out.println("No");
    }
}

Measured memory_bytes: 21840
#include<iostream>
using namespace std;
string a[50];
  int n, m,b[50];
void change(int x,int y){
  string t;
  int s;
  t=a[x];a[x]=a[y];a[y]=t;
  s=b[x];b[x]=b[y];b[y]=s;
}
int main(){
  cin>>n>>m;
  for(int i=0;i<50;i++)b[i]=99;
  for(int i=0;i<n;i++){
    cin>>b[i]>>a[i];
  }
  for(int i=n-1;i>0;i--){
    for(int j=0;j<i;j++){
      if(b[j]>b[j+1]){
	change(j,j+1);
      }
    }
  }
  int k;
  for(k=0;k<50;k++){
    if(b[k]>m){k--;break;}
    if(b[k]==m){break;}
  }
  if(b[0]<=m){
    cout<<a[k]<<endl;
  }  else{
    cout<<"kogakubu10gokan"<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

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

const int inf = 999999999;
const int mod = 1e9 + 7;
const long double pi = 3.141592653589793238462643383279502884197;
const long double eps = 1e-7;

ll a[2010];

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

        double o = 0;
        int count = 0;
        if (N>=0){
            while(N <= o){
                o += pow((double)2,(double)count);
                count+=2;
            }
        }

    	return 0;
    }
    */

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

    int LC = N/4;
    int LD = N/7;

    bool rb = false;

    for(int i=0;i<=LC;i++){
        for(int l=0;l<=LD;l++){
            if(i*4+l*7==N){
                rb=true;
            }
        }
    }

    if(rb) cout<<"Yes";
    else cout<<"No";

    return 0;

}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
typedef pair<int,int> P;
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define rep(i, n) for (lint i = 0; i < (n); i++)
#define INF LLONG_MAX
#define all(x) (x).begin(),(x).end()
#define pb push_back
int main(){
    string s;
    cin>>s;
    rep(i,s.size()){
        if(i%2==0){
            cout<<s[i];
        }
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;

/**
 * ZAKIREN第5章
 *
 * @author K.Yamauchi
 *
 */
public class Main {

	/**
	 *
	 * @param args
	 */
	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in); // 入力
		int n = Integer.parseInt(scan.nextLine()); // 要素数

		// ソート対象配列の読み込み
		String[] targetArrayStr = scan.nextLine().split(" ");
		int[] targetArray = new int[targetArrayStr.length];
		for (int i = 0; i < targetArrayStr.length; i++) {
			targetArray[i] = Integer.parseInt(targetArrayStr[i]);
		}

		// 読み込み終了
		scan.close();

		// ソート
		int exchangingCount = bubbleSort(n, targetArray);

		// 結果出力
		for (int i = 0; i < targetArray.length; i++) {
			if (i < targetArray.length - 1) {
				System.out.print(targetArray[i] + " ");
			} else {
				System.out.println(targetArray[i]);
			}
		}
		System.out.println(exchangingCount);;

	}

	/**
	 * 指定された整数配列をバブルソートする。
	 *
	 * @param n 配列の要素数
	 * @param targetArray バブルソートしたい整数配列
	 */
	private static int bubbleSort(int n, int[] targetArray) {
		boolean isNotSorted = true; // ソート未完了フラグ
		int exchangingCount = 0; // 入れ替え回数

		// ソートが完了するまで
		while (isNotSorted) {
			isNotSorted = false;

			// 天秤を右端から移動していく
			for (int i = n - 1; i > 0; i--) {
				// 自分より小さい値が左側に居たら
				if (targetArray[i] < targetArray[i - 1]) {
					// 2つの要素を入れ替える
					exchangeArrayValue(targetArray, i, i - 1);
					isNotSorted = true;
					exchangingCount++;
				}
			}
		}

		return exchangingCount;
	}

	/**
	 * 配列内の2つの要素を入れ替える。
	 *
	 * @param array 入れ替えたい要素を含む配列
	 * @param a 入れ替えたい要素のindex
	 * @param b 入れ替えたい要素のindex
	 */
	private static void exchangeArrayValue(int[] array, int a, int b) {
		int temp = array[a];
		array[a] = array[b];
		array[b] = temp;
	}

}


Measured memory_bytes: 26312
from copy import deepcopy
from sys import exit,setrecursionlimit
import math
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac

setrecursionlimit(1000000)


def main():
	n = input()
	print(n.count('+')-n.count('-'))

def zip(a):
	mae = a[0]
	ziparray = [mae]
	for i in range(1,len(a)):
		if(mae != a[i]):
			ziparray.append(a[i])
			mae = a[i]
	return ziparray

def is_prime(n):
	if n < 2: return False

	for k in range(2, int(math.sqrt(n)) + 1):
		if n % k == 0:
			return False

	return True

def list_replace(n,f,t):
	return [t if i==f else i for i in n]

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

def gcd(l):
	x = l.pop()
	y = l.pop()
	while(x%y!=0):
		z = x%y
		x = y
		y = z
	l.append(min(x,y))
	return gcd(l) if len(l) > 1 else l[0]

class Queue():
	def __init__(self):
		self.q = deque([])
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.popleft()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class Stack():
	def __init__(self):
		self.q = []
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.pop()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class graph():
	def __init__(self):
		self.graph = defaultdict(list)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
		self.graph[t].append(f)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
		self.graph[t].remove(f)
	def linked(self,f):
		return self.graph[f]

class dgraph():
	def __init__(self):
		self.graph = defaultdict(set)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
	def linked(self,f):
		return self.graph[f]

main()


Measured memory_bytes: 63340
n, k = gets.chomp.split.map(&:to_i)
a = gets.chomp.split.map(&:to_i)

res = (1..10**9).bsearch {|l|
  cnt = a.inject(0) {|acc, x| acc + (x + l - 1) / l - 1 }
  cnt <= k
}
puts res

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



int main() {
  ll A,B,N,ans=0;
  cin>>A>>B>>N;
  if(N>=B)
  {
    ans=A*(B-1)/B;
  }
  else
  {
    ans=A*N/B;
  }
  cout<<ans<<endl;
  return 0;
}

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

int main()
{
    int a, b;
    cin >> a >> b;

    for (int i = 0; i < 1010; ++i) {
        // cout << (int)(i * 0.08) << " " << (int)(i * 0.1) << endl;
        if ((a == (int)(i * 0.08) ) && (b == (int)(i * 0.1))) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}



Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n;
    cin>>n;
    vector<pi> a(n);
    rep(i,n){
        cin>>a[i].fi;
        a[i].se=i;
    }
    sort(all(a));
    int ans=0;
    rep(i,n){
        if(a[i].se%2!=i%2)ans++;
    }
    cout<<ans/2<<endl;
}

Measured memory_bytes: 1792
import sys
sys.setrecursionlimit(100000000)
def input():
    return sys.stdin.readline()[:-1]
from bisect import *
from collections import *
from heapq import *
from math import *

N, K = map(int, input().split())
A = list(map(int, input().split()))
S = sum(A)
x = [1, S]
for i in range(2, int(S**0.5)+1):
    if S % i == 0:
        x.append(i)
        x.append(S//i)
x.sort(reverse = 1)
for g in x:
    B = [a%g for a in A]
    B.sort()
    S1 = sum(B)
    S2 = 0
    for i in range(N)[::-1]:
        S1 -= B[i]
        S2 += g-B[i]
        if (S1-S2)%g == 0:
            if S2 < S1 and S1 <= K:
                print(g)
                exit()
            elif S1 <= S2 and S2 <= K:
                print(g)
                exit()


Measured memory_bytes: 42092
#include <bits/stdc++.h>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;

long long mod = 1000000007;

long long div(long long a, long long b, long long c){
    return b / c - (a - 1) / c;
}

void print_binary(long long a) {
    for (int i = 31; i >= 0; i--) {
        cout << (a >> i & 1);
    }
    cout << endl;
}

int main() {
    long long a, b, c;
    cin >> a >> b >> c;
    if ((a == b && c != a) || (a == c && b != a) || (b == c && a != c)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int a, b, c;

	do{
		scanf("%d %d %d", &a, &b, &c);
	}while(!(0 <= a && a <= 100 || 0 <= b && b <= 100 || 0 <= c && c <= 100));

	if(a < b && b < c)
		puts("Yes");
	else
		puts("No");
	return 0;
}
	

Measured memory_bytes: 580
# Problem: https://atcoder.jp/contests/agc025/tasks/agc025_a
# Python 2nd Try

import sys
# from collections import defaultdict
# import heapq,copy
# from collections import deque


def II(): return int(sys.stdin.readline())


def MI(): return map(int, sys.stdin.readline().split())


def LI(): return list(map(int, sys.stdin.readline().split()))


def LLI(rows_number): return [LI() for _ in range(rows_number)]


def solver(inputNo):
    result = 36
    for a in range(1, inputNo, +1):
        strA = str(a)
        strB = str(inputNo-a)
        checkDigitAdd = 0
        for j in range(0, len(strA)):
            checkDigitAdd = checkDigitAdd + int(strA[j])
        for j in range(0, len(strB)):
            checkDigitAdd = checkDigitAdd + int(strB[j])
        if checkDigitAdd < result:
            result = checkDigitAdd
#            print("Then {} {} , changed".format(strA, strB))
    # algorithm
    return result


if __name__ == "__main__":
    print("{}".format(solver(II())))


Measured memory_bytes: 3064
#pragma GCC optimize ("-O3")
#include <bits/stdc++.h>  
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> p32;
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<vector<ll> > vv64;
typedef vector<vector<p64> > vvp64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
ll MOD = 998244353;
#define forn(i,e) for(ll i = 0; i < e; i++)
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define rforn(i,s) for(ll i = s; i >= 0; i--)
#define rforsn(i,s,e) for(ll i = s; i >= e; i--)
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define INF 1e18
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())

ll mpow(ll a, ll b){
	if(b >= (MOD-1)) b %= (MOD-1);
	if(b==0) return 1;
	ll t1 = mpow(a,b/2);
	t1 *= t1;
	t1 %= MOD;
	if(b%2) t1 *= a;
	t1 %= MOD;
	return t1;
}

ll mpow(ll a, ll b, ll p){
	if(b==0) return 1;
	ll t1 = mpow(a,b/2,p);   t1 *= t1;
	t1 %= p;
	if(b%2) t1 *= a;
	t1 %= p;
	return t1;
}
ll modinverse(ll a, ll m){
	ll m0 = m; 
    ll y = 0, x = 1; 
    if (m == 1) return 0; 
    while (a > 1){
        ll q = a / m; 
        ll t = m; 
        m = a % m, a = t; 
        t = y; 
        y = x - q * y; 
        x = t; 
    }
    if (x < 0) x += m0; 
    return x; 
}
ll range(ll l, ll r){
	return l + rand()%(r-l+1);
}
     
void solve(){
    ll n,m,v,p;
    cin>>n>>m>>v>>p;
    v64 arr(n);
    forn(i, n)
    {
        cin>>arr[i];
    }
    sort(all(arr));
    v64 pref(n);
    pref[0] = arr[0];
    forsn(i, 1, n)
    {
        pref[i] = pref[i-1]+arr[i];
    }
    ll ans = p;
    forn(i, n-p)
    {
        ll quan = arr[i]+m;
        ll pos = ll(lower_bound(all(arr), quan+1)-arr.begin());
        if(n-1-pos+1 >= p) continue;
        ll req = v-1-i;
        req -= (p-1);
        if(req <= 0)
        {
            ans++;
            continue;
        }
        ll sm = pref[n-p];
        sm -= pref[i];
        sm = (n-p-i)*quan-sm;
        if(sm >= req*m)
        {
            ans++;
        }
    }
    cout<<ans<<ln;
}
 
int main()
{
	fast_cin();
    ll t=1;
    //cin>>t;
    forn(i,t) {
    	// cout << "Case #" << i+1 << ": ";
    	solve();
    }
    return 0;
}

Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;
 
public class Main {
 
    void solve() throws IOException {
        String S = ns();
        if(S.contains("RRR")){
            out.println(3);
        }else if(S.contains("RR")){
            out.println(2);
        }else if(S.contains("R")){
            out.println(1);
        }else{
            out.println(0);
        }
    }

    final int mod = 1000000007;
    final BigInteger MOD = BigInteger.valueOf(mod);
    int upperBound(ArrayList<Long> list, Long target){
        int i = Collections.binarySearch(list, target, new UpperBoundComparator<Long>());
        return ~i;
    }
    class UpperBoundComparator<T extends Comparable<? super T>> implements Comparator<T>{
        public int compare(T x, T y){
            return (x.compareTo(y) > 0) ? 1 : -1;
        }
    }
    int lowerBound(ArrayList<Long> list, Long target){
        int i = Collections.binarySearch(list, target, new LowerBoundComparator<Long>());
        return ~i;
    }
    class LowerBoundComparator<T extends Comparable<? super T>> implements Comparator<T>{
        public int compare(T x, T y){
            return (x.compareTo(y) >= 0) ? 1 : -1;
        }
    }
    int mul(int x, int y){
        int val = (int)((x * 1L * y) % mod);
        return val>=0 ? val : val+mod;
    }
    int add(int x, int y) {
        x += y;
        if(x < 0) x += mod;
        if(x>=mod) x -= mod;
        return x;
    }
    int sub(int x, int y){
        x = add(x,mod-y);
        if(x < 0) x += mod;
        if(x>=mod) x -= mod;
        return x;
    }
    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }
 
    int ni() throws IOException {
        return Integer.parseInt(ns());
    }
 
    long nl() throws IOException {
        return Long.parseLong(ns());
    }
 
    double nd() throws IOException {
        return Double.parseDouble(ns());
    }
 
    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }
 
    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }
 
    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }
 
    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;
 
    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

Measured memory_bytes: 33204
/*------------------------------------------------,
|  __                                       __    |
| |  |--.-----.---.-.----.----.-----.-----.|  |_  |
| |  _  |  -__|  _  |  __|  __|  -__|  _  ||   _| |
| |_____|_____|___._|____|____|_____|   __||____| |
|                                   |__|          |
`------------------------------------------------*/
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstdint>
#include <deque>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

typedef long long ll;
using namespace std;
#define INF 2147483647
#define MOD 10000007
#define REP(count_ver, lower, upper) for (long long count_ver = lower; count_ver < upper; count_ver++)

int gcd(int a, int b) {
  if (a % b == 0) {
    return (b);
  } else {
    return (gcd(b, a % b));
  }
}
int lcm(int a, int b) { return a * b / gcd(a, b); }
bool isPrime(int a) {
  if (a == 1)     return false;
  if (a == 2)     return true;
  if (a % 2 == 0) return false;
  for (int i = 3; i < sqrt(a) + 1; i += 2) if (a != i and a%i==0) return false;
  return true;
}

void execute(){

  char s;
  cin>>s;
  if(isupper(s)){
    cout<<"A"<<endl;
  }else{
    cout<<"a"<<endl;
  }

}
int main() {

  cin.tie(0);
  ios::sync_with_stdio(0);
  //cout<<fixed<<setprecision(20);

  execute();

  return 0;
}


Measured memory_bytes: 3668
local mod = 998244353
local mfl = math.floor
local function bmul(x, y)
  local x0, y0 = x % 31596, y % 31596
  local x1, y1 = mfl(x / 31596), mfl(y / 31596)
  return (x1 * y1 * 62863 + (x1 * y0 + x0 * y1) * 31596 + x0 * y0) % mod
end

local function badd(x, y)
  return (x + y) % mod
end

local n, s = io.read("*n", "*n")
local a = {}
for i = 1, n do
  a[i] = io.read("*n")
end
local dp = {}
for i = 1, s + 1 do
  dp[i] = 0
end
dp[1] = 1
if a[n] <= s then
  dp[a[n] + 1] = 1
end
local ret = dp[s + 1]
for i = n - 1, 1, -1 do
  local av = a[i]
  dp[1] = badd(dp[1], 1)
  for j = s + 1 - av, 1, -1 do
    dp[j + av] = badd(dp[j + av], dp[j])
  end
  ret = badd(ret, dp[s + 1])
end
print(ret)


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {

	final static long MOD = 1000000007L;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static ArrayList<int[]> list = new ArrayList<>();
	public static void main(String[] args) throws Exception {


		int N =nextInt();

		String s = nextString();
		String t = nextString();

		int ans = 2*N;
		for(int i=0;i<N;i++){
			int tmp=2*i;
			for(int k=0;k<N-i;k++){
				if(s.charAt(i+k)==t.charAt(k)){
					tmp++;
				}else{
					tmp=2*N;
					break;
				}
			}
			ans=Math.min(ans, tmp);
		}
		System.out.println(ans);

	}


	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


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

#ifdef LOCAL
#include "../../dump.hpp"
#else
#define dump(...)
#endif

#define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;i++)
#define FOR(i,a,b) for(int i=(a),i##_cond=(b);i<i##_cond;i++)
#define ROF(i,a,b) for(int i=(a)-1,i##_cond=(b);i>=i##_cond;i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumulate(all(a),0)
#define sz(x) ((int)(x).size())
#define pb push_back
#define fst first
#define snd second
#define mp make_pair

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<ll,ll> pii;

#define int ll

const int inf = 1ll<<62;
const int mod = 1e9+7;

main()
{
  int x, y;
  cin >> x >> y;

  int ans = inf;

  if(x <= y) ans = min(ans, y - x);

  if(-x <= y) ans = min(ans, y + x + 1);

  if(x <= -y) ans = min(ans, -y - x + 1);

  if(-x <= -y) ans = min(ans, -y + x + 2);

  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n));
#define Vec(a,n) vector<string> (a)((n));
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0));
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a));
#define Reverse(a) reverse(All(a));
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define print(a) cout << (a) << endl
#define printD(a) cout << setprecision(15) << (a) << endl;
using namespace std;
int max_int = 1000000007;
void Debug(auto a);
int nibul(auto a,auto b);
int nibuu(auto a,auto b);
void input(vector<auto>& a,int n);
double PI = 3.14159265358979;
int n;

signed main(){
    int k,a,b;
    cin >> k >> a >> b;
    int x = (b/k)*k;
    if(x>=a){
        print("OK");
    }
    else{
        print("NG");
    }

    return 0;
}

void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}

//key以上の初めてのitr
int nibul(auto a,auto b){return lower_bound(All(a),b) - a.begin();}
//key以下の最後のitr
int nibuu(auto a,auto b){return upper_bound(All(a),b) - a.begin()-1;}

void input(vector<auto>& a,int n){
    REP(i,n){
        cin >> a[i];
    }
}


Measured memory_bytes: 3592
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define LOOP(i) while(i--)
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

template<typename T>
class Point2D{
	T pos[2];
public:
	Point2D()=default;
	Point2D(T x,T y){
		pos[0]=x,pos[1]=y;
	}
	Point2D operator-(const Point2D& r){
		Point2D temp(*this);
		temp.pos[0] -= r.pos[0];
		temp.pos[1] -= r.pos[1];
		return temp;
	}
	T& operator[](int index){return pos[index];}
};

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

	int N=in();
	LOOP(N){
		Point2D<int> P[4];
		REP(i,4){
			P[i][0]=in();
			P[i][1]=in();
		}
		Point2D<double> v[2],u;
		REP(i,2){
			REP(j,2){
				v[i][j] = (P[2*i+1]-P[2*i])[j];
			}
			u[i] = P[2][i]-P[0][i];
		}

		auto cross = [](Point2D<double>& l,Point2D<double>& r){
			return l[0]*r[1]-l[1]*r[0];
		};

		if(abs(cross(v[0],v[1]))<=1e-10){
			Point2D<double> w;
			REP(i,2){
				w[i] = P[3][i]-P[0][i];
			}
			double nv[2],nu,nw;
			nv[0] = hypot(v[0][0],v[0][1]);
			nv[1] = hypot(v[1][0],v[1][1]);
			nu = hypot(u[0],u[1]);
			nw = hypot(w[0],w[1]);
			REP(i,2){
				v[0][i] /= nv[0];
				v[1][i] /= nv[1];
				//w[i] /= nw;
				//u[i] /= nu;
			}
			double k1,k2;
			k1 = v[0][0]*u[0]+v[0][1]*u[1];
			k2 = v[0][0]*w[0]+v[0][1]*w[1];

			if((nv[1]+nu>nw) && (nv[1]+nw>nu) && (nw+nu>nv[1])){
				out(0);
			}
			else if((0<=k1 && k1<=nv[0]) || (0<=k2 && k2<=nv[0]) || (0>=k1 && k2>=nv[0]) || (0>=k2 && k1>=nv[0])){
				out(1);
			}
			else out(0);
			continue;
		}
		double t1 = (cross(u,v[0]))/(cross(v[0],v[1]));
		double t2 = (cross(u,v[1]))/(cross(v[0],v[1]));
		if(0<=t1 && t1<=1 && 0<=t2 && t2<=1){
			out(1);
		}
		else{
			out(0);
		}
	}
	
	return 0;
}


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

int main() {
  string s;
  cin >> s;

  if(s.size() == 2){
    if(s[0] == s[1]){
      cout << "1 2" << endl;
    }
    else{
      cout << "-1 -1" << endl;
    }
    return 0;
  }

  rep(i, s.size() - 2){
    if(s[i] != s[i+1] && s[i] != s[i+2] && s[i+1] != s[i+2]) continue;
    cout << i+1 << " " << i+3 << endl;
    return 0;
  }
  cout << "-1 -1" << endl;
  return 0;
}

Measured memory_bytes: 512
from functools import reduce
read = input
n = int(read())
A = list(map(int, read().split()))
def gcd(a, b):
#     print(a,b)
    if a > b:
        a,b = b,a
    return a if b %a ==0 else gcd(b%a, a)
def cal(ac, x):
    if len(ac) == 0:
        ac.append(x)
        return ac
    nxt = gcd(ac[-1], x)
    ac.append(nxt)
    return ac
A1 = list(reduce(cal, A, []))
A.reverse()
A2 = list(reduce(cal, A, []))
A2.reverse()
mx = 1
for i in range(n):
    if i == 0:
        mx =max(A2[ 1 ], mx)
        continue
    elif i == n-1:
        mx = max(A1[ -2 ], mx)
        continue
    else: # i < n-1 && i > 0
        nxt = gcd(A1[i-1], A2[i+1])
        mx = max(nxt, mx)
print(mx)
# A.reverse()
# A1, A2, n, A

Measured memory_bytes: 14652
package main

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

func main() {
	io := NewIo(os.Stdin, os.Stdout)
	defer io.Flush()
	n, m := io.NextInt(), io.NextInt()
	a, b := make([]int, m), make([]int, m)
	i, j := 1, 1
	idx := 0
	if m%2 == 1 {
		a[idx] = i
		b[idx] = n + 1 - i
		i++
		idx++
	}
	for idx < m {
		a[idx] = i
		b[idx] = n + 1 - i
		i++
		idx++
		a[idx] = n/2 + 1 - j
		b[idx] = n/2 + 1 + j
		j++
		idx++
	}

	for i := range a {
		io.Println(a[i], b[i])
	}
}

// Io is I/O object
type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

// NewIo returns a new Io instance
func NewIo(r io.Reader, w io.Writer) *Io {
	return &Io{
		reader: bufio.NewReader(r),
		writer: bufio.NewWriter(w),
	}
}

// Flush flushes writer
func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

// NextLine scans a line from stdin
func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

// Next return a word from stdin
func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

// NextInt returns an integer from stdin
func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

// Println is a wrapper of fmt.Fprintln
func (io *Io) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}


Measured memory_bytes: 4792
#include <iostream>
#include <vector>

using namespace std;

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

	if (n < 105) {
		cout << 0 << endl;
	}
	else if (n < 135) {
		cout << 1 << endl;
	}
	else if (n < 165) {
		cout << 2 << endl;
	}
	else if (n < 189) {
		cout << 3 << endl;
	}
	else if (n < 195) {
		cout << 4 << endl;
	}
	else {
		cout << 5 << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i=a; i<n; i++)
#define RREP(i, a, n) for(ll i=n-1; i>=a; i--)
typedef long long ll;
const ll mod =1e9+7;
const ll inf =1e18;
using namespace std;

int a, b, c;
int main() {
    cin>>a>>b>>c;

    if(a+b+c>=22) cout<<"bust"<<endl;
    else cout<<"win"<<endl;
    return 0;
}

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

const double pi = acos(-1);
int main() {
  double a, b, h, m;
  cin >> a >> b >> h >> m;
  double theta = 2.0 * pi * (m / 60.0 - (h + m / 60.0) / 12.0);
  if (theta > pi) theta = 2.0 * pi - theta;
  double len = a * a + b * b - 2.0 * a * b * cos(theta);
  cout << setprecision(10) << sqrt(len) << endl;
  return 0;
}


Measured memory_bytes: 4216
#include<bits/stdc++.h>
using namespace std;
int main(){
        
	int k;
	cin>>k;
	int a,b;
	cin>>a>>b;
	if(a%k==0||b%k==0){
		cout<<"OK";
	}else{
		int n = a/k;
		int num = (n+1)*k;
		if(num<=b){
			cout<<"OK";
		}else{
			cout<<"NG";
		}
	}
}

Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <queue>
#include <deque>
#include <cmath>
#include <iomanip>
#include <cstdio>

using namespace std;

int main(){
    int a, b, c; cin >> a >> b >> c;
    cout << (a+b+c >= 22 ? "bust" : "win") << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <queue>
#include <sstream>
#include <unordered_map>
#include <cstring>
#include <iomanip>

using namespace std;

typedef long long ll;

const ll INF=1e13+7;

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

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

int main(){
    ll N,min=INF,count;
    cin>>N;
    for(ll i=1;i<=sqrt(N);i++){
        if(N%i==0){
            ll a=N/i;
            ll b=i;
            if(min>abs(a-b)){
                count=a+b-2;
                min=abs(a-b);
            }
        }
    }
    if(min==INF){
        cout<<N-1<<endl;
        return 0;
    }
    cout<<count<<endl;
    return 0;
}

//a=97,z=122


Measured memory_bytes: 256