akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cassert>
#include <cstdlib>
#include <complex>
#include <cstring>
#include <memory>
#include <string>
#include <vector>
#include <cstdio>
#include <ctime>
#include <set>
#include <iostream>

using namespace std;

#define fs first
#define sc second
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define pb push_back
#define mp make_pair

typedef unsigned int uint;

const int mod = 1000000007;

int a[100100];

int main() {
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int mx = 0, mn = n;
    forn (i, n) {
        cin >> a[i];
        mx = max(mx, a[i]);
        mn = min(mn, a[i]);
    }
    if (mn < mx - 1) {
        cout << "No\n";
        return 0;
    }
    if (mx == mn) {
        if (mx == n - 1) {
            cout << "Yes\n";
            return 0;
        }
        if (mx * 2 <= n) {
            cout << "Yes\n";
        } else {
            cout << "No\n";
        }
        return 0;
    }
    int ones = 0;
    forn (i, n) {
        ones += a[i] == mn;
    }
    mx -= ones;
    n -= ones;
    if (mx <= 0) {
        cout << "No\n";
        return 0;
    }
    if (mx * 2 <= n) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
    return 0;
}


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

int main(){
    string n; cin >> n;
    int d = n[n.size()-1] - '0';
    if(d==0 || d==1 || d==6 || d==8) cout << "pon" << endl;
    else if(d==3) cout << "bon" << endl;
    else cout << "hon" << endl;


}

Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <sstream>
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <numeric>
#include <bitset>
#include <ext/algorithm>
#include <ext/numeric>
#define ffor(_a,_f,_t) for(int _a=(_f),__t=(_t);_a<__t;_a++)
#define all(_v) (_v).begin() , (_v).end()
#define sz size()
#define pb push_back
#define SET(__set, val) memset(__set, val, sizeof(__set))
#define FOR(__i, __n) ffor (__i, 0, __n)
typedef long long LL; using namespace std;

vector<int> c;

int main() {
	int n, a;
	cin >> n;
	FOR (i, n) {
		cin >> a;
		c.pb(a);
	}
	sort(all(c));
	if (c[n - 1] - c[0] > 1) {
		cout << "No" << endl;
		return 0;
	}
	int unique = 0;
	FOR (i, n)
		unique += (c[i] < c[n - 1]);
	int nonunique = n - unique;
	int see = c[n - 1] - unique;
	if (c[0] == c[n - 1] && c[0] == n - 1) {
		nonunique = 0;
		see = 0;
	}
	if (nonunique == 0 && see == 0)
		cout << "Yes" << endl;
	else if ((nonunique > 0 && see == 0) || see < 0)
		cout << "No" << endl;
	else if (nonunique / see >= 2)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

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

void factrialzation (int n, vector<int> &expo){

    for( int i = 2; i * i <= n; i++ ){
        while( n%i == 0 ){
            expo[i]++;
            n /= i;
        }
    }

    if( n != 1 )expo[n]++;
    return;
}

int main() {
    int N; cin >> N;
    vector<int> expo(1001);

    for( int i = 1; i <= N; i++ ){
        factrialzation(i,expo);
    }

    long long ans = 1;
    for( auto k : expo ) {
        ans *= k + 1;
        ans %= (long long)(1e9 + 7);
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
int a1,a2,b1,b2,k;
signed main()
{
	scanf("%lld%lld%lld%lld%lld",&a1,&a2,&b1,&b2,&k);
	printf("%lld",60*(b1-a1)+(b2-a2)-k);
    return 0;
}

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

typedef long long ll;
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    vector<string> days = { "SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT" };
    for (int i = 0; i < 7; i++) {
        if (s == days[i]) {
            cout << 7 - i << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <numeric>
#include <iomanip>
#define fi first
#define se second
#define fcout(n) cout<<fixed<<setprecision((n))
#define cinl(str) getline(cin,(str))
using namespace std;
bool value(int y,int x,int R,int C){return 0<=y&&y<R&&0<=x&&x<C;}
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
double pie=acos(-1);
int INF=1000000007;
int dx[4] = { 0,-1,0,1 };
int dy[4] = { -1,0,1,0 };


int main() {
	int k,t,a[105];
	int ans;
	cin>>k>>t;
	for(int i=0;i<t;i++){
		cin>>a[i];
	}
	sort(a,a+t);
	if(a[t-1]>k/2){
		ans=k-2*(k-a[t-1])-1;
	}
	else{
		ans=0;
	}
	cout<<ans<<endl;
}
////途中

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (rint i = 1; i <= (n); i ++)
#define re0(i, n) for (rint i = 0; i < (int) n; i ++)
#define travel(i, u) for (rint i = head[u]; i; i = e[i].nxt)
#define rint register int
using namespace std;
   
typedef long long lo;

template<typename tp> inline void read(tp &x) {
    x = 0; char c = getchar(); int f = 0;
    for (; c < '0' || c > '9'; f |= c == '-', c = getchar());
    for (; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
    if (f) x = -x;
}

namespace {
    const int mo = 1e9 + 7;
    inline int add(int x) {return x >= mo ? x - mo : x;}
    inline int sub(int x) {return x < 0 ? x + mo : x;}
    inline int mul(int x, int y) {return (long long) x * y % mo;}
    inline int power(int a, int k = mo - 2) {
	int ans = 1;
	for (; k; k >>= 1, a = mul(a, a))
	    if (k & 1) ans = mul(ans, a);
	return ans;
    }
}

namespace G {
    vector <int> pre;
    int n;
    inline void init(int _n) {
	n = _n;
	pre.resize(n + 1);
	rep (i, n) pre[i] = i;
    }
    inline int find(int x) {
	return pre[x] == x ? x : pre[x] = find(pre[x]);
    }
    inline void make(int x, int y) {
	assert(x <= n); assert(y <= n);
	pre[find(x)] = find(y);
    }
}
const int N = 233;
int n, m;
char s[N][N];

int main(void) {
    read(n); read(m);
    G::init(n / 2 + m / 2);
    rep (i, n) scanf("%s", s[i] + 1);
    int ans = 1;
    if (n & 1) {
	for (int j = 1; j <= m / 2; j++)
	    if (s[n / 2 + 1][j] != s[n / 2 + 1][m + 1 - j]) {
		ans = mul(ans, 2);
		break;
	    }
    }
    if (m & 1) {
	for (int i = 1; i <= n / 2; i++)
	    if (s[i][m / 2 + 1] != s[n + 1 - i][m / 2 + 1]) {
		ans = mul(ans, 2);
		break;
	    }
    }
    for (int i = 1; i <= n / 2; i++)
	for (int j = 1; j <= m / 2; j++) {
	    int a[] = {s[i][j], s[n - i + 1][j], s[n - i + 1][m - j + 1], s[i][m - j + 1]};
	    sort(a, a + 4);
	    int cnt = 0;
	    do {
		++cnt;
	    } while (next_permutation(a, a + 4));
	    cnt == 24 ? G::make(i, j + n / 2), ans = mul(ans, 12) : ans = mul(ans, cnt);
	}
    int o = n / 2 + m / 2;
    rep (i, n / 2 + m / 2) o -= G::find(i) == i;
    ans = mul(ans, power(2, o));
    cout << ans << "\n";
}


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

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

    int sum=0,i;

    vector<string> v;
    string s;
    cin>>s;
    v.push_back(s);
    for(i=0;i<s.size();i++)
    {
        sum+=s[i]-48;
    }
    if(sum%9==0)
        cout <<"Yes";
    else cout <<"No";






}



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

int h,w;
int a[52][52]={0};

int main() {
  
  scanf("%d %d",&h,&w);
 
  for(int i=0;i<=h+1;i++) 
    for(int j=0;j<=w+1;j++)
      a[i][j] = 500000;

  string b;
  for(int i=1;i<=h;i++){
    cin >> b;
    for(int j=1;j<=w;j++) {
      a[i][j] = b[j-1] -'0';
    }
  }

  //  for(int i=0;i<=w;i++)
  //cout << a[1][i] << " " ;

  for(int i=1;i<=h;i++) {
    for(int j=1;j<=w;j++){
      if(i == 1 && j == 1)continue;

      if(a[i][j-1] > a[i-1][j]) a[i][j] += a[i-1][j];
      else a[i][j] += a[i][j-1];
    }
  }

  printf("%d\n",a[h][w]);


  return 0;

}

Measured memory_bytes: 1236
def main(argv)
  (n, k) = gets.chomp.split(' ').map(&:to_i)
  a = gets.chomp.split(' ').map(&:to_i)

  a.sort!

  if n == 1 then
    if a[0] == k then
      puts 'POSSIBLE'
    else
      puts 'IMPOSSIBLE'
    end
    return
  end

  if a[n - 1] < k then
    puts 'IMPOSSIBLE'
    return
  end

  d = a.select{|x| x >= k}.map{|x| x - k}

  b = [0] * (n - 1)
  (n - 1).times{|i| b[i] = a[i + 1] - a[i]}

  g = b[0]
  (n - 2).times{|i| g = g.gcd(b[i + 1])}
  if g == 0 then
    if a.include?(k) then
      puts 'POSSIBLE'
    else
      puts 'IMPOSSIBLE'
    end
    return
  end

  if d.select{|x| (x % g) == 0}.size > 0 then
    puts 'POSSIBLE'
  else
    puts 'IMPOSSIBLE'
  end
end

if self.to_s == 'main' then
  main(ARGV)
end

Measured memory_bytes: 11660
mod = int(1e9 + 7)
x, y = map(int,input().split())
if(2*x < y or 2*y < x or (2*x-y)%3 or (2*y-x)%3): print(0)
else:
    x, y = (2*x-y)//3, (2*y-x)//3
    #print(x,y)
    fac = [0 for i in range(x+y+1)]
    fac[0] = 1
    for i in range(1,x+y+1):
        fac[i] = fac[i-1]*i%mod
    ans = fac[x+y]*pow(fac[x],mod-2,mod)*pow(fac[y],mod-2,mod)%mod
    print(ans)

Measured memory_bytes: 29464
#include <iostream>
#include <utility>
#include <algorithm>
#include <cstdlib>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

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

    int n;
    cin >> n;
    pii ai[n];
    for (int i = 0; i < n; i++) {
        cin >> ai[i].first;
        ai[i].second = i;
    }
    sort(ai, ai+n);

    ll dp[n][n];
    for (int i = n - 1; i >= 0; i--) {
        for (int j = i; j < n; j++) {
            if (i == j) {
                dp[i][j] = 1ll * ai[0].first * abs(ai[0].second - i);
            } else {
                dp[i][j] = 0;
                if (i < n - 1) {
                    dp[i][j] = max(dp[i][j], dp[i+1][j] + 1ll * ai[j-i].first * abs(ai[j-i].second - i));
                }
                if (j > 0) {
                    dp[i][j] = max(dp[i][j], dp[i][j-1] + 1ll * ai[j-i].first * abs(ai[j-i].second - j));
                }
            }
        }
    }

    cout << dp[0][n-1] << endl;

    return 0;
}


Measured memory_bytes: 26268
#include <iostream>
#include <map>
#include <vector>

using namespace std;

#define int long long
#define MOD (long long)998244353
#define MAX_S 3001

int fact[MAX_S];
int inv_fact[MAX_S];

int mod_pow(int x, int p)
{
    int res = 1;
    while (p > 0)
    {
        if (p & 1)
            res = res * x % MOD;

        p >>= 1;
        x = x * x % MOD;
    }
    return res;
}

void set_fact()
{
    fact[0] = 1;
    for (int i = 1; i < MAX_S; i++)
    {
        fact[i] = (fact[i - 1] * i) % MOD;
    }

    inv_fact[0] = 1;
    for (int i = 1; i < MAX_S; i++)
    {
        inv_fact[i] = mod_pow(fact[i], MOD - 2);
        //cout << inv_fact[i] << endl;
    }
}

int nCr(int n, int r)
{
    return ((fact[n] * inv_fact[r]) % MOD) * inv_fact[n - r] % MOD;
}

signed main()
{
    int N, S;
    cin >> N >> S;

    set_fact();

    //cout << nCr(5, 2) << endl;
    vector<int> data(N);

    map<int, int> m;
    for (int i = 0; i < N; i++)
    {
        int a;
        cin >> a;
        data[i] = a;
        if (m.find(a) == m.end())
        {
            m[a] = 1;
        }
        else
        {
            m[a]++;
        }
    }

    vector<vector<int>> vvsum(N + 1, vector<int>(S + 1, 0));
    vvsum[0][0] = 1;
    int c = 0;

    for (int j = 0; j < N; j++)
    {
        for (int i = 0; i <= S; i++)
        {
            vvsum[j + 1][i] += vvsum[j][i] * 2;
            vvsum[j + 1][i] %= MOD;
            if (data[j] + i <= S)
            {
                vvsum[j + 1][i + data[j]] += vvsum[j][i];
                vvsum[j + 1][i + data[j]] %= MOD;
            }
        }
    }

    // for (const auto &[key, value] : m)
    // {
    //     for (int i = 0; i <= S; i++)
    //     {
    //         for (int j = 0; j <= value; j++)
    //         {
    //             int sum = i + key * j;
    //             if (sum > S)
    //                 break;
    //             int mul = 0;
    //             for (int k = j; k <= value; k++)
    //             {
    //                 mul += nCr(value, k) * nCr(k, j) % MOD;
    //                 mul %= MOD;
    //             }
    //             vvsum[c + 1][sum] += vvsum[c][i] * mul % MOD;
    //             vvsum[c + 1][sum] %= MOD;
    //             //cout << value << " " << j << " " << nPr(value, j) << endl;
    //         }
    //     }
    //     c++;
    // }

    // for (vector<int> v : vvsum)
    // {
    //     for (int x : v)
    //     {
    //         cout << x << " ";
    //     }
    //     cout << endl;
    // }

    // vector<int> cheat(S + 1, 0);
    // for (int i = 1; i < (1 << (N)); i++)
    // {
    //     int b = i;
    //     int s = 0;
    //     int mul = 1;
    //     for (int j = 0; j < N; j++)
    //     {
    //         if (b & 1)
    //             s += data[j];
    //         else
    //             mul *= 2;
    //         b >>= 1;
    //     }
    //     if (s <= S)
    //     {
    //         cheat[s] += mul;
    //         cheat[s] %= MOD;
    //     }
    // }
    // for (int x : cheat)
    // {
    //     cout << x << " ";
    // }
    // cout << endl;

    cout << vvsum[N][S] << endl;
}

Measured memory_bytes: 73544
#include <stdio.h>
#include <algorithm>
#include <functional>

long long num[100001][2] = { 0 };

long long MOD = 1000000007LL;
int main()
{
	int S[202];
	int N, X;
	scanf("%d%d", &N, &X);
	for (int i = 0; i < N; i++) {
		scanf("%d", &S[i]);
	}
	std::sort(S, S + N, std::greater<int>());

	num[X][0] = 1;
	int cur = 0, next = 1;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < 100001; j++) {
			num[j % S[i]][next] += num[j][cur];
			num[j % S[i]][next] %= MOD;

			num[j][next] += num[j][cur] * (N - i - 1);
			num[j][next] %= MOD;
		}
		for (int j = 0; j < 100001; j++) {
			num[j][cur] = 0;
		}
		std::swap(cur, next);
	}

	long long ans = 0;
	for (int i=0; i<100001; i++) {
		ans += i * num[i][cur];
		ans %= MOD;
	}

	printf("%lld\n", ans);
}


Measured memory_bytes: 1664
#include <stdio.h>

int main(void) {
  int n, k, p, i, j;
  scanf("%d", &n);
  for(i = 0; i < n; ++i) {
    scanf("%d%d", &k, &p);
    k %= p;
    if(k) printf("%d\n", k);
    else printf("%d\n", p);
  }
  return 0;
}


Measured memory_bytes: 2708
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <map>
#define MAXN 100005
#define LL long long
#define INF 1e9
using namespace std;

int n, k, x[MAXN], ans=INF;

int main()
{
	scanf("%d%d", &n, &k);
	for(int i=1; i<=n; i++) scanf("%d", &x[i]);
	for(int i=k; i<=n; i++)
	{
		if(x[i]<0) ans=min(ans, -x[i-k+1]);
		if(x[i]>=0 && x[i-k+1]<=0) ans=min(ans, x[i]-x[i-k+1]+min(x[i], -x[i-k+1]));
		if(x[i-k+1]>0) ans=min(ans, x[i]);
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 512
/******************************************************************************

                       

*******************************************************************************/

#include <iostream>
#include <set>

using namespace std;

int main()
{
    int n = 0;
    set<int> d;
    cin >> n;
    int number = 0;
    for(int i = 0; i < n; ++i){
        cin >> number;
        d.insert(number);
    }
    cout << d.size() << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
 
int main(){
    double r,are,circ;  //r,are,circは実数、areは円の面積、circは円周の長さ
    double p;
    p = 3.141592653589;
    scanf("%lf",&r);  //%lfは実数を求めるための入力変換指定子
    are = p * r * r;
    circ = 2 * p * r;
     
    printf("%.5lf %.5lf\n",are,circ);
     
    return 0;
}


Measured memory_bytes: 2148
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.LinkedList;
import java.util.PriorityQueue;
 
 
 
public class Main {
  public static void main(String[] args) {
    InputReader sc = new InputReader(System.in);
 
    int[] ar = new int[3];
    ar[0] = sc.nextInt();
    ar[1] = sc.nextInt();
    ar[2] = sc.nextInt();
    Arrays.sort(ar);
    System.out.println(ar[2]-ar[0]);
 
  }
 
 //ここからテンプレ
  static class InputReader {
      private InputStream stream;
      private byte[] buf = new byte[1024];
      private int curChar;
      private int numChars;
      private SpaceCharFilter filter;
 
      public InputReader(InputStream stream) {
          this.stream = stream;
      }
 
      public int next() {
          if (numChars == -1)
              throw new InputMismatchException();
          if (curChar >= numChars) {
              curChar = 0;
              try {
                  numChars = stream.read(buf);
              } catch (IOException e) {
                  throw new InputMismatchException();
              }
              if (numChars <= 0)
                  return -1;
          }
          return buf[curChar++];
      }
 
      public String nextStr() {
        int c = next();
        while(isSpaceChar(c)){c = next();}
        StringBuffer str = new StringBuffer();
        do{
          str.append((char)c);
          c = next();
        }while(!isSpaceChar(c));
        return str.toString();
      }
 
      public char nextChar() {
        int c = next();
        while(isSpaceChar(c)){c = next();}
        char ret;
        do{
          ret = (char)c;
          c = next();
        }while(!isSpaceChar(c));
        return ret;
      }
 
      public int nextInt() {
          int c = next();
          while (isSpaceChar(c))
              c = next();
          int sgn = 1;
          if (c == '-') {
              sgn = -1;
              c = next();
          }
          int res = 0;
          do {
              if (c < '0' || c > '9')
                  throw new InputMismatchException();
              res *= 10;
              res += c - '0';
              c = next();
          } while (!isSpaceChar(c));
          return res * sgn;
      }
 
      public boolean isSpaceChar(int c) {
          if (filter != null)
              return filter.isSpaceChar(c);
          return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
      }
 
      public interface SpaceCharFilter {
          public boolean isSpaceChar(int ch);
      }
  }
}

Measured memory_bytes: 22484
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    int a, b;
    cin >> a >> b;
    if (a <= 8 && b <= 8) {
        cout << "Yay!" << endl;
    }
    else {
        cout << ":(" << endl;
    }
}

Measured memory_bytes: 256
#if 0

#endif

#include <iostream>
#include <vector>
using namespace std;

int P[10000+10];

void init(int N){
	for(int i=0;i<=N;++i) P[i]=i;
}
int root(int a){
	if(P[a]==a)return a;
	else return(P[a]=root(P[a]));
}
bool is_same_set(int a,int b){
	return root(a)==root(b);
}
void unite(int a,int b){
	P[root(a)]=root(b);
}

int main(){
	int n,q;
	int com, x,y;
	cin>>n>>q;
	init(n);
	for(int i=0;i<q;++i){
		cin>>com>>x>>y;
		if(com==0)
			unite(x,y);
		else{
			if(is_same_set(x,y))
				cout << "1" << endl;
			else if(! is_same_set(x,y))
				cout << "0" << endl;
		}
	}
}

Measured memory_bytes: 3224
#include<bits/stdc++.h>
#define int long long
using namespace std;
constexpr int mod=1e9+7;
int a[200000],f[200000];
signed main(){
    int n,k;
    cin>>n>>k;
    for(int i=0;i<n;i++)
        cin>>a[i];
    for(int i=0;i<n;i++)
        cin>>f[i];
    sort(a,a+n);
    sort(f,f+n,greater<>());
    int ng=-1,ok=1e12;
    while(ok-ng>1){
        int mid=(ok+ng)/2,tmp=0;
        for(int i=0;i<n;i++)
            tmp+=max(a[i]-mid/f[i],0ll);
        if(tmp<=k)
            ok=mid;
        else
            ng=mid;
    }
    cout<<ok<<endl;
}


Measured memory_bytes: 3328
import java.util.*;
import java.io.*;

class Main {

	void solve() {
		
		int a = inint(), b = inint(), h = inint();
		out.println((a+b)*h/2);
		
	}

	public static Scanner in = new Scanner(System.in);
	public static PrintWriter out = new PrintWriter(System.out);

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

	public int inint() {
		return in.nextInt();
	}

	public long inlong() {
		return in.nextLong();
	}

	public String instr() {
		return in.next();
	}

	public char inchar() {
		return in.next().charAt(0);
	}

	public int[] inintar(int num) {
		int[] a = new int[num];
		for (int i=0; i<num; i++) {
			a[i] = in.nextInt();
		}
		return a;
	}

	public char[] incharar() {
		return in.next().toCharArray();
	}

	public char[][] incharmap(int h, int w) {
		char[][] a = new char[h][w];
		for (int i=0; i<h; i++) {
			String temp = in.next();
			for (int j=0; j<w; j++) {
				a[i][j] = temp.charAt(j);
			}
		}
		return a;
	}

}

Measured memory_bytes: 21332
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdlib>
using namespace std;

int main()
{
    int N;
    cin>>N;
    vector<long long> X(N), Y(N);
    for (int i=0; i<N; i++)
        cin>>X[i]>>Y[i];

    long long answer = 0;

    for (int r=0; r<10; r++)
    {
        for (int i=0; i<N*10; i++)
        {
            long long tx = X[i];
            long long ty = Y[i];
            for (int j=0; j<N; j++)
            {
                long long sx = 0;
                long long sy = 0;
                for (int k=0; k<N; k++)
                    if (tx*X[k]+ty*Y[k] > 0 ||
                        tx*X[k]+ty*Y[k]==0 && rand()%2==0)
                        sx += X[k],
                        sy += Y[k];
                tx = sx;
                ty = sy;
            }
            answer = max(answer, tx*tx+ty*ty);
        }
    }
    printf("%.16f\n", sqrt((double)answer));
}


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

const int N=1e5+20,C=3;

int n,k,c[C],ans;
char a[N];
map <char,int> m={{'r',0},{'s',1},{'p',2}};

int get_profit(int i)
{
	int move=m[a[i]];
	int win=(move+2)%3;
	if(i<k or a[i]!=a[i-k]) return c[win];
	else
	{
		a[i]='$';
		return 0;
	}
}

int main()
{
	scanf("%d%d%d%d%d %s",&n,&k,&c[0],&c[1],&c[2],a);

	for(int i=0;i<k;i++)
		for(int j=i;j<n;j+=k) ans+=get_profit(j);

	printf("%d",ans);
}

Measured memory_bytes: 384
#include <stdio.h>
#include <stdint.h>

int main(void) {
        int64_t N, M, result;
        result = 0;
        scanf("%lld %lld", &N, &M);
        if (N > 2 && M > 2)
                result += (N -2) * (M-2);
        else if (N == 1 && M == 1)
                result += 1;
        else if (N == 1 && M > 2)
                result += M - 2;
        else if (M == 1 && N > 2)
                result += N - 2;
        printf("%lld\n", result);

}

Measured memory_bytes: 128
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cstdio>
#include<cmath>
#include<deque>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<tuple>
#include<utility>
#include<vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef vector<vector<int>> vvi;

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define REP(i, n)  for(int i=0; i<(int)(n); i++)
#define REPS(i, n)  for(int i=1; i<=(int)(n); i++)
#define PER(i, n) for(int i=(int)(n)-1; i>= 0; i--)
#define PERS(i, n)  for(int i=(int)(n); i>0; i--)
#define FOR(i, c) for(__typeof((c).begin()) i = (c).begin(); i!=(c).end(); i++)
#define RFOR(i, c)  for(__typeof((c).rbegin()) i=(c).rbegin(); i!=(c).end(); i++)
#define ALL(container)  (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) (container).size()
#define FILL0(n)  setfill('0') << right << setw(n)
#define mp(a, b)  make_pair(a, b)
#define toLower(c)  c+0x20
#define toUpper(c)  c-0x20
#define pb  push_back
#define eb  emplace_back

const int INF = 1e9;
const long long LLINF = 1e18;
const int MOD = 1000000007;

int main(){
  ll a, b, n; cin >> a >> b >> n;
  if(n<=b-1)  cout << (ll)(floor((double)a/b*n)-a*floor(n/b)) << endl;
  else    cout << (ll)(floor((double)a/b*(b-1))-a*floor((b-1)/b)) << endl;
  return 0;
}


Measured memory_bytes: 3716
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main() {
  int n;
  scanf("%d", &n);
  long long a[n];
  for(int i=0;i<n;i++) {
    scanf("%lld", &a[i]);
    if(a[i]==0){
      printf("0");
      return 0;
    }
  }
  long long ans=1;
  for(int i=0;i<n;i++){
    if(log10(ans)+log10(a[i])>18){
      printf("-1");
      return 0;
    }
    ans *= a[i];
    if(ans > 1000000000000000000L){
      printf("-1");
      return 0;
    }
  }
  printf("%lld", ans);
  return 0;
}

Measured memory_bytes: 3188
#include <stdio.h>
#define N 100
#define INFTY 1<<21

int M[N][N],n;

int calc(){
  int i,j,x,y,v;
  int d[N],p[N],col[N];
  int res = 0;

  for(i=0; i<n; i++){
    d[i]= INFTY;
    p[i] = -1;
    col[i] = 0;
  }

  d[0] = 0;

  while(1){
    v = INFTY;
    x = -1;

    for(i=0; i<n; i++){
      if(v > d[i] && col[i] != 2){
        v = d[i];
        x = i;
      }
    }

    if(x == -1) break;
    col[x] = 2;

    for(y=0; y<n; y++){
      if(col[y] != 2 && M[x][y] != INFTY){
        if(d[y] > M[x][y]){
          d[y] = M[x][y];
          p[y] = x;
          col[y] = 1;
         }
      }
    }
  }

  for(i=0; i<n; i++){
    if(p[i] != -1) res += M[i][p[i]];
  }

  return res;
}

int main(){
  int i,j,a;
  scanf("%d",&n);

  for(i=0; i<n; i++){
    for(j=0; j<n; j++){
      scanf("%d",&a);
      M[i][j] = (a == -1) ? INFTY : a;
    }
  }

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

  return 0;
}



Measured memory_bytes: 2056
#include<stdio.h>

#define N 100

#define WHITE 0
#define GRAY 1
#define BLACK 2

int n;
int G[N+1][N+1];
int time;
int color[N+1];
int d[N+1],f[N+1];

void visit(int u){
  int i;
  
  color[u] = GRAY;
  d[u] = ++time;
  for(i=1;i<=n;i++){
    if(G[u][i]==1 && color[i]==WHITE) visit(i);
  }
  color[u] = BLACK;
  f[u] = ++time;
}

void dfs(){
  int i;

  for(i=1;i<=n;i++){    
    color[i] = WHITE;
  }
  time = 0;
  for(i=1;i<=n;i++){
    if(color[i]==WHITE) visit(i);
  }
}

int main(){

  int i,j,k;
  int flag;

  scanf("%d",&n);

  int Adj[n+1][n+2];

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

  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      G[i][j]=0;
      for(k=0;k<Adj[i][1];k++){
	if(j==Adj[i][k+2]){
	  G[i][j]=1;
	  break;
	}
      }
    }
  }

  dfs();

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

  return 0;
}



Measured memory_bytes: 2112
#include <iostream>
using namespace std;
int main(void){
    string s;
    cin>>s;
    if (s[0]!='A'){
        cout<<"WA";
        exit(0);
    }
    int inC=0;
    for (int i=2;i<s.size()-1;i++){
        if (s[i]=='C'){
            inC++;
        }
    }
    if (inC!=1){
        cout<<"WA";
        exit(0);
    }
    for (int i=0;i<s.size();i++){
        if (s[i]!='A' &s[i]!='C'& s[i]!=tolower(s[i])){
            cout<<"WA";
            exit(0);
        }
    }
    cout<<"AC";
    
}


Measured memory_bytes: 3628
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
// 標準入力からデータを読み込む準備
        Scanner sc = new Scanner(System.in);
// 最初の文字の固まりを整数値と想定して読み込む
        for (int i = 1; ; i++) {
            int x = sc.nextInt();
// xが0の時を考慮しながら、 Case i: x の形式で出力しよう！
// ...
            if(x==0) break;
            System.out.println("Case "+i+": "+x);
        }
    }
}


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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = (n-1); i >= 0; --i)

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

typedef long long ll;
typedef pair<int, int> P;

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

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

    int ans = 0;
    for (char &c : S) {
        if (c == '+') ans++;
        else ans--;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
from collections import Counter


N = int(input()) #1行目のNを取得する
s = [input() for i in range(N)] #複数行の数値の入力を取得
ans=[]

counted = Counter(s)#
counted_sort=counted.most_common()

for i in range(len(counted_sort)):
    if counted_sort[i][1]==counted_sort[0][1]:
        ans.append(counted_sort[i][0])


[print(i) for i in sorted(ans)]

Measured memory_bytes: 50200
///----------------------///
///---Code Written by----///
///-----Al-Shahreyaj-----///
///----------------------///
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
#define vin vector<int>
#define vll vector<long long>
#define pii pair<int,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
#define ff first
#define ss second
#define pb push_back
#define pq priority_queue
#define all(x) x.begin(),x.end()
#define mod 1000000007
#define cone __builtin_popcount
#define conel __builtin_popcountll
typedef vector<vector<ll> > matrixl;
typedef vector<vector<int> > matrix;
#define N 100009

int h[N], dp[N], n, k;

int solve(int i)
{
    if(i > n) return 0;
    if(dp[i] != -1) return dp[i];
    int ans = solve(i + 1) + (i != n? abs(h[i+1] - h[i]) : 0);
    for(int j = 1; i + j <= min(n, i + k); j++)
    {
        //cout<<i<<" "<<j<<endl;
        ans = min(ans, solve(i + j) + abs(h[i + j] - h[i]));
    }
    return dp[i] = ans;
}

int main()
{
    memset(dp, -1 ,sizeof(dp));
    cin >> n >> k;
    for(int i=1; i<=n; i++) scanf("%d", &h[i]);
    cout << solve(1) << endl;
}



Measured memory_bytes: 5760
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
using namespace std;
#define MM 1000000000
#define MOD MM+7
#define pi pair<int32,int32>
#define pl pair<int64,int64>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}

long long pow_mod(long long n,long long k,long long m){
    if (k == 0){
        return 1;
    } else if (k % 2 == 1){
        return pow_mod(n,k-1,m)*n % m;
    } else {
        long long t = pow_mod(n,k/2,m);
        return t*t % m;
    }
}


int main(){
    int n; cin >> n;
    int ans = 0;
    for(int i = 0; i < n; i++){
        int a; cin >> a;
        bool flg = true;
        for(int num = 2; num*num <= a; num++){
            if (a % num == 0) flg = false;
        }
        if (flg) ans++;
    }
    cout << ans << endl;
}
  




Measured memory_bytes: 3112
s = input()
n = len(s)

ans0, ans1 = 0, 0
n0_even, n0_odd = 0, 0
for i in range(n):
    if s[i] == "0":
        if i%2 == 0:
            n0_even += 1
        else:
            n0_odd += 1
n1_even = (n+1)//2 - n0_even
n1_odd = n//2 - n0_odd
ans0 = n1_even+n0_odd
ans1 = n0_even+n1_odd
print(min(ans0, ans1))


Measured memory_bytes: 3188
target_multi = int(input())
(min, max) = tuple(map(int, input().split(' ')))

# kで割って整数になればいい
is_ok = False
for i in range(min, max + 1):
  if(i % target_multi == 0):
    print("OK")
    is_ok = True
    break

if not(is_ok):
  print("NG")


Measured memory_bytes: 9176
#include<iostream>

using namespace std;

int main(void)
{
	int n;
	while(cin >> n){
		int count = 0;
		for(int a = 0; a < 10; a++){
			for(int b = 0; b < 10; b++){
				for(int c = 0; c < 10; c++){
					for(int d = 0; d < 10; d++){
						if(a + b + c + d == n) count++;
					}
				}
			}
		}
		cout << count << endl;
	}
		return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <map>

using namespace std;

int main(void) {
	int N,T;
	cin >> N >> T;
	vector<int> t(N);
	for (int i = 0; i < N; ++i) {
		cin >> t[i];
	}

	long long res = 0;
	for (int i = 0; i < N-1; ++i) {
		if (t[i+1]-t[i] < T) {
			res += t[i+1]-t[i];
		}
		else {
			res += T;
		}
	}
	cout << res+T << endl;
	return 0;
}


Measured memory_bytes: 1024
n,m = map(int,input().split())
ab = [[]]*n
for i in range(n):
  ab[i] = list(map(int,input().split()))
ab.sort()
cost = 0
for i in range(n):
  if m>0:
    bought = min(m,ab[i][1])
    m -= bought
    cost += bought*ab[i][0]
print(cost)

Measured memory_bytes: 27760
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define mxsize (int)1e6
#define pb push_back
#define nl cout<<"\n"
#define db(x) cout<<x<<" "
#define fi(a,b) for(int i=a;i<b;i++)
#define fj(a,b) for(int j=a;j<b;j++)
#define fk(a,b) for(int k=a;k<b;k++)
#define F first
#define S second
#define UM unordered_map<int,int>
#define MP map<int,int>
void yn(bool check){
    if(check)	cout<<"YES\n";
    else		cout<<"NO\n";
}
void fun(){
    ll k;
    cin>>k;
    int ans=1,num=0;
    fi(0,k){
        num=(num*10+7)%k;
        if(num==0){
            cout<<ans<<"\n";
            return ;
        }
        ans++;
    }
    cout<<"-1\n";
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("/ATOM/input.txt", "r", stdin);
        freopen("/ATOM/output.txt", "w", stdout);
    #endif
    int t=1;
    // cin>>t;
    while(t--){
        fun();
    }
}

Measured memory_bytes: 3608
n = int(input())
b = list(map(int, input().split()))

if b[0] > 1:
    print(-1)

else:
    a = []

    while len(b)>0:
        n = len(b)
        br = True
        for i in range(n):
            if  n-i == b[n-1-i]:
                a.append(n-i)
                b.remove(n-i)
                br = False
                break
        if br:
            break

    if br:
        print(-1)
    else:
        for _ in range(len(a)):
            print(a.pop())


Measured memory_bytes: 3060
// 2020-08-23 14:41:01
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

const ll inf = 1e18;
void answer() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  ll ans = inf;
  REPC(i, -100, 100) {
    ll cur = 0;
    rep(j, n) {
      cur += (i - a[j]) * (i - a[j]);
    }
    chmin(ans, cur);
  }
  cout << ans << '\n';
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 3584
n = int(input())
x = list(map(int, input().split()))
y = list(map(int, input().split()))

d1 = 0.0
d2 = 0.0
d3 = 0.0
dinf = 0.0

for i in range(n):
    d1 += abs(x[i] - y[i])
    d2 += (x[i] - y[i]) ** 2.0
    d3 += abs(x[i] - y[i]) ** 3.0
    dinf = max(dinf, abs(x[i] - y[i]))

d2 = d2 ** (1 / 2)
d3 = d3 ** (1 / 3)

print("{:.10f}".format(d1))
print("{:.10f}".format(d2))
print("{:.10f}".format(d3))
print("{:.10f}".format(dinf))



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

int main(){
  string n;
  cin>>n;
  if(n[0]=='7'||n[1]=='7'||n[2]=='7')cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=1e18;


int main() {
  ll n;
  cin>>n;
  vector<double> p(n);
  rep(i,n)cin>>p[i];
  double dp[n+5][n+5];
  dp[0][0]=1;
  rep(i,n)rep(j,n+1){
    if (j==0)dp[i+1][j]=dp[i][j]*(1-p[i]);
    else{
      dp[i+1][j]=dp[i][j]*(1-p[i])+dp[i][j-1]*p[i];
    }
  }
ll N=(n+1)/2;
double P=0;
for(ll i=N;i<=n;i++){
  P+=dp[n][i];
}
cout<<setprecision(10)<<P;
}


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

#define DEBUG(C) cerr << #C << " = " << C << endl

using namespace std;

const int MAX = 55;
int n, k;
int l[MAX];

int main() {
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; i++) {
    scanf("%d", l + i);
  }
  sort(l, l + n);
  reverse(l, l + n);
  int ans = 0;
  for (int i = 0; i < k; i++) {
    ans += l[i];
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 256
def main():
    m,d=map(int,input().split(' '))
    ans = 0
    for i in range(1,m+1):
        for j in range(1,d+1):
            if j%10 >= 2 and j//10 >= 2 and int(j%10)*int(j//10) ==i:
                ans += 1
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <cstdio>
#include <set>
#include <vector>
#include <cstring>

using namespace std;

typedef long long ll;
const ll mod = 1e9+7;
ll dp[333][333][333];

ll pl(ll a, ll b) {
  return (a+b)%mod;
}
ll ml(ll a, ll b) {
  return (a*b)%mod;
}

int main(void) {
  int n, m;
  scanf("%d%d", &n, &m);
  dp[0][1][0] = 1;
  for (int i = 0; i < m; i++) {
    for (int j = 1; j <= n; j++) {
      //*
      // 強連結な頂点から強連結な頂点へ
      dp[i+1][j][0] = pl(dp[i+1][j][0], ml(dp[i][j][0], j));
      // 強連結な頂点から強連結でない頂点へ
      dp[i+1][j][1] = pl(dp[i+1][j][1], ml(dp[i][j][0], n-j));
      //*/
      for (int k = 1; k < n; k++) {
        // 強連結でない頂点から強連結でない頂点，新しく加える
        if (n-j-k >= 0) {
          dp[i+1][j][k+1] = pl(dp[i+1][j][k+1], ml(dp[i][j][k], n-j-k));
        }
        // 強連結でない頂点から強連結でない頂点へ
        dp[i+1][j][k] = pl(dp[i+1][j][k], ml(dp[i][j][k], k));
        // 強連結でない頂点から強連結な頂点へ
        if (j+k <= n) {
          dp[i+1][j+k][0] = pl(dp[i+1][j+k][0], ml(dp[i][j][k], j));
        }
      }
    }
  }
  printf("%lld\n", dp[m][n][0]);
  return 0;
}


Measured memory_bytes: 235392
import java.io.*;
import java.util.*;
public class Main {
	public static void main(String[] args) throws Exception {
		MScanner sc=new MScanner(System.in);
		PrintWriter pw=new PrintWriter(System.out);
		int h=sc.nextInt();
		int n=sc.nextInt();
		long sum=0;
		for(int i=0;i<n;i++) {
			sum+=sc.nextInt();
		}
		h-=sum;
		if(h<=0) {
			pw.println("Yes");
		}
		else {
			pw.println("No");
		}
		pw.flush();
	}
	static class MScanner {
		StringTokenizer st;
		BufferedReader br;
		public MScanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}
 
		public MScanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}
 
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int[] takearr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public long[] takearrl(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public Integer[] takearrobj(int n) throws IOException {
	        Integer[]in=new Integer[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public Long[] takearrlobj(int n) throws IOException {
	        Long[]in=new Long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public String nextLine() throws IOException {
			return br.readLine();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public char nextChar() throws IOException {
			return next().charAt(0);
		}
 
		public Long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public boolean ready() throws IOException {
			return br.ready();
		}
 
		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}


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

	bool has3(int x){
		while(x){
			if (x % 10 == 3 ) return true;
			x /= 10;
		}
		return false;
	}
		
void call(int n){
	for ( int x =1 ; x <= n; x++ ){
		if ( x% 3 == 0 || has3(x) ){
			cout << " " << x;
		}
	}
	cout << endl;
}

int main(){
	int n;
	cin >> n;
	call(n);

	return 0 ;
}

Measured memory_bytes: 3100
a,b,c = map(int, input().split())
k = int(input())

flag = False

for i in range(k+1):
    for j in range(k+1-i):
        a1 = a*(2**i)
        b1 = b*(2**j)
        c1 = c*(2**(k-i-j))
        if c1 > b1 and b1 > a1:
            flag = True
            print('Yes')
            break
    if flag:
        break

if flag == False:
    print('No')


Measured memory_bytes: 9184
#include<cstdio>
#include<cstring>
#include<queue>
using namespace std;
int map[1005][1005];
struct node{
	int x,y,time;
}s[10],p;
queue<node> q;
int vis[1005][1005];
int n,m,T;
int dir[4][2]={{0,1},{1,0},{0,-1},{-1,0}};
int bfs(int a,int b){
	while(!q.empty())
		q.pop();
	q.push(s[a]);
	memset(vis,0,sizeof vis);
	vis[s[a].x][s[a].y]=1;
	while(!q.empty()){
		p=q.front();
		q.pop();
		int x=p.x,y=p.y,time=p.time;
		for(int i=0;i<4;i++){
			int x1=x+dir[i][0],y1=y+dir[i][1];
			if(x1<=0||y1<=0||x1>n||y1>m||vis[x1][y1]||map[x1][y1])
				continue ;
			if(x1==s[b].x&&y1==s[b].y)
				return time+1;
			vis[x1][y1]=1;
			p.x=x1,p.y=y1,p.time=time+1;
			q.push(p);
		}
	}
}
int main()
{
	scanf("%d%d%d",&n,&m,&T);
	for(int i=1;i<=n;i++){
		scanf("\n");
		for(int j=1;j<=m;j++){
			char c;
			c=getchar();
			if(c=='S')
				s[0].x=i,s[0].y=j;
			if(c=='X')
				map[i][j]=1;
			if(c>='1'&&c<='9')
				s[c-'0'].x=i,s[c-'0'].y=j;
		}
	}
	int time=0;
	for(int i=0;i<T;i++)
		time+=bfs(i,i+1);
	printf("%d\n",time);
}

Measured memory_bytes: 10584
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))

index = 0
answer = 0

for i in B:
    next = i - A[index]
    if next >= 1:
        answer += A[index]
        if A[index+1] >= next:
            answer += next
            A[index+1] -= next
        else:
            answer += A[index+1]
            A[index+1] = 0
    else:
        answer += i
    index += 1

print(answer)

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

int main(){
    int n, tem, i, j;
    cin >> n;
    ll res = 1, prime[n] = {};
    for(i=2; i<=n; i++){
        tem = i;
        for(j=2; j<=n; j++){
            while(tem%j == 0){
                tem /= j;
                prime[j-1]++;
            }
        }
    }
    for(i=0; i<n; i++){
        if(prime[i] > 0){
            res *= (prime[i]+1);
            res %= MOD;
        }
    }
    cout << res;
}

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

class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String[] size = br.readLine().split(" ");
        int H = Integer.parseInt(size[0]);
        int W = Integer.parseInt(size[1]);

        int[][] map = new int[H][W];

        // data in
        for (int h = 0; h < H; h++) {
            String[] line = br.readLine().split(" ");
            for (int w = 0; w < W; w++) {
                map[h][w] = Integer.parseInt(line[w]);
            }
        }

        int answer = Integer.MAX_VALUE;

        // select road
        for (int h = 0; h < H; h++) {
            for (int w = 0; w < W; w++) {
                int score = 0;
                // calculate distance
                for (int hh = 0; hh < H; hh++) {
                    for (int ww = 0; ww < W; ww++) {
                        score += map[hh][ww] * Math.min(Math.abs(h - hh), Math.abs(w - ww));
                    }
                }
                answer = Math.min(answer, score);
            }
        }

        System.out.println(answer);
    }
}


Measured memory_bytes: 25356
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

class CTetrominoTiling {
public:
    void solve(istream& in, ostream& out) {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        unsigned int i,o,_,j,l,ans,I,J,L;
        in>>i>>o>>_>>j>>l;
        ans=(i&(~1u))+o+(j&(~1u))+(l&(~1u));
        I=i>0,J=j>0,L=l>0;
        i&=1u,j&=1u,l&=1u;
        if(i+j+l==3) ans+=3;
        if((i+j+l==2)&((i&j&L)|(i&J&l)|(I&j&l))) ++ans;
        out<<ans<<endl;
    }
};

int main() {
    CTetrominoTiling solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


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

#define INF INT_MAX
#define UINF UINT_MAX
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef std::pair<int,int> pii;

using namespace std;


int main() {
    int n;
    cin >> n;
    vector<int> A(n);
    vector<int> B(n);
    vector<int> C(n-1);
    REP(i,n){cin >> A[i];A[i]--;}
    REP(i,n)cin >> B[i];
    REP(i,n-1)cin >> C[i];

    int ans = 0;

    int prev = -10;
    REP(i,n){
        ans += B[A[i]];
        if(prev == A[i]-1){
            ans += C[A[i-1]];
        }
        prev = A[i];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main(void){
    int n; cin >> n;
    vector<int> A(0);
    bool even;
    int sz = (n % 2 == 0 ? n / 2 : n / 2 + 1);
    REP(i, sz) A.push_back(0);
    even = (n % 2 == 0 ? true : false);
    
    bool ng = false; 

    REP(i, n){
        int num; cin >> num;
        if(even){
            if(num % 2 == 0) ng = true;
            A[(num - 1) / 2]++;
        }
        else {
            if(num % 2 != 0) ng = true;
            if(num == 0) A[0]++;
            else A[num / 2]++;
        }
    }

    REP(i, sz){
        if(!even and i == 0 and A[i] != 1){
            ng = true;
            break;
        }
        else if(A[i] != 2 and i != 0){
            ng = true;
            break;
        }
    }
    
    ll ans = 1, mul = n / 2;
    if(ng) cout << 0 << endl;
    else{
       
        REP(i, mul){
            ans = (ans * 2) % MOD;
        }
        cout << ans << endl;
    }
    
}

Measured memory_bytes: 640