akhauriyash/Code-Regression huggingface dataset:
from sys import stdin
from itertools import accumulate
from itertools import groupby

n = int(stdin.readline().rstrip())
li = [int(stdin.readline().rstrip()) for _ in range(n)]
point = 0
li.sort()

lin = []
for key, value in groupby(li):
    lin.append(len(list(value)))

for i in lin:
    if i%2 == 1:
        point += 1

print(point)

Measured memory_bytes: 8172
#include <iostream>

using namespace std;

int main()
{
	for(int n,a,b,c,x;cin>>n>>a>>b>>c>>x,n|a|b|c|x;){
		int y[n];
		for(int i=0;i<n;i++)
			cin>>y[i];
		
		int i=0,t=0;
		for(;t<=10000;t++){
			if(x==y[i])
				i++;
			if(i==n)
				break;
			x=(a*x+b)%c;
		}
		
		if(i==n)
			cout<<t<<endl;
		else
			cout<<-1<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1160
// ------------------------------------
// Date:2018/ 3/ 1
// Problem:ABC 053 AToZString b.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto&& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl

typedef long long ll;

static const int MOD = 1000000007;

int main()
{
  string s;
  cin >> s;
  int ans = 0;
  bool ok = false;
  bool check = false;
  int last = 100000;
  REP(i, s.size()) {
    if (s[i] == 'A') {
      if (!check) last = i;
      check = true;
    } else {
      if (s[i] == 'Z' && check) {
        ans = max(i - last + 1, ans);
      }
    }
  }
  cout << ans << endl;
  return 0;
}



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

using namespace std;

typedef long long llong;
typedef pair<llong,llong> P;

bool pairLess(const P& first, const P& second) {
    return first.first < second.first;
}

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

    vector<P> v(N);
    for(int i = 0; i < N; i++) {
        llong A, B;
        cin >> A >> B;
        v[i] = make_pair(A, B);
    }
    sort(v.begin(), v.end(), pairLess);

    llong money = 0;
    int count = 0;
    for(int i = 0; i < N; i++) {
        if(v[i].second + count <= M) {
            money += v[i].first * v[i].second;
            count += v[i].second;
            continue;
        } else {
            money += v[i].first * (M - count);
            count += (M - count);
            break;
        }
    }

    cout << money << endl;
    return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

import javax.sql.rowset.serial.SerialArray;

public class Main {

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

			
			String name1 = sc.next();
			String name2 = sc.next();

			StringBuffer sb = new StringBuffer(name1);
	        name1 = sb.reverse().toString();
	        
	        if(name1.endsWith(name2)){
			    System.out.println("YES");
	        }else{
			    System.out.println("NO");
	        }
		}
}


Measured memory_bytes: 20820
#include<iostream>
#include<string>
using namespace std;
string s;
typedef long long ll;
ll n,t=5*1e15;
int main()
{
	cin>>s>>n;
	
	for(int i=0;i<s.size();i++)
	{
		if(s[i]!='1')
		{
			cout<<s[i]<<endl;return 0;
		}
		if(s[i]=='1')n--;
		if(!n)
		{
			cout<<"1\n";return 0;
		}
		
	}
}

Measured memory_bytes: 256
using namespace std;
#include <bits/stdc++.h>
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define debug(x) cout << #x <<" = " << x << endl
void solve()
{
string s;
cin>>s;
int ans=0;
int i=0;
while (i<s.length())
{
    if(s[i]=='R')
    {
        int cnt=0;
        while (s[i]=='R'&&i<s.length())
        {
            cnt++;
            i++;
        }
        ans=max(ans,cnt);
    }
    i++;
}
cout<<ans<<endl;
}
int main()
{
FASTIO
 long long int t;
 t=1;
 while(t--)
  solve();
  return 0;
}


Measured memory_bytes: 3652
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef vector<ll> vec;
typedef vector<string> svec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-8;

void solve() {
	ll a, b; cin >> a >> b;
	if (a < b)swap(a, b);
	if ((a - b) % 2 == 0) {
		cout << (a + b) / 2 << endl;
	}
	else {
		cout << "IMPOSSIBLE" << endl;
	}
}
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(10);
	//cout << pow(1/6000.0, 1.0 / 25) << endl;
	//init();
	solve();
	//cout << "finish" << endl;
	//stop
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {

    int cnt = 0;
    int a, b, c;

    cin >> a >> b >> c;

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

	cout << cnt << "\n";
	return 0;
}



Measured memory_bytes: 3120
n = list(map(int,input().split()))
scores = list(map(int,input().split()))
cards = input()
cards = list(cards)
ans = 0

for i in range(n[0]):
    if i < n[1] or cards[i-n[1]] != cards[i]:
        if cards[i] == 'r':
            ans += scores[2]
        elif cards[i] == 's':
            ans += scores[0]
        else:
            ans += scores[1]
    else:
        cards[i] = 'k'

print(ans)



Measured memory_bytes: 4084
N, M = [ int(i) for i in input().split() ]
students = []
for i in range(N):
    students.append([int(i) for i in input().split()])
points = []
for i in range(M):
    points.append([int(i) for i in input().split()])
for x, y in students:
    shortest = 2000000000
    index = 0
    for j, (xx, yy) in enumerate(points):
        l = abs(x-xx) + abs(y-yy)
        if l < shortest:
            shortest = l
            index = j
    print(index+1)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define makei(N) int N; cin >> N;
#define makel(N) ll N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007
#define re return 0

using namespace std;
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using msi = map<string, int>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

void yn(bool b) {
	if (b)say("Yes");
	else say("No");
}

template<typename T>
void maxi(T &a, T &b) {
	a = max(a, b);
}

template<typename T>
void mini(T &a, T &b) {
	a = min(a, b);
}

int main() {
	int H, W;
	cin >> H >> W;
	vs v;
	string s;
	rep(W + 2)s.push_back('.');
	v.push_back(s);
	rep(H) {
		string tmp;
		cin >> tmp;
		v.push_back("." + tmp + ".");
	}
	v.push_back(s);
	FOR(i, 1, H) {
		FOR(j, 1, W) {
			if (v[i][j] == '#') {
				if (v[i][j + 1] == '.'&&v[i + 1][j] == '.'&&v[i - 1][j] == '.'&&v[i][j - 1] == '.') {
					yn(false);
					re;
				}
			}
		}
	}
	yn(true);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long
using namespace std;

ll n, m;

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

    cin >> n >> m;

    cout << min(m / 2, (n + m / 2) / 2) << endl;

    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/perl

my ($h1,$m1,$h2,$m2,$k) = map { $_ - 0 } split(/\s+/,<STDIN>);

my $r = $h2 * 60 + $m2 - ($h1 * 60 + $m1) - $k;
$r = 0 if $r < 0;
print "$r\n";




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

long long solve(long long A, long long B) {
    long long ok = 1, ng = sqrt(A * B) + 10;
    while (ng - ok != 1) {
        long long mid = (ok + ng) / 2;
        (mid * mid < A * B ? ok = mid : ng = mid);
    }

    if (ok * (ok + 1) < A * B) {
        if (A <= ok || B <= ok) {
            return 2 * (ok - 1) + 1;
        } else {
            return 2 * (ok - 1) + 2;
        }
    } else {
        return 2 * (ok - 1);
    }
}

int main() {
    int Q;
    cin >> Q;
    for (int i = 0; i < Q; i++) {
        long long A, B;
        cin >> A >> B;
        cout << solve(A, B) << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repo(i, n) for(int i=1; i<=n; i++)
#define ssort(a) sort(a.begin(), a.end())
#define INF 1001001001
#define INFll 100100100100100
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

using namespace std;
using ull = unsigned long long;
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

ll dp[105][4][4][4];

int main(){
  int n;
  cin >> n;
  dp[0][3][3][3]=1;
  rep(i, n){
    rep(j, 4){
      rep(k, 4){
        rep(l, 4){
          rep(ni, 4){
            if(k==0 && l==2 && ni==1)continue;
            if(k==0 && l==1 && ni==2)continue;
            if(k==2 && l==0 && ni==1)continue;
            if(j==0 && l==2 && ni==1)continue;
            if(j==0 && k==2 && ni==1)continue;
            dp[i+1][k][l][ni]+=dp[i][j][k][l];
            dp[i+1][k][l][ni]%=mod;
          }
        }
      }
    }
  }
  ll ans=0;
  rep(j, 4)rep(k, 4)rep(l, 4){
    ans+=dp[n][j][k][l];
    ans%=mod;
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

typedef long long ll;


int main()
{
    ll n, d;
    cin >> n >> d;
    d = d * d;
    int ans = 0;
    while(n--)
    {
        ll a, b;
        cin >> a >> b;
        ll sum = a * a + b * b;
        if(sum <= d)
            ans++;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3624
S = input()
S = list(map(int,S))

even = S[0::2]
odd = S[1::2]

even_1 = sum(even)
even_0 = len(even) - even_1
odd_1 = sum(odd)
odd_0 = len(odd) - odd_1

ans = 0
if even_0 + odd_1 <= even_1 + odd_0:
    ans = even_0 + odd_1
else:
    ans = even_1 + odd_0

print(ans)    

Measured memory_bytes: 4640
import java.util.*;
public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int goh = X / 500;
        X -= (goh*500);
        int go = X / 5;
        System.out.println(goh * 1000 + go*5);
    }

}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int h, w, k; cin >> h >> w >> k;
    vector<string> data(h);
    rep(i,h) cin >> data[i];
    rep(i,h) data[i].push_back('#');
    vvint ans(h,vint(w,0));
    vint line;
    rep(i,h) {
        vint place;
        rep(j,w+1) if (data[i][j] == '#') place.push_back(j);
        line.push_back(i);
        if (place.size() == 1) continue;
        else {
            rep(j,place[0]) {
               for (int l : line) ans[l][j] = k; 
            }
            rep(j,place.size()-1) {
                for (int row = place[j]; row < place[j+1]; row++) {
                    for (int l : line) ans[l][row] = k;
                }
                k--;
            }
            line.clear();
        }
    }
    for (int l : line) {
        rep(j,w) ans[l][j] = ans[line[0]-1][j];
    }
    rep(i,h) {
        rep(j,w) cout << ans[i][j] << " ";
        cout << endl;
    }
}


Measured memory_bytes: 4112
#include<stdio.h>
#include<stdlib.h>
#define nMAX 2000000
#define AMAX 10000

int main(){

  int i,j,n,*A,*B,C[AMAX+1];

  scanf("%d",&n);

  A = malloc(sizeof(int)*n+1);
  B = malloc(sizeof(int)*n+1);
  for ( i = 0; i <= AMAX; i++ ) {
    C[i] = 0;
  }

  for ( i = 0; i < n; i++ ){
    scanf("%d", &A[i + 1]);
    C[A[i + 1]]++;
  }

  for ( i = 1; i <= AMAX; i++ ) C[i] = C[i] + C[i - 1];

  for ( j = 1; j <= n; j++ ){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }

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

  return 0;
}

Measured memory_bytes: 16276
#include <bits/stdc++.h>
typedef long long ll;

using namespace std;

int gcd(int a, int b)
{
  int M = std::max(a, b);
  int m = std::min(a, b);

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

int main()
{
  int n;
  cin >> n;
  vector<int> v;

  int a;
  vector<int> g;
  for (int i = 0; i < n; i++)
  {
    cin >> a;
    v.push_back(a);
    if (i == 0)
    {
      g.push_back(a);
    }
    else
    {
      g.push_back(gcd(g[i - 1], a));
    }
  }

  vector<int> w = v;
  vector<int> wg;
  reverse(w.begin(), w.end());

  for (int i = 0; i < n; i++)
  {
    if (i == 0)
    {
      wg.push_back(w[0]);
    }
    else
    {
      wg.push_back(gcd(wg[i - 1], w[i]));
    }
  }

  int res = g[n - 2]; // 一番右を変えたとき
  for (int i = n - 2; i > 0; i--)
  {
    int tmp = gcd(g[i - 1], wg[n - i - 2]);
    res = std::max(res, tmp);
  }

  res = std::max(res, wg[n - 2]);

  cout << res << endl;
}


Measured memory_bytes: 2164
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll const mod=1e9+7;
double const pi=acos(-1);
ll s[200500];
ll a[200500];
ll b[200500];
int main()
{
    ll n;
    cin >> n;
    for(int i = 1; i <= n; i++) 
		cin >> s[i];
    for(int i = 1; i <= n; i++){
        if(i-s[i]>0)
		{
            b[i-s[i]]++;
        }
        if(i+s[i]<=n)
		{
            a[i+s[i]]++;
        }
    }
    ll sum = 0;
    for(int i=1; i<=n;i++){
        sum+=a[i]*b[i];
    }
    cout << sum << endl;
    return 0;
}

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

using namespace std;

const int MOD=1e9+7;
const double PI=3.14159265359;


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    long long a,b,c,x,y;
    cin>>a>>b>>c>>x>>y;
    
    
    long long ans=1e18;
    for(long long i=0; i<= 2*max(x,y); i+=2){
        long long arem=max(0ll,x-i/2), brem=max(0ll,y-i/2);
        ans= min(ans, c*i+a*arem+b*brem);
    }
    cout<<ans;
    
    return 0;
    
    
}

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

using ll = long long;

constexpr ll MOD = 1e9+7;
constexpr ll INF = 1ll<<60;

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

vector<vector<ll>> G;
vector<ll> res;

int main(int argc, char **argv)
{
	ll N, M; cin >> N >> M;
	G.resize(N);
	REP(i, M)
	{
		ll a, b; cin >> a >> b;
		--a, --b;
		G[a].push_back(b);
		G[b].push_back(a);
	}

	res.assign(N, -1);
	queue<ll>que;
	que.push(0);
	res[0] = 0;

	while (!que.empty())
	{
		ll now = que.front(); que.pop();

		for (auto &nv : G[now])
		{
			if (res[nv] != -1) continue;
			res[nv] = now;
			que.push(nv);
		}
	}

	auto pos = find(ALL(res), -1);
	if (pos != res.end())
	{
		std::cout << "No" << std::endl;
		return 0;
	}

	std::cout << "Yes" << std::endl;
	for (ll i = 1; i < N; ++i)
	{
		std::cout << res[i] + 1 << std::endl;
	}
}


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


class Program
{
    static void Main(string[] args)
    {
        new Magatro().Solve();
    }
}

class Magatro
{
    string S;


    private void Scan()
    {
        S = Console.ReadLine();
    }

    private int Cnt(char c)
    {
        var s = S.ToArray();
        char[] array;
        int cnt = 0;
        while (true)
        {
            bool flag = true;
            foreach (char cc in s)
            {
                if (cc != c)
                {
                    flag = false;
                    break;
                }
            }
            if (flag)
            {
                return cnt;
            }
            array = new char[s.Length - 1];
            for (int i = 0; i < s.Length - 1; i++)
            {
                if (s[i + 1] == c)
                {
                    array[i] = s[i + 1];
                }
                else
                {
                    array[i] = s[i];
                }
            }
            s = array;
            cnt++;
        }
    }

    public void Solve()
    {
        Scan();
        int ans = int.MaxValue;

        for(char c = 'a'; c <= 'z'; c++)
        {
            ans = Math.Min(ans, Cnt(c));
        }
        Console.WriteLine(ans);
    }


}








Measured memory_bytes: 11220
#include<iostream>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<string>
#include<cmath>
#include<algorithm>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
template<class T>bool valid(const T& x, const T& w) { return 0 <= x && x < w; }
#define what(x) cerr << #x << " is " << x << endl;
const int INF = 1<<28;

int main(){
    int N, M;
    cin >> N >> M;
    map<int, vi> m;
    for(int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        m[a].push_back(b);
        m[b].push_back(a);
    }
    bool ret = false;
    vi first;
    for(auto b : m[1]) {
        first.push_back(b);
    }
    for(auto f : first) {
        for(auto c : m[f])
            if(c == N) {
                ret = true;
                break;
            }
        if(ret)
            break;
    }
    if(ret)
        cout << "POSSIBLE" << endl;
    else
        cout << "IMPOSSIBLE" << endl;

    return 0;
}

Measured memory_bytes: 23664
N,u,v = map(int,input().split())
AB = [list(map(int,input().split())) for _ in range(N-1)]
import numpy as np
x = [[] for _ in range(N)]
for ab in AB:
  a = ab[0]
  b = ab[1]
  x[a-1].append(b-1)
  x[b-1].append(a-1)
  
flag1 = [False]*N
flag2 = [False]*N
length1 = [0]*N
length2 = [0]*N
go = [v-1]
while go!=[]:
  a = go.pop()
  if flag1[a]:
    continue
  else:
    flag1[a]=True
    for i in x[a]:
      if flag1[i]:
        continue
      else:
        length1[i]=length1[a]+1
        go.append(i)

go = [u-1]
while go!=[]:
  a = go.pop()
  if flag2[a]:
    continue
  else:
    flag2[a]=True
    for i in x[a]:
      if flag2[i]:
        continue
      else:
        length2[i]=length2[a]+1
        go.append(i)
        
length1 = np.array(length1)
length2 = np.array(length2)
print(max(length1[length1>length2])-1)

Measured memory_bytes: 60464
#include <iostream>

using namespace std;

int digit(int x){
    int ans = 0;

    while(x > 0){
        ans += x%10;
        x /= 10;
    }

    return ans;
}

int main(){
    int n,a,b,ans = 0;
    cin >> n >> a >> b;

    for(int i = 1;i <= n;i++){
        int t = digit(i);
        if(a <= t && t <= b)ans += i;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int w = sc.nextInt();
        long w1;
        ArrayList<ArrayList<Integer>> al = new ArrayList<>();
        for (int i = 0; i < 4; i++) al.add(new ArrayList<>());
        w1 = sc.nextInt();
        al.get(0).add(sc.nextInt());
        for (int i = 1; i < n; i++) {
            al.get((int)(sc.nextInt() - w1)).add(sc.nextInt());
        }
        for (ArrayList<Integer> a : al) {
            Collections.sort(a, Collections.reverseOrder());
        }

        long ans = 0;
        for (int i = 0; i <= al.get(0).size(); i++) {
            for (int j = 0; j <= al.get(1).size(); j++) {
                for (int k = 0; k <= al.get(2).size(); k++) {
                    for (int l = 0; l <= al.get(3).size(); l++) {
                        long weight = (i + j + k + l) * w1 + j + 2 * k + 3 * l;
                        if (weight > w) continue;
                        long candidate = 0;
                        for (int m = 0; m < i; m++) candidate += al.get(0).get(m);
                        for (int m = 0; m < j; m++) candidate += al.get(1).get(m);
                        for (int m = 0; m < k; m++) candidate += al.get(2).get(m);
                        for (int m = 0; m < l; m++) candidate += al.get(3).get(m);
                        if (ans < candidate) {
                            ans = candidate;
                        }
                    }
                }
            }
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 24936
#include<bits/stdc++.h>
#include <cstdio>   
#define pb          push_back 
#define endl        "\n"
#define mostrar(x,y) cout<<x<<" "<<y<<endl;
#define f           first
#define s           second
#define mod         1000000007
#define EPS         1e-9
using namespace std;
typedef pair<int,int> ii;
typedef pair<pair<int,int>,int> iii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef long long ll;


int main(){
    ofstream out("output.txt");

    string cad;
    cin>>cad;

    map<char,int> m;

    for(int i =0; i<4; i++){
        if(m.find(cad[i]) == m.end()){
            m[cad[i]] = 1;
        }
        else{
            m[cad[i]]++;
        }
    }
    if(m.size()!=2){
        cout<<"No\n";
    }
    else{
        bool sePuede = true;

        for(auto it = m.begin();it!=m.end();it++){
            if(it->s != 2){
                sePuede = false;
            }
        }
        if(sePuede) cout<<"Yes\n";
        else          cout<<"No\n";
    }

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define io ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define ss second
#define ff first
#define pii pair<int,int> 
#define mp make_pair()
int main(){
	io
    int n,d;
  cin>>n>>d;
  float v[n][d];
  for(int i=0;i<n;i++){
  	for(int j=0;j<d;j++){
  		cin>>v[i][j];
  	}
  }
  int ans=0;double x,y;
  for(int i=0;i<n;i++){
  	for(int j=i+1;j<n;j++){
  		x=0.0;
  		for(int k=0;k<d;k++){
  			x+=(v[i][k]-v[j][k])*(v[i][k]-v[j][k]);
  		}
  		y=sqrt(x);
  	//	cout<<y<<endl;
  		if(y-(int)y==0.0) ans++;
  	}
  }
  cout<<ans;
  
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define LL long long
#define mp make_pair
#define pb push_back
#define fi first
#define sc second
using namespace std;

int main(){
	LL a,b,c,x;
	cin>>a>>b>>c;
	x = a*100+b*10+c;
	if(x%4==0) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <string>
#include <iostream>
#include <algorithm>

using namespace std;

string S;

const string R1 = "iw(){}[]";
const string R2 = "iw)(}{][";

inline bool solve(string T)
{
	int is = 0, ws = 0;

	for (int i = 0; i < T.size(); i++)
	{
		if (T[i] == 'i') is++;
		if (T[i] == 'w') ws++;
	}

	if (!(is == 2 && ws == 1)) return false;

	bool flag = false;

	for (int i = 0; i < (int)(T.size()) - 2; i++)
	{
		if (T.substr(i, 3) == "iwi")
		{
			flag = true;
		}
	}

	if (!flag) return false;

	if (T.size() % 2 == 1)
	{
		char middle = T[T.size() / 2];

		if (!(middle == 'i' || middle == 'w')) return false;
	}

	for (int i = 0; i < T.size(); i++)
	{
		char c1 = T[i];
		char c2 = T[T.size() - i - 1];

		for (int j = 0; j < 8; j++)
		{
			if (R1[j] == c1)
			{
				if (R2[j] != c2)
				{
					return false;
				}
			}
		}
	}

	return true;
}

int main()
{
	cin >> S;

	int ret = 0;

	for (int i = 0; i < (1 << S.size()); i++)
	{
		string T;

		for (int j = 0; j < S.size(); j++)
		{
			if (i & (1 << j))
			{
				T += S[j];
			}
		}

		if (solve(T))
		{
			ret = max(ret, (int)(T.size()));
		}
	}

	printf("%d\n", ret);

	return 0;
}

Measured memory_bytes: 3328
#include<stdio.h>

int main(void){
    int a, b, c;
    int cnt=3;

    scanf("%d %d %d", &a, &b, &c);
    
    if(a==b){
        cnt--;
    }
    if(a==c){
        cnt--;
    }
    if(b==c&&cnt>1){
        cnt--;
    }

    printf("%d\n", cnt);

    return 0;
}

Measured memory_bytes: 128
def dijkstra(s):
    #始点sから各頂点への最短距離
    #n:頂点数,　w:辺の数, cost[u][v] : 辺uvのコスト(存在しないときはinf)
    d = [float("inf")] * n
    used = [False] * n
    d[s] = 0
    
    while True:
        v = -1
        #まだ使われてない頂点の中から最小の距離のものを探す
        for i in range(n):
            if (not used[i]) and (v == -1):
               v = i
            elif (not used[i]) and d[i] < d[v]:
                v = i
        if v == -1:
               break
        used[v] = True
               
        for j in range(n):
               d[j] = min(d[j],d[v]+cost[v][j])
    return d

Xs,Ys,Xt,Yt = map(int,input().split())
n = int(input())
p = [(Xs,Ys,0),(Xt,Yt,0)]
for i in range(2,n+2):
    p.append(tuple(map(int,input().split())))
cost = [[0]*(n+2)for i in range(n+2)]

for i in range(n+2):
    for j in range(i,n+2):
        cost[i][j] = cost[j][i] =  max(((p[i][0]-p[j][0])**2+(p[i][1]-p[j][1])**2)**0.5 - p[i][2] - p[j][2],0)
cost = tuple(cost)
n += 2

res = dijkstra(0)
print(res[1])

Measured memory_bytes: 23028
from collections import Counter

H, W, N = map(int, input().split())

# 3*3マスの処理用リスト
dir = [[0, 0], [1, 0], [1, 1], [0, 1], [-1, 1],
       [-1, 0], [-1, -1], [0, -1], [1, -1]]

# そのマスを中心とする3*3グリッドに含まれる黒マスの数
dict = {}

for i in range(N):
    a, b = map(int, input().split())
    for dy, dx in dir:
        # 3*3グリッドは、H*Wの中に完全に含まれていなければならないことに注意
        if 2 <= a + dy <= H - 1 and 2 <= b + dx <= W - 1:
            if (a + dy, b + dx) not in dict:
                dict[(a + dy, b + dx)] = 1
            else:
                dict[(a + dy, b + dx)] += 1

c = Counter(dict.values())
ans = [0 for _ in range(10)]

# ans[1], ans[2], ..., ans[9]を確定させる（ans[0]は後述）
for k, v in c.items():
    if v > 0:
        ans[k] = v

# 全体で作れる3*3グリッドは(H-2)*(W-2)個
# ans[1],...,ans[9]の総和を引くとans[0]になる
ans[0] = (H - 2) * (W - 2) - sum(ans[1:])

for i in range(10):
    print(ans[i])


Measured memory_bytes: 164440
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define LL long long
#define st first
#define nd second
#define endl '\n'
using namespace std;

const int MAXN=100005;
LL n,m,val[MAXN],a[MAXN],open1cnt[MAXN],open1[MAXN],open2[MAXN],open2cnt[MAXN],normal;

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin>>n>>m;
	for(int i=0;i<n;++i) {
		cin>>a[i];
		if(i) {
			if(a[i]>a[i-1]) {
				open1cnt[a[i-1]+1]++;
				open1cnt[a[i]+1]--;
				open1[a[i-1]+1]+=a[i-1]+1;
				open1[a[i]+1]-=a[i-1]+1;
			}
			else if(a[i]<a[i-1]) {
				open1[a[i-1]+1]+=a[i-1]+1;
				open1cnt[a[i-1]+1]+=1;
				open2cnt[a[i]]+=1;
				open2[a[i]]+=m-a[i-1];
			}
		}
	}
	LL cnt=0,sum=0;
	for(int i=1;i<=m;++i) {
		cnt+=open1cnt[i];
		sum+=open1[i];
		val[i]+=1LL*i*cnt-sum;
	}
	cnt=sum=0;
	for(int i=m;i>=1;--i) {
		cnt+=open2cnt[i];
		sum+=open2[i];
		val[i]+=sum+cnt*(i-1);
	}
	for(int i=1;i<n;++i) 
		if(a[i]>=a[i-1])
			normal+=a[i]-a[i-1];
		else normal+=m-a[i-1]+a[i];
	LL ans=1e15;
	for(int i=1;i<=m;++i) {
		//cout<<i<<" "<<normal-val[i]<<endl;
		ans=min(ans,normal-val[i]);
	}
	cout<<ans<<endl;

}


Measured memory_bytes: 4992
#include <iostream>
#include <sstream>
#include <string>
#include <cmath>

//void Aoj_learning1();
//void Aoj_learning2();
void Aoj_learning3();

int main()
{
	Aoj_learning3();
}

///////////////////////////////////////////////////////
//入力された複数の整数から素数の個数を返す
///////////////////////////////////////////////////////
void Aoj_learning3()
{
	std::string sInput;
	int intInputNum = 0;
	std::istringstream ss;	// 汎用文字列ストリーム

	// 入力個数の取得
	std::cin >> sInput;
	ss = std::istringstream(sInput);
	ss >> intInputNum;

	// 数値取得
	std::string sInputNum[10000];
	for (int count = 0; count < intInputNum; count++)
	{
		std::cin >> sInputNum[count];
	}

	// 素数の個数を取得する
	int divid;		// 除算用
	int number;		// 入力値
	int temp;
	int flag;		// 素数フラグ
	int primeCount = 0;	// 素数の個数
	for (int count = 0; count < intInputNum; count++)
	{
		divid = 3;	// 2から割り始める
		flag = 0;	// フラグリセット
		ss = std::istringstream(sInputNum[count]);
		ss >> number;
		
		// 偶数は弾く
		if (0 == (number % 2))
		{
			flag = 0;
		}
		else
		{
			// 素数判定
			if (number < 16)
			{
				while (divid <= number)
				{
					temp = number % divid;
					if (temp == 0) {
						break;
					}
					else
					{
						if (divid > (number / 2)) {
							flag = 1;
						}
						divid = divid + 2;
					}
				}
			}
			else
			{
				while (divid <= std::sqrt(number))
				{
					temp = number % divid;
					if (temp == 0) {
						flag = 0;
						break;
					}
					else
					{
						flag = 1;
						divid = divid + 2;
					}
				}
			}
		}
		// 素数2と3だけ特殊判定
		if (number == 2 || number == 3)
		{
			flag = 1;
		}
		// 素数フラグ立ってたらカウント＋１
		if (flag == 1)
		{
			primeCount++;
		}
	}
	// 素数の個数を表示
	std::string sOutput;
	sOutput = std::to_string(primeCount);
	std::cout << primeCount << std::endl;
}


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

using namespace std;

#define ios         ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ll          long long
#define cn          37
#define sn          2007
#define bn          1000007
#define M           100000007
#define inf         LLONG_MAX

ll f[bn];

int main()
{
        ios;
        ll n,m = 0; cin >> n;
        for(ll i = 1; i <= n; i++)
        {
                ll x; cin >> x; f[x]++;
                m = max(m,x);
        }
        bool a1 = 1,a2 = 1;
        for(ll i = 2; i <= m; i++)
        {
                ll c = 0;
                for(ll j = i; j <= m; j += i)
                {
                        c += f[j];
                }
                if(c > 1) a1 = 0;
                if(c == n) a2 = 0;
        }
        if(a1) cout << "pairwise coprime";
        else if(a2) cout << "setwise coprime";
        else cout << "not coprime";
}










Measured memory_bytes: 11476
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

vector<ll> memo1(51, -1);
vector<ll> memo2(51, -1);

ll level(ll N);
ll p(ll N);
ll f(ll N, ll X);

int main()
{
    ll N, X;
    cin >> N >> X;
    cout << f(N, X) << endl;
}

ll level(ll N)
{
    if (N == 0)
    {
        return memo1[N] = 1;
    }
    if (memo1[N] != -1)
    {
        return memo1[N];
    }
    return memo1[N] = 2 * level(N - 1) + 3;
}

ll p(ll N)
{
    if (N == 0)
    {
        return memo2[N] = 1;
    }
    if (memo2[N] != -1)
    {
        return memo2[N];
    }
    return memo2[N] = 2 * p(N - 1) + 1;
}

ll f(ll N, ll X)
{
    if (X <= 0)
    {
        return 0;
    }
    if (N == 0)
    {
        return 1;
    }
    if (level(N - 1) + 1 >= X)
    {
        return f(N - 1, X - 1);
    }
    else
    {
        return f(N - 1, X - 2 - level(N - 1)) + p(N - 1) + 1;
    }
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<algorithm>
#define LL long long
#define fo(i,j,k) for(int i=j;i<=k;i++)
#define fd(i,j,k) for(int i=j;i>=k;i--)
#define fr(i,j) for(int i=beg[j];i;i=nex[i])
using namespace std;
int const mn=5e3+3,mo=1e9+7;
int n,K,a[mn],f[mn];
int Pow(LL x,int y){
	LL ans=1;
	for(;y;y/=2,(x*=x)%=mo)if(y&1)(ans*=x)%=mo;
	return ans;
}
int main(){
	scanf("%d%d",&n,&K);
	int lim=sqrt(n);
	fo(i,1,lim)if(n%i==0){
		a[++a[0]]=i;
		if(i*i!=n)a[++a[0]]=n/i;
	}
	sort(a+1,a+a[0]+1);
	int ans=0;
	fo(i,1,a[0]){
		f[i]=Pow(K,(a[i]+1)/2);
		fo(j,1,i-1)if(a[i]%a[j]==0)f[i]=(f[i]-f[j])%mo;
		ans=(ans+1ll*f[i]*((a[i]&1)?a[i]:a[i]/2))%mo;
	}
	printf("%d",(ans+mo)%mo);
	return 0;
}


Measured memory_bytes: 128
// SumOfNumbers.c
// 与えられた数の各桁の和を計算するプログラムを作成して下さい。
// 【入力】
// 複数のデータセットが入力として与えられます。
// 各データセットは１つの整数 x を含む１行で与えられます。
// x は 1000 桁以下の整数です。
// x が 0 のとき入力の終わりとします。このデータセットに対する出力を行ってはいけません。
// 【出力】
// 各データセットに対して、x の各桁の和を１行に出力して下さい。
// 【例】
// 入力：
// 123
// 55
// 1000
// 0
// 出力：
// 6
// 10
// 1
#include<stdio.h>
#include<string.h>

int main( void) {
  char X[1001];

  while( 1) {
    scanf( "%s", X);
    if ( strcmp( X, "0") == 0) break;

    int len = (int)strlen( X);
    int sum = 0;
    for ( int i = 0; i < len; i++) {
      sum += (int)( X[i] - '0');
    }
    printf( "%d\n", sum);
  }

  return 0;
}



Measured memory_bytes: 2072
a = int(input())
b = list(map(int, input().split()))
e = {}
for i in b:
    if i not in e:
        e[i] = 1
    else:
        e[i] += 1
if len(e) > 3:
    print("No")
elif len(e) == 3:
    x, y, z = map(int, e.keys())
    xx, yy, zz = map(int, e.values())
    if x ^ y == z and y ^ z == x and z ^ x == y and xx == yy == zz:
        print("Yes")
    else:
        print("No")
elif len(e) == 2:
    x, y = map(int, e.keys())
    xx, yy = map(int, e.values())
    if (x == 0 and 2 * xx == yy) or (y == 0 and xx == 2 * yy):
        print("Yes")
    else:
        print("No")
elif len(e) == 1:
    x = list(map(int, e.keys()))[0]
    if x == 0:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 14212
#include <bits/stdc++.h>
#include<set>
#include <algorithm>
#define ll long long 
#include <string.h>
#define pb push_back
#define mp make_pair
# define pi 3.14159265358979323846
#define max 1e9;
using namespace std;

int main()
{
	ll int a,b;
	cin>>a;
	cin>>b;
	char ch;
	cin>>ch;
	ll int c;
	cin>>c;
	b=b*100+c;
	a=a*b;
	a=a/100;
	cout<<a<<endl;
}
    
	
		

	
			

		


 






Measured memory_bytes: 3560
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll n,i,j,k,l,a,b,c,d,m;
    cin>>a>>b;
    if(a>=2){a-=2;}
    if(b>=2){b-=2;}
    cout<<a*b<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.*;
 
class Main {
	public static void main (String args[]) {
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);
		String buf;
 
		try {
			while ((buf = br.readLine())!=null) {
				int n = Integer.parseInt(buf);
				boolean list[] = new boolean[2*n+1];
				for (int i=2;i<=2*n;i++) list[i] = true;
				for (int i=2;i<=2*n;i++) {
					for (int j=2;i*j<=2*n;j++) {
						list[i*j] = false;
					}
				}
				for (int i=n-1;i>=2;i--) {
					if (list[i]) {
						System.out.print(i+" ");
						break;
					}
				}
				for (int i=n+1;i<=2*n;i++) {
					if (list[i]) {
						System.out.println(i);
						break;
					}
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;

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; }

ll ngcd(vector<ll> a) {
  ll res = a[0];
  for(ll i=1; i<a.size() && res!=1; i++) res = gcd(a[i], res);
  return res;
}
ll nlcm(vector<ll> a){
  ll res = a[0];
  for(ll i=1; i<a.size(); i++) res = lcm(a[i], res);
  return res;
}
bool is_prime(ll n) {
  if(n < 2) return false;
  for (ll i = 2; i * i <= n; i++) if (n % i == 0) return false;
  return true;
}
ll digsum(ll n) {
  ll res=0;
  while(n) res += n%10, n /= 10;
  return res;
}
ll digcnt(ll n){
  ll res=0;
  while(n) res++, n /= 10;
  return res;
}
vector<ll> divisor(ll n) {
  vector<ll> res;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      res.push_back(i);
      if (i != n / i) res.push_back(n / i);
    }
  }
  sort(res.begin(), res.end());
  return res;
}
map<ll, ll> prime_factor(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) ++res[i], n /= i;
  }
  if (n != 1) res[n] = 1;
  return res;
}

ll f(ll a){
  ll cnt=0;
  while(a%2==0){
    cnt++;
    a/=2;
  }
  return cnt;
}

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n,m; cin>>n>>m;
  
  vll a(n);
  rep(i,n){
    cin>>a[i];
    a[i]/=2;
  }
  ll t=f(a[0]);
  rep(i,n){
    if(f(a[i])!=t){
      cout<<0<<endl;
      return 0;
    }
    a[i]>>=t;
  }
  m>>=t;
  
  ll l=1;
  rep(i,n){
    l=lcm(l,a[i]);
    if(l>m){
      cout<<0<<endl;
      return 0;
    }
  }
  
  m/=l;
  ll ans=(m+1)/2;
  cout<<ans<<endl;
  
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define mod 1e9 + 7
using namespace std;

void add_self(int& a, int b) 
{
  a += b;
  if(a >= mod)
    a -= mod;
}

void sub_self(int& a, int b)
{
  a -= b;
  if(a < 0)
    a += mod;
}

int main()
{
  int n, k;
  scanf("%d%d", &n, &k);
  vector<int> a(n);
  for(int i = 0; i < n; i++)
  {
    scanf("%d", &a[i]);
  }
  vector<int> dp (k + 1);
  dp[0] = 1;
  for(int i = 0; i < n; i++)
  {
    vector<int> fake(k + 1);
    for(int candies = k; candies >= 0; candies--)
    {
      int temp = dp[candies];
      int L = candies + 1;
      int R = candies + min(a[i], k - candies);
      if(L <= R)
      {
        add_self(fake[L], temp);
        if(R + 1 <= k)
        {
          sub_self(fake[R + 1], temp);
        }
      }
    }
    int prefix_sum = 0;
    for(int x = 0; x <= k; x++)
    {
      add_self(prefix_sum, fake[x]);
      add_self(dp[x], prefix_sum);
    }
      
  }
  printf("%d", dp[k]);
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main() {
double n,t,a;
cin >> n >> t >> a;
vector<double>  h(n),hight(n);
double mini = 1000000;
int ans = -1;
for(int i = 0;i < n;i++){
  cin >> h[i];
  hight[i] = abs(a - t + h[i]*0.006);
 if(mini > hight[i]){
  mini = hight[i];
  ans = i+1;
 }
}

cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

void rvs_str( char* , char* );

int main(void)
{
	char str[30], dst[30];
	
	scanf("%s", str );
	rvs_str( dst , str );
	printf("%s\n", dst);
	
	return 0;
}

void rvs_str( char *dst , char *src )
{
	int i, j;
	for( i = 0 ; src[i] != '\0' ; i++ )
	{
		;
	}
	for( j = 0 ; j < i ; j++ )
	{
		dst[j] = src[i-1-j];
	}
	dst[j] = '\0';
}

Measured memory_bytes: 524
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcount
#define ll long long
#define mp make_pair
#define f first
#define s second
#define Time (double)clock()/CLOCKS_PER_SEC

const int N = 101;
string s[N];
int len[N];
signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i)
        cin >> s[i] >> len[i];
    string w;
    cin >> w;
    int ans = 0;
    bool b = 0;
    for (int i = 0; i < n; ++i) {
        if (b)
            ans += len[i];
        b |= w == s[i];
    }
    cout << ans << '\n'; 
}   

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[6] = {1, 0, -1, 0,1,-1};
const int dy[6] = {0, 1, 0, -1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    while(1){
        int N;
        cin >> N;
        if(N == 0) break;
        vector<vector<bool>> G(N,vector<bool> (31,false));
        for(int i=0; i<N; i++){
            int k;
            cin >> k;
            for(int j=0; j<k; j++){
                int a;
                cin >> a;
                a--;
                G[i][a] = true;
            }
        }
        vector<ll> suzu(N,0);
        for(int i=0; i<N; i++){
            suzu[i] += (1LL<<i);
        }
        int ans = -1;
        for(int i=0; i<=30; i++){
            ll now = 0;
            for(int j=0; j<N; j++){
                if(G[j][i]){
                    now |= suzu[j];
                }
            }
            for(int j=0; j<N; j++){
                if(G[j][i]){
                    suzu[j] |= now;
                    if(suzu[j] == ((1LL<<N)-1)){
                        ans = i+1;
                        break;
                    }
                }
            }
            if(ans != -1) break;
        }
        cout << ans << enld;
    }
    return 0;
}


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

int main() {

  int n,m;

  while(true) {

    cin >> n >> m;
    if ( n == 0 ) break;

    int cnt = 0;
    int it;

    vector<int> map;
    for ( int i = 0; i < n; i++ ) {
      map.push_back( i+1 );
    }

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

      cnt = ( cnt + m-1 ) % map.size();

      vector<int>::iterator it = map.begin() + cnt;
      map.erase( it );

    }

    cout << map[0] << endl;

  }

  return 0;

}

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

int arr[MAX];
int brr[MAX];

int main(void)
{
	int N;
	cin >> N;
	long long sum = 0;
	for (int i = 0; i < N; i++)
	{
		cin >> arr[i];
		sum += arr[i];
	}
	long long sumExcept1 = 0;
	for (int i = 1; i < N; i++)
	{
		if (i % 2) sumExcept1 += arr[i] + arr[i];
	}
	brr[0] = sum - sumExcept1;
	for (int i = 1; i < N; i++) brr[i] = arr[i - 1] * 2 - brr[i - 1];
	for (int i = 0; i < N; i++) cout << brr[i] << " ";
	cout << endl;
	return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1)
#define IOS ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
#define ff first
#define ss second
#define pb push_back
#define debug(val) cerr << "The Value Of " << #val << " is : " << val << '\n';
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e18;
const ll inf = 0x3f3f3f3f;
const ll mininf = -922337203685477;
const ll nax = 0;
ll n, x, ans=1;

int main(){
	IOS
	cin >>  n;
	for(int i=0;i<n;i++){
		cin >> x;
		x/=__gcd(ans, x);
		ans*=x;
	}
	cout << ans << '\n';
}


Measured memory_bytes: 3656
import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

if __name__ == '__main__':
    a = [int(i) for i in input().split()]

    if a[0] <= a[1]:
        print(a[0])
    else:
        print(a[0]-1)

Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std; 
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a) (a).begin(),(a).end()
#define ll long long
long long min(long long x,long long y){return (x<y ? x:y);}
long long max(long long x,long long y){return (x>y ? x:y);}
#define ld long double
int stoi(string s) {return atoi(s.c_str());}
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
#define LINEY "YES\n"
#define Liney "Yes\n"
#define LINEN "NO\n"
#define Linen "No\n"

int func(string s){
  char c,d;
  int count = 0;
  int s_size = s.size();
  for(int i=1;i<s_size;i++){
    c = s[i-1];
    d = s[i];
    if(c=='A' && d=='B'){count++;}
  }
  return count;
}

// -A B-A B- 

int main(){
  int N; cin>>N;
  string s; char t,e;
  int count = 0;
  int num_a = 0;
  int num_b = 0;
  int num_ab = 0;
  REP(i,N){
    cin >> s;
    count += func(s);
    t = s[0];
    e = s[s.size()-1];
    if(e=='A'){
      if(t=='B'){num_ab++;}
      else{num_a++;}
    }
    else if(t=='B'){num_b++;}
  }
  if(num_a+num_b>0){
    count += min(num_a,num_b)+num_ab;
  }else{
    count += max(num_ab-1,0);
  }
  printf("%d\n",count);
}

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

int LCS(const char* s1, const char* s2){
	int i,j;
	int n1=strlen(s1);
	int n2=strlen(s2);
	int dp[n1+1][n2+1];
	for(i=0;i<=n1;i++)dp[i][0]=0;
	for(j=0;j<=n2;j++)dp[0][j]=0;
	for(i=1;i<=n1;i++){
		for(j=1;j<=n2;j++){
			if(s1[i-1]==s2[j-1]){
				dp[i][j]=dp[i-1][j-1]+1;
			}else{
				dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
			}
		}
	}
	return dp[n1][n2];
}

int main(){
	int n;
	cin >> n;
	string s1;
	string s2;
	for (int i=0;i<n;i++){
		cin >> s1 >> s2;
		cout << LCS(s1.c_str(),s2.c_str());
		cout << endl;
	}
	return 0;
}



Measured memory_bytes: 7100
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n); i >= 0; i--)
#define loop(i, r, n) for (int i = (r); i < (n); i++)
#define pb push_back
#define all(in) in.begin(),in.end()

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; }

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

int main(){
    int n; cin >> n;
    if(n >= 30) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3648
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        try (Scanner scanner = new Scanner(System.in)) {
            int n = Integer.parseInt(scanner.next());
            int m = Integer.parseInt(scanner.next());
            System.out.println(n <= m ? "Yes" : "No");
        }
    }

}


Measured memory_bytes: 22996