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

using vec = complex<double>;
using line = pair<vec,vec>;
const double eps = 0.0000001;

double inner_product(vec u,vec v){
    return real(u*conj(v));
}
double cross_product(vec u,vec v){
    return imag(conj(u)*v);
}

double norm(vec& u){
    return abs(u);
}

vec projection(line l,vec p){//p???l???????°???±
    vec s=l.first, t=l.second;
    double k = inner_product(t-s,p-s)/inner_product(t-s,t-s);
    return (1.0-k)*s+k*t;
}

vec reflection(line l,vec p){
    return 2.0*projection(l,p)-p;
}

int ccw(vec& a, vec& b, vec& c){
    vec ab = b-a, ac = c-a;
    double o = cross_product(ab,ac);
    if(o>0) return 1; //CCW
    if(o<0) return -1; //CW
    if(inner_product(ab,ac)<0){
        return 2; //C-A-B
    }else{
        if(inner_product(ab,ab)<inner_product(ac,ac)){
            return -2; //A-B-C
        }else{
            return 0; //A-C-B
        }
    }
}

int main(void){
    int q;
    cin >> q;
    for(int k=0;k<q;k++){
        int x,y;
        cin>>x>>y;
        vec p0(x,y);
        cin>>x>>y;
        vec p1(x,y);
        cin>>x>>y;
        vec p2(x,y);
        cin>>x>>y;
        vec p3(x,y);

        vec v1=p1-p0, v2=p3-p2;
        double i,o;
        i=inner_product(v1,v2);
        o=cross_product(v1,v2);
        if(abs(o)<eps){
            cout << 2 << endl;
        }else if(abs(i)<eps){
            cout << 1 << endl;
        }else{
            cout << 0 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3088
#include <iostream>
#include<set>
using namespace std;
int main(void){
    // Your code here!
    int n,m;
    set<int>s;
    cin>>n>>m;

    int H[n];
    for(int i=0;i<n;i++)
      {
          cin>>H[i];
          s.insert(i+1);
      }
    int a,b;
    for(int i=0;i<m;i++){
        cin>>a>>b;
        if(H[a-1] < H[b-1]){
            s.erase(a);
        }else if(H[a-1] > H[b-1]){
            s.erase(b);
        }else{
                s.erase(a);
                s.erase(b);
        }    
    }
    
    cout<<s.size();
}


Measured memory_bytes: 8232
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <queue>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define MP make_pair
#define F first
#define S second

typedef pair<int, int> P;

int N, R, L;
int point[100005];
int res[100005];

int main(){
  scanf("%d%d%d", &N, &R, &L);
  int now = 0;

  priority_queue<P>q;
  rep(i, N) q.push(P(0, -i));
  rep(i, R){
    //    printf("%d\n", i);

    int d, t, x;
    scanf("%d%d%d", &d, &t, &x);d--;
    //    printf("%d %d %d\n", d, t, x);

    //    printf("%d\n", i);
    P p = q.top(); q.pop();
    while(p.F != point[-p.S]){
      p = q.top(); q.pop();
    }
    q.push(p);

    res[-p.S] += t - now;
    now = t;

    point[d] += x;
    //    printf("%d\n", d);
    //    rep(j, N) printf("%d ", point[j]); puts("");
    q.push(P(point[d], -d));
  }

  P p = q.top(); q.pop();
  while(p.F != point[-p.S]){
    //    printf("%d %d\n", p.F, point[-p.S]);
    p = q.top(); q.pop();
  }
  //  printf("%d %d\n", p.F, point[-p.S]);
  res[-p.S] += L - now;

  //  rep(i, N) printf("%d ", res[i]); puts("");
  int team = 0;
  rep(i, N) if(res[team] < res[i]) team = i;
  printf("%d\n", team+1);
  exit(0);
  return (0);
}

Measured memory_bytes: 11232
#include<iostream>
using namespace std;
int main(){
  int a[4],b[4];
  while(cin >> a[0] >> a[1] >> a[2] >> a[3] >> b[0] >> b[1] >> b[2] >> b[3]){
    int hit=0,blow=0;
    for(int i=0;i<4;i++){
      if(a[i]==b[i])
        hit++;
    }
    for(int i=0;i<4;i++){
      for(int j=0;j<4;j++){
        if(i==j);
        else{
          if(a[i]==b[j])
            blow++;
        }
      }
    }
  cout << hit << " " << blow << endl;  
  }
}

Measured memory_bytes: 2972
a = input()
if(a == "MON"):
  print(6)
elif(a=="TUE"):
  print(5)
elif(a=="WED"):
  print(4)
elif(a=="THU"):
  print(3)
elif(a=="FRI"):
  print(2)
elif(a=="SAT"):
  print(1)
elif(a=="SUN"):
  print(7)

Measured memory_bytes: 3060
#include <cstdio>
#include <iostream>
#define int long long
#define INF 1e+18
using namespace std;

typedef pair<int,int> P;

int seg;
P dat[300000];

void add(int i,int x){
	i += seg - 1;
	dat[i].first += x;
	while(i){
		i = (i - 1) / 2;
		if(dat[i * 2 + 1].first < dat[i * 2 + 2].first) dat[i] = dat[i * 2 + 2];
		else dat[i] = dat[i * 2 + 1];
	}
}

signed main(){
	int n,r,l,cnt[100000] = {},prev = 0;
	scanf("%lld %lld %lld",&n,&r,&l);
	seg = 1;
	while(seg < n) seg *= 2;
	for(int i = 0;i < seg;i++){
		if(i < n) dat[i + seg - 1] = P(0,i);
		else dat[i + seg - 1] = P(-INF,i);
	}
	for(int i = seg - 2;i >= 0;i--){
		if(dat[i * 2 + 1].first < dat[i * 2 + 2].first) dat[i] = dat[i * 2 + 2];
		else dat[i] = dat[i * 2 + 1];
	}
	for(int i = 0;i < r;i++){
		int d,t,x;
		scanf("%lld %lld %lld",&d,&t,&x);
		cnt[dat[0].second] += t - prev;
		add(d - 1,x);
		prev = t;
	}
	cnt[dat[0].second] += l - prev;
	int ma = -1,mii;
	for(int i = 0;i < n;i++){
		if(ma < cnt[i]){
			mii = i;
			ma = cnt[i];
		}
	}
	cout << mii + 1 << endl;
	return 0;
}

Measured memory_bytes: 8656
#include <iostream>

using namespace std;

int main() {
        int n;
        char s;
        int count_y = 0;
        cin >> n;
        while(n--) {
                cin >> s;
                if(s=='Y') count_y++;
        }
        if(count_y!=0) cout << "Four" << endl;
        else cout << "Three" << endl;
        return 0;
}


Measured memory_bytes: 256
class FordFulkerson:
    """Ford-Fulkerson Algorithm: find max-flow
       complexity: O(FE) (F: max flow)
    """
    class edge:
        def __init__(self, to, cap, rev):
            self.to, self.cap, self.rev = to, cap, rev

    def __init__(self, V, E, source, sink):
        """ V: the number of vertexes
            E: adjacency list
            source: start point
            sink: goal point
        """
        self.V = V
        self.E = [[] for _ in range(V)]
        for fr in range(V):
            for to, cap in E[fr]:
                self.E[fr].append(self.edge(to, cap, len(self.E[to])))
                self.E[to].append(self.edge(fr, 0, len(self.E[fr])-1))
        self.maxflow = self.ford_fulkerson(source, sink)

    def ford_fulkerson(self, source, sink):
        """find max-flow"""
        INF = float('inf')
        maxflow = 0
        while True:
            self.used = [False] * self.V
            flow = self.dfs(source, sink, INF)
            if flow == 0:
                return maxflow
            else:
                maxflow += flow

    def dfs(self, vertex, sink, flow):
        """find augmenting path"""
        if vertex == sink:
            return flow
        self.used[vertex] = True
        for i, e in enumerate(self.E[vertex]):
            if not self.used[e.to] and e.cap > 0:
                d = self.dfs(e.to, sink, min(flow, e.cap))
                if d > 0:
                    self.E[vertex][i].cap -= d
                    self.E[e.to][e.rev].cap += d
                    return d
        return 0

V, E = map(int, input().split())
edge = [[] for _ in range(V)]
for _ in range(E):
    u, v, cap = map(int, input().split())
    edge[u].append((v, cap))
print(FordFulkerson(V, edge, 0, V-1).maxflow)

Measured memory_bytes: 7492
#include<stdio.h>
int main(){
	int x,i,c=0;
	scanf("%d",&x);
	while(1){
		for(i=1;i<=x;i++){
			if(x%i==0) c++;
		}
		if(c==2){
			break;
		}
		c=0;
		x++;
	}
	printf("%d\n",x);
	return 0;
}

Measured memory_bytes: 1732
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int a,b,sum=0,c=0;
    cin>>a;
    b=a;
    while(a>0)
    {
        c=a%10;
        sum+=c;
        a/=10;
    }
    if(b%sum==0)
        cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1000000000000000000;
long double pi=3.14159265358979323846L;
double eps=1e-12;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll popcount(ll n){
    ll ret=0;
    while(n>0){
        ret+=n%2;
        n/=2;
    }
    return ret;
}
ll gya[1000010];
ll kai[1000010];
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}

int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    ll h;cin>>h;
    ll ans=1;
    for(;;){
        if(ans<=h)ans*=2;
        else break;
    }
    cout<<ans-1<<endl;
}



Measured memory_bytes: 256
fn main() {
    let s = rl();
    let (x,y) = {
        let s = rv::<i32>();
        (s[0],s[1])
    };
    let mut dxy = vec![vec![];2];
    dxy[0].push(0);
    let mut k=0;
    for c in s.trim_right().bytes() {
        if c==b'F' {
            let i = dxy[k&1].len()-1;
            dxy[k&1][i]+=1;
        }
        else {
            k+=1;
            dxy[k&1].push(0);
        }
    }
    let mut t = std::collections::BTreeSet::new();
    let mut xs = t.clone();
    let mut ys = t.clone();
    xs.insert(dxy[0][0]);
    for &dx in &dxy[0][1..] { if dx>0 {
        for &x in &xs {
            t.insert(x+dx);
            t.insert(x-dx);
        }
        xs.clear();
        std::mem::swap(&mut xs, &mut t);
    }}
    ys.insert(0);
    for &dy in &dxy[1] { if dy>0 {
        for &y in &ys {
            t.insert(y+dy);
            t.insert(y-dy);
        }
        ys.clear();
        std::mem::swap(&mut ys, &mut t);
    }}
    println!("{}", if xs.contains(&x) && ys.contains(&y) {"Yes"} else {"No"});
}
fn rl() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s
}
fn rv<T>() -> Vec<T>
  where T: std::str::FromStr, T::Err: std::fmt::Debug, {
    rl().split_whitespace().map(|x|x.parse::<T>().unwrap()).collect()
}

Measured memory_bytes: 4352
using System;
using System.Collections.Generic;
using System.Linq;
class Test
{
    public static void Main()
    {

        var n = long.Parse(Console.ReadLine());

        var arr = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();

        Array.Sort(arr);
        int start = 0;
        double sum = (arr[0] + arr[1]) / (2*1.0);

        for (int j = 2; j < n; j++)
        {

            sum = (sum + arr[j]) / 2;
        }

        Console.Write(sum);
    }

}




Measured memory_bytes: 19924
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define pb push_back
#define mp make_pair
 
// random generator
// mt19937 rndm(time(0));
 
// ll gcd(ll a, ll b)
// {
//     while (b>0)
//     {
//         ll tmp = a;
//         a = b;
//         b = tmp%b;
//     }
//     return a;
// }
 
 
// long long gcd(long long a, long long b) {
//  return a? gcd(b % a, a) : b;
// }
 
 
const int M=1e9+7;
ll powmod(ll a,ll b, ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res%mod;}/* a^b%mod */
const int N=1e3+10; 

ll solve(ll a) {
     ll res[] = {a,1,a+1,0};
     return res[a%4];
}

ll solve1(ll a, ll b) {
     return solve(b)^solve(a-1);
}

int main() {	
    
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
	
	ll a, b;
	cin>>a>>b;
	if(a==0) {
		if(b==0) {
			cout<<"0\n";
			return 0;
		}
		else a=1;
	}
	cout<<solve1(a, b)<<endl;
	return 0;
}





Measured memory_bytes: 256
import java.util.Scanner;

class Clc{
	private int[][] NM;	//n*m?????????
	private int[] M1;	//m???1?????????	
	private int[] result;
	//---?????????????????????---//
	Clc(int[][] nm,int[] m1, int N){
		NM	= 	nm;
		M1	=	m1;
		result = new int[N];
	}
	
	int[] getclc(int N,int M){
		for(int x = 0; x < N ; x++){
			for(int y = 0; y < M; y++){
				result[x]=result[x]+NM[x][y]*M1[y];
			}
		}
		return result;
	}
	int[] get(int N){
		return M1;
	}
	
	
	
}
public class Main{

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		
		int N = scanner.nextInt();
		int M = scanner.nextInt();
		int[][] NM  = new int[N][M];
		int[] M1	= new int[M];
		
		for(int x = 0 ; x < N ;x++){
			for(int y = 0; y < M ; y++){
				NM[x][y]=scanner.nextInt();
			}
		}
		
		for(int i = 0; i < M ; i++){
			M1[i] = scanner.nextInt();
		}
		
		Clc seki = new Clc(NM, M1, N); 
		int[] result = seki.getclc(N,M);
		
		for(int i = 0;i < N ; i++){
			System.out.println(result[i]);
		}
		scanner.close();
	}

}

Measured memory_bytes: 40328
int main(void) {
  int n;
  scanf("%d", &n);
  int broken = 0;
  int temp = 0;
  int nextCount = 1;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &temp);
    if (temp != nextCount) {
      broken++;
    } else {
      nextCount++;
    }
  }
  if (nextCount == 1) {
    broken = -1;
  }
  printf("%d\n", broken);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
#define mk make_pair
#define hash hashh
using namespace std;

const int N = 3e5;
const int inf = 1e9;

int n, ans, a[N];
bool f[10001];

int main() {
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> a[i];
	f[0] = 1;
	for (int i = 1; i <= n; i++) {
		for (int j = 10000; j >= 0; j--) {
			if (f[j]) f[j + a[i]] = 1;
		}
	}
	for (int i = 1; i <= 10000; i++)
		if (f[i] && i % 10) ans = max(ans, i);
	cout << ans;
} 

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;

struct P
{
  int s,e,cost;
  P(int s=0,int e=0,int cost=0):s(s),e(e),cost(cost){}
  bool operator < (const P& p)const
  {
    if(s!=p.s)return s < p.s;
    return e < p.e;
  } 
};

int main()
{
  int N;
  while(cin >> N,N)
    {
      int MAX = 367;
      //dp[i][j] := テッツシツ妥」ツ?、テ」ツつ?」ツ?ョテゥツδィテ・ツアツ凝」ツ?景テヲツ猟・テ」ツつ?」ツ?ァ2テ」ツ?、テァツ崢ョテ」ツ?ョテゥツδィテ・ツアツ凝」ツ?桂テヲツ猟・テ」ツ?ョテヲツ卍づ」ツ?ョテヲツ慊?・ツ、ツァテ・ツ按ゥテァツ崢?
      VVI dp(MAX,VI(MAX,0));
      vector<P> requests(N);
      rep(i,N)
	cin >> requests[i].s >> requests[i].e >> requests[i].cost;
      sort(requests.begin(),requests.end());
  
      rep(k,N)
	{
	  VVI DP = dp;
	  REP(i,1,MAX)
	    {
	      REP(j,1,MAX)
		{
		  if(i == j && j == requests[k].e+1)
		    {
		      DP[i][j] = max(DP[i][j],
				     max(dp[requests[k].s][j]+requests[k].cost,
					 dp[i][requests[k].s]+requests[k].cost));
		    }
		  else if(j == requests[k].e+1)
		    {
		      DP[i][j] = max(DP[i][j],
				     dp[i][requests[k].s]+requests[k].cost);
		    }
		  else if(i == requests[k].e+1)
		    {
		      DP[i][j] = max(DP[i][j],
				     dp[requests[k].s][j]+requests[k].cost);
		    }
		  
		    DP[i][j] = max(DP[i][j],
				   max(DP[i-1][j],DP[i][j-1]));
		}
	    }
	  dp = DP;
	}
      cout << dp[MAX-1][MAX-1] << endl;
    }
  return 0;
}

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

using namespace std;

int main()
{
  vector<int> A(3);
  
  cin >> A[0] >> A[1] >> A[2];
  
  sort(A.begin(), A.end());
  
  cout << abs(A[0] - A[1]) + abs(A[1] - A[2]) << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define FORN(i,b,a)for(int i=(b);_a=(a);i>=_a;i--)
#define REP(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define re return
#define vi vector<int>
#define pb push_back
#define si set<int>
#define in insert
#define fl float
#define db double
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
#define mod 1000000007
#define INF 1000000007
#define x1 XZVJDFADSPFOE
#define y1 GASDIJSLDAEJF
#define x2 DFDAJKVOHKWIW
#define y2 PSFSAODSXVNMQ
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
int a,b;
int c[1001000],r[1001000];
int main()
{
  int n,m;
  cin>>n>>m;
  REP(i,n)
  {
  	cin>>a;
  	if(r[a])
  	{
		cout<<0<<endl;
		return 0; 
	}
  	r[a]=1;
  }
  REP(i,m)
  {
  	cin>>b;
  	if(c[b])
  	{
		cout<<0<<endl;
		return 0;
	}
  	c[b]=1;
  }
  ll nowr=0,nowc=0,ans=1;
  for(int i=n*m;i>=1;i--)
  {
  	if(r[i])
  	  nowr++;
  	if(c[i])
  	  nowc++;
	if(c[i]||r[i]) 
	{
	  if(c[i]&&!r[i])
	    ans*=nowr%mod;
	  if(r[i]&&!c[i])
	    ans*=nowc%mod;
    }
    else 
    {
	  ans*=(nowc*nowr-(n*m-i))%mod;
	}
	ans%=mod;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 2304
def fibonacci(F,n):
    F[0] = 1
    F[1] = 1
    for i in range(2,n+1,1):
        F[i] = F[i-1] + F[i-2]
    return F[n]

def main():
    n = int(input())
    F  = [0]*(n+1)
    ans = fibonacci(F,n)
    return ans

print(main())



Measured memory_bytes: 5600
#include <bits/stdc++.h>
using namespace std;
int ar[1000002];
int main()
{  int n; cin>>n;
   int a=n;
  int count=1;ar[a]++;
   while(a)
   {  
   	  if(a%2==0)
		   a=a/2;
		  else
		  a=3*a+1;
		ar[a]++;
		 if(ar[a]>1)
		   break;   
   	 count++;
	   }	
 cout<<count+1;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <stack>
#define ll long long
//#define local

using namespace std;

const int MOD = 1e9+7;
const int inf = 0x3f3f3f3f;
const double PI = acos(-1.0);
const int maxn = 1e5+10;

int main() {
#ifdef local
    if(freopen("/Users/Andrew/Desktop/data.txt", "r", stdin) == NULL) printf("can't open this file!\n");
#endif
    
    int n;
    int a[maxn];
    ll mx = 0;
    ll sum[maxn];
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        scanf("%d", a+i);
    }
    sort(a, a+n);
    for (int i = 0; i < n; ++i) {
        if (!i) sum[i] = a[i];
        if (i) sum[i] = sum[i-1]+a[i];
    }
    if (n&1) {
        if (n == 3) {
            mx = max(abs(2*a[2]-a[1]-a[0]), abs(2*a[0]-a[1]-a[2]));
        } else {
            mx = max(abs(2*(sum[n-1]-sum[n/2])-2*(sum[n/2-2])-(a[n/2]+a[n/2-1])), abs(2*(sum[n-1]-sum[n/2+1])-2*(sum[n/2-1])+(a[n/2]+a[n/2+1])));
        }
    } else {
        mx = abs(2*(sum[n-1]-sum[n/2])-2*(sum[n/2-2])+abs(a[n/2]-a[n/2-1]));
    }
    printf("%lld\n", mx);
#ifdef local
    fclose(stdin);
#endif
    return 0;
}











Measured memory_bytes: 1536
N = int(input())
A = input().strip()
B = input().strip()
C = input().strip()
cnt = 0
for i in range(N):
    a = set([A[i],B[i],C[i]])
    if len(a)==3:
        cnt += 2
    elif len(a)==2:
        cnt += 1
print(cnt)

Measured memory_bytes: 38384
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int n, k;
vector<int> et[100];

signed main() {
	int i, j;
	
	cin >> n >> k;
	int jyo = n * (n - 1) / 2 - (n - 1);
	if (k > jyo) { cout << -1 << endl; return 0; }
	
	for (i = 1; i < n; i++) {
		et[0].push_back(i);
	}
	
	int cnt = jyo - k;
	for (i = 1; i < n; i++) {
		for (j = i + 1; j < n; j++) {
			if (cnt > 0) {
				cnt--;
				et[i].push_back(j);
			}
		}
	}
	
	int m = 0;
	rep(i, n) {
		m += et[i].size();
	}
	cout << m << endl;
	
	rep(i, n) {
		rep(j, et[i].size()) {
			cout << i + 1 << " " << et[i][j] + 1 << endl;
		}
	}
	return 0;
}

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

ulong MAX = 1_000_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Pair = Tuple!(long, "a", long, "b");
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);

void main()
{
    auto n = lread();
    auto a = aryread();
    long t;
    foreach (i; iota(n))
        t = a[i] - t;
    t /= 2;
    foreach (i; iota(n))
    {
        write(2 * t, " ");
        t = a[i] - t;
    }
    writeln();
}

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


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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
ll mod = 1000000007;

int main() {
source:
    ul n;
    cin >> n;
    vector<ul> a(n);
    rep(i, n) { cin >> a[i]; }
    sort(a.begin(), a.end());

    ll ans = a[0];
    ll value = min(a[0], a[n - 1] - a[0]);
    rep(i, n - 1) {
        ll value_temp = min(a[i], a[n - 1] - a[i]);
        if (value_temp > value) {
            ans = a[i];
            value = value_temp;
        }
    }

    cout << a[n - 1] << " " << ans << endl;
    return 0;
}



Measured memory_bytes: 1024
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var n, m int
	if sc.Scan() {
		nm := splitToInt(sc.Text())
		n = nm[0]
		m = nm[1]
	}

	rcnt := 0
	scArr := make([][]int, m)

	for rcnt < m {
		if sc.Scan() {
			scArr[rcnt] = splitToInt(sc.Text())
			rcnt++
		}
	}

	ans := []int{}
	if n == 1 {
		// 0~99
		for i := 0; i < 10; i++ {
			strI := strconv.Itoa(i)

			for _, scV := range scArr {
				if scV[0] - 1 >= len(strI) {
					goto Next1
				}

				if string(strI[scV[0]-1]) != strconv.Itoa(scV[1]) {
					goto Next1
				}
			}
			ans = append(ans, i)
		Next1:
		}
	}

	if n == 2 {
		// 10~99
		for i := 10; i < 100; i++ {
			strI := strconv.Itoa(i)

			for _, scV := range scArr {
				if scV[0] - 1 >= len(strI) {
					goto Next2
				}

				if string(strI[scV[0]-1]) != strconv.Itoa(scV[1]) {
					goto Next2
				}
			}
			ans = append(ans, i)
		Next2:
		}
	}

	if n == 3 {
		// 100~999
		for i := 100; i < 1000; i++ {
			strI := strconv.Itoa(i)

			for _, scV := range scArr {
				if scV[0] - 1 >= len(strI) {
					goto Next3
				}

				if string(strI[scV[0]-1]) != strconv.Itoa(scV[1]) {
					goto Next3
				}
			}
			ans = append(ans, i)
		Next3:
		}
	}

	if len(ans) == 0 {
		fmt.Print("-1")
		return
	}

	sort.Ints(ans)
	fmt.Print(ans[0])
}

func splitToInt(s string) (intArr []int) {
	arr := strings.Split(s, " ")

	for _, v := range arr {
		intV, _ := strconv.Atoi(v)
		intArr = append(intArr, intV)
	}
	return
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define endl '\n'

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

using namespace std;
template<class T, class T2> inline void chkmax(T &x, const T2 &y) { if(x < y) x = y; }
template<class T, class T2> inline void chkmin(T &x, const T2 &y) { if(x > y) x = y; }
const int MAXN = (1 << 11);
const int MAXK = (int)1e4 + 17;

int n, k;
string s[MAXN];

void read()
{
	cin >> n >> k;
	for(int i = 0; i < n; i++)
		cin >> s[i];
}

bitset<MAXK> dp[MAXN];
bitset<MAXK * 100> bs[26], curr, temp, pref_bs[26];
int last[MAXN];
vector<char> cli;

bool check(char let, int c_l)
{
	temp = (curr << 1) & pref_bs[let - 'a'];

	bool ok = 0;
	for(int i = 0; i < n; i++)
	{
		if(curr[last[i]]) ok = 1;
		if(ok && cli[last[i] + 1] <= let)
		{
			temp[last[i] + 1] = 0;
			if(c_l + (int)s[i].size() <= k && dp[i + 1][k - c_l - (int)s[i].size()]) 
				temp[last[i] + 1] = 1;
		}
	}

	return !temp.none();
}

void solve()
{
	dp[n][0] = 1;
	for(int i = n - 1; i >= 0; i--)
		dp[i] = dp[i + 1] | (dp[i + 1] << s[i].size());

	cli.push_back(0);
	for(int i = 0; i < n; i++)
	{
		for(char c: s[i])
			cli.push_back(c);

		last[i + 1] = cli.size() - 1;
	}

	for(int i = 1; i < (int)cli.size(); i++)
		bs[cli[i] - 'a'][i] = 1;

	for(int i = 0; i < 26; i++)
		pref_bs[i] = (i == 0) ? (bs[0]) : (pref_bs[i - 1] | bs[i]);

	string answer = "";
	curr[0] = 1;
	for(int c_l = 0; c_l < k; c_l++)
	{
		char let, low = 'a', high = 'z', mid;
		while(low <= high)
		{
			mid = (low + high) >> 1;

			if(check(mid, c_l))
				let = mid, high = mid - 1;
			else 
				low = mid + 1;
		}

		temp = (curr << 1) & bs[let - 'a'];

		bool ok = 0;
		for(int i = 0; i < n; i++)
		{
			if(curr[last[i]]) ok = 1;
			if(ok && cli[last[i] + 1] == let)
			{
				temp[last[i] + 1] = 0;
				if(c_l + (int)s[i].size() <= k && dp[i + 1][k - c_l - (int)s[i].size()]) 
					temp[last[i] + 1] = 1;
			}
		}

		answer += let;
		curr = temp;
	}

	cout << answer << endl;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	read();
	solve();
	return 0;
}



Measured memory_bytes: 12280
def p_c():
    import sys
    sys.setrecursionlimit(10 ** 9)
    n = int(input())
    ans = 0

    def dfs(s):
        """
        :type s: str
        """
        if int(s) > n:
            return 0
        ret = 1 if all(s.count(c) for c in "753") else 0
        for c in "753":
            ret += dfs(s + c)
        return ret

    print(dfs("0"))
    
p_c()

Measured memory_bytes: 55132
#include <iostream>
#include<bits/stdc++.h>
#define rep(k,i,n) for(int i=k;i<n;++i)
using namespace std;
typedef long long ll;
int N;
long a[100001],b[100000];
ll sum=0;
int main(void){
    // Your code here!
    cin>>N;
    rep(0,i,N+1)cin>>a[i];
    rep(0,i,N){
        cin>>b[i];
        if(b[i]<a[i]){
            a[i]-=b[i];
            sum+=b[i];
            b[i]=0;
        }else{
            sum+=a[i];
            b[i]-=a[i];
            a[i]=0;
            if(a[i+1]>b[i]){
                sum+=b[i];
                a[i+1]-=b[i];
                b[i]=0;
            }else{
                sum+=a[i+1];
                b[i]-=a[i+1];
                a[i+1]=0;
            }
        }
    }
    cout<<sum<<endl;
}

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

int main(){
	int n;
	cin>>n;
	int temp;
	vector<double> v(n);
	for (int i = 0; i < n; i++) {
		cin>>temp;
		v[i]=1.0*temp;
	}
	sort(v.begin(),v.end());
	double sum=(v[0]+v[1])/2;
	for (int i = 2; i < n; i++) {
		sum+=v[i];
		sum/=2;
	}
	cout<<sum<<endl;
}

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

long cube(int x) {
    return 1l * x * x * x;
}

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

    if (k % 2 == 1) {
        cout << cube(n / k) << endl;
    } else {
        cout << cube(n / k) + cube((n + k / 2) / k) << endl;
    }
}


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

int main() {
	ll n, q; cin >> n >> q;
	vector<vector<ll> > stop(n, vector<ll>(3));
	for (int i = 0; i < n; ++i)
	{
		cin >> stop[i][0] >> stop[i][1] >> stop[i][2];
	}
	sort(stop.begin(), stop.end(), [](auto& x, auto& y){return x[2] < y[2];});

	set<ll> d;
	map<ll, ll> d_to_i;
	vector<ll> ans(q, -1);

	for (int i = 0; i < q; ++i)
	{
		ll x; cin >> x;
		d.insert(x);
		d_to_i[x] = i;
	}

	for (int i = 0; i < n; ++i)
	{
		ll left = std::max((ll)0, stop[i][0] - stop[i][2]);
		ll right = std::max((ll)0, stop[i][1] - stop[i][2]);
		auto fr = d.lower_bound(left);
		auto ba = d.lower_bound(right);
		auto fr_copy = fr;
		while (fr != ba)
		{
			ans[d_to_i[*fr]] = stop[i][2];
			++fr;
		}
		d.erase(fr_copy, ba);
	}

	for (int i = 0; i < q; ++i)
	{
		cout << ans[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 36224
#include<bits/stdc++.h>
using  namespace std;
int ar[50][50];
int m[100];
int cp[50];
int main()
{
    int i,j,k=1;
    for(i=0; i<3; i++)
        for(j=0; j<3; j++)
        {
            cin>>ar[i][j];
            m[ar[i][j]]=k;
            k++;
        }
    int n,x,cnt1=0,cnt2=0,cnt3=0,cnt4=0,cnt5=0,cnt6=0,cnt7=0,cnt8=0;
    cin>>n;
    for(int i=0; i<n; i++)
    {
        cin>>x;
        cp[i]=m[x];
    }
    for(int j=0; j<n; j++)
    {
        if(cp[j]==1)
            cnt1++;
        if(cp[j]==5)
            cnt1++;
        if(cp[j]==9)
            cnt1++;
    }
    for(int j=0; j<n; j++)
    {
        if(cp[j]==3)
            cnt2++;
        if(cp[j]==5)
            cnt2++;
        if(cp[j]==7)
            cnt2++;
    }
        for(int j=0; j<n; j++)
    {
        if(cp[j]==1)
            cnt3++;
        if(cp[j]==4)
            cnt3++;
        if(cp[j]==7)
            cnt3++;
    }
    for(int j=0; j<n; j++)
    {
        if(cp[j]==2)
            cnt4++;
        if(cp[j]==5)
            cnt4++;
        if(cp[j]==8)
            cnt4++;
    }
        for(int j=0; j<n; j++)
    {
        if(cp[j]==3)
            cnt5++;
        if(cp[j]==6)
            cnt5++;
        if(cp[j]==9)
            cnt5++;
    }
    for(int j=0; j<n; j++)
    {
        if(cp[j]==1)
            cnt6++;
        if(cp[j]==2)
            cnt6++;
        if(cp[j]==3)
            cnt6++;
    }
      for(int j=0; j<n; j++)
    {
        if(cp[j]==4)
            cnt7++;
        if(cp[j]==5)
            cnt7++;
        if(cp[j]==6)
            cnt7++;
    }
    for(int j=0; j<n; j++)
    {
        if(cp[j]==7)
            cnt8++;
        if(cp[j]==8)
            cnt8++;
        if(cp[j]==9)
            cnt8++;
    }
    if(cnt1==3||cnt2==3||cnt3==3||cnt4==3||cnt5==3||cnt6==3||cnt7==3||cnt8==3)
      cout<<"Yes"<<endl;
    else
      cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,C,K;cin >> N >> C >> K;
  vector<int> T(N);
  for(auto&&e:T){
    cin >> e;
  }
  sort(T.begin(), T.end());
  int cnt = 0, i = 0, j = 0;
  while(1){
    if(j >= N)break;
    while(j < N && T[j] - T[i] <= K && j - i + 1 <= C)++j;
    cnt++;
    i=j;
  }
  cout << cnt << endl;
  return 0;
}


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

using namespace std;

#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n);i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(a);i>=(int)(b);--i)
#define ALL(a) (a).begin(),(a).end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;

const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
  if(a < b) {a = b; return true;}
  return false;
}

template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
  if(a > b) {a = b; return true;}
  return false;
}

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  REP(i, SZ(v)) {
    if(i) os << " ";
    os << v[i];
  }
  return os;
}



int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int c, n, m; cin >> c >> n >> m;
  vi s(n), p(n);
  REP(i, n) {
    cin >> s[i] >> p[i];
  }

  vvi dp(n+1, vi(c+1, -INF));
  dp[0][0] = 0;
  REP(i, n) {
    REP(j, c+1) {
      if(dp[i][j] == -INF) continue;
      chmax(dp[i+1][j], dp[i][j]);
      if(j+s[i] <= c) chmax(dp[i+1][j+s[i]], dp[i][j] + p[i]);
    }
  }

  FOR(k, 1, m+1) {
    int ans = 0;
    REP(j, (c/k)+1) {
      chmax(ans, dp[n][j]);
    }
    cout << ans * k << endl;
  }

}





Measured memory_bytes: 383056
#include<fstream>
#include<string>
#include<iostream>
#include<sstream>
#include<iterator>
#include<cmath>
 
using namespace std;
 
int main(){
 int N;
 cin >> N;
 int A[N];
 int i;
 for(i=0;i<N;++i){
   cin >> A[i];}
int count = 0;
int ser = 1;
 for(i=0;i<N;++i){
  if(A[i] != ser)count++;
  else if(A[i] == ser)ser++;
 }
 if(ser==1)cout << -1 << endl;
 else{
     cout << count << endl;
 }
}

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

const int N = 200005;

int main(){

	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif

	ios::sync_with_stdio(false),cin.tie(0);

	int n; cin >> n;
	string s; cin >> s;
	cin >> s;
	int mod = 0;
	for(int i=0; i<n;i++){
		if(s[i] =='1') mod++;
	}
//	cout << mod << endl;
	int modplusrest[n];
	int modmoinsrest[n];
	int indp = 1;
	int indm = 1;
	if(mod == 0){
		for(int i=0;i<n;i++){
			cout << 1 <<endl;
		}
	}
	else{
	for(int i =n-1;i>-1;i--){
		modplusrest[i] = indp;
//		cout << modplusrest[i] << " ";
		modmoinsrest[i] = indm;
		indp =(indp*2) % (mod+1);
//		cout << indp << endl;
		if(mod>1) indm = indm*2 % (mod-1);
	}
			int mp = 0;
			int mm = 0;
			for(int j=0;j<n;j++){
				if(s[j] == '1'){
				mp = (mp+modplusrest[j])%(mod+1);
				if(mod>1) mm = (mm + modmoinsrest[j])%(mod-1);
			}
			}	
	for(int i=0;i<n;i++){
		if(s[i] == '0'){
			int m = mp;
			m = (m+modplusrest[i])%(mod+1);
//			cout << "m = " << m << " ";
			int ans = 1;
			while(m!=0){
				int p = __builtin_popcount(m);
				m = m%p;
				ans++;
			}
			cout << ans << endl;
		}
		else if(mod != 1){
			int m = mm;
			m = (mod-1 + (m-modmoinsrest[i])%(mod-1)) % (mod-1);
			int ans = 1;
			while(m!=0){
				int p = __builtin_popcount(m);
				m = m%p;
				ans++;
			}
			cout << ans << endl;

		}
		else{
			cout << 0 << endl;
		}
	}
}
	return 0;
}

Measured memory_bytes: 5300
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int preT = 0;
        int preX = 0;
        int preY = 0;

        for (int i=0; i<N; i++) {
            int postT = sc.nextInt();
            int postX = sc.nextInt();
            int postY = sc.nextInt();

            int dt = postT - preT;
            int dist = Math.abs(postX - preX) + Math.abs(postY - preY);
            if ((dt < dist) || ((dist - dt) % 2 != 0)) {
                System.out.println("No");
                return;
            }

            preT = postT;
            preX = postX;
            preY = postY;
        }

        System.out.println("Yes");
    }
}

Measured memory_bytes: 48028
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
using namespace std;

int main(){
  int N;
  cin >> N;
  vector<string> v(N);
  for (int i=0; i<N; i++) cin >> v[i];
  long m=0, a=0, r=0, c=0, h=0;

  long res = 0;

  for (int i=0; i<N; i++) {
    if (v[i][0]=='M') m++; 
    if (v[i][0]=='A') a++; 
    if (v[i][0]=='R') r++; 
    if (v[i][0]=='C') c++; 
    if (v[i][0]=='H') h++; 
  }

  res += m * a * r;
  res += m * a * c;
  res += m * a * h;
  res += m * r * c;
  res += m * r * h;
  res += m * c * h;
  res += a * r * c;
  res += a * r * h;
  res += a * c * h;
  res += r * c * h;

  cout << res << endl;
}


Measured memory_bytes: 3192
#include <bits/stdc++.h>
#define LOOP(n) for (int _i = 0; _i < (n); _i++)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define FOR(i, r, n) for (int i = (r); i < (n); ++i)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

const int INF = 2100100100;
const int MOD = 1e9 + 7;

// 多次元 vector 生成
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

/*  divisor(n)
    入力：整数 n
    出力：nのすべての約数
    計算量：O(√n)
*/
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end(), greater<long long>());
    return ret;
}

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    int sum = 0;
    REP(i, N) {
        cin >> A.at(i);
        sum += A[i];
    }
    auto divi = divisor(sum);

    vector<int> r(N);
    REP(i, divi.size()) {
        // cout << divi[i] << endl;
        REP(j, N) { r[j] = A[j] % divi[i]; }
        sort(ALL(r));
        vector<int> left(N + 1), right(N + 1);
        left[0] = 0;
        right[N] = 0;
        REP(j, N) { left[j + 1] += r[j] + left[j]; }
        for (int j = N - 1; j >= 0; j--) {
            right[j] += (divi[i] - r[j]) + right[j + 1];
        }
        /*
        REP(j, N + 1) { cout << " " << left[j]; }
        cout << endl;
        REP(j, N + 1) { cout << " " << right[j]; }
        cout << endl;
*/
        REP(j, N + 1) {
            if (left[j] == right[j] && left[j] <= K) {
                cout << divi[i] << endl;
                return 0;
            }
        }
    }

    cout << N << endl;
    return 0;
}


Measured memory_bytes: 256
local n, k = io.read("*n", "*n")
local function getgcd(x, y)
  while(0 < y) do
    x, y = y, x % y
  end
  return x
end
local gcd = 0
for i = 1, n do
  local t = math.abs(k - io.read("*n"))
  if(t ~= 0) then
    if(gcd == 0) then gcd = t else gcd = getgcd(gcd, t) end
  end
end
print(gcd)


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

int main() {
    int n;
    cin>>n;
    int ans=n;
    vector<char> s(n);
    rep(i,n){
        cin>>s[i];
        if(i>0 && s[i]==s[i-1]){
            ans--;
        }
    }
    cout<<ans<<endl;
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);

/* -----  2019/07/09  Problem: SQUARE869120CONTEST_03 E / Link: https://atcoder.jp/contests/s8pc-3/  ----- */


LL N, K;
double theta;
double calc(int a, int b, int c) {
	return (sin(a*theta) + sin(b*theta) + sin(c*theta)) / 2;
}
LL count(double s) {
	LL cntsum = 0;
	FOR(a, 1, N - 1) {
		int lef = N - a;
		double ac = (2 * s - sin(a*theta)) / 2.0 / sin(lef*theta / 2);
		int tmp = 0;
		if (ac >= 1) {
			tmp = lef - 1;
		}
		else if (ac < -1) {

		}
		else {
			double t = acos(ac);
			int x = ceil(t / theta + lef / 2.0);
			if (x < lef) tmp = (lef - x) * 2;
		}
		cntsum += tmp;
	}
	return cntsum * 2;
}
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);

	cin >> N >> K;
	theta = 2 * PI / N;
	K = (K - 1) * 6 / N;
	double ub = 1.3, lb = 0;
	FOR(_, 0, 40) {
		double m = (ub + lb) / 2;
		if (count(m) > K) ub = m;
		else lb = m;
	}
	cout << fixed << setprecision(10) << ub << endl;
}

Measured memory_bytes: 1024
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int s = sc.nextInt();
        sc.close();

        Set<Integer> set = new HashSet<>();
        int prev = s;
        for (int i = 2; i <= 1000000; i++) {
            set.add(prev);
            int next = f(prev);
            if (set.contains(next)) {
                System.out.println(i);
                break;
            }
            prev = next;
        }
    }

    static int f(int input) {
        if (input % 2 == 0) {
            return input / 2;
        } else {
            return 3 * input + 1;
        }
    }
}


Measured memory_bytes: 21972
#include<cstdio>
#include<queue>
#include<utility>
#include<cstring>
#include<stack>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<map>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
bool cmp_P(const P &a,const P &b){
  return a.second < b.second;
}
int main()
{
  ll sum[200010],res=0,N,A[200010];
  map<ll,ll> mp;
  cin >> N;
  REP(i,N)cin >> A[i];

  sum[0] = A[0];
  REP(i,N){
    sum[i+1] = sum[i] + A[i+1];
  }
  mp[0] = 1;
  REP(i,N){
    res += mp[sum[i]];
    mp[sum[i]]++;
  }
  cout << res << endl;
  return 0;
}



Measured memory_bytes: 15872
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <limits.h>
using namespace std;

int main(){
  int N, X, ans = 0 ;
  cin >> N ;
  for(int i=0;i<N;i++){
    cin >> X ;
    if(X%2==1) continue ;
    if(X%3==0) continue ;
    if(X%5!=0){
      ans = 1 ;
      break ;
    }  
  }  
  if(ans == 1){
    cout << "DENIED" << endl ;
  }  
  else{
    cout << "APPROVED" << endl ;
  }  
  return 0 ;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
using namespace std;




int main(){
ll n;
ll ans=0;
cin>>n;
vector<ll> a(n+1);
a[0]=2;
a[1]=1;
for(ll i=2;i<n+1;i++){
  a[i]=a[i-1]+a[i-2];
}
cout<<a[n]<<endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int N, K, Q;

int main() {
  cin >> N >> K >> Q;
  vector<int> A(Q);
  vector<int> win(N, K-Q);
  for(int i=0; i<Q; i++){cin >> A.at(i);}
  
  for(int i=0; i<Q; i++){win.at(A.at(i)-1)++;}
  for(int i=0; i<N; i++){
  	cout << (win.at(i)>0 ? "Yes":"No") << endl; 
  }
  return 0;
}


Measured memory_bytes: 1408
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        for(int i = 0; i < 50; i++) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            int c = sc.nextInt();
            if(a == -1 && b == -1 && c == -1) {
                break;
            }
            if(a == -1 || b == -1) {
                System.out.println("F");
                continue;
            }
            if(a + b >= 80) {
                System.out.println("A");
                continue;
            }
            if(a + b >= 65) {
                System.out.println("B");
                continue;
            }
            if(a + b >= 50) {
                System.out.println("C");
                continue;
            }
            if(a + b >= 30) {
                if(c >= 50) {
                    System.out.println("C");
                    continue;
                } else {
                    System.out.println("D");
                    continue;
                }
            }
            System.out.println("F");
            continue;
        }
    }
}


Measured memory_bytes: 26352
n,m = map(int,input().split())
li = []

ac = 0
wa = 0

li_2 = []
for i in range(n):
  li_2.append(0)
wa_li = []
for i in range(n):
  wa_li.append(0)
  
for i in range(m):
  s = list(input().split())
  s[0] = int(s[0])
  if li_2[s[0]-1] == 0:
    if s[1] == "AC":
      ac+=1
      wa+= wa_li[s[0]-1]
      li_2[s[0]-1] =1
    else:
      wa_li[s[0]-1]+=1
print(ac,wa)
  

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

int main() {
 long long int N;
  cin>>N;
long long int answer=0;
  for(long long int i=1;i<=N;i++){
    if(i%3!=0&&i%5!=0){
      answer+=i;
    }
  }
    cout<<answer<<endl;
}

Measured memory_bytes: 3620
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#define rep(i,n,m) for(int i=(n);i<(int)(m);i++)
#define reps(i,n,m) for(int i=(n);i<=(int)(m);i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define LB(a,x) lb(all(a), x) - a.begin()
#define UB(a,x) ub(all(a), x) - a.begin()
#define MOD 1000000007
#define itn int
#define enld endl
using namespace std;
typedef long long ll;
const double pi = 3.141592653589793;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b){if(b<a){a=b; return 1;} return 0;}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int N,A,B; cin >> N >> A >> B;
    string s; cin >> s;
    int qualified = 0;
    int cnt = 0;
    int S = A+B;
    rep(i,0,SZ(s)){
        if(s[i] == 'c'){
            cout << "No" << endl;
            continue;
        }else if(s[i] == 'a'){
            if(qualified < S){
                cout << "Yes" << endl;
                qualified++;
            }else{
                cout << "No" << endl;
            }
        }else if(s[i] == 'b'){
            if(qualified < S && cnt < B){
                cout << "Yes" << endl;
                qualified++;
                cnt++;
            }else{
                cout << "No" << endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3780
import java.util.Scanner;

public class Main {
	static int N,M,ans;
	static int map[],d[];
	public static void main(String[] args) {
		// TODO ツ篠ゥツ督ョツ青カツ青ャツつウツづェツつスツδソツッツドツ・ツスツタツブ
		Scanner sc=new Scanner(System.in);
		int i;

		while(true){
			N=sc.nextInt();
			M=sc.nextInt();
			if(N==0 & M==0) break;

			map=new int[N+1];
			d=new int[M+1];
			for(i=1;i<=N;i++){
				map[i]=sc.nextInt();
			}
			for(i=1;i<=M;i++){
				d[i]=sc.nextInt();
			}		
			
			play(1,0);
			
			System.out.println(ans);
			
		}//while
	}
	
	static void play(int s,int i){
		//System.out.println("s= "+s+" i= "+i);
		if(s>=N){
			//goal
			ans=i;
			return;
		}
		s+=d[i+1];
		if(s<N){
			s=mapaction(s);
		}
		play(s,i+1);
	}
	
	static int mapaction(int s){
		
		if(map[s]==0){
			return s;
		}
		else if(map[s]>0){
			s+=map[s];
			return s;
		}
		else if(map[s]<0){
			s+=map[s];
			return s;
		}
		
		return -1;
	}
}

Measured memory_bytes: 12000
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
typedef long long ll ;
#define rep(i, a, b) for (int i = a; i <= b; ++ i) 
const int N = 1e5 + 5 ;
using namespace std ;

int n, a[N] ;

int gcd(int x, int y) {
	return (y ? gcd(y, x % y) : x) ;
}

bool solve() {
	int cnt[2] = {0} ;
	rep(i, 1, n) ++ cnt[a[i] & 1] ;
	if ((cnt[0] & 1)) return true ;
	if (cnt[1] > 1 || cnt[0] + cnt[1] == 1) return false ;
	rep(i, 1, n) if (a[i] & 1) {
		if (a[i] > 1) -- a[i] ; else return false ;	
	}
	int x = a[1] ;
	rep(i, 2, n) x = gcd(x, a[i]) ;
	rep(i, 1, n) a[i] /= x ;
	return !solve() ;
}

int main() {
	scanf("%d", &n) ;
	rep(i, 1, n) scanf("%d", &a[i]) ;
	if (solve()) printf("First\n") ; else printf("Second\n") ;
	return 0 ; 
}

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

long N;
int ret = 0;

int dfs(string s){
    if(stol(s) > N){
        return 0;
    }
    
    if(s.find("7") != -1 && s.find("5") != -1 && s.find("3") != -1){
        ret += 1;
    }
    
    dfs(s + "7");
    dfs(s + "5");
    dfs(s + "3");
    
    return ret;
}

int main(){
    cin >> N;
    
    cout << dfs("0") << endl;
}


Measured memory_bytes: 256