akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
using namespace std;
typedef pair<int, int> pairII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
#define long long ll;
#define shig_for(i, a, b) for(int i = (a); i < (b); ++i)
#define shig_rep(i, n) shig_for(i, 0, n)
#define shig_forB(bit,a,b) for(int bit = (a); bit < (1<<(b)); ++bit)
#define shig_repB(bit,n) shig_forB(bit,0,n)
#define tmp int temp = 0




int main()
{
    //cout << "Atcoder" << endl;
    int flag = -1;
    int N, M, X;
    cin >> N >> M >> X;
    int c[N] = {};
    
    VVI A(N);
    int cost_min = 10000000;
    
    shig_rep(i, N){
        cin >> c[i];
        shig_rep(j, M){
            tmp;
            cin >> temp;
            A[i].push_back(temp);
        }
    }
    
    shig_repB(bit,N){
        int cost = 0;
        int AA[M] = {};
        shig_rep(i, N){

            if( ((bit >> i) & 1) ){
                cost += c[i];
                shig_rep(j, M){
                    AA[j] += A[i][j];
                }
            }
        }

        int cnt = 0;
        shig_rep(j, M){
            if(AA[j] >= X)continue;
            else{
                cnt = -1;
                break;
            }
        }

        if(cnt == -1)continue;

        flag = 1;

        if(cost < cost_min){
            cost_min = cost;
        }

    }

    if(flag == -1){
        cout << -1 << endl;
    }else{
        cout << cost_min << endl;
    }

    return 0;
}

Measured memory_bytes: 3636
#include <algorithm>
#include <climits>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>

#define int long long int
constexpr int INF = std::numeric_limits<int>::max();
constexpr int NINF = std::numeric_limits<int>::min();
using namespace std;

void solve() {
  int N, K, Q;
  cin >> N >> K >> Q;
  vector<int> v(N, K - Q);
  while (Q--) {
    int A;
    cin >> A;
    v[A - 1]++;
  }

  for (int i = 0; i < v.size(); i++) {
    if (v[i] > 0) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}


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

using namespace std;

typedef long long ll;

int main(){
    int N;
    cin >> N;
    int cnt = 0;
    for(int i = 1; i <= N; i++){
        if((i % 2) == 1){
            cnt++;
        }
    }
    double ans = (double)cnt/(double)N;
    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    public static void main(String[] args) throws Exception {
        int N = Integer.parseInt(br.readLine().trim());
        if(N%10 ==9 || N/10 == 9) System.out.println("Yes");
        else System.out.println("No");
    }


    static int[] inputval() throws Exception {
        String[] strarray = br.readLine().trim().split(" ");
        int[] intarray = new int[strarray.length];
        for (int i = 0; i < intarray.length; i++) {
            intarray[i] = Integer.parseInt(strarray[i]);
        }
        return intarray;
    }

    static void array_sout(int[][] array) {
        for (int i = 0; i < array.length; i++) {
            for (int j = 0; j < array[0].length; j++) {
                System.out.print(array[i][j] + " ");
            }
            System.out.println();
        }
    }

    static void array_sout(int[] array) {
        for (int i = 0; i < array.length; i++) {
            System.out.print(array[i] + " ");
        }
        System.out.println();
    }
}

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

//Chairs Where Demanding People Sit
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			int m = sc.nextInt();
			if((n|m)==0)break;
			char[] c = new char[n];
			Arrays.fill(c, '#');
			while(m--!=0){
				char p = sc.next().charAt(0);
				if(p=='A'){
					for(int i=0;i<n;i++)if(c[i]=='#'){c[i]=p;break;}
				}
				else if(p=='B'){
					boolean f = false;
					for(int i=n-1;i>=0;i--){
						if(c[i]=='#'){
							boolean r = i==n-1 || c[i+1]!='A';
							boolean l = i==0 || c[i-1]!='A';
							if(r&&l){
								f = true;
								c[i] = p;
								break;
							}
						}
					}
					if(f)continue;
					for(int i=0;i<n;i++)if(c[i]=='#'){c[i]=p;break;}
				}
				else if(p=='C'){
					boolean f = false;
					for(int i=0;i<n;i++){
						if(c[i]!='#'){
							if(i+1<n && c[i+1]=='#'){
								f = true;
								c[i+1]=p;
								break;
							}
							if(i>0 && c[i-1]=='#'){
								f = true;
								c[i-1]=p;
								break;
							}
						}
					}
					if(f)continue;
					int x = n%2==0?(n/2):((n+1)/2-1);
					c[x] = p;
				}
				else {
					boolean f = true;
					int[] l = new int[n];
					for(int i=0;i<n;i++){
						if(c[i]=='#'){
							if(i==0)l[i]=100;
							else l[i]=l[i-1]+1;
						}
						else {
							l[i] = 0;
							f = false;
						}
					}
					int[] r = new int[n];
					for(int i=n-1;i>=0;i--){
						if(c[i]=='#'){
							if(i==n-1)r[i]=100;
							else r[i]=r[i+1]+1;
						}
						else{ 
							r[i]=0;
							f = false;
						}
					}
					if(f){
						c[0]=p;
						continue;
					}
					int x = 0;
					int max = Math.min(Math.min(100, r[0]), Math.min(100, l[0]));
					for(int i=0;i<n;i++){
						int d = Math.min(Math.min(100, r[i]), Math.min(100, l[i]));
						if(max < d){
							max = d;
							x = i;
						}
					}
					c[x] = p;
				}
			}
			System.out.println(new String(c));
		}
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
#include <iostream>
#include <cstring>
#include <set>
#include <algorithm>
#include <math.h>
#include <vector>
#include <iterator>
#include<deque>
#include<cstdio>

#define lp(i,a,n) for(int i=a;i<n;++i)
#define rep(i,a,n) for(ll i=a;i<=n;++i)
#define all(v) v.begin(),v.end()
#define clr(n,a) memset(n,a,sizeof(n))
#define vi vector <int>
#define sc set <char>
#define si set<int>
#define pb push_back
#define vb vector <bool>
#define pi(n) printf("%d\n",n)
#define ln "\n"
#define mahmoud_abdelsamie ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef unsigned long long ull;
using namespace std;


int main()
{
    mahmoud_abdelsamie
    string s,t;
    int cnt=0;
    cin>>s>>t;
    for(int i=0;i<s.size()&&s!=t;++i){
        if(s[i]==t[i])
            continue;
        else{
            t[i] = s[i];
            ++cnt;
        }
    }
    cout<<cnt<<ln;
    return 0;
}


Measured memory_bytes: 3820
import java.util.Scanner;

class Main{

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		if(N < 1000){
			System.out.println("ABC");
		}else{
			System.out.println("ABD");

		}
		
	}









}








Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;


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

    long long N;
    cin >> N;
    long long ans=1;
    rep(i,N){
        ans=(ans*(i+1))%MOD;
    }
    cout << ans << endl;


}


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

int main(){
  string s;
  cin >> s;
  int num = 0;
  int N = s.size();
  for(int i = 1; i < N-1; i++){
    num++;
  }
  cout << s[0] << num << s[num + 1] << endl;
}

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

using lint = long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

constexpr lint INF = 1'010'000'000'000'000'017LL;
constexpr lint MOD = 1'000'000'007LL;
constexpr double EPS = 1e-12;
constexpr double PI = 3.14159265358979323846;

#define FOR(i, start, end) for(lint i = (start); i < end; i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(v) v.begin(), v.end()

template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }

lint mod(lint val, lint m){ lint res = val % m; if(res < 0) res += m; return res;}
lint modinv(lint a, lint m) { lint b = m, u = 1, v = 0; while (b) { lint t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); } u %= m; if (u < 0) u += m; return u;}
lint modpow(lint a, lint n, lint mod) { lint res = 1; while (n > 0) { if (n & 1) res = res * a % mod; a = a * a % mod; n >>= 1;} return res;}
lint gcd(lint a, lint b){ if(a < b) swap(a, b); if(b == 0) return a; return gcd(b, a%b);}
lint lcm(lint a, lint b){ return a * b / gcd(a, b);}


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

void Main()
{
    int N, ans;
    string S;
    cin >> N;
    cin >> S;

    ans = 0;
    REP(i, N-2){
        if(S[i] == 'A' && S[i+1] == 'B' && S[i+2] == 'C'){
            ans ++;
        }
    }

    cout << ans << endl;
}

//---------------------------------------------------------------
int main()
{
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	Scanner sc = new Scanner(System.in);
	
	void a() {
		int a = sc.nextInt(), b = sc.nextInt();
		String aStr = Integer.toString(a),bStr = Integer.toString(b);
		if(aStr.length() >= 2 || bStr.length() >= 2) {
			System.out.println("-1");
			return;
		}else {
			System.out.println(a*b);
		}
	}
	
	
	void b() {
		int n = sc.nextInt();
		for(int i = 1;i <= 9;i ++) {
			if(n % i == 0) {
				String s = Integer.toString(n/i);
				if(s.length() == 1) {
					System.out.println("Yes");
					return;
				}
			}
		}
		System.out.println("No");
	}
	
	public static void main(String[] args) {
		new Main().b();
	}
}


Measured memory_bytes: 23760
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int n;
  while(1){
    cin>>n;
    if(n==0)break;
    vi v(100005,0);
    rep(i,n){
      int a,b,c;
      scanf("%d:%d:%d",&a,&b,&c);
      v[a*3600+b*60+c]++;
      scanf("%d:%d:%d",&a,&b,&c);
      v[a*3600+b*60+c]--;
    }
    rep(i,100000)v[i+1]+=v[i];
    int ans=0;
    rep(i,100000)ans=max(ans,v[i]);
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 3620
import math

a, b, x = [int(x) for x in input().split()]

if x/a/a > b/2:
    print(180/3.141592*math.atan(2*(b - x/a/a)/a))
else:

    print(180/3.141592*math.atan(0.5*a*b*b/x))


Measured memory_bytes: 2940
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n, b, f, r, v;
    int room[4][3][10];
    
    for(int i=0;i<4;i++){
        for(int j=0;j<3;j++){
            for(int k=0;k<10;k++){
                room[i][j][k]=0;
            }
        }
    }
    
    cin >> n;
    
    for(int i=0;i<n;i++){
        cin >> b >> f >> r >> v;
        room[b-1][f-1][r-1] += v;
    }
    
    for(int i=0;i<4;i++){
        for(int j=0;j<3;j++){
            for(int k=0;k<10;k++){
                cout <<" "<<room[i][j][k];
            }
            cout << endl;
        }
        if(i<3) cout << "####################" << endl;
    }   
    
}



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

int main() {
	int a, b, count = 0;
	cin >> a >> b;
	for(a; a <= b; a++) {
		if (a / 10000 == a % 10 and a % 10000 / 1000 == a % 100 / 10) {
			count++;
		}
	}
	cout << count << endl;
}

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


int Len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}


int Sint(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}


int Svec(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}


long long int GCD(long long int a,long long int b){
  long long int r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return b;
}


long long int LCM(long long int a,long long int b){
  long long int c=a,d=b,r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return c/b*d;
}


int Factorial(int n){
  int m=1;
  while(n>=1) m*=n,n--;
  return m;
}


/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  long long int n,ans=1;
  cin>>n;
  vector<long long int> v(n);
  rep(i,n) cin>>v[i];
  rep(i,n){
    ans=LCM(ans,v[i]);
  }
  cout<<ans<<endl;
}

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

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

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

int main(){
  int N,X;
  cin >> N >> X;
  vector<int> vec(N*2-1);
  vec.at(0) = X-(N-1);
  for (int i=1;i<N*2-1;i++){
      vec.at(i) = vec.at(i-1)+1;
  }
  for (int i=0;i<N*2-1;i++){
      cout << vec.at(i) << endl;
  }
}


Measured memory_bytes: 256
package main

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

func main(){
	reader := bufio.NewReader(os.Stdin)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()

	var N int 
	fmt.Fscan(reader, &N)
	var ans uint = 0
	for i := 1; i <= N; i++ {
		var s string = strconv.Itoa(i)
		if len(s) % 2 == 1 { ans++}
	}
	fmt.Fprintln(writer,ans)
}

Measured memory_bytes: 1152
#include<stdio.h>
#include<string.h>
int T,N,i,j,x,y,f[200][200]={0},q[10000][3],l,r,t;
int mx[6]={0,1,1,0,-1,-1},my[6]={1,1,0,-1,-1,0};
 
int main()
{
	for(;scanf("%d%d",&T,&N),T;)
	{
		memset(f,0,sizeof(f));
		for(i=r=0;i<N;f[x+70][y+70]=1,i++)
			scanf("%d%d",&x,&y);
		scanf("%d%d",&x,&y);
		q[0][0]=x+70;
		q[0][1]=y+70;
		f[x+70][y+70]=-1;
		q[0][2]=T;
		for(r=0,l=1;r<l;r++)
		{
			x=q[r][0];
			y=q[r][1];
			t=q[r][2];
			for(i=0;i<6;i++)
			if(f[x+mx[i]][y+my[i]]==0&&t>0)
			{
				q[l][0]=x+mx[i];
				q[l][1]=y+my[i];
				q[l][2]=t-1;
				f[x+mx[i]][y+my[i]]=-1;
				l++;
			}
		}
		for(i=r=0;i<200;i++)
		for(j=0;j<200;j++)
		if(f[i][j]==-1)
		r++;
		printf("%d\n",r);
	}
	return 0;
}

Measured memory_bytes: 796
#include <stdio.h>

int abs(int a){
	if(a>0) return a;
	else return -1*a;
}
int min(int a,int b){
	if(a<b) return a;
	else return b;
}

int main(void) {
	int N=0;
	scanf("%d",&N);
	int step[N];
	for(int i=0;i<N;i++){
		scanf("%d",&step[i]);
	}
	int dp[N];
	dp[0] = 0;
	dp[1] = abs(step[0]-step[1]);
	for(int i=2;i<N;i++){
		dp[i] = min(dp[i-1]+abs(step[i]-step[i-1]),dp[i-2]+abs(step[i]-step[i-2]));
	}
	printf("%d",dp[N-1]);
	/*for(int i=0;i<N;i++){
		printf("%d\n",dp[i]);
	}*/
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

vector<pair<ll, ll>> adj[100005];
bool used[100005];
int color[100005];

void dfs(int v){
    if(used[v] == true) return;

    used[v] = true;
    for(int i=0; i<adj[v].size(); i++){
        int to = adj[v][i].first;
        ll dist = adj[v][i].second;
        if(dist%2 == 0){
            if(color[v] == 0){
                color[to] = 0;
                dfs(to);
            }
            else{
                color[to] = 1;
                dfs(to);
            }
        }
        else{
            if(color[v] == 0){
                color[to] = 1;
                dfs(to);
            }
            else{
                color[to] = 0;
                dfs(to);
            }
        }
    }
    
}

int main(){
    int N; cin >> N;
    for(int i=0; i<100005; i++) {used[i] = false; color[i] = 0;}
    
    for(int i=0; i<N-1; i++){
        int u,v; cin >> u >> v;
        ll w; cin >> w;
        adj[u].push_back({v, w});
        adj[v].push_back({u, w});
    }

    dfs(1);
    for(int i=1; i<=N; i++) cout << color[i] << endl;

}

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

typedef long long ll;

int main(void) {
	ll N;
	ll ans = (ll)0;

	cin >> N;
	for (ll i = (ll)1; i * i <= N; ++i) {
		if (N % i != 0) continue;
		ll j = N / i;
		if (i > j) break;
		ll a = i - 1;
		if (a != 0) {
			if (N / a != N % a)
				a = 0;
		}
		ll b = j - 1;
		if (b != 0) {
			if (N / b != N % b)
				b = 0;
		}
		ans += a;
		if (a != b)
			ans += b;
	}

	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<bitset>
using namespace std;

int main() {

	vector<long> l(3, 0);
	cin >> l[0] >> l[1] >> l[2];

	sort(l.begin(), l.end());

	cout << l[0] * l[1] / 2 << endl;

	return 0;
}


Measured memory_bytes: 256
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
#define int long long
   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; }
    const int MAX =200005;
const int MOD =1000000007;

signed main(){
int t,n,m,a,b;
cin>>t;
for(int i=0;i<t;i++){
  cin>>n>>m>>a>>b;
  cout<<floor_sum(n,m,a,b)<<endl;
}
}

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

int main(void) {
    int N;
    int total = 0;
    std::cin >> N;
    std::vector<int> s(N, 0);
    for (int i = 0; i < N; i++) {
        std::cin >> s[i]; 
        total += s[i];
    }
    std::sort(s.begin(), s.end());

    if (total % 10 != 0) {
        std::cout << total << std::endl;
        return 0;
    }

    for (int i = 0; i < N; i++) {
        if ((total - s[i]) % 10 != 0) {
            std::cout << total - s[i] << std::endl;
            return 0;
        }
    }
    std::cout << "0" << std::endl;

    return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Edge=pair<int,int>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
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;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  ll L,R,D;
  cin>>L>>R>>D;
  co(R/D-(L-1)/D);
  return 0;
}

Measured memory_bytes: 3568
N=int(input())
S=[list(map(int,list(input()))) for i in range(N)]
VE=[[] for i in range(N)]
for i in range(N):
  for j in range(N):
    if S[i][j]:
      VE[i].append(j)
C=[0]*(N*N+1)
def ni(v,c):
  global S,C,N
  C[v]=c
  for i in range(len(VE[v])):
    if C[VE[v][i]]==c:
      return False
    if C[VE[v][i]]==0 and not(ni(VE[v][i],-c)):
      return False
  return True

if not(ni(0,1)):
  print(-1)
  exit()
INF=10**12
D=[[INF]*N for i in range(N)]
for i in range(N):
  D[i][i]=0
  for j in range(len(VE[i])):
    D[i][VE[i][j]]=1
for k in range(N):
  for i in range(N):
    for j in range(N):
      D[i][j]=min(D[i][j],D[i][k]+D[k][j])
P=0
for i in range(N):
  P=max(P,max(D[i]))
print(P+1)

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

int main()
{
	long long q, h, s, d;
	long long n;
	cin >> q >> h >> s >> d;
	cin >> n;

	long long oneL = min(s, min(4 * q, 2 * h));

	long long twoL = min(oneL * 2, d);

	long long ans;

	if (n % 2 == 1) {
		ans = (n - 1) / 2 * twoL + oneL;
	}
	else {
		ans = n / 2 * twoL;
	}

	cout << ans << endl;

    return 0; 
}

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

using namespace std;

#define all(x) x.begin(), x.end()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;

const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;

int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }

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

	int a, b, c;
	cin >> a >> b >> c;
	cout << min(a * c, b) / a;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    Scanner sc;
    int w;
    int h;
    boolean[][] isVisited;
    void run() {
        sc = new Scanner(System.in);
        while (true) {
            w = sc.nextInt();
            h = sc.nextInt();
            if (w == 0 && h == 0) break;
            isVisited  = new boolean[h+2][w+2];
            for (int i=1;i<h+1;i++)
                for (int j=1;j<w+1;j++) isVisited[i][j] = true;
            Wall wall = new Wall(w, h);

            Point p = new Point(1, 1);
            LinkedList<Point> l = new LinkedList<Point>();
            l.add(p);
            int count = 0;
            int pointer = 0,nextPointer = l.size();
            while (!p.isGoal()) {
                if (l.isEmpty()) {
                    count = 0;
                    break;
                }
                p = l.removeFirst();
                if (pointer == 0) {
                    count ++;
                    pointer = nextPointer;
                    nextPointer = 0;
                }
                pointer--;
                if (!isVisited[p.getY()][p.getX()]) continue;
                isVisited[p.getY()][p.getX()] = false;
                LinkedList<Point> tmp = wall.getNextP(p);
                nextPointer += tmp.size();
                
                l.addAll(tmp);
                
            }
            System.out.println(count);
        }
    }

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

    class Wall {
        int[][] wall;

        Wall(int w,int h) {
            wall = new int[2*h+1][w+2];
            for (int i=0;i<2*h+1;i++)
                for (int j=0;j<w+2;j++) wall[i][j] = 1;
            for (int i=1;i<2*h;i++) {
                
                for (int j=1;j<w+((i+1)%2);j++) {
                    wall[i][j] = sc.nextInt();
                }
            }
        }

        int[] dxw = {-1,0,0,0};
        int[] dyw = {-1,-2,-1,0};
        int[] dx = {-1,0,1,0};
        int[] dy = {0,-1,0,1};
        LinkedList<Point> getNextP(Point p) {
            LinkedList<Point> l = new LinkedList<Point>();
            for (int i=0;i<4;i++) {
                if (wall[2*p.getY()+dyw[i]][p.getX()+dxw[i]] == 0) {
                    Point nextP = new Point(p.getX()+dx[i],p.getY()+dy[i]);
                    l.add(nextP);
                }
            }
            return l;
        }

        void printWall() {
            for (int i=0;i<2*h+1;i++) {
                for (int j=0;j<w+2;j++) System.out.print(wall[i][j]);
                System.out.println();
            }
        }
    }
    class Point {
        int x;
        int y;
        Point (int x, int y) {
            this.x = x;
            this.y = y;
        }
        int getX() {
            return x;
        }
        int getY() {
            return y;
        }
        void printP() {
            System.out.println(x + " " + y);
        }

        boolean isGoal() {
            if (x == w && y == h ) return true;
            return false;
        }
    }

}

Measured memory_bytes: 13000
#include<stdio.h>

int main(void){
    int x,y,r,tmp;
    
    scanf("%d",&x);
    scanf("%d",&y);
    
    if(x<y){
        tmp=x;
        x=y;
        y=tmp;
    }
    
    
    r=x%y;
    while(r!=0){
        x=y;
        y=r;
        r=x%y;
    }
    printf("%d\n",y);
    
}


Measured memory_bytes: 2100
N,T = map(int,input().split())
A = list(map(int,input().split()))
B = [-1]
buy = A[0]
for i in A:
    buy = min(i,buy)
    B.append(i-buy)
B.sort(reverse=True)
i = 0
while B[0] == B[i]:
    i += 1
print(i)

Measured memory_bytes: 14252
X, Y = map(int, input().split())
if 1 <= X <= 3:
  x = 400000 - X*100000
else:
  x = 0
if 1 <= Y <= 3:
  y = 400000 - Y*100000
else:
  y = 0
if X == 1 and Y == 1:
  print(x + y + 400000)
else:
  print(x + y)

Measured memory_bytes: 2940
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		var n=sc.I;
		var h=new double[n<<1][];
		var b=new bool[n][];
		for(int i = 0;i<n;i++) {
			var e=sc.Ia;
			b[i]=new bool[n];
			h[i]=new double[]{e[0],e[1],Atan2(e[1],e[0])*180/PI+180};
			h[i+n]=new double[]{e[0],e[1],Atan2(e[1],e[0])*180/PI+540};
		}
		Array.Sort(h,(u,v)=>u[2].CompareTo(v[2]));
		double ans=0;
		for(int i = 0;i<n;i++) {
			double p1=0,p2=0;
			for(int j = i;h[i][2]+180>=h[j][2];j++) {
				p1+=h[j][0];
				p2+=h[j][1];
				ans=Max(ans,Sqrt(p1*p1+p2*p2));
			}
			p1-=h[i][0];
			p2-=h[i][1];
		}
		Console.WriteLine("{0}",ans);
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 13396
#include<cstdio>
#include<algorithm>
#include<vector>
#include <iostream>
#include <map>
#include <queue>
using namespace std;
#define PB push_back
#define fi first
#define se second
#define mkpr make_pair
#define reps(i,j,k) for(int i = j; i <k; i++)
#define rep(i,j) reps(i,0,j)
typedef pair<int,int> Pii;
class data{
    public:
    int cnt;
    int state[32];
    data(){}
    data(int _cnt,int _state[32]){
        cnt = _cnt;
        rep(i,32){
            state[i] = _state[i];
        }
    }
};
string getIndex(int array[32]){
    string str="";
    rep(i,30){
        str += (array[i]+'0');
    }
    return str;
}
vector <Pii> chenge[4];
bool check(int array[32]){
    rep(i,8){
        if(array[i] != array[i+1])return false;
    }
    reps(i,9,11){
        if(array[i] != array[i+1])return false;
    }
    reps(i,12,14){
        if(array[i] != array[i+1])return false;
    }
    reps(i,15,17){
        if(array[i] != array[i+1])return false;
    }
    reps(i,18,20){
        if(array[i] != array[i+1])return false;
    }
    reps(i,21,28){
        if(array[i] != array[i+1])return false;
    }
    return true;
}
int main(){


    chenge[0].PB(Pii(0,23));
    chenge[0].PB(Pii(3,26));
    chenge[0].PB(Pii(6,29));
    chenge[0].PB(Pii(9,20));
    chenge[0].PB(Pii(15,17));

    chenge[1].PB(Pii(2,21));
    chenge[1].PB(Pii(5,24));
    chenge[1].PB(Pii(8,27));
    chenge[1].PB(Pii(11,18));
    chenge[1].PB(Pii(12,14));

    chenge[2].PB(Pii(0,27));
    chenge[2].PB(Pii(1,28));
    chenge[2].PB(Pii(2,29));
    chenge[2].PB(Pii(14,15));
    chenge[2].PB(Pii(20,18));

    chenge[3].PB(Pii(6,21));
    chenge[3].PB(Pii(7,22));
    chenge[3].PB(Pii(8,23));
    chenge[3].PB(Pii(12,17));
    chenge[3].PB(Pii(9,11));

    int n;
    scanf("%d",&n);
    while(n--){
        map < string , int >  memo;
        int ini[32]={0};
        rep(i,30){
            scanf("%d",&ini[i]);
        }
        int ans = -1;
        queue < data > Q;
        Q.push(data(0,ini));
        while(!Q.empty()){
            data d = Q.front();Q.pop();
            if(check(d.state)){
                ans = d.cnt;
                break;
            }
            rep(i,4){
                rep(j,5){
                    Pii a = chenge[i][j];
                    swap(d.state[a.fi],d.state[a.se]);
                }
                if(memo[getIndex(d.state)]==0){
                    memo[getIndex(d.state)] = 1;
                    Q.push(data(d.cnt+1,d.state));
                }
                rep(j,5){
                    Pii a = chenge[i][j];
                    swap(d.state[a.fi],d.state[a.se]);
                }
            }
        }
        printf("%d\n",ans);
    }

    return 0;
}

Measured memory_bytes: 1300
#include <iostream>
using namespace std;
int main(){
  int n;
  cin>>n;
  int c[n];
  int ord[n];
  int ans =1000;
  for(int i=0;i<n;i++){
    cin>>c[i];
    ord[i]=0;
    while(c[i]%2==0){
      ord[i]++;
      c[i]/=2;
      }
    ans=min(ord[i],ans);
    }
  cout <<ans<<endl;
  return 0 ;
  }



Measured memory_bytes: 256
from collections import deque
N,M=map(int,input().split())
A=[0]*M;B=[0]*M
C=[[] for i in range(N+1)]

for i in range(M):
  A[i],B[i]=sorted(list(map(int,input().split())))
  C[A[i]].append(B[i])
  C[B[i]].append(A[i])

d=[-1]*(N+1)
d[0]=0
d[1]=0

queue=deque([1])
while queue:
  now = queue.popleft()
  for i in C[now]:
    if d[i]!=-1:continue
    if d[i]==-1:d[i]=now
#    d[i]=d[now]+1
    queue.append(i)
#print(d)
#exit()
#E=[0]*(N+1)
#for i in range(M):
#  if d[B[i]]-d[A[i]]==1 and E[B[i]]==0:E[B[i]]=A[i]
#  elif d[A[i]]-d[B[i]]==1 and E[A[i]]==0:E[A[i]]=B[i]
if d.count(0)>2:print('No');exit
print('Yes')
for i in range(2,N+1):
  print(d[i])

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

namespace ConsoleApp19
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int a = Convert.ToInt32(input[0]);
            int b = Convert.ToInt32(input[1]);
            int c = Convert.ToInt32(input[2]);

            if(c>=a&&b>=c)
            {
                Console.Write("Yes");
            }
            else
            {
                Console.Write("No");
            }
            Console.Read();
        }
    }
}


Measured memory_bytes: 11220
import sys
import os


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    K, S = map(int, sys.stdin.readline().split())

    ret = 0
    for x in range(K + 1):
        for y in range(K + 1):
            if S - x - y <= K and S - x - y >= 0:
                ret += 1
    print(ret)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/*
 * AtCoder Beginner Contest 083 A "Libra"
 *   https://abc083.contest.atcoder.jp/tasks/abc083_a/
 */
public class Main {

	public static void main(String[] args) {

		InputScanner in = new InputScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		int A = in.nextInt();
		int B = in.nextInt();
		int C = in.nextInt();
		int D = in.nextInt();

		if (A + B > C + D) {
			out.println("Left");
		} else if (A + B < C + D) {
			out.println("Right");
		} else {
			out.println("Balanced");
		}

		in.close();
		out.close();
	}

	/*
	 * extends java.util.Scanner
	 */
	static class InputScanner {

		Scanner scanner;

		public InputScanner(InputStream inputStream) {
			this.scanner = new Scanner(inputStream);
		}

		public int nextInt() {
			return scanner.nextInt();
		}

		public long nextLong() {
			return scanner.nextLong();
		}

		public double nextDouble() {
			return scanner.nextDouble();
		}
		public String next() {
			return scanner.next();
		}

		public int[] nextIntArray(int n) {
			int[] ret = new int[n];
			for (int i = 0; i < n; i++) {
				ret[i] = scanner.nextInt();
			}
			return ret;
		}

		public int[][] nextIntArray(int h, int w) {
			int[][] ret = new int[h][w];
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					ret[i][j] = scanner.nextInt();
				}
			}
			return ret;
		}

		public long[] nextLongArray(int n) {
			long[] ret = new long[n];
			for (int i = 0; i < n; i++) {
				ret[i] = scanner.nextLong();
			}
			return ret;
		}

		public long[][] nextlongArray(int h, int w) {
			long[][] ret = new long[h][w];
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					ret[i][j] = scanner.nextLong();
				}
			}
			return ret;
		}

		public double[] nextDoubleArray(int n) {
			double[] ret = new double[n];
			for (int i = 0; i < n; i++) {
				ret[i] = scanner.nextDouble();
			}
			return ret;
		}

		public double[][] nextDoubleArray(int h, int w) {
			double[][] ret = new double[h][w];
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					ret[i][j] = scanner.nextLong();
				}
			}
			return ret;
		}

		public String[] nextStringArray(int n) {
			String[] ret = new String[n];
			for (int i = 0; i < n; i++) {
				ret[i] = scanner.next();
			}
			return ret;
		}

		public String[] nextStringArray(int n, String split) {
			String[] ret = scanner.next().split(split);
			return ret;
		}

		public String[][] nextStringArray(int h, int w) {
			String[][] ret = new String[h][w];
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					ret[i][j] = scanner.next();
				}
			}
			return ret;
		}

		public String[][] nextStringArray(int h, int w, String split) {
			String[][] ret = new String[h][w];
			for (int i = 0; i < h; i++) {
				ret[i] = scanner.next().split(split);
			}
			return ret;
		}

		public void close() {
			scanner.close();
		}

	}

}


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

int main() {
    string s;
    cin >> s;
    if (s[0] == s[1] || s[1] == s[2] || s[2] == s[3]){ 
     cout << "Bad" << endl; 
    }
  else cout << "Good" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
long long int power(int a,int b)
{
    if(b==0)
        return 1;
    long long int k=power(a,b/2);
    if(b%2==0)
        return ((k%M)*(k%M))%M;
    else
        return ((k%M)*(k%M)*(a%M))%M;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
     #ifndef ONLINE_JUDGE
 
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
 
   #endif
  string A,B,C;
  cin>>A>>B>>C;
  list<char> a,b,c;
  for(int i=0;i<A.size();i++)
    a.push_back(A[i]);
for(int i=0;i<B.size();i++)
    b.push_back(B[i]);
for(int i=0;i<C.size();i++)
    c.push_back(C[i]);
int d=0;
  if(a.front()=='a')
  {
     a.pop_front();
     d=1;
  }
  else if(a.front()=='b')
  {
    a.pop_front();
    d=2;
  }
  else {
    a.pop_front();
    d=3;
  }
  while(1)
  {
    if(d==1)
    {
       if(a.size()==0)
       {
        cout<<"A";
        return 0;
       }
       if(a.front()=='a')
  {
     a.pop_front();
     d=1;
  }
  else if(a.front()=='b')
  {
    a.pop_front();
    d=2;
  }
  else {
    a.pop_front();
    d=3;
  }

    }
    else if(d==2)
    {
          if(b.size()==0)
       {
        cout<<"B";
        return 0;
       }
       if(b.front()=='a')
  {
     b.pop_front();
     d=1;
  }
  else if(b.front()=='b')
  {
    b.pop_front();
    d=2;
  }
  else {
    b.pop_front();
    d=3;
  }
    }
    else if(d==3)
    {
           if(c.size()==0)
       {
        cout<<"C";
        return 0;
       }
       if(c.front()=='a')
  {
     c.pop_front();
     d=1;
  }
  else if(c.front()=='b')
  {
    c.pop_front();
    d=2;
  }
  else {
    c.pop_front();
    d=3;
  }
    }
  }

    return 0;
}








Measured memory_bytes: 3620
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int x = scan.nextInt();
		long d[] = new long[x];
		for(int i = 0 ; i < x ; i++){
			d[i] = scan.nextLong();
		}
		for(int i = 0 ; i < x ; i++){
			System.out.println("Case " + (i+1) + ":");
			for(int j = 0 ; j < 10 ; j++){
				long ExponentiationA = d[i]*d[i];
				String text = "00000"+String.valueOf(ExponentiationA);
				String getText = text.substring(text.length()-6, text.length()-2);
				d[i] = Integer.parseInt(getText);
				System.out.println(d[i]);
			}
		}
	}
}

Measured memory_bytes: 26028
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin>>n;
  vector<int> a(n);for(int i=0;i<n;i++)cin>>a[i];
  sort(a.begin(),a.end());
  int cnt=0;int sum=0;
  for(int i=0;i<n-1;i++){
    cnt++;
    if(a[i]!=a[i+1]){
      sum+=cnt-1;
      cnt=0;
    }
  }
  sum+=cnt;
  int t=(sum+1)/2;
  cout<<n-t*2<<endl;
}

Measured memory_bytes: 640
a,b = map(int, input().split())
cl=[]
tl=[]
for i in range(a):
    c,t = map(int, input().split())
    cl.append(c)
    tl.append(t)
    
ind=0
resut_list=[]
for p in range(a):
    if tl[ind]<=b:
        resut_list.append(cl[ind])   
    ind+=1
    
if len(resut_list)==0:
  print("TLE")  

else:
  print(min(resut_list))


Measured memory_bytes: 3060
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
temp = 0
work = []
result = 0
for a in A:
    temp += a
    if temp == 0:
        result += 1
    work.append(temp)
work = Counter(work)
for v in work.values():
    if v > 1:
        result += v*(v-1)//2
print(result)

Measured memory_bytes: 41728
#include <string>
#include <math.h>
#include <iostream>
 
using namespace std;
 
int main()
{
  int a, x, y;
  cin >> a;
  if (a == 1) {
    cout << "Hello World";
  }
  else if (a == 2) {
    cin >> x >> y;
    cout << x + y;
  }
}

Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <algorithm>
#include <ctime>
#include <cmath>
#include <string>
#include <stdlib.h>
#include <fstream>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <iterator>
#include <iomanip>
using namespace std;


int n;
vector < vector<int> > g;
vector<int> gi;
vector<int> cl;
vector<int> p;
vector<long long> cycle;

bool dfs (int v) {
	if(cl[v] == 2) return false;
  if(cl[v] == 1){
    while(cycle.back() != v){
      p.push_back(cycle.back());
      cycle.pop_back();
    }
    p.push_back(v);
    reverse(p.begin(), p.end());
    return true;
  }
  cl[v] = 1;
  cycle.push_back(v);
  long long u = -1;
  for(int i = 0; i < g[v].size(); ++i){
    long long to = g[v][i];
    if(cl[to] == 1){
      if(u == -1 || gi[to] > gi[u]) u = to;
    }
  }
  if(u != -1){
    dfs(u);
    return true;
  }

  for (int i = 0; i < g[v].size(); i++) {
      int y = g[v][i];
      if (!cl[y]) {
          gi[y] = gi[v] + 1;
          if (dfs(y)) return true;
      }
  }
  cycle.pop_back();
	cl[v] = 2;
	return false;
}

int main() {
	long long m, in, ot;
  cin >> n >> m;
  g.resize(n);
  gi.resize(n);
  for(int i = 0; i < m; ++i){
    cin >> in >> ot;
    in--, ot--;
    g[in].push_back(ot);
  }
	cl.resize(n);
	for (int i = 0; i < n; ++i)
		if (dfs (i))
			break;

	if (p.size() == 0){
		cout << -1;
    return 0;
  }

  vector<long long> q(n, -1);
  for(int i = 0; i < p.size(); ++i)
      q[p[i]] = i;
  
  long long v = p[0];
  vector<long long> res;
  while(true){
    res.push_back(v);
    long long vv = v;
    for(long long a: g[v])
        if(q[a] > q[vv]) vv = a;
    if(vv == v) break;
    v = vv;
  }
  cout << res.size() << endl;
  for(int i = 0; i < res.size(); ++i) cout << res[i] + 1 << endl;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		int N = input.nextInt();
		long sum = 0;
		for (long i = 1; i <= N; i++) {
			if (i%5!=0&&i%3!=0) sum+=i;
		}
		System.out.println(sum);
	}

}

Measured memory_bytes: 27228
#include <stdio.h>
#include <math.h>

int main(){
  int i, j, k, N;
  int f, cnt[10050];
  
  scanf("%d", &N);
  
  for(i = 0; i < 10050; i++) cnt[i] = 0;
  
  for(i = 1; i < 105; i++){
    for(j = 1; j < 105; j++){
      for(k = 1; k < 105; k++){
        f = i*i + j*j + k*k + i*j + j*k + k*i;
        if(f<10050){
          cnt[f]++;
        }
      }
    }
  }
  
  for(i = 0; i < N; i++) printf("%d\n", cnt[i+1]);
  
  return 0;
}

Measured memory_bytes: 1740
n=int(input())
pointx=0
pointy=0
for i in range(n):
    x,y=[j for j in input().split()]
    p=1
    if len(x)<len(y):
        for j in range(len(x)):
            if ord(list(x)[j])>ord(list(y)[j]):
                pointx=pointx+3
                p=0
                break
            elif ord(list(x)[j])<ord(list(y)[j]):
                pointy=pointy+3
                p=0
                break
        if p:
            pointy=pointy+3
    elif len(x)==len(y):
        for j in range(len(x)):
            if ord(list(x)[j])>ord(list(y)[j]):
                pointx=pointx+3
                p=0
                break
            elif ord(list(x)[j])<ord(list(y)[j]):
                pointy=pointy+3
                p=0
                break
        if p:
            pointx=pointx+1
            pointy=pointy+1
    else:
        for j in range(len(y)):
            if ord(list(x)[j])>ord(list(y)[j]):
                pointx=pointx+3
                p=0
                break
            elif ord(list(x)[j])<ord(list(y)[j]):
                pointy=pointy+3
                p=0
                break
        if p:
            pointx=pointx+3
print("{0} {1}".format(pointx,pointy))

Measured memory_bytes: 7832
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
use std::io::*;
use std::str::FromStr;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);

impl<T: PartialEq> Eq for Total<T> {}

impl<T: PartialOrd> Ord for Total<T> {
    fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering {
        self.0.partial_cmp(&other.0).unwrap()
    }
}

//const MAX:usize = 100006;
//const INF:u64 = u64::max_value();

fn main() {
    let a:i32 = read();
    let b:i32 = read();
    let c:i32 = read();

    println!("{}", a*b/2);
}


Measured memory_bytes: 4352
#include "bits/stdc++.h"
#define MAXN 100009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x)  cerr<< #x <<" = "<< x<<endl;
using namespace std;

typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
char s[MAXN];
int main(){
	//~ #ifndef ONLINE_JUDGE
    //~ freopen("file.in", "r", stdin);
	//~ #endif	
	scanf("%s",s);int mn=INF;
	int n=strlen(s);
	for(int i=0;i<n;i++){
		int mx=0,last=-1;
		for(int j=0;j<n;j++){
			if(s[j]==s[i]){
				umax(mx,j-last-1);
				last=j;
			}
		}umax(mx,n-1-last);
		umin(mn,mx);
	}printf("%d\n",mn);
	return 0;
}


Measured memory_bytes: 256
ans = 0
s = 100
for i in range(5):
    a = int(input())
    r = a % 10
    if r > 0:
        s = min(s, r)
    ans += a // 10 * 10 + (10 if r > 0 else 0)
if s == 100:
    print(ans)
else:
    print(ans + s - 10)


Measured memory_bytes: 2940
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>

typedef int32_t i32;

#define SORT(a,num,cmp) qsort((a),(num),sizeof(*(a)),cmp)

int cmp_char (const void *a, const void *b) {
  i32 d = *(char *)a - *(char *)b;
  return d == 0 ? 0 : d < 0 ? -1 : 1;
}

void run (void) {
  char s[5];
  scanf ("%s", s);
  SORT (s, 4, cmp_char);
  puts (s[0] == s[1] && s[1] != s[2] && s[2] == s[3] ? "Yes" : "No");
}

int main (void) {
  run();
  return 0;
}

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

int main(){
	string s;
	
	cin >> s;
	int i = 0,ans = 0;
	char c = s[0];
	
	while(i<s.size()){
		while(s[i]==c&&i<s.size()) i++;
		ans++;
		c = s[i];
	}
	 cout << ans-1;
}

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

int main(void)
{
    int a, b, c;
    int i;
    int count;

    cin >> a >> b >> c;

    count = 0;
    for (i = a; i <= b; i++){
        if (c % i == 0){
            count++;
        }
    }

    cout << count << "\n";

    return (0);
}


Measured memory_bytes: 3112
#include "bits/stdc++.h"
using namespace std;
int main() {
	long long N; cin >> N;
	vector<long long>A(N);
	vector<bool>B(N);
	for (int i = 0; i < N; i++) {
		cin >> A.at(i);
		if (A.at(i) == i + 1) B.at(i) = false;
		else B.at(i) = true;
	}
	long long ans = 0;
	for (int i = 0; i < N; i++) {
		if (!B.at(i)) {
			ans++;
			B.at(i) = true;
			if (i < N - 1) {
				B.at(i + 1) = true;
			}
			else {
				B.at(i - 1) = true;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024