akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
typedef long long int lld;
typedef unsigned long long int llu;
#define INF (lld)(9223372036854775807)
#define IINF (int)(2147483647)

using namespace std;
int main(void) {
  lld a[3][3], n, b;
  for (int i = 0; i < 9; i++) {
    cin >> a[i / 3][i % 3];
  }
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> b;
    for (int i = 0; i < 9; i++) {
      if (a[i / 3][i % 3] == b) {
        a[i / 3][i % 3] = -1;
        break;
      }
    }
  }
  if (
    a[0][0] + a[0][1] + a[0][2] == -3 ||
    a[1][0] + a[1][1] + a[1][2] == -3 ||
    a[2][0] + a[2][1] + a[2][2] == -3 ||
    a[0][0] + a[1][0] + a[2][0] == -3 ||
    a[0][1] + a[1][1] + a[2][1] == -3 ||
    a[0][2] + a[1][2] + a[2][2] == -3 ||
    a[0][0] + a[1][1] + a[2][2] == -3 ||
    a[0][2] + a[1][1] + a[2][0] == -3
  ) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
}

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

int main()
{
    int b, t;
    double a;
    cin >> a >> b >> t;
    double k = t + 0.5;
    int ans = 0;
    int c = int(k / a);
    //cout << c << endl;
    for (int i = 0; i < c; i++)
    {
        ans += b;
    }
    cout << ans << endl;
}

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

int main(){
  long long a,b;
  long long tmp;
  cin >> a >> b;
  
  if((a < 0 && b > 0) || (a > 0 && b < 0)){
    cout << "Zero";
  }else if(a > 0){
    cout << "Positive";
  }else{
    tmp = labs(b - a) + 1;
    if(tmp % 2 == 0) cout << "Positive";
    else cout << "Negative";
  }
}


Measured memory_bytes: 256
import math
def func():
#    a=int(input())
    i1=list(map(int,input().split()))
    #print(a)
    #for i in range(a):
    #    print(b[i])
    a=abs(i1[0])
    b=i1[1]
    c=i1[2]
#    print(a,b,c)
    l=math.floor(a/c)
    m=b-l
    n=a-c*l
    if l>=b: z=a-c*b
    else:
        z=a-(c*l)
        if m%2==1:
            z=z-c
    print(abs(z))

func()

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

using namespace std;

int n;
int a[3010];
long long f[3010][3010];
char v[3010][3010];

inline long long dp(int l,int r){
	if(l==r)return f[l][r]=a[l];
	if(v[l][r])return f[l][r];
	v[l][r]=1;
	f[l][r]=max(a[l]-dp(l+1,r),a[r]-dp(l,r-1));
	return f[l][r];
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",a+i);
	}

	printf("%lld\n",dp(1,n));
	return 0;
}

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

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

// 多次元 vector 生成
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
inline std::string to_bin_str(T n) {
    std::string str;
    while (n > 0) {
        str.push_back('0' + (n & 1));
        n >>= 1;
    }
    std::reverse(str.begin(), str.end());
    return str;
}
int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    ll N;
    cin >> N;

    ll S;
    if (N == 0) {
        cout << 0 << endl;
        return 0;
    }

    ll dp[50][2] = {0};  // 0:min, 1:max

    REP(i, 32) {
        ll m = 1LL << i;
        if (i % 2 == 0) {
            dp[i + 1][1] = dp[i][1] + m;
            dp[i + 1][0] = dp[i][0];
        } else {
            dp[i + 1][1] = dp[i][1];
            dp[i + 1][0] = dp[i][0] - m;
        }
    }

    for (int i = 32; i >= 0; i--) {
        ll m = 1LL << i;
        if (N > 0) {
            if (N > dp[i][1] && i % 2 == 0) {
                N -= m;
                S |= m;
            }

        } else if (N < 0) {
            if (N < dp[i][0] && i % 2 == 1) {
                N += m;
                S |= m;
            }
        }
        // cout << N << endl;
    }

    cout << to_bin_str(S) << endl;

    return 0;
}


Measured memory_bytes: 256
//CODECHEF :-
//coded by AMAN BHARTI NIT PATNA
//ALL RIGHTS RESERVED
//ECE 2K18

#include<bits/stdc++.h>
using namespace std;

//#define home
#define TASK "soln"
#define eprintf(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define ll long long int
#define br cout<<endl;
#define fo for(int i=0;i<n;i++)
 

void solve(){
    int n;
    cin>>n;

    int f=0,se=0,t=0,forth=0;

    fo{
        string s;
        cin>>s;
        if(s[0]=='A')f++;
        else if(s[0]=='W')se++;
        else if(s[0]=='T')t++;
        else if(s[0]=='R')forth++;
    }

    cout<<"AC x "<<f<<endl<<"WA x "<<se<<endl<<"TLE x "<<t<<endl<<"RE x "<<forth;
}


int main(){
	#ifdef home
        assert(freopen(TASK".in", "r", stdin));
        assert(freopen(TASK".out", "w", stdout));
    #endif
 
    ios::sync_with_stdio(false);
    cin.tie(NULL);
 
    //int t;
    //cin>>t;
    //while(t-->0)
    solve();
 
    #ifdef home
        eprintf("Time: %d ms\n", (int)(clock() * 1000. / CLOCKS_PER_SEC));
    #endif
 
    return 0;
}

Measured memory_bytes: 3656
#include<stdio.h>
int main(void){
	int num;
	int spl;
	int ans=1;
	scanf("%d",&num);
	
	if(num%2==0) printf("-1\n");
	else if(num%5==0) printf("-1");
	//else if(num==1)  printf("-1");
	else {
       spl=7%num;
	while(1){
		if(spl==0){
			printf("%d\n",ans);
			break;
		}
       ans+=1;
	   spl=spl*10+7%num;
	   if(spl>=num)
	     spl=spl%num;
	}
    }
	return 0;
}

Measured memory_bytes: 1716
H, W = list(map(int, input().split()))
M = []

A = [chr(i) for i in range(ord('A'), ord('Z')+1)]

for i in range(H):
    r = input().split()
    M.append(r)


# for i in range(H):
#     print(M[i])

for i in range(H):
    for j in range(W):
        if M[i][j] == 'snuke':
            output = A[j] + str(i+1) 
            print(output)

Measured memory_bytes: 3060
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const long double PI = acos(-1.0L);
//const long long MOD = 1000000007LL;
const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
///////////////////////////////////////////////////////////////////////////////////////////////////

vector<vector<int>> G;
void dfs(int l, int r, int k) {
    if (r - l <= 1) return;
    for (int i = l; i < (l+r)/2; i++) {
        for (int j = (l+r)/2; j < r; j++) {
            G[i][j] = k;
        }
    }
    dfs(l,(l+r)/2,k+1);
    dfs((l+r)/2,r,k+1);
} 

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    G.resize(N, vector<int>(N));
    dfs(0,N,1);
    rep(i,N-1) {
        for (int j = i+1; j < N; j++) {
            cout << G[i][j] << " ";
        }
        cout << endl;
    }
}


Measured memory_bytes: 1536
import java.util.*;

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

        int n = sc.nextInt();
        int y = sc.nextInt();

        for (int i = 0; i <= n; i++) {
            for (int j = 0; j <= n; j++) {
                int k = n - i - j;
                if (k < 0) {
                    continue;
                }
                if (i * 10000 + j * 5000 + k * 1000 == y) {
                    System.out.println(i + " " + j + " " + k);
                    return;
                }
            }
        }
        System.out.println("-1 -1 -1");
    }
}

Measured memory_bytes: 25044
#include<iostream>
#include<algorithm>
#include<cstdlib>
using namespace std;
int main()
{
  string n;
  int ans=0;
  cin >> n;
  for(int i=0; i<2; i++){
    if(n[i]=='9'){
      ans=1;
    }
  }
  if(ans==1) cout <<"Yes"<<endl;
    else cout <<"No"<<endl; 
  return 0;
}


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

using namespace std;
using ll = long long;

ll solve(int a, int b, int c, int k)
{
    ll ans = 0;

    ans += min(a, k);
    k -= min(a, k);
    if (k == 0)
        return ans;

    k -= min(b, k);
    if (k == 0)
        return ans;

    ans -= min(c, k);
    k -= min(c, k);

    return ans;
}

int main(void)
{
    int a, b, c, k;
    cin >> a >> b >> c >> k;

    cout << solve(a, b, c, k) << endl;

    return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define ll long long
#define loop(n) for(ll i = 0; i<n; i++)
#define sort(a) sort(a.begin(), a.end())
using namespace std;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    ll n; cin>>n;
    map <string, ll> mp;
    string s;
    loop(n){
        cin>>s;
        mp[s]++;
    }
    
    ll ma = -1;
    for(auto i : mp) ma = max(ma, i.second);
    for(auto i : mp){
        if(i.second == ma) cout<<i.first<<"\n";
    }
    return 0;
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_V 1010
#define MAX_E 2222

//// shortest path
struct edge{int from,to,cost;};
//// Bellman-Ford
struct BellmanFord{
	edge es[MAX_E];
	int d[MAX_V];
	int V,E;

	void init(int v,int e,edge *ess){
		V=v; E=e;
		for(int i=0;i<E;i++)es[i]=ess[i];
	}
	bool find_negative_loop(){
		memset(d,0,sizeof(d));
		for(int i=0;i<V;i++){
			for(int j=0;j<E;j++){
				edge e=es[j];
				if(d[e.to]>d[e.from]+e.cost){
					d[e.to]=d[e.from]+e.cost;
					if(i==V-1)return true;
				}
			}
		}
		return false;
	}
	bool shortpath(int s){
		for(int i=0;i<V;i++)d[i]=INF;
		d[s]=0;
		int cnt=0;
		while(true){
			bool update=false;
			for(int i=0;i<E;i++){
				edge e=es[i];
				if(d[e.from]!=INF&&d[e.to]>d[e.from]+e.cost){
					d[e.to]=d[e.from]+e.cost;
					update=true;
				}
				if(cnt==V-1)return false;
			}
			cnt++;
			if(!update)break;
		}
		return true;
	}
};

BellmanFord bf;
edge es[2222];
int V,E,s;

int main(){
	cin.sync_with_stdio(false);
	cin>>V>>E>>s;
	rep(i,E)cin>>es[i].from>>es[i].to>>es[i].cost;
	bf.init(V,E,es);
	/*if(bf.find_negative_loop()){
		cout<<"NEGATIVE CYCLE"<<endl;
		return 0;
	}*/
	if(!bf.shortpath(s)){
		cout<<"NEGATIVE CYCLE"<<endl;
		return 0;
	}
	rep(i,V){
		if(bf.d[i]==INF)cout<<"INF"<<endl;
		else cout<<bf.d[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 3232
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main(){
	int n,a,b;cin>>n>>a>>b;
	cout<<min(a,b)<<' '<<max(0,a+b-n)<<endl;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef long long ll;
const int N=2e5+5;
struct edge
{
    int u,v,w;
    bool operator<(const edge&o)const
    {
        return w<o.w;
    }
}e[N];
int n,m,a[N];
stack<int>f[N];
int vis[N],dep[N];
ll sum[N];
int getf(int x){return f[x].top()==x?x:getf(f[x].top());}
void del(int x,ll s)
{
    sum[x]-=s;
    if(f[x].top()!=x) del(f[x].top(),s);
}
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    for(int i=1;i<=n;i++) f[i].push(i),sum[i]=a[i];
    for(int i=1;i<=m;i++) scanf("%d%d%d",&e[i].u,&e[i].v,&e[i].w);
    sort(e+1,e+1+m);
    for(int i=1;i<=m;i++)
    {
       int fu=getf(e[i].u),fv=getf(e[i].v);
       if(fu==fv) continue;
       //cout<<" F: "<<e[i].u<<' '<<e[i].v<<' '<<e[i].w<<endl;
       if(dep[fu]<dep[fv])
       {
           f[fu].push(fv);
           sum[fv]+=sum[fu];
           vis[i]=fu;
       }
       else
       {
           f[fv].push(fu);
           sum[fu]+=sum[fv];
           dep[fu]=max(dep[fv]+1,dep[fu]);
           vis[i]=fv;
       }
    }
    for(int i=m;i>=1;i--)
        if(vis[i])
        {
            int fu=getf(e[i].u);
            //cout<<fu<<' '<<sum[fu]<<' '<<e[i].w<<endl;
            if(e[i].w>sum[fu])
            {
                del(f[vis[i]].top(),sum[vis[i]]);
                f[vis[i]].pop();
            }
        }
    int ans=0;
    for(int i=1;i<=m;i++)
    {
        int fu=getf(e[i].u),fv=getf(e[i].v);
        if(fu!=fv) continue;
        //cout<<e[i].w<<' '<<sum[fu]<<endl;
        if(e[i].w<=sum[fu]) ans++;
    }
    printf("%d\n",m-ans);
}


Measured memory_bytes: 138880
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;


class Program
{
    public static long Read()
    {
        return long.Parse(Console.ReadLine());
    }

    public static long[] Reads()
    {
        return Console.ReadLine().Split().Select(long.Parse).ToArray();
    }

   
    public static void Main()
    {
        var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);

        var s = Console.ReadLine();
        long n = 0;
        long d = 753;
        for (int i = 0; i < s.Length - 2; i++)
        {
            n = long.Parse(s.Substring(i, 3));
            if (d > Math.Abs(n - 753))
                d = Math.Abs(n - 753);
        }
        Console.WriteLine(Math.Abs(d));

        Console.Out.Flush();
    }
}

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int x,a; cin >> x >> a;
	if (x<a) cout << "0\n"; 
	else cout << "10\n";
	return 0;
}

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

#define int long long
#define double long double
int a[100005];
int inf = 1e18;

main()
{
    int ans = 1, n, x;
    cin >> n;
    for (int i = 1; i <= n; ++i)
    {
        cin >> a[i];
        if (a[i] == 0)
        {
            cout << 0;
            exit(0);
        }
    }
    for (int i = 1; i <= n; ++i)
    {
        if (ans > inf/ (double)a[i] )
        {
            cout << -1;
            exit(0);
        }
        ans *= a[i];
    }
    cout << ans << '\n';
    return 0;
}
//

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

void fnInput(string& rsSLine, string& rsTLine)
{
  cin >> rsSLine >> rsTLine;

  sort (begin(rsSLine), end(rsSLine));
  sort (begin(rsTLine), end(rsTLine), greater<char>());
}

void fnAnagramCheck(string sSLine, string sTLine)
{
  if (sSLine < sTLine) cout << "Yes" << endl;
  else                 cout << "No"  << endl;
}

int main()
{
  string sSLine;
  string sTLine;

  fnInput(sSLine, sTLine);
  fnAnagramCheck(sSLine, sTLine);

  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#define ll long long
#define N 100105
using namespace std;
struct node{
	ll x,y;
}a[2*N];
ll h,n,ans,cnt,c;
bool cmp(const node&a,const node&b)
{
	return a.x>b.x;
}
int main()
{
	scanf("%lld%lld",&n,&h);
	for(int i=1;i<=2*n;i++)
	{
		scanf("%lld",&a[i].x);
		if(i%2==1) a[i].y=1;
		else a[i].y=0;
	}
	sort(a+1,a+2*n+1,cmp);
	cnt=1;
	while(ans<h)
	{
		c++;
		ans+=a[cnt].x;
		if(!a[cnt].y) cnt++;
	}
	printf("%lld",c);
	return 0;
}

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

using namespace std;

int main(){
  
  int M, D;
  cin >> M >> D;
  
  int counter = 0;
  
  for (int i = 1; i <= D; i++) {
    int d1, d2;
    d2 = i / 10;
    //cout << i << ": " << d2 << endl;
    if (d2 != 0) d1 = i % (d2 * 10);
    else continue;
    for (int j = 1; j <= M; j++){
      if (d1 > 1 && d2 > 1 && d1 * d2 == j){
        //cout << j << "/" << d2 << d1 << endl;
        counter++;
      }
    }
  }
  
  cout << counter;
  
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

int dp[45];

int fibonacci(int n);

int main(){
  int n,i;
  for(i=0;i<45;i++){
    dp[i] = -1;
  }
  scanf("%d",&n);
  printf("%d\n",fibonacci(n));

  return 0;
}

int fibonacci(int n){
  if(n == 0 || n == 1) return 1;
  if(dp[n] != -1) return dp[n];
  return dp[n] = fibonacci(n-2) + fibonacci(n-1);
}



Measured memory_bytes: 2048
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

static class Program
{
    static long Solve(long I, long O, long J, long L)
    {
        Func<long, long> f = x => x * 3 + ((I - x) & ~1L) + ((J - x) & ~1L) + ((L - x) & ~1L) + O;
        var n = new[] { I, J, L }.Min();
        long a = f(n);
        long b = (n > 0) ? f(n - 1) : 0;
        return Math.Max(a, b);
    }

    static void Main(string[] args)
    {
        var V = Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
        Console.WriteLine(Solve(V[0], V[1], V[3], V[4]));
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <cassert>

int main () {
    int N, D;
    std::cin >> N >> D;
    assert(2 <= N && N <= 10);
    assert(1 <= D && D <= 10);

    int X[N][D];

    for (int i=0; i<N; i++) {
        for (int j=0; j<D; j++) {
            int x;
            std::cin >> x;
            assert(-20 <= x && x <= 20);
            X[i][j] = x;
        }
    }

    struct { int operator()(int *p1, int *p2, int dim) {
        int sum = 0;
        for (int i=0; i<dim; i++) {
            auto diff = p2[i] - p1[i];
            sum += diff * diff;
        }
        return sum;
    } } squaredDistance;

    struct { bool operator()(int n) {
        bool isSN = false;
        for (int k=1; k*k<=n; k++) if (k * k == n) isSN = true;
        return isSN;
    } } isSquareNumber;

    int count = 0;

    for (int i=0; i<N; i++)
        for (int j=i+1; j<N; j++)
            if (isSquareNumber(squaredDistance(X[i], X[j], D)))
                count++;

    std::cout << count << std::endl;

    return 0;
}

Measured memory_bytes: 256
def subset_sum(s, a):
	n = len(a)
	dp = [[False for x in range(s+1)] for x in range(n+1)]
	for i in range(n):
		v = a[i]
		for j in range(s+1):
			if v == j:
				dp[i+1][j] = True
			elif v > j:
				dp[i+1][j] = dp[i][j]
			else:
				dp[i+1][j] = dp[i][j] or dp[i][j-v]
	return dp[n][s]

n = int(input())
a = list(map(int, input().split()))
q = int(input())
m = list(map(int, input().split()))
for i in range(q):
	if subset_sum(m[i], a) == True:
		print('yes')
	else:
		print('no')


Measured memory_bytes: 5948
#include<bits/stdc++.h>
using namespace std;
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	fastio
	string s,t;
	cin>>s>>t;
	int flag=1;
	for(int i=0;s[i]!='\0';++i){
		if(s[i]!=t[i]){
			cout<<"No";
			flag=0;
			break;
		}
	}
	if(flag) cout<<"Yes";
	return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define ll long long int
const ll mod=1e9+7;
const int maxn=2e5+50;
using namespace std;
int main()
//int found; found=chaine.find(cara); if (found!=std::string::npos) how to verify if a caracter exists in a chaine
// toupper(caractere) ==> return the majuscule of a caractere
//floor(x) Returns the largest integer smaller than x
//ceil(x) returns  Returns the smallest integer greater
{
	
	ll n;
	cin>>n;
	ll a;
	a=1e5+50;
	ll tab[a];
	ll nb;
	nb=-1;
	for(ll i=1;i<=sqrt(n);i++)
	{
		if(n%i==0)
		{
			nb++;
			tab[nb]=i-1+(n/i-1);
		}
	}
	ll res;
	res=tab[0];
	for(ll i=0;i<=nb;i++)
	{
		res=min(res,tab[i]);
	}
	cout<<res;
}



Measured memory_bytes: 256
#include<algorithm>
#include <bits/stdc++.h>
using namespace std;
int main(void){
	int ans=0,n,i,c=0;
	string s;
	cin>>n>>s;
	for(i=0;i<n;i++){
		if(s[i]=='I') c++;
		else c--;
		ans=max(ans,c);
	}

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

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

int main() {
	char a; cin >> a;
	if (a == 'a' || a == 'i' || a == 'u' || a == 'e' || a == 'o')puts("vowel");
	else puts("consonant");
}

Measured memory_bytes: 256
// package app;

import java.math.BigDecimal;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.Scanner;
import java.util.StringJoiner;
import java.util.stream.Stream;

public class Main {

    public static void main(final String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);

        long N = sc.nextLong();
        long D = sc.nextLong();
        // long K = sc.nextLong();
        double[][] X = new double[(int) N][(int) D];

        int cnt = 0;
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < D; j++) {
                X[i][j] = sc.nextDouble();
            }
        }

        for (int i = 0; i < N; i++) {
            for (int j = i + 1; j < N; j++) {
                boolean flag = true;
                double tmp = 0;
                for (int k = 0; k < D; k++) {
                    tmp += (X[i][k] - X[j][k]) * (X[i][k] - X[j][k]);
                }
                double ret = Math.sqrt(tmp);
                if (ret % 1.0 > 0.0001) {
                    flag = false;
                }
                cnt += flag ? 1 : 0;
            }
        }

        System.out.println(cnt);
    }
}

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

using namespace std;

const int N = 1e5+10;
short dp[N][4][4][4];

// u,v 0-1-2
int encode(int a, int b, int c, int u) {
    return (((a << 4) | (b << 2) | c) << 2) | u;
}

void dfsans(int n, int i, int j, int k) {
    if (dp[n][i][j][k] == 0) return ;
    assert(n > 0);

    int t = dp[n][i][j][k];
    dfsans(n-1, (t>>6)&3, (t>>4)&3, (t>>2)&3);

    putchar((t&3) + 'A');
    putchar('\n');
}

int main() {

    int n, a, b, c;
    scanf("%d%d%d%d", &n, &a, &b, &c);
    a = min(3, a);
    b = min(3, b);
    c = min(3, c);

    memset(dp, -1, sizeof(dp));
    dp[0][a][b][c] = 0;

    for (int t = 0; t < n; t++) {
        char s[5];
        scanf("%s", s);
        bool hasa = (s[0] == 'A' || s[1] == 'A');
        bool hasb = (s[0] == 'B' || s[1] == 'B');
        bool hasc = (s[0] == 'C' || s[1] == 'C');

        for (int i = 0; i < 4; i++) {
            for (int j = 0; j < 4; j++) {
                for (int k = 0; k < 4; k++) {
                    if (dp[t][i][j][k] < 0) continue;
                    if (hasa && hasb) {
                        if (i) {
                            dp[t+1][i-1][min(3, j+1)][k] = encode(i, j, k, 1);
                        }
                        if (j) {
                            dp[t+1][min(3, i+1)][j-1][k] = encode(i, j, k, 0);
                        }
                    }
                    if (hasa && hasc) {
                        if (i) {
                            dp[t+1][i-1][j][min(3, k+1)] = encode(i, j, k, 2);
                        }
                        if (k) {
                            dp[t+1][min(3, i+1)][j][k-1] = encode(i, j, k, 0);
                        }
                    }
                    if (hasb && hasc) {
                        if (j) {
                            dp[t+1][i][j-1][min(3, k+1)] = encode(i, j, k, 2);
                        }
                        if (k) {
                            dp[t+1][i][min(3, j+1)][k-1] = encode(i, j, k, 1);
                        }
                    }
                }
            }
        }
    }

    for (int i = 0; i < 4; i++) {
        for (int j = 0; j < 4; j++) {
            for (int k = 0; k < 4; k++) {
                if (dp[n][i][j][k] >= 0) {
                    printf("Yes\n");
                    dfsans(n, i, j, k);
                    return 0;
                }
            }
        }
    }
    printf("No\n");

    return 0;
}

Measured memory_bytes: 17840
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
constexpr double eps=1e-8;
const double pi=acos(-1);
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int Random(int mi,int ma){
    random_device rnd;
    mt19937 mt(rnd());//32bit
    //[mi,ma]
    uniform_int_distribution<int>engine(mi,ma);
    return engine(mt);
}
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
vector<int>kaijo,invkaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    invkaijo.resize(n+1);
    kaijo[0]=1;
    for(int i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
    rep(i,n+1)invkaijo[i]=modpow(kaijo[i],mod-2);
}
int comb(int a,int b){
    if(a<b)return 0;
    if(a<0||b<0)return 0;
    return kaijo[a]*invkaijo[a-b]%mod*invkaijo[b]%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
int n,x,d;
map<int,vector<P>>v;
signed main(){
    cin.tie(0);ios::sync_with_stdio(false);
    cin>>n>>x>>d;
    if(d<0){
        x=-x;
        d=-d;
    }
    if(d==0){
        if(x==0)cout<<1<<endl;
        else cout<<n+1<<endl;
        return 0;
    }
    rep(i,n+1){
        int le=i*x+(i-1)*i/2*d;
        int ri=i*x+(2*n-i-1)*i/2*d;
        v[i*x%d].pb({le,ri});
    }
    int ans=0;
    for(auto a:v){
        sort(all(a.se));
        int ma=-INF;
        for(P p:a.se){
            if(ma<p.fi)ans+=(p.se-p.fi)/d+1;
            else if(ma<p.se)ans+=(p.se-ma)/d;
            chmax(ma,p.se);
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 25400
#include <bits/stdc++.h>
typedef long long ll;
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
using namespace std;
int n, a, b , c ,d;
string s;
int dp[200005];
bool solve(int s1, int s2, int d1, int d2){
	if(dp[s1]  == 1 ||  dp[s2] == 1) return 1;
	if(dp[s1] == 0 && dp[s2] == 0) return 0;
	if(s1 == d1 && s2 == d2){
		return true;
	}
	if(s1>d1 || s2 > d2) {
      return 0;
    }
	bool f = 0;
	if(dp[s1] == -1){
		if(s[s1+1] == '.' && s1+1 != s2){
			 f = solve(s1+1,s2,d1,d2);
			if(f == true){
			       	dp[s1] = true;
				return f;
			}
		}	
		if(s[s1+2] == '.' && s1+2!= s2){
			 f = solve(s1+2,s2,d1,d2);
			if(f) {
				dp[s1] = true;
				return true;
			}
		}
	}
	if(dp[s2]  == -1){
	if(s[s2+1] == '.' && s2+1!= s1){
		 f = solve(s1,s2+1,d1,d2);
		 if(f) {
			dp[s2] = true;
			 return true;
		 }
	}
	if(s[s2+2] == '.' && s2+2!=s1){
		f = solve(s1,s2+2,d1,d2);
		if(f) {
			dp[s2] = true;
			return true;
			}
		}
	}
	dp[s1] = false; dp[s2] = false;
	return false;
}
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	for(int i = 0; i < 200005; i++) dp[i] = -1;
	cin >> n >> a  >> b >> c >> d;
	cin >> s;
	s = '.' + s;
	bool f = solve(a,b,c,d);
	if(f) cout <<"Yes\n";
	else cout <<"No\n";
	return 0;
}


Measured memory_bytes: 13456
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("YES")
#define p_no() p("NO")

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

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

const ll mod = 1e9 + 7;
const ll inf = 1e18;

ll K, A, B;

// n回変換できるか
bool can_make(ll n){
    // 2, 3の変換をn回
    // たたける回数 K - 2*n

    ll hit = K - 2*n;
    ll cookie = 1 + hit;

    ll max_convert = cookie / A;

    if(max_convert >= n){
        // たたける
        return true;
    }else{
        return false;
    }
}

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

    // input
    cin >> K >> A >> B;

    // 交換が得ではない
    if(B-A <= 2){
        p(K+1);
        return 0;
    }

    // K-2回たたいても変換できない
    if(K-1 < A){
        p(K+1);
        return 0;
    }

    // Aまでたたく
    ll hit = A - 1;
    
    // 行動回数
    ll rest = K - hit;

    // 変換回数
    ll convert_num = rest / 2;
    //pn(convert_num);

    ll simple_cookie = K-2*convert_num + 1;
    ll cookie = (B-A) * convert_num + simple_cookie;

    p(cookie);

    // // n=1回は変換できる
    // // では何回か？
    // // nに関して単調増加
    // ll left = 1;
    // ll right = K;
    // while(left+1 != right){
    //     ll center = (left + right) / 2;
    //     if(can_make(center)){
    //         left = center;
    //     }else{
    //         right = center;
    //     }
    // }

    // // 変換回数
    // ll convert_num = left;
    // pn(convert_num);

    // ll hit = K - 2*convert_num;
    // ll cookie = 1 + hit;

    // cookie -= A * convert_num;
    // cookie += B*convert_num;

    // p(cookie);
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define ALL(c) (c).begin(), (c).end()

typedef int64_t ll;
#define REP(i, n) for(auto i = 0 * (n); i < (n); ++i)
#define FOR(i, s, n) for(size_t i = (s); i < (n); ++i)

typedef vector<ll> Vector;
typedef vector<Vector> Matrix;
struct GaussJordan {
	typedef size_t T;
	GaussJordan(Matrix mat, T m) : x(move(mat)) {
		T row = x.size(), col = x[0].size(), r = 0;
		REP(c, col) {
			T p = r;
			FOR(i, r, row) if (abs(x[i][c]) > abs(x[p][c])) p = i;
			swap(x[r], x[p]);
			if (x[r][c]) {
				if (c == col - 1) impossible = 1; // ??????????????????????????????????????????
				det = det * x[r][c] % m; // ??????????????????????????????????????????
				//FOR(j, c + 1, col) x[r][j] = x[r][j] * inverse(x[r][c], m) % m;
				FOR(j, c + 1, col) x[r][j] = x[r][j] * x[r][c];
				x[r][c] = 1;
				REP(i, row) if (r != i) {
					//FOR(j, c + 1, col) x[i][j] = (x[i][j] - x[i][c] * x[r][j] % m + m) % m;
					FOR(j, c + 1, col) x[i][j] ^= x[i][c] * x[r][j];
					x[i][c] = 0;
				}
                if (++r == row) break;
			}
		}
        rank = r;
	}
	Matrix x;
	T rank;
	ll det = 1;  // mat ?????£??????????????? full rank ?????¨???????????????
	bool impossible = 0; // ?????¢????¬?????¨????????§£??????????????´???????????????????§£????????? <-> true
};

GaussJordan linear_equations(Matrix A, const Vector & b, size_t m) {
	REP(i, A.size()) A[i].push_back(b[i]);
    return GaussJordan(move(A), m);
}

bool ba[30][30];

int main() {
#ifdef INPUT_FROM_FILE
	ifstream cin("sample.in");
	ofstream cout("sample.out");
#endif
	cin.tie(0);
	ios::sync_with_stdio(0);
	int m, n, d;
	while (cin >> m >> n >> d, m || n || d) {
		Matrix A(n * m, Vector(n * m));
		Vector b(n * m);
		REP(i, n) {
			REP(j, m) {
				cin >> ba[i][j];
				A[i * m + j][i * m + j] = 1;
				REP(k, n) {
					REP(l, m) {
						int dis = abs(i - k) + abs(j - l);
						if (dis == d) {
							A[k * m + l][i * m + j] = 1;
						}
					}
				}
				b[i * m + j] = ba[i][j];
			}
		}
		cout << (linear_equations(move(A), b, 2).impossible ? 0 : 1) << endl;
	}
}

Measured memory_bytes: 8536
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>a
#define pb push_back
#define sz(x) int(x.size())

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

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

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

class UnionFind{
  public:
  vi Parent;
  UnionFind(int n){
    Parent = vi(n,-1);
  }

  int root(int a){
    if(Parent[a] < 0) return a;
    else return Parent[a] = root(Parent[a]);
  }

  int size(int a){
    return -Parent[root(a)];
  }

  bool merge(int a, int b){
    a = root(a);
    b = root(b);
    if(a == b) return false;

    if(size(a) < size(b)) swap(a,b);
    Parent[a] += Parent[b];
    Parent[b] = a;

    return true;
  }
};

class Factrial{
  public:
  vl Fac;
  Factrial(int MAX){
    Fac = vl(MAX+1);
    rep(i,MAX) {
      if(i == 0) Fac[i+1] = 1;
      else Fac[i+1] = ((i+1)*Fac[i])%MOD;
    }
  }
};


int main(){
  int n; cin >> n;
  vi a(n);
  rep(i, n) cin >> a[i];
  
  map<int,int> C;
  vector<pii> ai(n);
  rep(i,n) ai[i] = mp(a[i],i);
  sort(all(ai));
  rep(i,n) {
    C[ai[i].first] = i;
  }

  int cnt = 0;
  rep(i,n) {
    int ideal = C[a[i]];
    if(i%2 != ideal%2) cnt++;
  }

  cout << cnt/2 << endl;
}

Measured memory_bytes: 6144
import java.util.*;
import java.io.*;
public class Main
{
    public static void main(String args[])throws Exception
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw=new PrintWriter(System.out);
        String s=br.readLine();
        if(s.charAt(2)==s.charAt(3)&&s.charAt(5)==s.charAt(4))
        pw.println("Yes");
        else
        pw.println("No");
        pw.flush();
        pw.close();
    }
}

Measured memory_bytes: 23124
object Scanner {
  private val buf = new Array[Byte](1024); private var ptr = 0; private var len = 0
  @inline private def isPrintableChar(c: Int): Boolean = 33 <= c && c <= 126
  @inline private def hasNextByte(): Boolean =
    if (ptr >= len) { ptr = 0; len = System.in.read(buf); len > 0 } else { true }
  @inline private def hasNext(): Boolean = {
    while (hasNextByte() && !isPrintableChar(buf(ptr))) ptr += 1
    hasNextByte()
  }
  @inline private def readByte(): Byte =
    if (hasNextByte()) { val res = buf(ptr); ptr += 1; res } else { -1 }
  def next(): String = {
    if(!hasNext()) ???
    val sb = new StringBuilder; var b = readByte()
    while (isPrintableChar(b)) { sb.append(b.toChar); b = readByte() }
    sb.toString
  }
  def nextInt(): Int = {
    val n = nextLong()
    if (n < Int.MinValue || Int.MaxValue < n) ???
    n.toInt
  }
  def nextLong(): Long = {
    if(!hasNext()) ???
    var minus = false; var b = readByte()
    if (b == '-') { minus = true; b = readByte() }
    def go (b: Byte, n: Long = 0): Long =
      if ('0' <= b && b <= '9') { go(readByte(), n * 10 + b - '0') }
      else if (minus) { -n } else { n }
    go(b)
  }
  def nextDouble(): Double = next.toDouble
}

object Main extends App{
  val a,b,c,k = Scanner.nextInt()
  val array = Array(a,b,c).sorted
  val doubled = array.last * scala.math.pow(2,k).toInt
  println(doubled+array.init.sum)
}

Measured memory_bytes: 25560
#include<iostream>
#include<algorithm>
using namespace std;int*t,n,m,d,i,s[99999];main(){for(;cin>>d>>n>>m,s[i=n]=d;cout<<i<<'\n'){for(;--i;)cin>>s[i];for(sort(s,s+n);m--;t=upper_bound(s,s+n,d),i+=min(d-*--t,*t-d))cin>>d;}}

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

typedef long long int ll;
typedef string str;

int main ()
{
	// ios::sync_with_stdio(0);
 //    cin.tie(0);
 //    cout.tie(0);
	ll t,n,m,k,i,a,b,j;
	cin >> a >> b;
	ll ans=-1;
	for(i=b*10;i<=b*10+9;i++)
	{
		if((i*8)/100==a)
		{
			ans=i;
			break;
		}
	}
	cout << ans <<  "\n";
	return 0;
}

Measured memory_bytes: 256
import std.stdio;
import std.algorithm;

void main(){
    int n,res,m;
    int[] R = new int[200000];
    readf("%d\n",&n);
    for(int i=0;i<n;i++){
	readf("%d\n",&R[i]);
    }

    m = 2000000000;
    res = -2000000000;
    for(int i=0;i<n-1;i++){
	m = min(m,R[i]);
	res = max(R[i+1] - m,res);
    }
    writeln(res);
}
	

Measured memory_bytes: 3224
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // input
        Scanner sc = new Scanner(System.in);
        long h = sc.nextLong();
        long w = sc.nextLong();
        if (h == 1 || w == 1) {
            System.out.println(1);
        } else {
            long ans = h * w / 2;
            if (h * w % 2 == 1) {
                ans++;
            }
            System.out.println(ans);
        }
    }
}

Measured memory_bytes: 21588
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
#define ALL(X) X.begin(), X.end()
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef std::pair<LL,LL> PLL;//
typedef std::pair<int,int> PII;//
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)1e18+20;
const LD PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	int H,W;
	cin >> H >> W;
	vector< vector<int> > fld(H,vector<int>(W) );
	vector<int> hist(26,0);
	for(int h=0;h<H;++h){
		string str;
		cin >> str;
		for(int w=0;w<W;++w){
			fld[h][w] = str[w]-'a';
			hist[ fld[h][w] ]++;
		}
	}
	//////////////
	int P1=0;
	int P2=0;
	int P4=0;
	for(int i=0;i<26;++i){
		int res = hist[i];
		P4 += res/4;
		res %= 4;
		P2 += res/2;
		res %= 2;
		P1 += res;
	}
	bool flag = false;
	if( H%2 == 0 && W%2 == 0 ){
		if( P1 == 0 && P2 == 0 ){
			flag = true;
		}
	}else if( H%2 == 1 && W%2 == 1 ){
		if( P1 == 1 && P2 <= (H/2)+(W/2) ){
			flag = true;
		}
	}else{
		int res;
		if( H%2 == 0 ){//Hが偶数
			res = H/2;
		}else{
			res = W/2;
		}
		if(P1 == 0 && P2 <= res ){
			flag = true;
		}
	}

	if(flag ){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<stdio.h>
#include<time.h>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<deque>
#include<set>
#include<map>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define FOR(i, a, b) for(ll i = a; i < b; ++i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int qx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
int qy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

int main(void) {while(true) {int H, W;cin>>H>>W;if(H==0&&W==0)break;REP(i, H) {REP(j, W)cout<<'#';cout<<endl;}cout<<endl;}}

Measured memory_bytes: 3048
import java.io.*;
import java.util.*;
import java.math.BigInteger;
public class Main {

static long[] list=new long[87];

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

  // String nyuA=sc.nextLine();
 //  String nyuB=sc.nextLine();
 
   String[] s=sc.nextLine().split(" ");
 //    String[] t=sc.nextLine().split("");

int N=Integer.parseInt(s[0]);
int A=Integer.parseInt(s[1]);
int B=Integer.parseInt(s[2]);

long C=0;

for(int i=1;i<=N;i++){
String temp=""+i;
String[] tem=temp.split("");
int hekaku=0;
for(int j=0;j<tem.length;j++){
hekaku+=Integer.parseInt(tem[j]);
}//for
if(A<=hekaku && hekaku<=B){
C+=i;
}
}//for

System.out.println(C);



}

}



Measured memory_bytes: 35028
#include <bits/stdc++.h>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define DEBUG
#define PI 3.141592653589793238462643383279
 
#define _GLIBCXX_DEBUG
#ifdef DEBUG
#define s(...) show(__VA_ARGS__);
#define sl(...) show(__VA_ARGS__);cout<<endl;
#else
#define s(...)
#define sl(...)
#endif
void show() {}
template <class Head,class... Args>void show(Head t,Args... args){std::cout<<t<<" ";show(args...);}
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define REP1(i, n) for(ll i = 1; i <= n; i++)
#define REPR1(i, n) for(ll i = n; i >= 1; i--)
#define FOR1(i, m, n) for(ll i = m; i <= n; i++)
const ll INF = LLONG_MAX;
const ull MOD = 1000000007;
#define VEC(type,A,N) vector<type> A(N)
#define VECi(type,A,N,i) vector<type> A(N,i)
#define VEC2(type,A,N,M) vector<vector<type>> A(N,vector<type>(M))
#define VEC2i(type,A,N,M,i) vector<vector<type>> A(N,vector<type>(M,i))
#define ALL(v) v.begin(), v.end()
ll frac(ll k){
    int s = 1;
    for (ll i=1; i<=k; ++i)s *= i;
    return s;
}
ll gcd(ll a, ll b){
   if (a%b==0)return(b);
   else return(gcd(b, a%b));
}
ll lcm(ll a,ll b){
    return a*b/gcd(a,b);
}
ll antidiv(ll N,ll C,ll D){
    return N-floor(N/C)-floor(N/D)+floor(N/lcm(C,D));
}
vector<ll> yakusuu(ll N){
    vector<ll> ret;
    for (ll i = 1; i * i <= N; i++) {
        if (N % i == 0) {
            ret.push_back(i);
            if (i * i != N) ret.push_back(N / i);
        }
    }
    sort(ret.begin(), ret.end());
    return ret;
}
int main(){
    string S;
    ll Q;
    cin>>S>>Q;
    
    bool rev=false;
    string a="",b="";
    REP(i,Q){
        ll t;
        cin>>t;
        if(t==1){
            rev=!rev;
        }else{
            ll f;
            char c;
            cin>>f>>c;
            if(f==1){
                if(!rev){
                    b+=c;
                }else{
                    a+=c;
                }
            }else{
                if(!rev){
                    a+=c;
                }else{
                    b+=c;
                }
            }
        }
        
    }
    if(!rev){
        reverse(ALL(b));
        cout<<b+S+a;
    }else{
        reverse(ALL(S));
        reverse(ALL(a));
        cout<<a+S+b;
    }
    //cout<<fixed<<setprecision(32)<<m;
    //sort(ALL(C),[](auto& a, auto& b) {return a[2] < b[2];});
    //if(equal(D.begin(), D.end()-1, K.begin()))cout<<"Yes";else cout<<"No";
    cout<<endl;
    return 0;
}


Measured memory_bytes: 1348
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int[] arr = new int[a];
		for(int i = 0; i < a; i++){
			arr[i] = sc.nextInt();
		}
		
		int sum = 0;
		for(int i = 0; i < a - 1; i++){
			for(int j = i + 1; j < a; j++){
				sum += arr[i] * arr[j];
			}
		}
		System.out.println(sum);
	}

	}

Measured memory_bytes: 21972
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	// AtCoder Beginner Contest 114
	// https://atcoder.jp/contests/abc114/tasks
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		String s = sc.next();
		int res = Integer.MAX_VALUE;
		for (int i = 0; i < s.length() - 3 + 1; i++) {
			int curr = ((s.charAt(i) - '0') * 100 + (s.charAt(i+1) - '0') * 10 + (s.charAt(i+2) - '0'));
			res = Math.min(res, Math.abs(curr - 753));
		}
		System.out.println(res);
	}
	
	static class FastReader { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() { 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next() { 
            while (st == null || !st.hasMoreElements()) { 
                try { 
                    st = new StringTokenizer(br.readLine()); 
                } catch (IOException  e) { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() { 
            String str = ""; 
            try{ 
                str = br.readLine(); 
            } catch (IOException e) { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
}


Measured memory_bytes: 22868
fun main(args:Array<String>?): Unit {
    val teamName = arrayOf("NS", "EW")
    while(true){
        val header = readLine()!!.trim()
        if (header == "#") return
        val trump = header.first().asSuit()
        val  players = Array(4){
            readLine()!!.trim().split(' ').map{Card(it)}
        }
        val winCount = IntArray(2){0}
        var prevWinner = 0
        for (i in 0 until 13) {
            prevWinner = players.indices.filter{players[it][i].suit == trump}.maxBy{players[it][i].number} ?: players.indices.filter{players[it][i].suit == players[prevWinner][i].suit}.maxBy{players[it][i].number}!!
            winCount[prevWinner % 2]++
        }
        println(
                winCount.indices.maxBy(winCount::get)?.let{"${teamName[it]} ${winCount[it] - 6}"}
        )
    }
}
enum class Suit {
    Clover, Diamond, Heart, Spade
}
sealed class CardNumber: Comparable<CardNumber> {
    protected abstract val value: Int
    private fun asRank(): Int = (value + 11) % 13
    override fun compareTo(other: CardNumber): Int {
        return asRank().compareTo(other.asRank())
    }
    data class Number(override val value: Int): CardNumber()
    data class Sign(override val value: Int): CardNumber()
}
fun Char.asSuit(): Suit {
    return when(this){
        'C' -> Suit.Clover
        'D' -> Suit.Diamond
        'H' -> Suit.Heart
        'S' -> Suit.Spade
        else -> TODO()
    }
}
fun Char.asCardNumber(): CardNumber {
    return if (isDigit()) CardNumber.Number(this - '0') else CardNumber.Sign(when (this) {
        'T' -> 10
        'J' -> 11
        'Q' -> 12
        'K' -> 13
        'A' -> 1
        else -> TODO()
    })
}
data class Card(val number: CardNumber, val suit: Suit) {
    constructor(expression: String):this(expression[0].asCardNumber(), expression[1].asSuit())
}


Measured memory_bytes: 33456
#118
k, m = map(int, input().split())
l = [0] * m

for i in range(k):
    a = list(map(int, input().split()))
    for j in range(1,a[0]+1):
        l[a[j]-1] += 1

ans = 0
for i in range(m):
    if(l[i]==k):
        ans += 1
print(ans)


Measured memory_bytes: 3060