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

#define pb push_back
#define PQ priority_queue
#define make_unique(x) sort((x).begin(), (x).end()); (x).erase(unique((x).begin(), (x).end()), (x).end())

typedef long long ll;
typedef long double ld;

//__builtin_popcount(x)

using namespace std;

/*const int mod = 1e9 + 7;

ll add(ll a, ll b) {
    ll res = a + b;
    if (res >= mod) res -= mod;
    return res;
}

ll sub(ll a, ll b) {
    ll res = a - b + mod;
    if (res >= mod) res -= mod;
    return res;
}

ll mul(ll a, ll b) {
    return (((a % mod) * (b % mod)) % mod);
}*/

/*vector<int> find_dividers(int x) {
    vector<int> dividers;

    for (int i = 1; i <= sqrt(x); i++) {
        if (x % i == 0) {
           dividers.push_back(i);
            if (i * i != x) {
                dividers.push_back(x / i);
            }
        }
    }

    return dividers;
}*/

/*int nok(int a, int b) {
    return a / __gcd(a, b) * b;
}*/

void solve() {
    int k;
    cin >> k;
    if (k % 2 == 0 || k % 5 == 0) {
        cout << -1 << endl;
    } else {
        ll mod = 7, ans = 1;
        while (mod % k != 0) {
            mod = (mod * 10 + 7) % k;
            ans++;
        }
        cout << ans << endl;
    }
}

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

    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }

    return 0;
}


Measured memory_bytes: 3660
#include<iostream>
using namespace std;int main(){string u[256],t;int n,m,i,j,f=0,k;cin>>n;for(i=0;i<n;i++)cin>>u[i];cin>>m;for(i=0;i<m;i++){cin>>t;k=f;for(j=0;j<n;j++)if(t==u[j]){if(f==0)f=1,cout<<"Opened by ";else f=0,cout<<"Closed by ";}if(k==f)cout<<"Unknown ";cout<<t<<endl;}return 0;}

Measured memory_bytes: 1220
#include <iostream>
#include <map>
#include <string>

class CounterInterface
{
public:
    virtual std::map<char, int> count(std::string w) = 0;
};

class AlphaCounter : public CounterInterface
{
public:
    virtual std::map<char, int> count(std::string w)
    {
        std::map<char, int> a;
        for (auto itr = w.begin(); itr != w.end(); ++itr)
        {
            char c = *itr;
            if (a.count(c))
            {
                a[c]++;
            }
            else
            {
                a[c] = 1;
            }
        }
        return a;
    }
};

class JudgterInterface
{
public:
    virtual std::string judge(std::map<char, int> a) = 0;
};

class OddJudgter : public JudgterInterface
{
public:
    virtual std::string judge(std::map<char, int> a)
    {
        for (auto itr = a.begin(); itr != a.end(); ++itr)
        {
            if (1 == itr->second % 2)
            {
                return "No";
            }
        }
        return "Yes";
    }
};

class StringBeautifer
{
private:
    CounterInterface* counter;
    JudgterInterface* judgter;

public:
    static StringBeautifer* factory(CounterInterface* counter, JudgterInterface* judgter)
    {
        return new StringBeautifer(counter, judgter);
    };
    StringBeautifer(CounterInterface* counter, JudgterInterface* judgter)
    {
        this->counter = counter;
        this->judgter = judgter;
    }
    std::string judge(std::string w)
    {
        return this->judgter->judge(this->counter->count(w));
    };
};

int main(void)
{
    std::string w;
    std::cin >> w;
    std::cout << StringBeautifer::factory(new AlphaCounter(), new OddJudgter())->judge(w) << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  map<string, int>m;
  int n;
  cin >> n;
  string arr[n];
  int maxno = 0;
  for (int i=0; i<n; i++) {
	cin >> arr[i];
    m[arr[i]]++;
    if (m[arr[i]] > maxno) maxno = m[arr[i]];
  }
  set<string>s;
  for (int i=0; i<n; i++) {
	if (m[arr[i]] == maxno) s.insert(arr[i]);
  }
  for (auto it:s) cout << it << endl;
}

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

int n, m, k;

int dfs(int t, int sum) {
    if (t == n) {
        sum = max(1, sum-k);
        return sum;
    }
    int res = 0;
    for (int i=1; i<=m; ++i) {
        res += dfs(t+1, sum+i);
    }
    return res;
}

int main() {
    while (cin >> n >> m >> k) {
        if (!n) break;
        printf("%.8f\n", dfs(0, 0) / (double)pow(m, n));
    }
    return 0;
}


Measured memory_bytes: 3340
from sys import stderr
from functools import reduce
from operator import add
def f(): return [int(i) for i in input().split()]
def debug(*x): stderr.write(reduce(add,repr(x)).strip("()\',")+'\n')

n = int(input())
s = list(input())

must = [0 for i in range(n)]
# 一番左の人の値を決める
for i in range(1,n):
    if s[i] == "E":
        must[0] += 1
# 2番目以降の人
for j in range(1,n):
    must[j] = must[j-1]
    if s[j-1] == "W":
        must[j] += 1
    if s[j] == "E":
        must[j] -= 1
print(min(must))

Measured memory_bytes: 18280
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
using namespace std;

struct UnionFind {
  vector<int> par;

  UnionFind(int N) : par(N) {
    for(int i = 0; i < N; i++) par[i] = i;
  }

  int root(int x) {
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y) {
    int rx = root(x);
    int ry = root(y);
    if (rx == ry) return;
    par[rx] = ry;
  }

  bool same(int x, int y) {
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
};

int main() {
  int N, M, K;
  cin >> N >> M >> K;
  int A[M], B[M];
  int C[K], D[K];
  for (int i = 0; i < M; ++i) {
    cin >> A[i] >> B[i];
    --A[i];
    --B[i];
  }

  for (int i = 0; i < K; ++i) {
    cin >> C[i] >> D[i];
    --C[i];
    --D[i];
  }


  UnionFind uf(N);
  for (int i = 0; i < M; ++i) {
    uf.unite(A[i], B[i]);
  }


  int ans[N];
  fill (ans, ans + N, 0);
  {
    int t[N];
    fill (t, t + N, 0);
    for (int i = 0; i < N; ++i) {
      ++t[uf.root(i)];
    }

    for (int i = 0; i < N; ++i) {
      ans[i] = t[uf.root(i)] - 1;
    }
  }

  for (int i = 0; i < M; ++i) {
    if (uf.same(A[i], B[i])) {
      --ans[A[i]];
      --ans[B[i]];
    }
  }

  for (int i = 0; i < K; ++i) {
    if (uf.same(C[i], D[i])) {
      --ans[C[i]];
      --ans[D[i]];
    }
  }

  for (int i = 0; i < N; ++i) {
    if (i != 0) {
      cout << " ";
    }
    cout << ans[i];
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 3584
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] height = new int[n];
        for(int i = 0; i < n; i++){
            height[i] = scanner.nextInt();
        }
        System.out.println(new Main().f(n, height));
    }

    public int f(int n, int[] height) {
        int pre = 0;
        int cur = 0;
        if(n <= 1)
            return 0;
        pre = 0;
        cur = Math.abs(height[1] - height[0]);
        for(int i = 2; i < n; i++){
            int t = Math.min(cur + Math.abs(height[i] - height[i-1]),
                            pre + Math.abs(height[i] - height[i-2]));
            pre = cur;
            cur = t;
        }
        return cur;
    }
}


Measured memory_bytes: 53360
#include<bits/stdc++.h>
using namespace std;
#define ms(x,y) memset(x, y, sizeof(x))
#define lowbit(x) ((x)&(-x))
#define sqr(x) ((x)*(x))
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;


void run_case() {
    int n; cin >> n;
    map<LL, int> a;
    vector<LL> buf(n+1);
    for(int i = 1; i <= n; ++i) {
        cin >> buf[i];
        a[i+buf[i]]++;
    }
    LL ans = 0;
    for(int i = 1; i <= n; ++i)
        ans += a[i-buf[i]];
    cout << ans;
}


int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    cout.flags(ios::fixed);cout.precision(9);
    //int t; cin >> t;
    //while(t--)
    run_case();
    cout.flush();
    return 0;
}

Measured memory_bytes: 27372
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>
using namespace std;

typedef pair<int, int> pii;

int main(void) {

    int N, M;
    while (cin >> N >> M, N||M) {
        vector<pii> PD(N);      // P, D
        for (int i = 0; i < N; i++) {
            cin >> PD[i].second >> PD[i].first;
        }

        sort(PD.begin(), PD.end(), greater<pii>());

        // for (int i = 0; i < N; i++) {
        //     cout << "# P[" << i << "]: " << PD[i].first << endl;
        //     cout << "# D[" << i << "]: " << PD[i].second << endl;
        // }

        int ans = 0;
        for (int i = 0; i < N; i++) {
            int P = PD[i].first;
            int D = PD[i].second;

            if (M > 0) {
                if (M >= D) {
                    M -= D;
                } else {
                    D -= M; M = 0;
                    ans += D*P;
                }
            } else {
                ans += D*P;
            }
        }

        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 3160
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

#ifdef RUBICK
#include "dbg.h"
#endif

using namespace std;
using namespace __gnu_pbds;

template<class T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;

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

    set<char> S(begin(s), end(s));

    for (char x = 'a'; x <= 'z'; x ++) {
        if (S.count(x) == 0) {
            cout << x << '\n';
            return 0;
        }
    }

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



Measured memory_bytes: 512
#include <stdio.h>
#include <string.h>
int main(){
int n;
scanf("%d",&n);
char judge[n]={};
int ac=0,tle=0,wa=0,re=0;
for(int i=0;i<n;i++){
	scanf("%s",judge);
	if(strcmp(judge,"AC")==0){
		ac++;
	}
	else if(strcmp(judge,"TLE")==0){
		tle++;
	}
	else if(strcmp(judge,"WA")==0){
		wa++;
	}
	else if(strcmp(judge,"RE")==0){
		re++;
	}
}

printf("AC x %d\n",ac);
printf("WA x %d\n",wa);
printf("TLE x %d\n",tle);
printf("RE x %d\n",re);
return 0;
}


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

int main() {
  int n,k;
  cin >> n >> k;
  vi p(n);
  rep(i,n) cin >> p[i];
  sort(p.begin(),p.end());
  int sum = 0;
  rep(i,k) sum += p[i];
  cout << sum << endl;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define llu unsigned long long int
#define Endl endl
#define mod  998244353
#define mkp make_pair
#define pb push_back
#define cin(n) scanf("%d",&n)
#define cout(n) printf("%d ",n)
#define sf(n) scanf("%d",&n)
#define pf(n) printf("%d ",n)
#define bitget(n) __builtin_popcountll(n)
ll dx[] = {1,1,0,-1,-1,-1,0,1};
ll dy[] = {0,-1,-1,-1,0,1,1,1};
ll dxx[] = {1,-1,0,0};
ll dyy[] = {0,0,-1,1};
ll modexpo(ll x,ll y){if(y==0)return 1;if(y%2){ll viky=modexpo(x,y/2);
return (((x*viky)%mod)*viky)%mod;}else{ll viky=modexpo(x,y/2);return (viky*viky)%mod;
}}
bool isvalid(ll x,ll y,ll n, ll m) { return (x>=0&&x<n&&y>=0&&y<m); }

int main() {
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "r", stdin);
    //     freopen("output.txt", "w", stdout);
    // #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll n,m;

    cin>>n;
    ll ap[n+11];

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

    ll ans = 1;
    for(ll i=0;i<n;i++){
        if(ap[i] == ans){
            ans++;
        }
    }

    if(ans == 1){
        cout<<-1;
        return 0;
    }
    cout<<(n-ans+1);
   
    return 0;
}

Measured memory_bytes: 1792
Module Program
  Sub Main
    Dim s=GetInts()
    Dim a=s(0),b=s(1),c=s(2)
    Dim ans=If(Math.Abs(a-b)<Math.Abs(a-c),"A","B")
    Console.WriteLine(ans)
  End Sub
  
  '/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
  Function Gets() As String()
    Gets = Console.ReadLine().Split(" "c)
  End Function
  Function GetInts() As Integer()
    Dim s = Gets(), r(UBound(s)) As Integer
    For i As Integer=0 To UBound(s): r(i)=s(i): Next i
    GetInts = r
  End Function
End Module

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

int main(){
  int n;
  cin >> n;
  for(int i=1;i<=n;i++){
    int x = i;
    if(i%3==0){
      cout << " " << i;
      continue;
    }
    while(x>0){
      if(x%10==3){
        cout << " " << i;
        break;
      }
      x /= 10;
    }
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 3080
#include<stdio.h>
int main(void)
{
  int money,cake,dnt,left;
  char str[32];
  
  fgets(str,sizeof(str),stdin);
  sscanf(str,"%d",&money);
  fgets(str,sizeof(str),stdin);
  sscanf(str,"%d",&cake);
  fgets(str,sizeof(str),stdin);
  sscanf(str,"%d",&dnt);
  
  left = money - cake;
  
  while(left >= dnt)
  {
    left -= dnt;
  }
  
  printf("%d",left);
  
  return 0;
}

Measured memory_bytes: 256
#include "iostream"
#include "vector"
#include "string"
#include "algorithm"
#include "math.h"
#include "cstring"
#include "stack"
#include "queue"

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<vector<int> > mat;

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

  cout << (s[5] == '0' && s[6] <= '4' ? "Heisei" : "TBD") << "\n";
}

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

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

  int x = stoi(a + b);
  double i_part = 0.0;
  double f_part = 0.0;
  f_part = modf(sqrt(x), &i_part);
  
  if (i_part > 0 && f_part == 0.0) {
    printf("Yes");
  } else {
    printf("No");
  }
  return 0;
}

Measured memory_bytes: 512
#include<cstring>
#include<cstdio>
#include<cmath>
#include<algorithm>
#define LL long long
using namespace std;

int main()
{
	LL n,m; 
	scanf("%lld",&n);
 	m=sqrt(n);
	while (m*(m+1)<n*2) ++m;
	printf("%lld\n",m);
	return 0;
 }  

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

typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100005;

int main(){

    int H,W;cin>>H>>W;
    vector<int> cnt(26);
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            char a;cin>>a;
            cnt[a-'a']++;
        }
    }
    
    if(H%2==0&&W%2==0){
        bool flag=true;
        for(int i=0;i<26;i++){
            if(cnt[i]%4!=0) flag=false;
        }
        if(flag) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    
    else if(H%2==1&&W%2==1){
        int cnt1=0,cnt2=0;
        for(int i=0;i<26;i++){
            if(cnt[i]%4==1) cnt1++;
            else if(cnt[i]%4==2) cnt2++;
            else if(cnt[i]%4==3){
                cnt1++;
                cnt2++;
            }
        }
        if(cnt1>1) cout<<"No"<<endl;
        else if(cnt2>H/2+W/2) cout<<"No"<<endl;
        else cout<<"Yes"<<endl;
    }
    
    else if(H%2==0&&W%2==1){
        int cnt1=0,cnt2=0;
        for(int i=0;i<26;i++){
            if(cnt[i]%4==1) cnt1++;
            else if(cnt[i]%4==2) cnt2++;
            else if(cnt[i]%4==3){
                cnt1++;
                cnt2++;
            }
        }
        if(cnt1>0) cout<<"No"<<endl;
        else if(cnt2>H/2) cout<<"No"<<endl;
        else cout<<"Yes"<<endl;
    }
    
    else if(H%2==1&&W%2==0){
        int cnt1=0,cnt2=0;
        for(int i=0;i<26;i++){
            if(cnt[i]%4==1) cnt1++;
            else if(cnt[i]%4==2) cnt2++;
            else if(cnt[i]%4==3){
                cnt1++;
                cnt2++;
            }
        }
        if(cnt1>0) cout<<"No"<<endl;
        else if(cnt2>W/2) cout<<"No"<<endl;
        else cout<<"Yes"<<endl;
    }
}


Measured memory_bytes: 256
using System;
using System.ComponentModel;
using System.Security.Cryptography.X509Certificates;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] line = Console.ReadLine().Split(' ');
            int goukei = int.Parse(line[0]);
            int ashigoukei = int.Parse(line[1]);
            //全部鶴だった場合の足の数y
            int y = (4 * goukei);
            //想定との足差
            int x = y - ashigoukei;
            //カメの匹数
            int kame = x / 2;
            //鶴の匹数
            int turu = (ashigoukei - kame * 2) / 4;
            if (turu * 4 + kame * 2 == ashigoukei && turu + kame == goukei && turu >= 0 && kame >= 0)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 27532
#include <stdio.h>

int main(void){

    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);

    if(a >= 0 && b >= 0 && c >= 0 && a <= 100 && b <= 100 && c <= 100){

        if(a < b && b < c){

            printf("Yes\n");
        }
        else{

            printf("No\n");
        }

    }

    return 0;

}

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

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

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N;
    cin >> N;
    vector<pair<ll, pair<ll, ll>>> A;
    rep(i, N) {
        ll a, b;
        cin >> a >> b;
        A.emplace_back(a + b, pair<ll, ll>{a, b});
    }
    sort(A.rbegin(), A.rend());
    ll a = 0, b = 0;
    rep(i, A.size()) {
        if(i % 2) b += A[i].second.second;
        else a += A[i].second.first;
    }
    cout << a - b << endl;
    return 0;
}


Measured memory_bytes: 6348
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
using namespace std;
typedef long long ll;
typedef struct pair<int,int> P;
typedef struct pair<int,P> P2;

ll d[1001]={};
int a[200001]={};
int main() {
	int n,k;
	cin>>n>>k;
	int a1;
	for(int i=0;i<n;++i){
		cin>>a1;
		a[a1]++;
	}
	sort(a,a+200001,greater<int>());
	int total=0;
	for(int i=k;i<200001;++i){
		total+=a[i];
	}
	cout<<total<<endl;
	return 0;
}



Measured memory_bytes: 1024
n = int(input())
M = [["0"]*n for _ in range(n)]
for _ in range(n):
    i = [int(i) for i in input().split()]
    u = i[0]
    k = i[1]
    V = i[2:]
    for v in V: M[u-1][v-1] = "1"
for i in M: print(*i)


Measured memory_bytes: 6384
#include <iostream>

using namespace std;

int ca(int c){
  int x = 0;
  for(int i=1; i<=c; i++){
    if(c<i) break;
    c-=i;
    x++;
  }
  return x;
}

int main(void){

  long long N;
  int a, c, ans = 0;

  cin >> N;

  for(long long z=2; z*z<=N; z++){
    a = c = 0;
    while(true){
      if(N%z==0){
        N = N / z;
        c++;
      }
      else{
        ans += ca(c);
        break;
      }
    }
  }
  if(N!=1) ans++;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3632
// https://atcoder.jp/contests/abc171/tasks/abc171_c
#include<bits/stdc++.h>
using namespace std;

int main(int argc, char* argv[]) {
	long long n;
	cin >> n;
	string ans;
	long long rem;
	char c;
	while (n) {
		rem = n%26;
		n = n/26;
		if (rem == 0 && n) {
			rem = 26;
			n=n-1;
		}
		c = rem+'a'-1;
		ans = c + ans;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3608
a=(list(map(int,input().split())))
l=a[0]
r=a[1]
if(l-r>2021):
	print(0)
else:
	mini=2019
	i=l
	notFound=True
	while(i<=r-1 and notFound):
		j=i+1
		while(j<=r and notFound):
			p=(i*j)%2019
			
			mini=min(mini,p)
			if(mini==0):
				notFound=False	
			j+=1

		i+=1
	print(mini)

Measured memory_bytes: 3064
n = int(input())
l = [3, 5, 7]
ans = 0

for i in range(26484):
    x = str(l[i])
    l.append(int(x+"3"))
    l.append(int(x+"5"))
    l.append(int(x+"7"))

for i in l:
    if i > n:
        print(ans)
        break
    
    x = str(i)
    if x.count("3")>0 and x.count("5")>0 and x.count("7")>0:
        ans += 1

Measured memory_bytes: 6260
#include <iostream>

#include <cmath>

using std::cin;
using std::cout;
using std::endl;

using std::fabs;

int
main()
{
    int N, T, A;
    cin >> N >> T >> A;
    int best_place = 0;
    double best_diff = 0;
    for (int n = 1; n <= N; n++)
    {
        int H;
        cin >> H;
        double diff = fabs(double(A - (T - H * 0.006)));
        if (best_place == 0 || diff < best_diff)
        {
            best_place = n;
            best_diff = diff;
        }
    }
    cout << best_place << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
using namespace std;
typedef pair<int,int>P;
typedef pair<int,P>P2;
#define fi first
#define se second

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

int n;
string s;

signed main(){
  int n,k;
  cin>>n>>k;
  cin>>s;
  s[k-1]=tolower(s[k-1]);
  cout<<s<<endl;
}

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

int main(){
  string s;
  cin >> s;
  long kekka = 0,n = s.size(),c = 0;
  for(long i = 0;i < n;i++){
    if(s.at(i) == 'W'){
      kekka += i-c;
      c++;
    }
  }
  cout << kekka << endl;
}

Measured memory_bytes: 640
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.next());
    long[] a = new long[n];
    long c = 0;
    for(int i=0; i<n; i++){
      a[i] = Integer.parseInt(sc.next());
      c ^= a[i];
    }

    if(c==0){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
    
         
  }
}

Measured memory_bytes: 48192
def value(k1,k2,k,D):
    if k2 == 0:
        v0 = D[:k1] + [0]
    else:
        v0 = D[:k1] + D[-(k2):] + [0]
    v0.sort()  # 取り出す宝石の価値リスト
    n_neg = v0.index(0)  # 負価値の数
    k0 = k - (k1+k2)  # 残り操作回数
    if n_neg <= k0:
        ans = sum(v0[n_neg:])
    else:
        ans = sum(v0[k0:])
    #print(k1,k2,n,k0,v0, ans)
    return ans

n,k = map(int,input().split(' '))
D = list(map(int,input().split(' ')))
score = 0
k1 = 0
while k1 < min(k+1,n+1):
    k2 = 0
    while k2 + k1 < min(k+1,n+1):
        v = value(k1,k2,k,D)
        if v > score:
            score = v
            #print(k1,k2)
            #print(score)
        k2 += 1
    k1 += 1
print(score)


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


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

	long long n,x,t;
	cin>>n>>x>>t;

	long long k = ceil(n/(x*1.0));

	cout<<k*t;

	
	return 0;
}

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

using namespace std;

int main()
{
    int n;
    cin>>n;
    vector<int>v(n);
    for(int i=0;i<n;i++){
        cin>>v[i];
    }
    set<int>s;
    int ans=0;
    for(int i=0;i<n;i++){
        s.insert(v[i]);
        if(*(s.begin())==v[i])ans+=1;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 10368
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define set_bits(a) __builtin_popcount(a)
#define pb push_back
#define pf push_front
#define mod 1000000007
#define M 998244353
#define fi first
#define se second
#define endl '\n'
#define INF 1e18
#define PI 3.14159265358979323846
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);


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

    ll n;
    cin>>n;
    ll x = n%1000;

    if(x==0)
    {
        cout<<0;
    }
    else 
    {
        x = 1000-x;
        cout<<x;
    }
}

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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>istream &operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
//template <typename T, typename S>ostream &operator<<(ostream &os, pair<T, S> &p) {os << p.first << " " << p.second;return os;}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T, class U>bool chmin(T& a, U b) { if (a > b) { a = b; return true; }return false; }
template <class T, class U>bool chmax(T& a, U b) { if (a < b) { a = b; return true; }return false; }
using Weight = int;
using Flow = int;
struct Edge {
	int s, d; Weight w; Flow c; int id;
	Edge() {};
	Edge(int s, int d, Weight w = 1) : s(s), d(d), w(w), c(w) {};
};
bool operator<(const Edge &e1, const Edge &e2) { return e1.w < e2.w; }
bool operator>(const Edge &e1, const Edge &e2) { return e2 < e1; }
inline ostream &operator<<(ostream &os, const Edge &e) { return (os << '(' << e.s << ", " << e.d << ", " << e.w << ')'); }

using Edges = vector<Edge>;
using Graph = vector<Edges>;
using Array = vector<Weight>;
using Matrix = vector<Array>;

void addArc(Graph &g, int s, int d, Weight w = 1) {
	g[s].emplace_back(s, d, w);
}
void addEdge(Graph &g, int a, int b, Weight w = 1) {
	addArc(g, a, b, w);
	addArc(g, b, a, w);
}

signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	string S; cin >> S;

	int N = S.size() + 1;
	Graph g(N);
	vector<int>indeg(N);
	rep(i, 0, S.size()) {
		if (S[i] == '<') {
			addArc(g, i, i + 1);
			indeg[i + 1]++;
		}
		else {
			addArc(g, i + 1, i);
			indeg[i]++;
		}
	}
	vector<int>a(N,-1);
	queue<int>q;
	rep(i, 0, N) {
		if (indeg[i] == 0) {
			q.push(i);
			a[i] = 0;
		}
	}
	while (q.size()) {
		int v = q.front(); q.pop();
		for (auto e : g[v]) {
			if (chmax(a[e.d], a[e.s] + 1)) {
				q.push(e.d);
			}
		}
	}

	int ans = 0;
	for (auto x : a) {
		assert(x != -1);
		ans += x;
	}

	cout << ans << endl;
	

	return 0;
}


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

using namespace std;
 
int main()
{
    int card[5];
     
    while (scanf("%d", &card[0]) != EOF) {
        for (int i = 1; i < 5; i++) {
            scanf(",%d", &card[i]);
        }
         
        int cnt = 0;
        for (int i = 0; i < 5; i++) {
            for (int j = 0; j < 5; j++) {
                if (card[i] == card[j] && i != j) {
                    cnt++;
                }
            }
        }
         
        int flg = 0;
        switch (cnt) {
            case 2:
                printf("one pair\n");
                flg = 2;
                break;
            case 4:
                printf("two pair\n");
                flg = 2;
                break;
            case 6:
                printf("three card\n");
                flg = 2;
                break;
            case 8:
                printf("full house\n");
                flg = 2;
                break;
            case 12:
                printf("four card\n");
                flg = 2;
                break;
            default:
                flg = 1;
        }
         
        if (flg == 2) continue;
         
        int ct = 0;
        if (flg) {
            sort(card, card + 5);
            for (int i = 1; i < 5; i++) {
                if(card[i] - card[i-1] == 1) ct++;
            }
        }
         
        if (ct == 4) {
            printf("straight\n");
        } else if (card[0] == 1 &&
                   card[1] == 10 &&
                   card[2] == 11 &&
                   card[3] == 12 &&
                   card[4] == 13) {
            printf("straight\n");
        } else {
            printf("null\n");
        }
    } 
    return 0;
}

Measured memory_bytes: 3076
chomp($n=<>);
chomp($in=<>);
@a=split/ /,$in;
%hash=();
for($i=1;$i<=$n;$i++){
	$hash{$a[$i-1]} = $i;
}
for (sort {$a <=> $b} keys %hash ) {
    push @ary ,$hash{$_};
}

print join (' ', @ary);


Measured memory_bytes: 38932
#include <iostream>
#include <math.h>
using namespace std;

int N, D, ans = 0;
int main() {
  cin >> N >> D;
  for (int i = 0; i < N; i++) {
  	int x, y;
  	cin >> x >> y;
	if(pow(x,2)+pow(y,2)<=pow(D,2)) ans++;
	//if(x*x + y*y <= D*D) ans++;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3604
#include <algorithm>
#include <cassert>
// #include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
// #include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

/*
unsigned seed1 = std::chrono::system_clock::now().time_since_epoch().count();
mt19937 g1.seed(seed1);
*/
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<pii, pii> ppiipii;
typedef pair<int, ppiipii> pippiipii;
typedef pair<int, pii> pipii;
typedef pair<pii, int> ppiii;
typedef pair<int, ppiii> pippiii;
typedef pair<int, ll> pill;
typedef pair<int, double> pid;
typedef pair<string, string> pss;
// note to self, the below two triggers someone
typedef pair<ll, ll> pll;
typedef pair<ll, int> plli;
typedef long double ld;

int dp[5001];
int ndp[5001];

char buf[5005];

const int MOD = 1000000007;

int main() {
  int n;
  scanf("%d\n%s", &n, buf);
  dp[strlen(buf)] = 1;
  for(int numOp = n; numOp > 0; numOp--) {
    memset(ndp, 0, sizeof(dp));
    for(int i = 0; i <= numOp; i++) {
      ndp[i+1] += 2 * dp[i];
      ndp[i+1] %= MOD;
      ndp[max(0,i-1)] += dp[i];
      ndp[max(0,i-1)] %= MOD;
    }
    for(int a = 0; a <= numOp; a++) {
      dp[a] = ndp[a];
    }
  }
  printf("%d\n", dp[0]);
}


Measured memory_bytes: 384
#define ll long long
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define mp make_pair
#define fo(i , n) for(ll i = 0 ; i < n ; i++)
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<utility>
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<queue>
#include<set>
#include<stack>
ll z = 1000000007 ;
ll inf = 100000000000000000 ;
ll gcd(ll a , ll b){ if(b > a) return gcd(b , a) ; if(b == 0) return a ; return gcd(b , a%b) ;}
ll power(ll a ,ll b){if(b == 0) return 1 ; ll c = power(a , b/2) ; if(b%2 == 0) return ((c*c)%z) ; else return ((((c*c)%z)*a)%z) ;}
ll inverse(ll a ,ll n){return power(a , n-2) ;}
ll max(ll a , ll b){if(a > b) return a ; return b ;}
//ios_base::sync_with_stdio(0);
//cin.tie(0); cout.tie(0);
using namespace std ;


void solve()
{
	ll h , w ;
	cin >> h >> w ;
	if(h == 1 || w == 1)
	{
	    cout << 1 << endl ;
	    return ;
	}
	cout << ((h*w)+1)/2 << endl ;
	return ;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	
	ll t ;
	//cin >> t ;
	t = 1 ;
	while(t--)
	{
		solve() ;
	}
	return 0;
}

Measured memory_bytes: 256
let N=Int(readLine()!)!,a=(1..<N).map{_ in readLine()!.characters.split(" ").map{Int(String($0))!}},C=a.map{$0[0]},S=a.map{$0[1]},F=a.map{$0[2]}
for i in 0..<N{print((i..<N-1).reduce(0){max(S[$1],$0+(F[$1]-$0%F[$1])%F[$1])+C[$1]})}

Measured memory_bytes: 1900
#include <algorithm>
#include <functional>
#include <iostream>
#include <string>

int main(){
    int N, L;
    std::string S[110];
    std::string answer;
    std::cin >> N >> L;
    for (int i = 1; i <= N; i++) {
        std::cin >> S[i];
    }
    
    std::sort(&S[1], &S[N+1]);

    for (int i = 1; i <= N; i++) {
        answer += S[i];
    }

    std::cout << answer << std::endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }
template<typename S, typename T> istream& operator>>(istream &is, pair<S, T> &p){ return is >> p.first >> p.second; }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ return os << "[" << p.first << ", " << p.second << "]"; }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define For1(i, n) for(int i = 1; i <= (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)
#define Return(x) { Cout(x); return 0; }

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(double, x1, y1, x2, y2, x3, y3);
    double l1 = sqrt(Sq(x2-x3) + Sq(y2-y3));
    double l2 = sqrt(Sq(x3-x1) + Sq(y3-y1));
    double l3 = sqrt(Sq(x1-x2) + Sq(y1-y2));
    double s = abs((x2-x1)*(y3-y1) - (y2-y1)*(x3-x1))/2;
    double r = 2*s/(l1+l2+l3);
    
    printf("%.20f\n", max({l1*r/(l1+2*r), l2*r/(l2+2*r), l3*r/(l3+2*r)}));
}


Measured memory_bytes: 256
#include <iostream>
#include <list>

using namespace std;

/*---------------------------------------------------*/
/* 0 : insert                                        */
/* 1 : move / d>0 moveBack, d<0 moveFront            */
/* 2 : erase                                         */
/*---------------------------------------------------*/

int main()
{
  std::list<int> L;
  list<int>::iterator it = L.end();

  int n;
  cin >> n;

  for(int i=0; i<n; i++){
    int query;
    cin >> query;

    if(query == 0){
      int num;
      cin >> num;
      it = L.insert(it, num);
    }

    else if(query == 1){
      int d;
      cin >> d;

      if(d > 0){
        for(int j=0; j<d; j++) it++;
      }
      else{
        for(int j=0; j<-d; j++) it--;
      }
    }else if(query == 2){
      it = L.erase(it);
    }
  }

  for(list<int>::iterator c = L.begin(); c != L.end(); c++){
    cout << *c << endl;
  }
  return 0;
}



Measured memory_bytes: 18600
def main():
    w,h,x,y = map(int,input().split())
    flg = 0

    if x * 2 == w :
        flg +=1
    if y * 2 == h :
        flg +=1

    if x * h == w * y :
        flg += 1


    ans = max(w * y, h*x)
    if ans * 2 > w*h:
        ans = min(w*y,h*x)

    if flg > 1:
        print(w*h/2, 1)


    else:
        print(w*h/2, 0)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;

namespace LogicSummoner
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = GetNumber();
            var p1 = 0;
            var p2 = 0;
            for (int i = 0; i < N; i++)
            {
                var line = GetStrings();
                var cmp = line[0].CompareTo(line[1]);
                if (cmp > 0)
                {
                    p1 += 3;
                }
                else if (cmp < 0)
                {
                    p2 += 3;
                }
                else
                {
                    p1++;
                    p2++;
                }
            }

            System.Console.WriteLine("{0} {1}", p1, p2);
        }

        //static StreamReader Console = new StreamReader("input.txt");

        static int GetNumber()
        {
            return int.Parse(Console.ReadLine().Trim());
        }

        static double GetDounble()
        {
            return double.Parse(Console.ReadLine().Trim());
        }

        static int[] GetNumbersInt(int n = 0)
        {
            return Console.ReadLine().Trim().Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries).Select(x => int.Parse(x)).ToArray();
        }

        static long[] GetNumbersLong(int n = 0)
        {
            return Console.ReadLine().Trim().Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries).Select(x => long.Parse(x)).ToArray();
        }

        static double[] GetNumbersDouble(int n = 0)
        {
            return Console.ReadLine().Trim().Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries).Select(x => double.Parse(x)).ToArray();
        }

        static string[] GetStrings(int n = 0)
        {
            return Console.ReadLine().Trim().Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries).ToArray();
        }
    }
}

Measured memory_bytes: 10380
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>
#include <functional>
//#include <boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)
#define llrep(i, n) for(ll i = 0; i < n; ++i)
#define llREP(i, m, n) for(ll i = m; i < n; ++i)
#define llrrep(i,n) for(ll i = n; i >= 0; --i)
#define llRREP(i, m, n) for(ll i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;
using pil = std::pair<int, long long>;
using pli = std::pair<long long, int>;
using plpii = std::pair<long long, std::pair<int, int>>;
using pdd = std::pair<double, double>;

const long long INF = 1000000000000000001;
const long long _MOD = 1000000007;
const long long MOD = 998244353;
const int ALPHABET = 27;
const double pi = 3.14159265358979;

using namespace std;
//namespace mp = boost::multiprecision;

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

	int n, m;
	cin >> n >> m;
	pli* ab = new pli[n];
	rep(i, n) cin >> ab[i].first >> ab[i].second;
	sort(ab, ab + n);

	ll ans = 0;
	int sum = 0;
	rep(i, n) {
		ans += min(m-sum, ab[i].second)*ab[i].first;
		sum += min(m - sum, ab[i].second);

		if (m == sum) break;
	}

	cout << ans << "\n";

	return 0;
}



Measured memory_bytes: 1792
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <map>
#include <cstdlib>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    long long a, b, c, ans;

    cin >> a >> b >> c;

    if(a%2==0 || b%2==0 || c%2==0){
        cout << 0 << endl;
    }

    else{
        ans = min(a*b, b*c);
        ans = min(ans, c*a);

        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import Control.Monad
import Control.Applicative

solve :: [Int] -> String
solve [-1, _, _] = "F"
solve [_, -1, _] = "F"
solve [a, b, c]
    | 80 <= (a+b) = "A"
    | 65 <= (a+b) = "B"
    | 50 <= (a+b) = "C"
    | 30 <= (a+b) && 50 <= c = "C"
    | 30 <= (a+b) = "D"
    | otherwise = "F"

main =
    mapM_ putStrLn =<< map solve . takeInputs . lines <$> getContents
    where
    takeInputs :: [String] -> [[Int]]
    takeInputs = takeWhile (not . all (== -1)) . map (map read . words)

Measured memory_bytes: 4032
import java.util.Scanner;

public class Main {

	static Main instance = new Main();

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		//入力値
		long A = scan.nextLong();
		long B = scan.nextLong();
		long N = scan.nextLong();

		//WK変数
		long result = 0L;

		//演算
		for (long x = Math.min(B - 1L, N); x <= N; x += B) {

			if (B == 1L) {
				break;
			}
			long num1 = (A * x) / B;
			long num2 = A * (x / B);

			if (num1 - num2 > result) {
				result = num1 - num2;
			}
		}

		//結果出力
		System.out.println(result);
	}
}

Measured memory_bytes: 35664
#include <cstdio>
#include <set>
#include <vector>
#include <algorithm>
#include <deque>
#include <bitset>
#include <iostream>
#include <utility>
using namespace std;

#define EMPTY 10

typedef vector<int> vint;

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

int n, k;
int sx[8], sy[8];
int u[100], v[100];
int X, Y;
set<vint> st, st2;
deque<vint> dq;
vector<vector<char> > rocks, field;
int ans;


void move(vint &snake, int movable){
	for(int t = 0; t < n; ++t){
		if( t > 0 && ans == 19 ) return;

		if( !(movable & (1 << t)) ) continue;

		int pos = snake[t];
		int px = pos >> 8;
		int py = pos & 0xff;
		int check = (7 << t >> 1) & ((1 << n) - 1);
		for(int i = 0; i < 6; ++i){
			int x = px + dx[i];
			int y = py + dy[i];
			
			if( field[x][y] == EMPTY ){
				int c = 0;
				for(int j = 0; j < 6; ++j){
					int nx = x + dx[j];
					int ny = y + dy[j];

					if( field[nx][ny] < n ){
						c |= 1 << field[nx][ny];
					}
				}

				if( c == check ){
					snake[t] = x << 8 | y;
					if( st.find(snake) == st.end() ){
						if( st2.find(snake) == st2.end() ){
							if( t == 0 && x == X && y == Y ){
								throw 0;
							}
							st2.insert(snake);
							dq.push_back(snake);
						}
						swap(field[px][py], field[x][y]);
						
						int mv = movable & ~(7 << t >> 1);

						move(snake, mv);
						swap(field[px][py], field[x][y]);
					}
					snake[t] = pos;
				}
			}
		}
	}
}

int solve(){
	int ofx = X;
	int ofy = Y;

	for(int i = 0; i < n; ++i){
		ofx = min(ofx, sx[i]);
		ofy = min(ofy, sy[i]);
	}

	ofx -= 22;
	ofy -= 22;
	
	X -= ofx;
	Y -= ofy;
	
	vint snake(n);
	for(int i = 0; i < n; ++i){
		sx[i] -= ofx;
		sy[i] -= ofy;
		
		snake[i] = sx[i] << 8 | sy[i];
	}

	rocks.assign(50, vector<char>(50, EMPTY));
	for(int i = 0; i < k; ++i){
		u[i] -= ofx;
		v[i] -= ofy;
		
		if( u[i] >= 0 && u[i] < 50 && v[i] >= 0 && v[i] < 50 ){
			rocks[u[i]][v[i]] = 100;
		}
	}
	
	ans = 1;
	dq.clear();
	dq.push_back(snake);
	dq.push_back(vint());
	
	st.clear();
	st.insert(snake);
	st2.clear();

	while(ans < 20){
		snake = dq.front();
		dq.pop_front();
		
		if( snake.empty() ){
			dq.push_back(snake);
			++ans;
			
			st.insert(st2.begin(), st2.end());
			st2.clear();
			
			continue;
		}

		field = rocks;
		for(int i = 0; i < n; ++i){
			int x = snake[i] >> 8;
			int y = snake[i] & 0xff;
			field[x][y] = i;
		}

		try{
			move(snake, (1 << n) - 1);
		}
		catch(int){
			return ans;
		}
	}
	
	return 20;
}

int main(){
	while( scanf("%d", &n), n != 0 ){
		for(int i = 0; i < n; ++i){
			scanf("%d%d", &sx[i], &sy[i]);
		}
		scanf("%d", &k);
		for(int i = 0; i < k; ++i){
			scanf("%d%d", &u[i], &v[i]);
		}
		scanf("%d%d", &X, &Y);
		
		printf("%d\n", solve());
	}
}

Measured memory_bytes: 24500
#include <bits/stdc++.h>
#define debug if (1)

using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pii;
#define pb push_back

const int N = 60;

ll a[N], v[N];
ll n;

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

    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> a[i];

    ll ch;
    ll k = 0;
    do {
        ch = 0;
        for (int i = 0; i < n; i++) {
            ll x = a[i]/n;
            ch += x;
            a[i] %= n;
            a[i] -= x;
        }
        for (int i = 0; i < n; i++)
            a[i] += ch;
        k += ch;
    } while (ch);

    cout << k << endl;
}


Measured memory_bytes: 256
function Main(input){
  	var num = input.split("\n");
  	var elem = num[1].split(" ").map(str => parseInt(str, 10));

  	var count = 0; 	
  	inf_loop:
  	while(1){
      tmp = elem;
      for(var i=0; i<num[0]; i++){
      	if(elem[i]%2==0){
          tmp[i] = tmp[i]/2;
        }else{
          break inf_loop;
        }
      }
      count+=1;
      elem = tmp;         
    }
  	console.log(count);

}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7500
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        
        double x_p1 = scan.nextDouble();
        double y_p1 = scan.nextDouble();
        double x_p2 = scan.nextDouble();
        double y_p2 = scan.nextDouble();
        
        double vx = x_p2 - x_p1;
        double vy = y_p2 - y_p1;
        
        int q = scan.nextInt();
        double l = norm(x_p1, y_p1, x_p2, y_p2);
        
        StringBuilder sb = new StringBuilder();
        
        for(int i = 0; i < q; i++) {
            double x = scan.nextDouble();
            double y = scan.nextDouble();
            double ux = x - x_p1;
            double uy = y - y_p1;
            double t = dot(ux, uy, vx, vy);
            double k = t / l;
            double a = k * vx + x_p1;
            double b = k * vy + y_p1;
            
            //System.out.println(a + " " + b);
            sb.append(a).append(" ").append(b).append("\n");
        }
        scan.close();
        System.out.print(sb.toString());
    }
    
    static double dot(double x1, double y1, double x2, double y2) {
        return x1 * x2 + y1 * y2;
    }
    
    static double norm(double x1, double y1, double x2, double y2) {
        return (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);
    }
}


Measured memory_bytes: 42296
N = int(input())
A = [int(input()) for i in range(N)]
INF = 10**18
N2 = 2**N
def dfs(i, D):
    if i == N:
        return sum(D)
    b = 1 << i
    a = A[i]
    def sel(j, state, u):
        if j == N2:
            D2 = D[:]
            for e in u:
                D2[e] -= 1
                D2[e | b] += 1
            D2[b] = a - len(u)
            return dfs(i+1, D2)
        r = sel(j+1, state, u)
        if D[j] > 0 and state & j == 0 and len(u) < a:
            u.append(j)
            r = min(r, sel(j+1, state | j, u))
            u.pop()
        return r
    return sel(0, 0, [])
print(dfs(0, [0]*N2))


Measured memory_bytes: 5748