akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main(){
    string S; cin >> S;
    int ans=0;
    for (int i=0; i<S.size(); i++){
        if (S[i]=='a') ans++;
        else if (S[i]=='b') ans+=2;
        else if (S[i]=='c') ans+=3;
     }
     if (ans==6) cout << "Yes";
     else cout << "No";
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
int a[4][4],i,j,test[4][4]={};
  for(j=0;j<3;j++){
	for(i=0;i<3;i++){
      scanf("%d",&a[j][i]);
    }
  }
int N,b[11];
  scanf("%d",&N);
  for(i=0;i<N;i++){
  scanf("%d",&b[i]);
   
  }
  
   for(j=0;j<3;j++){
	for(i=0;i<3;i++){
      for(int k=0;k<N;k++){
        if(a[j][i]==b[k])test[j][i]++;
      }
    }
  }

  
   for(j=0;j<3;j++){
	
      if(test[j][0]>0&&test[j][1]>0&&test[j][2]){printf("Yes");return 0;}
  }
  for(j=0;j<3;j++){
	
      if(test[0][j]>0&&test[1][j]>0&&test[2][j]){printf("Yes");return 0;}
  }
  if(test[0][0]>0&&test[1][1]>0&&test[2][2]>0){printf("Yes");return 0;}
  if(test[0][2]>0&&test[1][1]>0&&test[2][0]>0){
    printf("Yes");return 0;}
  
  printf("No");
  return 0;
}


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

using namespace std;

int main(){
	ios_base::sync_with_stdio (false);
	cout << fixed;
	cout.precision(10);
	if(fopen("joke.in", "r")){
		freopen ("joke.in","r",stdin);
		freopen ("joke.out","w",stdout);
	}

	int n;
	cin >> n;
	map<string, int> mp;
	string s;
	for(int i = 0; i < n; ++i){
		cin >> s;
		mp[s]++; 
	}

	for(string s : {"AC", "WA", "TLE", "RE"}){
		cout << s << " x " << mp[s] << endl;
	}

    return 0;
}


Measured memory_bytes: 3676
import sys
import fractions
sys.setrecursionlimit(10**6)
if sys.platform in (['ios','darwin','win32']):
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

def main():
	N, M = MAP()
	S = input().rstrip()
	T = input().rstrip()

	L = (N*M)//fractions.gcd(N, M)
	# print(L)
	n = L//N
	m = L//M
	for i in range(0, L, n):
		if i % m == 0:
			if S[i//n] != T[i//m]:
				print(-1)
				sys.exit()
	print(L)


if __name__ == '__main__':
	main()

Measured memory_bytes: 5460
s = input()
if '01' <= s[:2] <= '12':
    if '01' <= s[2:] <= '12':
        exit(print('AMBIGUOUS'))
    else:
        exit(print('MMYY'))
else:
    if '01' <= s[2:] <= '12':
        exit(print('YYMM'))
print('NA')


Measured memory_bytes: 2940
#include<stdio.h>
#include<algorithm>
using namespace std;
long long d[510000];
pair<long long,int> e[510000];
int main(){
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	for(int i=0;i<a;i++)scanf("%lld",d+i);
	long long ret=-999999999999999LL;
	long long sum=0;
	for(int i=0;i<a;i++){
		e[i]=make_pair(d[i]+(long long)i*b,i);
		sum+=d[i];
	}
	std::sort(e,e+a);
	for(int i=0;i<=a;i++){
		//printf("%lld\n",sum);
		ret=max(ret,(long long)i*(i-1)*b+sum+(long long)b*c*i);
		if(i<a){
			sum-=d[e[i].second];
			sum-=(long long)e[i].second*b;
		}
		
	}
	printf("%lld\n",ret);
}

Measured memory_bytes: 12904
import java.util.*

fun main(args : Array<String>) {
    val sc = Scanner(System.`in`)

    val r = sc.next().toInt()

    val res = if(r < 1200) {
        "ABC"
    }else if(r < 2800) {
        "ARC"
    }else{
        "AGC"
    }

    println(res)
}

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

int main() {
  ios::sync_with_stdio(false);

  int N, T, A;
  cin >> N >> T >> A;

  double mni = 1e9;
  int cnt = 1, ans;

  for (int i = 0; i < N; i++) {
    int H;
    cin >> H;
    double tem = T - H * 0.006;
    if (abs(A - tem) < mni) mni = abs(A - tem), ans = cnt;
    cnt++;
  }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
#define rep(i, n) for(int i=0; i < (n); i++)
#define ALL(a) (a).begin(),(a).end()
#define PRINT(V) for(auto v:(V))cout<<v<<" "
inline int GCD(int a, int b){return b ? GCD(b, a % b) : a;}
const int MOD = 1000000007;

int bcont(vi &b, int n)
{
    int bc = -1;
    rep(i, n)
    {
        if (b.at(i) == i + 1)
        {
            bc = i;
        }
    }
    return bc;
}

int main()
{
    int N;
    cin >> N;
    vi b(N);
    rep(i, N)
    {
        cin >> b.at(i);
    }
    vi ans;
    for (int i = N; i > 0; i--)
    {
        int bc = bcont(b, i);
        if (bc == -1)
        {
            cout << -1 << endl;
            return 0;
        }
        ans.insert(ans.begin(), bc+1);
        b.erase(b.begin()+bc);
    }
    rep(i, N)
    {
        cout << ans.at(i) << endl;
    }
}

Measured memory_bytes: 256
// {{{
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
// }}}

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

static constexpr int mod = (int)1e9 + 7;
static constexpr int inf = 100100100;
static constexpr ll linf = 1e18;
static constexpr double eps = 1e-9;
static constexpr double pi = 3.14159265359;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rrep(i, n) for (ll i = n; i >= 0; --i)
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define pb push_back
#define ist insert
#define fst first
#define snd second


ll N, D;
double dist(const vector<ll>& lhs, const vector<ll>& rhs) {
    double d = 0;
    rep (i, D) {
        d += pow(lhs[i] - rhs[i], 2);
    }
    return sqrt(d);
}

int main() {
    // cin.tie(0);
    // ios_base::sync_with_stdio(false);
    cin >> N >> D;
    vector<vector<ll>> X;
    rep (i, N) {
        vector<ll> x;
        rep (j, D) {
            ll c;
            cin >> c;
            x.pb(c);
        }
        X.pb(move(x));
    }
    ll ans = 0;
    for (ll i = 0; i < N; ++i) {
        for (ll j = i + 1; j < N; ++j) {
            double d1 = dist(X[i], X[j]);
            double d2 = round(d1);
            if (abs(d1 - d2) < eps) {
                ++ans;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=n;i<(int)N;i++)
#define RREP(i,n,N) for(int i=N-1;i>=n;i--)
#define p(s) cout<<(s)<<endl
#define ck(n,a,b) ((a)<=(n)&&(n)<=(b))
#define F first
#define S second
typedef long long ll;
using namespace std;
const ll inf=LONG_LONG_MAX;

ll N,K;
ll x[51],y[51];
ll ans;
int main() {
	cin>>N>>K;
	REP(i,0,N){
		cin>>x[i]>>y[i];

	}
	ans=inf;
	REP(i,0,N){
		REP(j,i,N){
			REP(k,j,N){
				REP(l,k,N){
					ll dot=0;
					ll mnx=min(min(x[k],x[l]),min(x[i],x[j]));
					ll mxx=max(max(x[k],x[l]),max(x[i],x[j]));
					ll mny=min(min(y[k],y[l]),min(y[i],y[j]));
					ll mxy=max(max(y[k],y[l]),max(y[i],y[j]));
					REP(n,0,N){
						if(ck(x[n],mnx,mxx)&&ck(y[n],mny,mxy)) dot++;
					}
					if(dot==K){
						ans=min(ans,(mxx-mnx)*(mxy-mny));
					}
				}
			}
		}
	}
	p(ans);
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
int a[31]={0},i,k;


for(i=1;i<=28;i++){

scanf("%d",&k);
a[k]=1;
k=0;

}

for(i=1;i<=30;i++){
if(a[i]==0){printf("%d\n",i);
}
}

return 0;



}

Measured memory_bytes: 1784
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	int n, m; cin>>n>>m;
	vector<string> v(n);
	for(int i = 0; i<n and cin>>v[i]; i++);
	sort(v.begin(), v.end());
	for(int i = 0; i<n and cout<<v[i]; i++);
	
	return 0;
}

Measured memory_bytes: 3664
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}


int main(){
  string s;
  cin >> s;
  bool fd = false;
  rep(i,0,sz(s)) rep(j,i+1,sz(s))
    fd |= s[i] == 'C' && s[j] == 'F';
  cout << (fd ? "Yes" : "No") << endl;
  return 0;
}


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

int main() {
	int a;
	while (cin >> a, a) {
		int s = 1 << 29;
		for (int x = 0;; x++) {
			if (x*x*x > a)break;
			int y = sqrt(a - x*x*x);
			s = min(s, x + y + a - x*x*x - y*y);
		}
		cout << s << endl;
	}
}

Measured memory_bytes: 3088
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.format;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

enum MOD = (10 ^^ 9) + 7;

void main()
{
    long N = lread();
    long[long] D;
    foreach (n; 1 .. N + 1)
    {
        long i = 2;
        while (n != 1)
        {
            // writeln(n);
            if (n < i * i)
            {
                D[n]++;
                n = 1;
            }
            while (n % i == 0)
            {
                n /= i;
                D[i]++;
            }
            i++;
        }
    }
    long ans = 1;
    // writeln(D);
    foreach (v; D.values)
    {
        ans = ans * (v + 1) % MOD;
    }
    writeln(ans);
}


Measured memory_bytes: 256
use std::io::{self, Read};
use std::str::FromStr;

pub struct Scanner<R: Read> {
    reader: R,
}
impl<R: Read> Scanner<R> {
    pub fn new(reader: R) -> Scanner<R> {
        Scanner { reader: reader }
    }
    pub fn read<T: FromStr>(&mut self) -> T {
        let s = self
            .reader
            .by_ref()
            .bytes()
            .map(|c| c.expect("failed to read char") as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        s.parse::<T>().ok().expect("failed to parse token")
    }
}

struct Node {
    parent: Option<usize>,
    left: Option<usize>,
    right: Option<usize>,
}

fn preorder(nodes: &Vec<Node>, idx: Option<usize>, top: bool){
    if let Some(i) = idx {
        if top {
            println!("Preorder");
        }
        print!(" {}", i);
        preorder(nodes, nodes[i].left, false);
        preorder(nodes, nodes[i].right, false);
    }
}

fn inorder(nodes: &Vec<Node>, idx: Option<usize>, top: bool){
    if let Some(i) = idx {
        if top {
            println!("Inorder");
        }
        inorder(nodes, nodes[i].left, false);
        print!(" {}", i);
        inorder(nodes, nodes[i].right, false);
    }
}

fn postorder(nodes: &Vec<Node>, idx: Option<usize>, top: bool){
    if let Some(i) = idx {
        if top {
            println!("Postorder");
        }
        postorder(nodes, nodes[i].left, false);
        postorder(nodes, nodes[i].right, false);
        print!(" {}", i);
    }
}


fn main() {
    let sin = io::stdin();
    let sin = sin.lock();
    let mut sc = Scanner::new(sin);

    let n: usize = sc.read();
    let mut nodes: Vec<Node> = (0..n)
        .map(|_| Node{ 
            parent: None,
            left: None,
            right: None,
        }).collect();

    for _ in 0..n {
        let id: usize = sc.read();
        let left: i32  = sc.read();
        let right: i32 = sc.read();
        if left != -1 {
            let lf = left as usize;
            nodes[id].left = Some(lf);
            nodes[lf].parent = Some(id);
        }
        if right != -1 {
            let rg = right as usize;
            nodes[id].right = Some(rg);
            nodes[rg].parent = Some(id);
        }
    }

    for i in 0..n {
        if nodes[i].parent.is_none() {
            preorder(&nodes, Some(i), true);
            println!("");
            inorder(&nodes, Some(i), true);
            println!("");
            postorder(&nodes, Some(i), true);
            println!("");
            break;
        }
    }
}



Measured memory_bytes: 5020
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for (ll i = 0; i < n; i++)
#define IREP(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i < b + 1; i++)
#define all(v) v.begin(), v.end()
#define SENTINEL 2000000000
#define NIL -1
using namespace std;
typedef long long ll;

const ll MAX = 510000;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
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;}

int main()
{
    int a,b,q;
    cin >> a >> b >> q;
    vector<ll> s(a+2);
    REP(i,a){
        cin >> s[i+1];
    }
    s[0]=-30000000000;
    s.back()=30000000000;
    vector<ll> t(b+2);
    REP(i,b){
        cin >> t[i+1];
    }
    t[0]=-30000000000;
    t.back()=30000000000;
    REP(i,q){
        ll x;
        cin >> x;
        auto itr1=lower_bound(all(s),x);
        auto itr2=lower_bound(all(t),x);
        auto itr1_=itr1-1;
        auto itr2_=itr2-1;
        ll m=20000000001;
        chmin(m,max(*itr1-x,*itr2-x));
        chmin(m,max(x-*itr1_,x-*itr2_));
        chmin(m, min(*itr1 - x, x - *itr2_) * 2 + max(*itr1 - x, x - *itr2_));
        chmin(m, min(*itr2 - x, x - *itr1_) * 2 + max(*itr2 - x, x - *itr1_));
        cout << m << endl;
    }
}


Measured memory_bytes: 4840
import java.util.Arrays;
import java.util.Scanner;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

public class Main {
  Scanner sc = new Scanner(System.in);

  public static void main(String[] args) {
    new Main().run();
  }

  void run() {
    String str = sc.next();
    char[] ans = str.toCharArray();
    int k = ni();
    for (int i = 0; i < str.length(); ++i) {
      int a = str.charAt(i);
      if (a == 'a') {
        continue;
      }
      int v = 'z' - a + 1;
      if (v <= k) {
        k -= v;
        ans[i] = 'a';
      }
    }
    int r = ans[str.length() - 1];
    r += k;
    r -= 'a';
    r %= 'z' - 'a' + 1;
    r += 'a';
    ans[str.length() - 1] = (char)r;
    String aaa = new String(ans);
    System.out.println(aaa);
  }

  int ni() {
    return Integer.parseInt(sc.next());
  }

  void debug(Object... os) {
    System.err.println(Arrays.deepToString(os));
  }

}


Measured memory_bytes: 14296
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

int asc(const void* a, const void* b) {
	return *(int*)a- *(int*)b;
}

int main()
{
	int n, i;
	int h[100050];
	cin >> n;
	rep(i, n) cin >> h[i];
	for (i = n-2; i >= 0; i--) {
		if (h[i] - h[i + 1] > 1) {
			break;
		}
		else if (h[i] - h[i + 1] > 0) {
			h[i]--;
		}
	}
	if (i < 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 640
#include <vector>
#include <cmath>
#include <algorithm>
#include <iostream>

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


ll minimum(ll a, ll b){
  if(a<b) return a;
  else return b;
}

void solve(long long N, std::vector<long long> A, std::vector<long long> B){
  ll d, rst=0;
  for(ll i=0; i<N; i++){
    d = minimum(A[i], B[i]);
    B[i] -= d;
    A[i] -= d;
    rst += d;

    d = minimum(A[i+1], B[i]);
    B[i] -= d;
    A[i+1] -= d;
    rst += d;
  }
  cout << rst << endl;

}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N+1);
    for(int i = 0 ; i < N+1 ; i++){
        scanf("%lld",&A[i]);
    }
    std::vector<long long> B(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&B[i]);
    }
    solve(N, std::move(A), std::move(B));
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long MOD=1000000007;
  long long P=1;
  int N;cin>>N;
  for(long long i=1;i<N+1;i++){
    P=(P*i)%MOD;
  }
  cout<<P%MOD<<endl;
}
    

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int i,j,k;string s,t;
int main(){
	getline(cin,s);
	while (s.length()>0){
		t=s.substr(0,5);
		if (t=="dream"){
			s=s.substr(5);
			if (s=="") break;
			if (s.length()==1){printf("NO");return 0;}
			else if (s.length()==2){
				if (s[0]=='e'&&s[1]=='r') s="";
				else {printf("NO");return 0;}
			}
			else {
				if (s[0]=='e'&&s[1]=='r'&&s[2]!='a') s=s.substr(2);
			}
		}
		else if (t=="erase"){
			s=s.substr(5);
			if (s=="") break;
			if (s.length()==1){
				if (s[0]=='r') s="";
				else {printf("NO");return 0;}
			}
			else {
				if (s[0]=='r') s=s.substr(1);
			}
		}
		else {printf("NO");return 0;}
	}
	printf("YES\n");
}

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

using namespace std;

int H,W,K;
int X1,Y1,X2,Y2;
int dx[]={-1,1,0,0};
int dy[]={0,0,-1,1};
vector<vector<bool>> grid;
vector<vector<int>> dist;

bool inside(int i,int j){
	return (i>=0)&&(i<H)&&(j>=0)&&(j<W)&&(grid[i][j]);
}
 
int main(){
    cin>>H>>W>>K;
    cin>>X1>>Y1>>X2>>Y2;
    X1--;X2--;Y1--;Y2--;
    grid.resize(H);
    dist.resize(H);
    for(int i=0;i<H;i++){
        string s;
        cin>>s;
        grid[i].resize(W);
        dist[i].resize(W,INT_MAX);
        for(int j=0;j<W;j++) 
        	grid[i][j]=(s[j]=='.');
    }
    queue<pair<int,int>> q;
    q.push({X1,Y1});
    dist[X1][Y1]=0;
    while(!q.empty()){
        int i=q.front().first,j=q.front().second;
        	q.pop();
        for(int k=0;k<4;k++){
        	for(int d=1;d<=K;d++){
            	int x=i+d*dx[k],y=j+d*dy[k];
            	if(!inside(x,y)||dist[x][y]<=dist[i][j]) 
            		break;
            	if(dist[x][y]==INT_MAX){
                	dist[x][y]=dist[i][j]+1;
                	q.push({x,y});
            	}
        	}
        }
    }
    int ans=dist[X2][Y2];
    if(ans==INT_MAX) 
    	ans=-1;
    cout << ans << endl;
}

Measured memory_bytes: 8204
#include <bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i = (int)j;i <= (int)k;i ++)
#define debug(x) cerr<<#x<<":"<<x<<endl
const int maxn=(int)1e6+5;
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n;cin>>n;
    int cur=1;
    rep(i,1,n){
        int x;cin>>x;
        if(x==cur)cur++;
    }
    cout<<(cur==1?-1:n-cur+1)<<endl;
}
/* 
3
2 1 2
 */

Measured memory_bytes: 384
#include <iostream>//cout<<right で右揃え
#include <iomanip>//cout<<setw(数字) で空白による桁揃え
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <cstdlib>//abs()で整数絶対値
#include <cmath>//abs()かfabs()で少数絶対値
#include <functional>//sort第三引数greater<型名>()で降順
#include <map>

using namespace std;
using ll = long long int;

int main(){
    ll N;cin>>N;
    ll ans = N*(N+1)-1;
    for(int i=2;i<=N/2;i++){
        for(int j=2;i*j<=N;j++){
            ans += i*j;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main(void) {
    ll N;
    cin >> N;
    ll c;
    ll head,leg;
    for (ll a=1; a<=3500; a++) {
        for (ll b=1; b<=3500; b++) {
            head = N*a*b;
            leg = 4*a*b - N*a - N*b;
            if (leg <= 0 || head % leg != 0) {
                continue;
            } else {
                c = head / leg;
                if (c < 1 || c > 3500) continue;
                cout << a << " " << b << " " << c << endl;
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 764
#include<stdio.h>
int main()
{
	int a,b,c=0,i;
	int x[100001],y[100001],z[100001],w[100001]={0};
	scanf("%d %d",&a,&b);
	for(i=1;i<=a;i++){
		scanf("%d",&x[i]);
	}
	for(i=1;i<=b;i++){
		scanf("%d %d",&y[i],&z[i]);
		if(x[y[i]]==x[z[i]]){
			w[y[i]]++;
			w[z[i]]++;
		}
		else if(x[y[i]]<x[z[i]]){
			w[y[i]]++;
		}
		else w[z[i]]++;
	}
	for(i=1;i<=a;i++){
		if(w[i]==0){
			c++;
		}
	}
	printf("%d\n",c);
	return 0;
}

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

// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
  
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

#define ll long long
#define fill fill_n
#define pf push_front
#define pb push_back
#define FOR(i,l,r) for(int i=l;i<r;i++)
#define ROF(i,r,l) for(int i=r;i>=l;i--)
#define comp(v) (v).begin(),(v).end()
#define ff first
#define ss second
#define infile freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
typedef vector<int> vi;
typedef vector<ll> vli;
typedef vector<pair<int,int>> vpi;

const int M = 1e9+7;
const int N = 2e5;
ll po(int,int);


void solve(){
    int n;cin>>n;
    
    ll a;
    
    ll s=0,ans=0;
    
    FOR(i,0,n){
        cin>>a;
        ans = (ans + (a*s))%M;
        s = (s+a)%M; 
    }
    cout<<ans<<"\n";
    
}





int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    int t=1;
    //cin>>t;
    FOR(i,1,t+1){
        //cout<<"Case #"<<i<<": "; 
        solve();
    }
    
	return 0;
	
	
}


ll po(int a,int b){
    if(b==0) return 1;
    ll ans=1;
    if(b%2==0){
        ans = po(a,b/2)%M;
        ans=(ans%M * ans%M)%M;
    }
    else{
        ans = po(a,(b-1)/2)%M;
        ans = (ans%M * ans%M * a)%M;
    }
    return ans%M;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define LL long long
#define maxn 100005
using namespace std;

int main()
{
     int n;
     cin>>n;
     char ch[200];
     scanf("%s",ch);
     int flag=1;
     if(n%2==1)
        flag=0;
     int k=n/2;
     //cout<<k<<endl;
     for(int i=0;i<k&&flag;i++)
     {
         if(ch[i]!=ch[i+k])
         {
             flag=0;
             break;
         }
     }
     if(flag)
        cout<<"Yes"<<endl;
     else
        cout<<"No"<<endl;
}


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

int main()
{
	unsigned long long H, W;
	cin >> H >> W;
	unsigned long long sum;
	
	if (H == 1||W==1) {
		sum = 1;
	}

	else if (W % 2 == 0)
	{
		sum = H * W / 2;
	}
	else if (W%2 !=0)
	{
		if (H % 2 != 0) {
			unsigned long long x = W / 2 + 1;
			unsigned long long y = H / 2 + 1;

			sum = x * y + (x - 1)*(H - y);
		}
		else {
			unsigned long long x = W / 2 + 1;
			unsigned long long y = H / 2;

			sum = x * y + (x - 1)*(H - y);
		}
	}

	cout << sum << endl;

	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define PI 3.14159265358979
#define EPS 1e-8
#define mod  998244353
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define endl "\n"
#define NEG_INF -2e18
			 
const ll INF=1e15;	
const int N=2e5+50;
		 
 

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(0);
		
	ll n;
	cin>>n;
	ll ans=0;
	for(ll i=1;i<n;i++)
	{
		ans+=(n-1)/i;
	}
	cout<<ans;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
const ll INF = 1e18;
/* テンプレートここまで */
void yes(){
  cout << "Yes" << endl;
  exit(0);
}

void no(){
  cout << "No" << endl;
  exit(0);
}

int main() {
  string s; cin >> s;
  map<char, ll> cnt;
  FOREACH(x, s){
    cnt[x]++;
  }
  FOREACH(x, cnt){
    if(x.second%2 != 0) no();
  }
  yes();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll          long long int
#define uu          first
#define vv          second
#define pii         pair<int,int>
#define pll         pair<ll,ll>
#define INF         1e9
#define fastRead    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;

const ll MOD = 1e9 + 7;
const int MAX = 3e5 + 5;

int main()
{
    fastRead;
    int n , m;
    cin>>n>>m;
    vector<ll>sum(n+1);
    
    for(int i =1 ; i<=n ; i++) {
        sum[i] = (i+ sum[i-1])%MOD;
    }
    
//    for(auto x : sum )cout<<x<<" ";
//    cout<<'\n';
//    
    ll ans = 0;
    for(int i = m ; i <=n + 1 ; i++ ) {
        
        ll frm = sum[i-1];
        ll to = sum[n];
        if( n- i >= 0 ) to = (sum[n] - sum[n-i])%MOD;
        
//        cout<<i<<" "<<frm<<" "<<to<<'\n';
        
        ll tmp = (to -frm + MOD +1)%MOD;
        ans = (ans + tmp)%MOD;
    }
    
    cout<<ans<<'\n';
    
}

Measured memory_bytes: 4784
n = int(input())
a = [0] + list(map(int, input().split()))
for i in range(n):
  a[i+1] += a[i]
an = a[-1]
ans = an
p,r = 1,3
for q in range(2,n-1):
  lef = a[q]
  while abs(a[p]*2-lef) > abs(a[p+1]*2-lef):
    p += 1
  while r < n and abs(an+lef-a[r]*2) > abs(an+lef-a[r+1]*2):
    r += 1
  l = [a[p]-a[0], a[q]-a[p], a[r]-a[q], an-a[r]]
  cur = max(l)-min(l)
  if ans > cur:
    ans = cur
print(ans)

Measured memory_bytes: 24792
#include<iostream>
#include<algorithm>
#include<queue>

using namespace std;

int main(){
  int w,h;
  cin>>w>>h;
  int m[h+2][w+2];
  for(int i = 0;i<=h+1;i++)
    for(int j = 0;j<=w+1;j++)
      m[i][j] = 0;
  
  
  for(int i = 1;i<=h;i++){
    for(int j = 1;j<=w;j++){
      cin>>m[i][j];
    }
  }
  int dx_1[] ={0,1,-1,1,0,+1};
  int dy_1[] = {-1,-1,0,0,1,1};
  int dx_0[] = {-1,0,-1,1,-1,0};
  int dy_0[] = {-1,-1,0,0,1,1};

  int ans = 0;

  queue<pair<int,int> > que;
  que.push(make_pair(0,0));
  m[0][0] = 2;

  while(!que.empty()){
    pair<int,int> p = que.front();que.pop();
    if(m[p.second][p.first] == 1)
      continue;
    for(int k = 0;k<6;k++){
      int x = p.second % 2 == 0 ? p.first+dx_0[k]:p.first+dx_1[k];
      int y = p.second % 2 == 0 ? p.second+dy_0[k]:p.second+dy_1[k];
      if(x >= 0 && x <= w+1 && y >= 0 && y <= h+1 && m[y][x] == 0){
	que.push(make_pair(x,y));
	m[y][x] = 2;
      }
    }   

  }
  //m[h+1][w+1] = 2;
  /*
  for(int i = 0;i<=h+1;i++){
    for(int j = 0;j<=w+1;j++){
      cout<<m[i][j];
    }
    cout<<endl;
  }
  
  */
  
  for(int i = 0;i<=h+1;i++){
    for(int j = 0;j<=w+1;j++){
      int tmp = 0;
      if(m[i][j] == 2){
	for(int k = 0;k<6;k++){
	  int x = i % 2 == 0 ? j+dx_0[k]:j+dx_1[k];
	  int y = i % 2 == 0 ? i+dy_0[k]:i+dy_1[k];
	  if(x >= 0 && x <= w+1 && y >= 0 && y <= h+1)
	    if(m[y][x] == 1)
	      tmp++;
	}
	//cout<<"xy:"<<j<<"\t"<<i<<endl;
	//cout<<"tmp:"<<tmp<<endl;
	ans += tmp;
      }
    }
  }


  cout<<ans<<endl;
	  
  
  

  return 0;

}

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

#define MP make_pair
#define FF first
#define SS second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pie;
const int MOD = 1e9 + 7;
const int INF = 2e9;
const ll LINF = 4e18;
const ll delta = 10289;

const int N = 1e5 + 20;
ll n , a[N], p[N], pre[N], suf[N], k, ans;

int main() {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n >> k;
	for (int i = 1; i <= n; i++)
		cin >> a[i], p[i] = a[i];
	for (int i = 1; i <= n; i++) {
		p[i] += p[i - 1];
		pre[i] = pre[i - 1] + (a[i] > 0) * a[i];
	}
	for (int i = n; i >= 1; i--)
		suf[i] = suf[i + 1] + (a[i] > 0) * a[i];
	for (int i = 1; i <= n - k + 1; i++)
		ans = max({ans, p[i + k - 1] - p[i - 1] + pre[i - 1] + suf[i + k], pre[i - 1] + suf[i + k]});
	cout << ans << endl;
}



Measured memory_bytes: 3328
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
#define debug(x) cout << #x << " = " << x << '\n'
#define debug_arr(a , n) for(int i = 0 ; i < n ; i++)cout << a[i] << " "
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define vll vector<ll> 
#define inf 1000000000
#define mod 1000000007

const int max_n = 1e5 + 9;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
ll power(ll a , ll b)
{
    ll prod = 1;
    while(b)
    {
        if(b&1)
        prod = (prod*a)%mod;
        a = (a*a)%mod;
        b >>= 1;
    }
    return prod;
}
int main()
{
    string s;
    cin >> s;

    for(char c : s){
        if(c == '?')cout << "D";
        else
        cout << c;
    }
    return 0;
}

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

#define ll long long
#define ar array

const int mxH=10, mxW=1e3;
int h, w, k, ans=1e9;
string g[mxH];
vector<int> v[mxW];

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

	cin >> h >> w >> k;
	for(int i=0; i<h; ++i)
		cin >> g[i];
	for(int i=0; i<1<<h-1; ++i) {
		int ca=__builtin_popcount(i);
		for(int j=0; j<w; ++j) {
			int s=0;
			for(int k=0; k<h; ++k) {
				s+=g[k][j]&1;
				if(i>>k&1) {
					v[j].push_back(s);
					s=0;
				}
			}
			v[j].push_back(s);
			for(int vi : v[j])
				if(vi>k)
					ca=1e9;
		}
		vector<int> u(v[0].size());
		for(int j=0; j<w; ++j) {
			bool split=0;
			for(int l=0; l<u.size(); ++l)
				split|=u[l]+v[j][l]>k;
			if(split) {
				++ca;
				u=vector<int>(u.size());
			}
			for(int l=0; l<u.size(); ++l)
				u[l]+=v[j][l];
			v[j].clear();
		}
		//cout << i << " " << ca << endl;
		ans=min(ca, ans);
	}
	cout << ans;
}

Measured memory_bytes: 384
/*
    Life Before Death, Strength Before Weakness, Journey Before Destination
    ------------------------------------------------------------------------
    You don't become great by trying to be great.
    You become great by wanting to do something,
    and then doing it so hard that you become great in the process.
    */
 
    //#pragma comment(linker, ack:200000000")
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
    #include <bits/stdc++.h>
    using namespace std;
    
    #define TRACE
    
    #ifdef TRACE
    #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
      cerr << name << " : " << arg1 << std::endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
      const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
    #else
    #define trace(...)
    #endif
    
    #define rep(i, n)    for(ll i = 0; i < (n); ++i)
    #define repA(i, a, n)  for(ll i = a; i <= (n); ++i)
    #define repD(i, a, n)  for(ll i = a; i >= (n); --i)
    #define trav(a, x) for(auto& a : x)
    #define all(x) x.begin(), x.end()
    #define sz(x) (int)(x).size()
    #define fill(a)  memset(a, 0, sizeof (a))
    #define fst first
    #define snd second
    //#define mp make_pair
    #define pb push_back
    #define PI           3.141592653589793238462643383279502884197169399  /* pi */
    // #define te    
    typedef long double ld;
    typedef long long ll;
    typedef pair<ll, ll> pii;
    typedef vector<ll> vi;
    const int maxN = 100100;

    map<ll, ll> dp;

    void solve() {
        dp[0] = 0;
        ll N, W, res = 0;
        cin >> N >> W;
        while(N--){
            ll w, v, cnt = 0;
            cin >> w >> v;
            for(auto i = dp.rbegin(); i!=dp.rend(); i++){
                ll wt = w + i->fst, vt = v + i->snd;
                //cout << i.fst << " this " << i.snd << endl;
                if(wt <= W){
                    dp[wt] = max(dp[wt], vt);
                   // cout << N << " " << wt << " " << dp[wt] << endl;
                }           
            }
        }
        trav(i, dp) res = max(res, i.snd);
        cout << res << endl;    
    }
 
    int main() {
      cin.sync_with_stdio(0); cin.tie(0);
      cin.exceptions(cin.failbit);
       // ll ti;   cin >> ti;  while(ti--)
      solve();
      return 0;
    } 

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define fo(i,n) for(int i=0; i<n; i++)
#define fof(i,s,e) for(int i=s; i<e; i++)
#define fob(i,e,s) for(int i=e; i>=s; i--)

#define pb push_back
#define mp make_pair
#define F first
#define S second
#define clr(x) memset(x, 0, sizeof(x))
#define all(v) (v).begin(),(v).end() 
#define arl(v) (v).rbegin(),(v).rend() // from right
#define vmn(a) (*min_element(a.begin(),a.end())) // vector min   
#define vmx(a) (*max_element(a.begin(),a.end())) // vector max
#define MOD 1000000007
typedef long long ll;
typedef map<int, int> mi;
typedef unordered_map<int, int> umi;
typedef pair<int, int> pii;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
void inn(int &number);
//-----------------------------------------------------------------------------

void code(){
    int n;
    cin>>n;

    int a=0, r=0, t=0, w=0;
    while(n--) {
        string s;
        cin>>s;

        if(s=="AC") a++;
        else if(s=="RE") r++;
        else if(s=="TLE") t++;
        else w++;
    }

    cout<<"AC x "<<a<<endl;
    cout<<"WA x "<<w<<endl;
    cout<<"TLE x "<<t<<endl;
    cout<<"RE x "<<r<<endl;


}

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

int main(){
    IOS;
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
        
    int t=1;
    // cin>>t;
    fo(i,t) {
        //cout<<"Case #"<<i+1<<" :";
        code();
    }

    return 0;
}

Measured memory_bytes: 3676
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        v: chars
    }
    let n = v.len();
    let mut dp = vec![vec![usize::max_value(); 2]; n + 1];
    dp[0][0] = 0;
    dp[0][1] = 1;
    for i in 0..n {
        let d = ctoi(v[i]);
        dp[i + 1][0] = min(dp[i][0] + d, dp[i][1] + 10 - d);
        dp[i + 1][1] = min(dp[i][0] + d + 1, dp[i][1] + 10 - d - 1);
    }
    println!("{}", dp[n][0]);
}

fn ctoi(c: char) -> usize {
    (c as u8 - '0' as u8) as usize
}


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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;
    cin >> N;
    
    vector<int> L;
    L.emplace_back(0);
    for (int i = 0; i < N; ++i) {
        int t;
        cin >> t;
        L.emplace_back(t);
    }
    L.emplace_back(0);
    int p = 0;
    int cost = 0;
    for (int j = 1; j < N+2; ++j) {
        cost += abs(L[j] - p);
        p = L[j];
    }
    
    for (int i = 1; i < N+1; ++i) {
        cout << cost - abs(L[i-1]-L[i]) - abs(L[i]-L[i+1]) + abs(L[i-1]-L[i+1]) << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1784
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>	
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r);
#define TYPE long long
#define MEMSET(a) memset(a,0,sizeof(a))
const int mod=(int)1e09+7;

int in(void){
	int i;scanf("%d",&i);
	return i;
}
long long llin(void){
	long long i;scanf("%lld",&i);
	return i;
}
double din(void){
	double i;scanf("%lf",&i);
	return i;
}
void chin(char s[]){
	scanf("%s",s);
}
void print(int a){
	printf("%d\n",a);
}
void llprint(long long a){
	printf("%lld\n",a);
}
void dprint(double a){
	printf("%.10f\n",a);
}
void print2(int a,int b){
	printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
	return a>b?a:b;
}
long long min(long long a,long long b){
	return a<b?a:b;
}
long long llabs(long long a){
	return a>0?a:-a;
}
double dmax(double a,double b){
	return a>b?a:b;
}
int cmp(const void *a,const void *b){
	return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
	return *(TYPE *)b-*(TYPE *)a;
}
int char_cmp(const void *a,const void *b){
	return strcmp((char *)a,(char *)b);
}
int char_cmp_r(const void *a,const void *b){
	return strcmp((char *)b,(char *)a);
}
void swap(int *a,int *b){
	int t=*a;
	*a=*b;
	*b=t;
}
long long gcd(long long x,long long y){
	return x%y?gcd(y,x%y):y;
}
long long lcm(long long x,long long y){
	return x/gcd(x,y)*y;
}

// konoshita kara kaku

int dp[45][401][401];

int main(void){
	int n=in(),ma=in(),mb=in(),a[40],b[40],c[40],i,j,k,ans=inf;
	rep(i,n){
		a[i]=in();
		b[i]=in();
		c[i]=in();
	}
	rep(i,41)rep(j,401)rep(k,401)dp[i][j][k]=inf;
	dp[0][0][0]=0;
	rep(i,n){
		rep(j,401){
			rep(k,401){
				if(dp[i][j][k]==inf)continue;
				dp[i+1][j][k]=min(dp[i+1][j][k],dp[i][j][k]);
				dp[i+1][j+a[i]][k+b[i]]=min(dp[i+1][j+a[i]][k+b[i]],dp[i][j][k]+c[i]);
			}
		}
	}
	for(i=1;i<401;i++)
		for(j=1;j<401;j++)
			if(ma*j==i*mb)ans=min(ans,dp[n][i][j]);
	print(ans!=inf?ans:-1);
	return 0;
}

Measured memory_bytes: 26752
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <stack>
#include <bitset>

using namespace std;
typedef vector<int> vi;
typedef vector<vi> vi2;

const int INF = 1 << 30;

int solve();

int main(void) {

	while (solve()){}

	return 0;

}

int solve() {

	int n;
	cin >> n;
	if (!n) { return 0; }

	//input
	vector<bool> visited((1 << n),false);


	vi x(n), y(n), r(n), c(n);
	vi2 con(n, vi(n,0));

	for (int i = 0; i < n; i++)
		cin >> x[i] >> y[i] >> r[i] >> c[i];

	//are circles touching
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			int dx, dy, dr, d;
				dx = x[i] - x[j];
				dy = y[i] - y[j];
				dr = r[i] + r[j];
				d = dx*dx + dy*dy;
			//d:??????????????¢
			if (dr*dr > d) {
				con[i][j] = 1;
			}
		}
	}

	/*
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cout << con[j][i] << " ";
		}
		cout << endl;
	}
	*/
	//depth first search

	int ans = 0;

	stack<int> q;
	q.push( 0 );

	while ( !q.empty() && ans < n ) {

		int p = q.top();
		q.pop();
		visited.at(p) = true;

		ans = max(ans,(int)bitset<32>(p).count());
		
		//remove two circles
		for (int i = 0; i < n; i++) {

			if (p & (1 << i)) { continue; }

			for (int j = i+1; j < n; j++) {

				if (p & (1 << j)) { continue; }
				if (c[i] != c[j]) { continue; }

				bool b = false;
				for (int k = 0; k < i && b == false; k++) {
					b |= (con[k][i] != 0 && ( ( p & ( 1 << k ) ) == 0 ) );
				}
				for (int k = 0; k < j && b == false; k++) {
					b |= (con[k][j] != 0 && ( ( p & ( 1 << k ) ) == 0 ) );
				}

				if ( !b ) {

					int next = (p | (1 << i) | (1 << j));
					if (!visited.at(next)) {
						q.push(next);
					}

				}

			}
		}

	}
	cout << ans << endl;

	return 1;
}

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


int main(){
    int n;
    long long max = 1000000;
    long long min = -1000000;
    long long sum = 0;
    long long a;
    
    
    
    cin >> n;
    
    
    for(int i = 0; i < n; i++){
        cin >> a;
        if (a < max) max = a;
        if (a > min) min = a;
        sum += a;
    }
    
    
    cout << max << " " << min << " " << sum << endl;

    
    return 0;
    
}

Measured memory_bytes: 3096
from collections import deque
import sys
readline = sys.stdin.readline
write = sys.stdout.write

D = [
    (1, 5, 2, 3, 0, 4), # 'U'
    (3, 1, 0, 5, 4, 2), # 'R'
    (4, 0, 2, 3, 5, 1), # 'D'
    (2, 1, 5, 0, 4, 3), # 'L'
]
p_dice = (0, 0, 0, 1, 1, 2, 2, 3)*3

def rotate_dice(L, k):
    return (L[e] for e in D[k])

def enumerate_dice(L0):
    *L, = L0[:]
    for k in p_dice:
        yield L
        L[:] = (L[e] for e in D[k])

def dice_graph():
    L0 = [0, 1, 2, 3, 4, 5]
    DA = list(map(tuple, enumerate_dice(L0)))
    DA.sort()
    DM = {tuple(e): i for i, e in enumerate(DA)}
    G = [list(DM[tuple(rotate_dice(ds, i))] for i in range(4)) for ds in DA]
    return DA, G
DA, DG = dice_graph()

def solve():
    W, D = map(int, readline().split())
    if W == D == 0:
        return False
    clr = "wrgbcmy#"
    MP = [list(map(clr.find, readline().strip())) for i in range(D)]
    vs = list(map(clr.find, readline().strip()))
    ps = [-1]*7
    for i, v in enumerate(vs):
        ps[v] = i
    CX = [0]*8; CY = [0]*8
    for i in range(D):
        s = MP[i]
        for j in range(W):
            k = s[j]
            if k >= 1:
                CX[k] = j; CY[k] = i
                if k == 7:
                    s[j] = 0
    dd = ((0, -1), (1, 0), (0, 1), (-1, 0))
    L = (1, 5, 3, 6, 2, 4)
    sx = CX[7]; sy = CY[7]
    que = deque([(0, sx, sy, 0)])
    dist = [[[{} for i in range(W)] for j in range(D)] for k in range(7)]
    dist[0][sy][sx][0] = 0
    C = [4]*6
    ans = -1
    while que and ans == -1:
        i, x, y, d = que.popleft()
        if C[i] == 0:
            continue
        d0 = dist[i]
        d1 = dist[i+1]
        c = d0[y][x][d]
        for k in range(4):
            dx, dy = dd[k]
            nx = x + dx; ny = y + dy
            if not 0 <= nx < W or not 0 <= ny < D or MP[ny][nx] == -1:
                continue
            nd = DG[d][k]
            if MP[ny][nx] != 0:
                l = L[DA[nd][0]]
                if l != MP[ny][nx] or ps[l] != i:
                    continue
                if nd not in d1[ny][nx]:
                    d1[ny][nx][nd] = c+1
                    C[i] -= 1
                    if i+1 < 6:
                        que.append((i+1, nx, ny, nd))
                    else:
                        ans = c+1
            else:
                if nd not in d0[ny][nx]:
                    d0[ny][nx][nd] = c+1
                    que.append((i, nx, ny, nd))
    if ans != -1:
        write("%d\n" % ans)
    else:
        write("unreachable\n")
    return True
while solve():
    ...


Measured memory_bytes: 10708
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  string ans;
  for(int i=0; i<s.size(); i++){
    if(i%2 == 0){
      ans += s.substr(i,1);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 512
n, m = map(int, input().split(" "))
A = []
b = []
ci = 0

for i in range(n):
    a = list(map(int, input().split(" ")))
    A.append(a)
for i in range(m):
    bi = int(input())
    b.append(bi)

for i in range(n):
    for j in range(m):
         ci += A[i][j]*b[j]
    print(ci)
    ci = 0


Measured memory_bytes: 6012
#include <stdlib.h>
#include <cmath>
#include <cstdio>
#include <cstdint>
#include <string>
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
using namespace std;

int main(){
  long long N;
  cin >> N;
  long long sum=0;
  for(long long i=1;i<=N;i++){
    if(i%3==0 || i%5==0){
      continue;
    }
    sum+=i;
  }

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


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e9;
const ll mod = 1e9+7;
typedef pair<int,int> P;
#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,m,N) for(int i=m;i<N;i++)
#define mm(n,m) memset(n,m,sizeof(n))

int er[1100000];

int main(){
  mm(er,0);
  int m;
  int a,b;
  
  er[0]=1,er[1]=1;
    for(ll i = 2; i < 1100000; i++){
      if(er[i]==1)continue;
      ll j = i*2;
      while(j < 1100000){
        if(er[j] == 0)er[j] = 1;
        j+=i;
      }
    }

  while(cin>>m>>a>>b){
    if(m==0)break;

    // rep(i,100){
    //   cout<<"i:"<<i<<" er:"<<er[i]<<endl;
    // }
    int ansp = 2 , ansq = 2;
    int resp = 0 , resq = 0;
    int maxpq = 0;
    // while((ansp * ansq) <= m){
    //   double asab = (double)a/(double)b;
    //   double aspq = (double)ansp/(double)ansq;
    //   //cout<<(double)(ansp/ansq)<<endl;
    //   if(asab >  aspq || aspq > 1){
    //     //cout<<"test"<<endl;
    //     ansp++;
    //     while(er[ansp]==1){
    //       ansp++;
    //     }
    //     continue;
    //   }
    //   if(maxpq < (ansp*ansq)){
    //     maxpq = ansp*ansq;
    //     resp = ansp; resq = ansq;
    //   }
    //   ansq++;
    //   while(er[ansq]==1){
    //     ansq++;
    //   }
    // }
    for(ansp = 2;ansp<=100000;ansp++){
      while(er[ansp]==1){
        ansp++;
      }
      for(ansq = 2;ansq<=100000;ansq++){
        while(er[ansq]==1){
          ansq++;
        }
        if((ansp*ansq) > m)break;
        double asab = (double)a/(double)b;
        double aspq = (double)ansp/(double)ansq;
        if(asab >  aspq || aspq > 1){
          //cout<<"ansq:"<<ansq<<endl;
          continue;
        }
        if(maxpq < (ansp*ansq)){
          maxpq = ansp*ansq;
          resp = ansp; resq = ansq;
        }
      }
    }
    cout<<resp<<" "<<resq<<endl;
  }
}



Measured memory_bytes: 7284
n, k, q = list(map(int, input().split()))

correct = {}
for parti in range(1, n+1):
    correct[parti] = 0

for i in range(q):
    a = int(input())
    correct[a] += 1

for parti in range(1, n+1):
    if k - q + correct[parti] > 0:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 19460
#include <stdio.h>

int n,k,i,p1,p2,ans ;

int main(void){

    scanf ("%d%d",&n,&k) ;
    int a[n] ;
    
    
    for(i=0; i<n; i++){
        scanf("%d",&a[i]);
        if (a[i]==1){
            p1 = i+1 ;
            p2 = i+1 ;
        }
    }
    
   
    
    while(p1>1){
        ans++ ;
        p1 = p1-k+1 ;
    }
    
    if (ans!=0) {
        n += p1-1 ;
    }
    
    while(p2<n){
        ans++ ;
        p2 = p2+k-1 ;
    }
    
    printf ("%d",ans) ;
    
    return 0 ;
}


Measured memory_bytes: 512