akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
const long long mod = pow(10, 9) + 7;
const long long MOD = 998244353;
const long long INF = 1LL << 60;
const int inf = pow(10, 9) + 7;
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, int B) {return (A + (B - 1)) / B;}
long long divCeil(int A, long long B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, long long B) {return (A + (B - 1)) / B;}

int myGCD(int A, int B)
{
  int a = A, b = B;
  while (a * b != 0  &&  a != 1  &&  b != 1)
  {
    if (a < b) b %= a;
    else a %= b;
  }
  if (a * b == 0) return max(a, b);
  else return 1;
}

int main()
{
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  
  vector<int> L(N + 1), R(N + 1);
  L.at(0) = 0;
  L.at(1) = A.at(0);
  //cout << L.at(0) << " " << L.at(1) << " ";
  for (int i = 2; i < N + 1; i++)
  {
    L.at(i) = myGCD(L.at(i - 1), A.at(i - 1));
    //cout << L.at(i) << " ";
  }
  //cout << endl;
  R.at(0) = 0;
  R.at(1) = A.at(N - 1);
  //cout << R.at(0) << " " << R.at(1) << " ";
  for (int i = 2; i < N + 1; i++)
  {
    R.at(i) = myGCD(R.at(i - 1), A.at(N - i));
    //cout << R.at(i) << " ";
  }
  //cout << endl;
  
  int ans = 1;
  for (int i = 0; i < N; i++)
  {
    chmax(ans, myGCD(L.at(i), R.at(N - i - 1)));
    //cout << myGCD(L.at(i), R.at(N - i - 1)) << " ";
  }
  //cout << endl;
  
  cout << ans << endl;
}

Measured memory_bytes: 1408
import numpy as np
import copy
from itertools import product
h, w, k = map(int, input().split())
C = [list(input()) for _ in range(h)]
C = np.array(C)

cnt = 0
# 行と列を分けて考えるとループが入り組むので
# 行も列も一緒くたにproductで生成してループひとつで済ませる
for p in product([True, False], repeat=(h+w)):
    c = copy.deepcopy(C)
    c = np.array(c)
    for i, v in enumerate(p):
        if i < h and v:
            c[i, :] = "$"
        elif v:
            c[:, i - h] = "$"
    if np.count_nonzero(c == "#") == k:
        cnt += 1

print(cnt)

Measured memory_bytes: 27156
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long

using namespace std;

int main(){

    string S;cin>>S;

    char before=S[0];

    int ans;
    REP(i,S.size()){
        if(S[i]!=before)ans++;
        before =S[i];
    }
    cout<<ans<<endl;

    return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf = (int)1e9;
const double INF = 1e12, EPS = 1e-9;


const bool chs[5][13][3] ={
	{
		{1, 1, 1},
		{1, 0, 0},
		{1, 1, 1},
		{1, 1, 1},
		{1, 0, 1},
		{1, 1, 1},
		{1, 1, 1},
		{1, 1, 1},
		{1, 1, 1},
		{1, 1, 1},
		{0, 1, 0},//
		{1, 1, 1},
		{1, 0, 0},
	},
	{
		{1, 0, 1},
		{1, 0, 0},
		{0, 0, 1},
		{0, 0, 1},
		{1, 0, 1},
		{1, 0, 0},
		{1, 0, 0},
		{0, 0, 1},
		{1, 0, 1},
		{1, 0, 1},
		{1, 1, 1},//
		{0, 0, 0},
		{0, 0, 0},
	},
	{
		{1, 0, 1},
		{1, 0, 0},
		{1, 1, 1},
		{1, 1, 1},
		{1, 1, 1},
		{1, 1, 1},
		{1, 1, 1},
		{0, 0, 1},
		{1, 1, 1},
		{1, 1, 1},
		{0, 1, 0},//
		{0, 0, 0},
		{0, 0, 0},
	},
	{
		{1, 0, 1},
		{1, 0, 0},
		{1, 0, 0},
		{0, 0, 1},
		{0, 0, 1},
		{0, 0, 1},
		{1, 0, 1},
		{0, 0, 1},
		{1, 0, 1},
		{0, 0, 1},
		{0, 0, 0},//
		{0, 0, 0},
		{0, 0, 0},
	},
	{
		{1, 1, 1},
		{1, 0, 0},
		{1, 1, 1},
		{1, 1, 1},
		{0, 0, 1},
		{1, 1, 1},
		{1, 1, 1},
		{0, 0, 1},
		{1, 1, 1},
		{1, 1, 1},
		{0, 0, 0},//
		{0, 0, 0},
		{0, 0, 0},
	},
};


const int h = 300, w = 300;
int n;
bool a[300][300], v[300][300], b[5][4];

void dfs(int y, int x, int i = 0, int j = 1){
	const int dy[] = {-1, 0, 1, 0}, dx[] = {0, -1, 0, 1};
	
	v[y][x] = 1;
	b[i][j] = 1;
	
	rep(d, 4){
		int ny = y + dy[d], nx = x + dx[d];
		
		if(ny < 0 || ny >= h || nx < 0 || nx >= w) continue;
		if(!a[ny][nx] || v[ny][nx]) continue;
		
		dfs(ny, nx, i + dy[d], j + dx[d]);
	}
}

bool ok(int d){
	
	rep(i, 5) rep(j, 3){
		
		if(chs[i][d][j] != b[i][j + (d != 10)]) return 0;
	}
	return 1;
}

string s;
int p;

int number(){
	int res = 0;
	while(p < s.size() && isdigit(s[p])) res *= 10, res += s[p++] - '0';
	return res;
}
int term(){
	int res = 1;
	
	while(1){
		int n = number();
		res *= n;
		if(p >= s.size() || s[p] != '.') break;
		p++;
	}
	return res;
}
int expr(){
	int res = 0;
	bool mi = 0;
	
	while(1){
		int n = term();
		
		if(mi) res -= n;
		else res += n;
		
		if(p >= s.size()) break;
		mi = s[p++] == '-';
	}
	return res;
}



int main(){
	cin >> n;
	rep(i, n){
		int x, y, X, Y;
		cin >> x >> y >> X >> Y;
		
		if(x > X) swap(x, X);
		if(y > Y) swap(y, Y);
		
		if(x == X) for(int i = y; i <= Y; i++) a[i][x] = 1;
		else for(int i = x; i <= X; i++) a[y][i] = 1;
	}
	
	vector<pair<int, char> > cs;
	
	rep(i, h) rep(j, w) if(!v[i][j] && a[i][j]){
		
		//cerr<<"i: "<<i<<" j: "<<j<<endl;
		
		memset(b, 0, sizeof(b));
		dfs(i, j);
		
		rep(k, 13) if(ok(k)){
			cs.pb(mp(j, "0123456789+-."[k]));
			break;
		}
	}
	
	sort(all(cs));
	rep(i, cs.size()) s += cs[i].second;
	
	//dbg(s);
	cout << expr() << endl;
	
	return 0;
}


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

int main(){
    int N, M, ans = 0;
    cin >> N >> M;
    vector<int> k(M+1);
    vector<int> p(M+1);
    vector<vector<int>> s(M+1, vector<int>());
    for(int i = 1; i <= M; ++i){
        cin >> k[i];
        s[i].resize(k[i]+1);
        for(int j = 1; j <= k[i]; ++j) cin >> s[i][j];
    }
    for(int i = 1; i <= M; ++i) cin >> p[i];
    for(int i = 0; i < pow(2,N); ++i){
        vector<int> buf(M+1, false);
        vector<bool> tmp(N+1, false);
        int flag = 1;
        for(int j = 0; j < N; ++j){
            if((i >> j) & 1) tmp[j+1] = true;
        }
        for(int j = 1; j <= M; ++j){
            for(int l = 1; l <= k[j]; ++l){
                if(tmp[s[j][l]]) ++buf[j];
            }
            if(buf[j] % 2 != p[j]){
                flag = 0;
                break;
            }
        }
        if(flag) ++ans;
    }
    cout << ans << endl;
    return 0;
}

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

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int (i)=(a);(i)<(b);++(i))
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cout<<#x<<"="<<(x)<<endl;
#define DBG(v) REP(i, LEN((v))) cout<<(v)[i]<<(i==LEN((v))-1 ? '\n' : ' ')
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
typedef vector<int> vi;
typedef vector<lint> vl;
typedef vector<vector<int>> vii;
typedef vector<vector<lint>> vll;

class EStringsOfImpurity {
public:
    int N, M;
    string S, T;
    vii C;

    void input(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in>>S>>T;
        N = LEN(S), M = LEN(T);
        C = vii(26, vi());
    }

    void solve(std::istream& in, std::ostream& out) {
        input(in, out);
        REP(i, N){
            C[S[i]-'a'].pb(i);
        }
        int t = 0, cur = -1;
        REP(i, M){
            int d = T[i] - 'a';
            if(C[d].empty()) {out<<"-1\n"; return;}
            int idx = distance(C[d].begin(), upper_bound(ALL(C[d]), cur));
            if(idx==LEN(C[d])) t++, idx = 0;
            cur = C[d][idx];
        }
        out<<1LL*t*N+cur+1<<'\n';
    }
};


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


Measured memory_bytes: 1228
// In the name of God

#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>

using namespace std;

#define rep(i, n) for (int i = 0, _n = (int)(n); i < _n; ++i)
#define int long long
const int N = 2005, M = N * N, mod = (int) 1e9 + 7;
int pw(int a, int b) { return b != 0? pw(a * a % mod, b >> 1) * (b & 1? a: 1) % mod: 1; }
int ft[M], fi[M];
int dp[N][N];

int comb(int n, int r) {
    if (r < 0 || n < 0 || n - r < 0) return 0;
    return ft[n] * fi[r] % mod * fi[n - r] % mod;
}
void sadd(int &x, int y) {
    x += y;
    x %= mod;
}

int32_t main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ft[0] = fi[0] = 1;
    for (int i = 1; i < M; ++i)
        ft[i] = ft[i - 1] * i % mod;
    fi[M - 1] = pw(ft[M - 1], mod - 2);
    for (int i = M - 2; i >= 0; --i)
        fi[i] = fi[i + 1] * (i + 1) % mod;
    int n, k;
    cin >> n >> k;
    if (k == 1) {
        cout << 1 << endl;
        return 0;
    }
    /*
    if (k == 2) {
        cout << (mod + comb(n + n, n) - comb(n + n, n + 1)) % mod;
        return 0;
    } */
    dp[0][0] = 1;
    for (int p1 = 0; p1 <= n; ++p1)
        for (int p0 = 0; p0 <= p1; ++p0) {
            if (p1) {
                int g = p0 * k + (p1 - p0 - 1) * (k - 1);
                sadd(dp[p1][p0], dp[p1 - 1][p0] * comb(g + 1 + k - 2 - 1, g) % mod);
            }
            if (p0) {
                sadd(dp[p1][p0], dp[p1][p0 - 1]);
            }
        }
    cout << dp[n][n] * ft[n] % mod << endl;
}








Measured memory_bytes: 85760
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define pb push_back

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

struct BIT {
private:
	vector<ll> node; int n;
public:
	BIT(int n_) {
		n = n_; node.assign(n + 1, 0);
	}
	void add(int i, ll x) {
		while(i <= n) {
			node[i] += x;
			i += i & -i;
		}
	}
	ll sum(int i) {
		ll ret = 0;
		while(i > 0) {
			ret += node[i];
			i -= i & -i;
		}
		return ret;
	}
    ll sum(int a, int b) {
        return sum(b) - sum(a - 1);
    }
};

struct query {
    int id; ll a, b;
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int Q; cin >> Q;
  vector<query> v(Q);
  vector<ll> x;
  rep(i, Q) {
      cin >> v[i].id;
      if(v[i].id == 1) {
          cin >> v[i].a >> v[i].b;
          x.push_back(v[i].a);
      }
  }
  sort(x.begin(), x.end());
  x.erase(unique(x.begin(), x.end()), x.end());
  map<ll, int> mp;
  rep(i, x.size()) mp[x[i]] = i + 1;

  BIT num(x.size()), b(x.size());
  ll bsum = 0; int len = 0;

  rep(i, Q) {
      if(v[i].id == 2) {
          int l = 0, r = x.size() + 1;
          while(r - l > 1) {
              int mid = (l + r) / 2;
              if(num.sum(mid) <= (len - 1) / 2) l = mid;
              else r = mid;
          }
          ll lsum = b.sum(l + 1), rsum = b.sum(l + 2, x.size());
          int lnum = num.sum(l + 1), rnum = num.sum(l + 2, x.size());
          ll sum = bsum + rsum - lsum + x[l] * (lnum - rnum);
          cout << x[l] << " " << sum << "\n";
      } else {
          len ++;
          bsum += v[i].b;
          num.add(mp[v[i].a], 1);
          b.add(mp[v[i].a], v[i].a);
      }
  }
  return 0;
}

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

int main() {
    int n;
    cin >> n;
    ll mod = 1e9 + 7;
    ll ans = 1;
    for (int i = 1; i <= n; i++) {
        ans *= i;
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}

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

int main(void) {
    string search,target;
    cin>>target;
    int ans=0;
    while(cin>>search) {
        if(search=="END_OF_TEXT") break;
        transform(search.begin(),search.end(),search.begin(),::toupper);
        transform(target.begin(),target.end(),target.begin(),::toupper);
        if(search==target) {
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3228
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s, t;
  cin>>s>>t;
  int cnt = 0;
  for(int i = 0; i< 3; i++) if(s[i] == t[i]) cnt++;
  cout<<cnt<<'\n';
  return 0;
}

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

public class Main {
	private static void solve(){
		//Implement solution here.
		int n = ni();
		int result = (int)Math.pow(n, 3);
		System.out.println(result);
	}

	//Switch input source (stdin/file)
	private static BufferedReader br  = new BufferedReader(new InputStreamReader(System.in));
	public static void main(String[] args){
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		solve();
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}


Measured memory_bytes: 22484
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind 
#define Pint pair<int,int>
#define Pll pair<llint,llint>
#define keta(a)  fixed << setprecision(a)
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
const llint INF = 100000000;

struct edge { int to, cost; };
int main() {
	llint n, k;
	cin >> n >> k;
	hei(llint) a(n);
	rep(i,0,n)cin >> a[i];
	llint left = 0;
	llint right = 10000000000;
	while (right - left > 1) {
		llint mid = left + (right - left) / 2;
		llint cnt = 0;
		rep(i, 0, n) {
			cnt += (a[i] + mid - 1) / mid;
			cnt--;
		}
		if (k >= cnt)right = mid;
		else left = mid;
	}
	cout << right << endl;
	return 0;
}


Measured memory_bytes: 4820
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// #include <ext/pb_ds/detail/standard_policies.hpp>
// using namespace __gnu_pdbs;
using namespace std;

// typedef tree<int, null_type, less<int>, rb_tree_tag,  
//             tree_order_statistics_node_update>  
//     ordered_set;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define mt make_tuple
#define eb emplace_back
#define sf(x) sizeof(x)
#define len(x) x.length()
#define sz(x) x.size()
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

#define LB(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define UB(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef vector<ld> vd;
typedef unsigned long long ull;
typedef tuple<int,int,int> State;

ll mod = 1e9 + 7;

#define citc(tc) int tc; cin>>tc; while(tc--) 
#define each(a,x) for( auto &a:(x))
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rep2(i, l, r) for (ll i = (l); i < (r); i++)
#define rep2r(i, l, r) for (ll i = (r) - 1; i >= (l); i--)
#define range(a) a.begin(), a.end()
#define deb(x) cout<<#x<<" "<<x<<endl;
#define cini(i) int i; cin>>i;
#define cinll(l) ll l; cin>>l;
#define cinll2(l, z) ll l, z; cin>>l>>z;
#define cinll3(l, z, x) ll l, z, x; cin>>l>>z>>x;
#define cinai(a, n) vi a(n); rep(i, n) { cin>>a[i]; }
#define cinal(a, n) vd a(n); rep(i, n) { cin>>a[i]; }
#define coutai(a, n) rep(i, n) { cout<<a[i]<<" "; } ent;
#define coutal(a, n) rep(i, n) { cout<<a[i]<<" "; } ent;
#define ent cout<<endl;

ll powm(ll a, ll b, ll mod) {
	ll res=1;
	while(b) {
		if(b&1)
			res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}

void solve()
{
	ll n;
	ld m;
	cin>>n>>m;
	cinal(a, n);
	ll ma = (ll)m;
	ld sum = 0, cnt = 0;
	rep(i, n)
		sum += a[i];
	rep(i, n)
	{
		if(a[i]/sum >= (1/(4*m)))
		{
			cnt++;
		}
	}
	if(cnt >= m)	
		cout<<"Yes\n";
	else
		cout<<"No\n";
}
int main()
{
	fastio();
	// citc(tc)
		solve();
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
 
using namespace std;
 
int main(void){

  int n;
  long long sum = 0;
  cin >> n;
  
  for(int i = 1; i <= n; i++){
   if(i % 3 == 0);
   else if(i % 5 == 0);
   else sum += i;
  }

  cout << sum;
  return 0;
}

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

vector<int> forintinput(int n) {
	vector<int> x(100000);
	for(int i = 0;i < n;i++) cin >> x[i];
	return x;
}
int main(){
	string s,t;
	int a,b;
	string u;
	cin >> s >> t >> a >> b >> u;
	if(u == s){
		cout << a-1 << ' ' << b << endl;
	}else{
		cout << a << ' ' << b-1 << endl;
	}
}

Measured memory_bytes: 3628
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#define SIZE 200005
#define INF 100000000000000000LL

using namespace std;
typedef long long int ll;
typedef pair <ll,int> P;

vector <ll> vec[SIZE];
ll mx[SIZE];
ll ans[SIZE];

int main()
{
	int n,m;
	scanf("%d %d",&n,&m);
	for(int i=0;i<n;i++)
	{
		int c,v;
		scanf("%d %d",&c,&v);c--;
		vec[c].push_back(v);
	}
	vector <P> vx;
	for(int i=0;i<m;i++)
	{
		sort(vec[i].begin(),vec[i].end(),greater <ll>());
		vx.push_back(P(vec[i][0]+vec[i][1],i));
	}
	sort(vx.begin(),vx.end(),greater <P>());
	for(int i=m-1;i>=0;i--)
	{
		int t=vx[i].second;
		mx[i]=-INF;
		if(vec[t].size()>=3) mx[i]=vec[t][0]+vec[t][1]+vec[t][2];
		if(i+1<m) mx[i]=max(mx[i],mx[i+1]);
	}
	priority_queue <ll> que;
	int to=0,cnt=0;
	ll sum=0,last=INF;
	for(int i=1;i<=n;i++) ans[i]=-INF;
	while(1)
	{
		if(last<INF)
		{
			sum-=last;
			que.push(last);
			last=que.top();
			sum+=last;
			que.pop();
			ans[cnt]=max(ans[cnt],sum);
		}
		if(que.size()>0) ans[cnt+1]=max(ans[cnt+1],sum+que.top());
		if(to<m) ans[cnt+3]=max(ans[cnt+3],sum+mx[to]);
		if(que.size()>0&&to<m)
		{
			ans[cnt+3]=max(ans[cnt+3],sum+que.top()+vx[to].first);
			ans[cnt+4]=max(ans[cnt+4],sum+mx[to]+que.top());
		}
		if(last<INF)
		{
			ans[cnt-1]=max(ans[cnt-1],sum-last);
			if(to<m) ans[cnt+2]=max(ans[cnt+2],sum-last+mx[to]);
		}
		if(que.size()<2)
		{
			if(to==m) break;
			int t=vx[to++].second;
			sum+=vec[t][0]+vec[t][1];
			for(int i=2;i<vec[t].size();i++) que.push(vec[t][i]);
		}
		else
		{
			ll a=que.top();que.pop();
			ll b=que.top();que.pop();
			if(to==m||a+b>vx[to].first)
			{
				sum+=a+b;
				last=min(last,b);
			}
			else
			{
				que.push(a);que.push(b);
				int t=vx[to++].second;
				sum+=vec[t][0]+vec[t][1];
				for(int i=2;i<vec[t].size();i++) que.push(vec[t][i]);
			}
		}
		cnt+=2;
		ans[cnt]=max(ans[cnt],sum);
	}
	for(int i=1;i<=n;i++)
	{
		if(ans[i]<0) puts("-1");
		else printf("%lld\n",ans[i]);
	}
	return 0;
}


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

using namespace std;

int gcd(int x, int y) {
		if ( x < y ) swap(x, y);
		if ( y == 0 ) return x;
		return gcd(x % y, y);
}

int main() {
		int N;
		cin >> N;
		int A[N];
		for ( int i = 0; i < N; i++ ) cin >> A[i];

		vector<int> L(N, 0), R(N, 0);
		L[0] = A[0];
		R[0] = A[N - 1];
		for ( int i = 0; i < N - 1; i++ ) {
				L[i + 1] = gcd(L[i], A[i + 1]);
		}

		for ( int i = 0; i < N - 1; i++ ) { 
				R[i + 1] = gcd(R[i], A[(N - 2) - i]);
		}

		int ans = 0;
		for ( int erase_e = 0; erase_e < N; erase_e++ ) {
				int t;
				if ( erase_e == 0 ) t = R[(N - 1) - erase_e - 1];
				else if ( erase_e == N - 1) t = L[erase_e - 1];	
				else t = gcd(L[erase_e - 1], R[(N - 1) - erase_e - 1]);
				if ( ans < t ) ans = t;
		}

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


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

using namespace std;
using ll = long long;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

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

  int n = s.size();
  int cnt = 0;
  rep(i, n) {
    if (s[i] == '0')
      ++cnt;
    else
      --cnt;
  }

  if (cnt == 0)
    cout << n << endl;
  else
    cout << n - abs(cnt) << endl;
  return 0;
}


Measured memory_bytes: 3728
def kaibun(A):
    check=1
    for i in range(len(A)//2):
        if A[i]==A[-(i+1)]:
            pass
        else:
            check=check*0
            break
    return check

N=input()
a=kaibun(N)
B=N[0:(len(N)-1)//2]
C=N[(len(N)+3)//2-1:len(N)]
b=kaibun(B)
c=kaibun(C)
if a==1 and b==1 and c==1:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
#include <iostream>
#include <string>

int main()
{
  std::string S;
  std::cin >> S;
  int n = std::stoi(S), m=0;
  for(int i = 0;i < S.size(); ++i){
    m += (S[i] - '0');
  }
  ////↓でもok
  //for(const auto& v : S){
  //  m += (v - '0');
  //}
  if(n%m==0){
    std::cout << "Yes" << std::endl;
  }
  else{
    std::cout << "No" << std::endl;
  }
}


Measured memory_bytes: 256
import Data.List
import qualified Data.ByteString.Char8 as B
import Control.Monad

main = getLine >> breads >>= print . solve
    where
        solve xs = maximum xs - minimum xs
        
breads :: IO [Int]
breads = unfoldr uff <$> B.getLine
    where
        uff b = check <$> B.readInt b
        check (a, b)
            | B.null b = (a, b)
            | otherwise = (a, B.tail b)


Measured memory_bytes: 508
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

int main(){
    cin>>N>>M>>Q;
    vector<string> grid(N);
    rep(i,N) cin>>grid[i];
    mat edge(N, vec(M, 0)), num(N + 1, vec(M + 1, 0)), addr(N, vec(M,0)), addc(N, vec(M,0));
    rep(i,N){
        rep(j,M){
            bool blue = grid[i][j] == '1';
            if(i > 0) {
                edge[i][j] += edge[i-1][j] + (blue && grid[i-1][j] == '1');
                addc[i][j] = addc[i-1][j] + (blue && grid[i-1][j] == '1');
            }
            if(j > 0) {
                edge[i][j] += edge[i][j-1] + (blue && grid[i][j-1] == '1');
                addr[i][j] = addr[i][j-1] + (blue && grid[i][j-1] == '1');
            }
            if(i > 0 && j > 0) edge[i][j] -= edge[i-1][j-1];
            num[i+1][j+1] = num[i][j+1] + num[i+1][j] - num[i][j] + blue;
        }
    }
    vec x(2), y(2);
    rep(i,Q){
        rep(j,2) cin>>x[j]>>y[j];
        --x[0], --y[0];
        ll res = 0;
        rep(j,2) rep(k,2) res += (j^k ? -1 : 1) * num[x[j]][y[k]];
        --x[1], --y[1];
        rep(j,2) rep(k,2) res += (j^k ? 1 : -1) * edge[x[j]][y[k]];
        res -= addr[x[0]][y[1]] - addr[x[0]][y[0]];
        res -= addc[x[1]][y[0]] - addc[x[0]][y[0]];
        cout<<res<<endl;
    }
    /*rep(i,N){
        rep(j,M) cout<<edge[i][j]<<' ';
        cout<<endl;
    }*/
}

Measured memory_bytes: 131200
n,k = map(int, input().split())
al = [0]+list(map(int, input().split()))

s = 1
visited = [0]*(n+1)
cnt = 0
for i in range(k):
    s = al[s]
    cnt += 1
    if visited[s]>0:
        r = k - cnt
        l = cnt - visited[s]
        for _ in range(r%l):
            s = al[s]
        break
    else:
        visited[s] = cnt
print(s)

Measured memory_bytes: 32372
def main():
    N = int(input())
    txy = [list(map(int, input().split())) for i in range(N)]

    ok = True
    pt, px, py = 0, 0, 0
    for i in range(N):
        t, x, y = txy[i]
        dt = t - pt
        dxy = abs(px - x) + abs(py - y)
        if dt < dxy:
            ok = False
            break
        elif dt&1 != dxy&1:
            ok = False
            break
        pt, px, py = t, x, y
    
    if ok:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()

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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] ary = Console.ReadLine().Split(' ').ToArray();
           
                Console.Write((int.Parse(ary[0])-1)*(int.Parse(ary[1])-1));
            
        }
    }
}


Measured memory_bytes: 13268
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int n;
typedef double D;  
typedef complex<D> P;
typedef pair<P, P> L;
const D EPS = 1e-9;
#define X real()
#define Y imag()
#define LE(n,m) ((n) < (m) + EPS)
#define GE(n,m) ((n) + EPS > (m))
#define EQ(n,m) (abs((n)-(m)) < EPS)
D dot(P a, P b) {return (conj(a)*b).X; }
D cross(P a, P b) {  return (conj(a)*b).Y;}
D distPP(P a,P b){
  return (sqrt((a.X-b.X)*(a.X-b.X)+(a.Y-b.Y)*(a.Y-b.Y)));
}
P crosspointLL(P a1, P a2, P b1, P b2) {
  D d1 = cross(b2-b1, b1-a1);
  D d2 = cross(b2-b1, a2-a1);
  if (EQ(d1, 0) && EQ(d2, 0)) return a1;
  if (EQ(d2, 0)) return P(1000,1000);
  return a1 + d1/d2 * (a2-a1);
}
int main(){
  while(cin>>n,n){
    L l[101];
    int sum=1;
    P a,b;
    double q,w,e,r;
    r(i,n){
      cin>>q>>w>>e>>r;
      a=P(q,w),b=P(e,r);
      l[i]=L(a,b);
    }
    r(i,n){ 
      vector<P>v;
      r(j,i){
	int c=0;
	a=crosspointLL(l[i].first,l[i].second,l[j].first,l[j].second);
	if(a.X>-100&&a.X<100&&a.Y<100&&a.Y>-100){
	  r(k,(int)v.size())if(distPP(v[k],a)<EPS)c++;
	 if(!c)sum++;
	}
	v.push_back(a);
      }
      sum++;
    }
    cout<<sum<<endl;
  }
}

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(int (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define debugP int debug_point; cin>>debug_point;
const ll MOD= 1e9 + 7;
template <typename T>
void putv(vector<T>& V){
	// cout << "The elements in the vector are: " << endl;
	for(auto x: V)
		cout << x << " ";
	cout << endl;
}
template <class T>
vector<T> getv(ll n){
	vector<T> Vector_temp;
	rep(i,n){
		T input;
		cin >> input;
		Vector_temp.emplace_back(input);
	}
	return Vector_temp;
}
ll gcd(ll c,ll b){
    while(1){
        if(c%b!=0){
        ll tmp=b;
        b=c%b;
        c=tmp;
        }else{
            return b;
        }
    }
}
/* <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3*/


int main(){
    ll n;
    cin>>n;
    vec(b,n);
    rep(i,n){
        cin>>b[i];
    }
    vec(c,n);
    int j=0;
    while(j!=n){
        bool k=false;
    for(int i=b.size()-1;i>=0;i--){
        if(b[i]==i+1){
            c[j]=b[i];
            b.erase(b.begin()+i);
            j++;
            k=true;
            break;
        }
    }
    if(b[0]!=1||k==false){
        op(-1);
        return 0;
    }
    for(int i=b.size()-1;i>=0;i--){
        if((b[i]-(i+1))>0){
            op(-1);
            return 0;
        }
    }
    }
    rep(i,n){
        op(c[n-1-i]);
    }
    return 0;
}

Measured memory_bytes: 256
n = int(input())
L = list(map(int, input().split()))
ans = 0
for i in range(n):
    for j in range(i+1, n):
        for k in range(j+1, n):
            a, b, c = sorted([L[i], L[j], L[k]])
            if a == b or b == c or c == a:
                continue
            if c < a+b:
                ans += 1
print(ans)


Measured memory_bytes: 9188
#include <stdio.h>

int main(){
    long int n,i;
    long int s=1;
    scanf("%ld",&n);
    if(n>=1 && n<=20){
        for(i=1;i<=n;i++)
            s = s*i;
        printf("%ld\n",s);
	}
    return 0 ;

}

Measured memory_bytes: 592
H,W = (int(i) for i in input().split())  
a = [[int(i) for i in input().split()] for i in range(H)] 

ans = []
ans_list = []

for h in range(H):
	for w in range(W):
		if w!=W-1:
			if a[h][w]%2==1:
				a[h][w+1]+=1
				ans.append([h+1,w+1,h+1,w+2])
		else:
			if a[h][w]%2==1 and h!=H-1:
				a[h+1][w]+=1
				ans.append([h+1,w+1,h+2,w+1])

print(len(ans))
for i in range(len(ans)):
	print(*ans[i])

Measured memory_bytes: 30112
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <climits>

using namespace std;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

typedef long long LL;
typedef vector<int> VI;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  cout << max(0, c-(a-b)) << endl;
  return 0;
}


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

int N;
int A[100];

int main(void){

    cin >> N;
    for (int i = 1; i <= N;i++) cin >> A[i];

    long long ans = 1000;

    int sell = 0;
    int buy = A[1];
    long long kabu = 0;

    for (int i = 2; i <= N;i++){
        if (buy == 0) {
            buy = A[i];
            sell = 0;
        } else if (buy >= A[i]){
            buy = A[i];
        } else {
            sell = A[i];
        }

        if (buy < sell){
            if (i == N){
                kabu = ans / buy;
                ans = ans + (sell - buy) * kabu;
//                cout << i << "," << ans << endl;
                buy = 0;
            } else if (sell > A[i+1]){
                kabu = ans / buy;
                ans = ans + (sell - buy) * kabu;
//                cout << i << "," << ans << endl;
                buy = 0;
            } else {
                sell = A[i];
            }
        }
    }


    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3592
import sys

sys.setrecursionlimit(10 ** 6)

def main():
    n=int(input())
    dd=list(map(int, input().split()))
    ans=0
    for i in range(n-1):
        for j in range(i+1,n):
            ans+=dd[i]*dd[j]
    print(ans)

main()

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		//数取得
		String a = sc.next();
		String b = sc.next();

		String gudem = a+b;
		int num = Integer.parseInt(gudem);

		String answer = "No";

		for(int i = 0; i * i < 100000; i++) {
			if(num == i * i) {
				answer = "Yes";
				break;
			}
		}

		System.out.println(answer);
	}

}


Measured memory_bytes: 27028
# AGC009a
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)
    # map(int, input().split())
    n = int(input())

    a = list()
    b = list()
    for _ in range(n):
        aa, bb = map(int, input().split())
        a.append(aa)
        b.append(bb)

    ans = 0
    dif = 0
    for i in range(n-1, -1, -1):
        osu = b[i]-(a[i]+dif) % b[i] if (a[i]+dif) % b[i] != 0 else 0
        #print(a[i]+dif, b[i], osu, ans)
        ans += osu
        dif += osu
    print(ans)


if __name__ == '__main__':
    main()


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

using namespace std;

int main() {
    long long n, a, b;
    cin >> n >> a >> b;
    if ((b - a) % 2 == 0) {
        cout << (b - a) / 2 << endl;
    } else {
        cout << min((a - 1), (n - b)) + 1 + (b - a - 1) / 2 << endl;
    }
    return 0;
}


Measured memory_bytes: 3620
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <stdio.h>
#include <string>
#include <vector>

using namespace std;

long long P = 1000000007;
int n, m, x, y, z;

long long power(long long e, long long x) {
  if (x == 0)
    return 1;
  if (x == 1)
    return e;
  if (x % 2 == 0)
    return power((e * e) % P, x / 2);
  return (power(e, x - 1) * e) % P;
}

bool ok[1 << 17][11] = {0};

bool same(vector<int> &l, vector<int> &r) {
  if (r.size() == 0)
    return false;
  int li = l.size() - 1;
  int ri = r.size() - 1;
  for (; li >= 0; li--) {
    while (l[li] > 0 && ri >= 0)
      l[li] -= r[ri--];
  }
  for (int i = 0; i < l.size(); i++)
    if (l[i] != 0)
      return false;
  return true;
}

long long memo[41][1 << 17] = {0};

int maxK(int i) {
  int ret = 0;
  while (i > 0) {
    ret++;
    i >>= 1;
  }
  return ret;
}

long long dfs(int now, int bef) {
  if (memo[now][bef] >= 0)
    return memo[now][bef];
  if (now == n) {
    if (!ok[bef][0])
      return 1;
    else
      return 0;
  }
  long long ret = 0;
  for (int k = 1; k <= 10; k++) {
    if (ok[bef][k])
      continue;
    ret = (ret + dfs(now + 1, ((bef << k) | (1 << (k - 1))) & (m - 1))) % P;
  }
  return memo[now][bef] = ret;
}

int main() {
  cin >> n >> x >> y >> z;
  m = 1 << (x + y + z - 1);
  for (int i = 0; i <= n; i++)
    for (int j = 0; j < m; j++)
      memo[i][j] = -1;
  for (int i = 0; i < m; i++) {
    vector<int> v;
    int k = i;
    int base = 1;
    while (k > 0) {
      if (k & 1) {
        v.push_back(base);
        base = 0;
      }
      base++;
      k >>= 1;
    }
    reverse(v.begin(), v.end());
    for (int k = 0; k <= 10; k++) {
      if (z - k < 0)
        continue;
      vector<int> w;
      w.push_back(x);
      w.push_back(y);
      if (z - k != 0)
        w.push_back(z - k);
      ok[i][k] = same(w, v);
    }
  }

  long long ans = (power(10, n) - dfs(0, 0) + P) % P;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 42240
n, k, q = map(int, input().split())
a = [input() for i in range(q)]
a_i = [int(s) for s in a]

res = [k] * n

for i in a_i:
    res[i-1] += 1    

ans = []

for i in range(n):
    if res[i] > q:
        ans.append('Yes')
    else:
        ans.append('No')

i = 0
while i != n:
    print(ans[i])
    i += 1

Measured memory_bytes: 17504
#include<iostream>
using namespace std;
int main(){
   int a,b,c,d;
   cin>>a>>b>>c>>d;
   if(a<=10&&b<=10&&c<=10&&d<=10) {
       if ((a + b) == (c + d)) {
           cout << "Balanced" << endl;
       } else if ((a + b) < (c + d)) {
           cout << "Right" << endl;
       } else if((a+b)>(c+d)){
           cout << "Left" << endl;
       }
   }


}

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

#define FOR(i, a, b) for (int i = (a); i < static_cast<int>(b); i++)
#define FORR(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) FOR (i, 0, n)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
template <typename T>
void print(const vector<vector<T>> matrix);
template <typename T>
void print(const vector<T> vec);
template <typename Arg>
void print(const Arg arg);
template <typename Head, typename... Args>
void print(const Head head, const Args... args);
template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = INT_MAX / 2;
using ll = long long;

typedef pair<int, int> P;

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

    int H, W;
    cin >> H >> W;
    vector<vector<int>> v(H + 1, vector<int>(W + 1));
    vector<vector<int>> memory;
    vector<int> memo;

    rep (i, H)
        rep (j, W)
            cin >> v[i + 1][j + 1];

    int x, y;
    bool move = false;
    rep (i, H) {
        x = i + 1;
        rep (j, W) {
            y = i % 2 == 0 ? j + 1 : W - j;
            if (move) {
                v[x][y] += 1;
                memo.pb(x);
                memo.pb(y);
                memory.pb(memo);
            }

            if (v[x][y] % 2 == 1 and (i + 1) * (j + 1) != H * W) {
                move = true;
                memo = vector<int>{x, y};
            } else {
                move = false;
            }
        }
    }
    print(memory.size());
    print(memory);
    cout << endl;

    return 0;
}

//---------------------------------------------
template <typename T>
void print(const vector<vector<T>> matrix) {
    repall (vec, matrix)
        print(vec);
}
template <typename T>
void print(const vector<T> vec) {
    unsigned int len = vec.size();
    rep (i, len - 1)
        cout << vec[i] << ' ';
    cout << vec[len - 1] << '\n';
}
template <typename Arg>
void print(const Arg arg) {
    cout << arg << '\n';
}
template <typename Head, typename... Args>
void print(const Head head, const Args... args) {
    cout << head << " ";
    print(args...);
}


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

int main()
{
    char v[5] = {'a', 'e', 'i', 'o', 'u'};
    char c;
    cin >> c;
    
    int con = 0;
    for(int i = 0; i < 5; i++){
        if(v[i] == c){
            cout << "vowel" << endl;
            con++;
            break;
        }
    }
    if(con == 0) cout << "consonant" << endl;
    return 0;
}


Measured memory_bytes: 256
while True:
    h,w = map(int,input().split())
    if w == 0 and h == 0:
        break
    for j in range(h):
        for i in range(w):
            if i == 0 or i == w-1 or j == 0 or j == h-1:
                print('#', end='')
            else:
                print('.', end='')
        print()
    print()

Measured memory_bytes: 8960
import java.util.*;
import java.util.Arrays;

public class Main{
  
  public static void main(String[] args) throws Exception{
    
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.next());
    int x = Integer.parseInt(sc.next());
    
    if(N>=2 && N<=100 && x>=1){
    int[] list = new int[N];
    
    for(int i = 0 ; i < N ; i++){
      list[i] = Integer.parseInt(sc.next());
      if(list[i] == 0){
        throw new Exception("入力条件に違反しています");
      }
    }
    Arrays.sort(list);
   
    int count = 0;
    for(int i = 0 ; i < N && x > 0; i++){
      x -= list[i];
      if(x >= 0){
        count++;
      }
    }
    
    if(count == N && x > 0){
       count -= 1;
       System.out.println(count);  
    }else{
      System.out.println(count);
    }
    }else{
      System.out.println("入力条件に違反しています");
    }
  }  
}

Measured memory_bytes: 35692
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	costs := make([]int, n-1, n-1)
	starts := make([]int, n-1, n-1)
	freqs := make([]int, n-1, n-1)
	for i := 0; i < n-1; i++ {
		var c, s, f int
		fmt.Scan(&c)
		fmt.Scan(&s)
		fmt.Scan(&f)
		costs[i] = c
		starts[i] = s
		freqs[i] = f
	}
	for i := 0; i < n; i++ {
		fmt.Println(solve(i, 0, costs, starts, freqs))
	}

}

func solve(index int, time int, costs []int, starts []int, freqs []int) int {
	if index == len(costs) {
		return time
	}
	start := ((time + freqs[index] - 1) / freqs[index]) * freqs[index]
	if start < starts[index] {
		start = starts[index]
	}
	return solve(index+1, start+costs[index], costs, starts, freqs)
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#include<vector>
using namespace std;
int main() {
  int N;
  double c,d=0,e,f,g,h,b;
    cin>>N>>b;
  vector<int> a(2000000);
	for(int i=0;i<b;i++){
      cin>>a.at(i);
      d+=a.at(i);
    }
  e=d;
  if(b==N){
    cout<<fixed<<setprecision(12)<<(d+b)/2;
    return 0;
  }
  for(int i=b;i<N;i++){
    cin>>a.at(i);
    e=e+a.at(i)-a.at(i-b);
    d=max(e,d);
    f=d+b;
    g=f/2;
  }
cout<<fixed<<setprecision(12)<<g;
}

Measured memory_bytes: 8064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define vll vector<ll> 
#define inf 1000000000000
#define mod 1000000007

ll power(ll a, ll b)
{
    ll prod = 1;
    while(b)
    {
        if(b&1)
        prod = (prod*a);
        a = (a*a);
        b >>= 1;
    }
    return prod;
}

ll a[100009];
ll dp[3009][3009][2];
ll fun(ll  l , ll r , ll chance)
{
	if(l > r)
	{
		return 0;
	}
	if(dp[l][r][chance] != inf)return dp[l][r][chance];
	if(chance == 0)
	{
		dp[l][r][chance] = max(a[l] + fun(l+1 , r , chance^1) , a[r] + fun(l , r-1 , chance^1));
		return dp[l][r][chance];
	}
	else
	{
		
		return dp[l][r][chance] = min((-1)*a[l] + fun(l+1 , r , chance^1) , (-1)*a[r] + fun(l , r-1 , chance^1));
	}
	
}
signed main()
{
	ll n;
	cin >> n;
	// ll a[n];
	for(int i = 0 ; i < n ; i++)
		for(int j = 0 ; j < n ; j++)
			for(int k = 0 ; k < 2 ; k++)
				dp[i][j][k] = inf;
	for(ll i = 0 ; i < n ; i++)
	{
		cin >> a[i];
	}

	cout << fun(0 , n-1 , 0);
 	return 0;

}




Measured memory_bytes: 141696
#include <cstdio>
#include <algorithm>
using namespace std;
#define fr(i, a, b) for ( int i = a; i <= b; i ++) 
typedef long long ll;
int a[200010], n;
int main() {
	scanf("%d", &n); fr(i, 1, n) scanf("%d", a+i), a[i] -= i;
	sort(a+1, a+1+n); int mid = 1 + n >> 1;
	ll ans = 0;
	fr(i, 1, n) ans += 1LL * abs(a[i] - a[mid]);
	printf("%lld\n", ans);
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()

ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t=rep_jijo(n,x/2);
        return t*t;
    }
    return n*rep_jijo(n,x-1);
}

int main(){
    int a,b;
    cin >> a >> b;
    cout << max(0,a-2*b) <<endl;
    
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	  public static void main(String args[]){
      	Scanner scan = new Scanner(System.in);
        StringBuilder sb = new StringBuilder("");
            
        String s = scan.next();
        String cnt = "";
        int i;
        
        for( i = 0 ; i < s.length() ; i++ ){
          if( s.substring(i,i+1).charAt(0) == '0' )sb.insert( sb.length() , "0");
          else if( s.substring(i,i+1).charAt(0) == '1' )sb.insert( sb.length() , "1");
          else{
            if( sb.length() == 0 ){//何もしない
            }
            else if( sb.length() == 1 ){
              sb.setLength(0);
            }
            else{
              sb.setLength( sb.length()-1 );
            }
              
          }

        }
        
        System.out.println(new String(sb));
	  }
}

Measured memory_bytes: 21972
#!/usr/bin/ruby

class NilClass
  def +(other)
    return other
  end
end

s = STDIN.readline.chomp.split(/T/)
X, Y = STDIN.readline.chomp.split(/\s+/).map{|i| i.to_i}
x, y = 0, 0
x += s.shift.length if s.length > 0

memo = [{x => true}, {0 => true}]
memo2 = [{}, {}]
r = 1
s.each do |i|
  memo[r].each do |k, v|
    memo2[r][k-i.length] = true
    memo2[r][k+i.length] = true
  end
  memo[r] = memo2[r]
  memo2[r] = {}
  r = 1 - r
end

if memo[0][X] and memo[1][Y]
  puts "Yes"
else
  puts "No"
end


Measured memory_bytes: 96892
#include<iostream>
#include<string>
#include<sstream>
using namespace std;
 
class Stack{
private:
  int sp;
  int S[100];
public:
  Stack(){
    sp=0;
  }
  bool isFull(){
    return (sp==100);
  }
  bool isEmpty(){
    return (sp==0);
  }
  void push(int d){
    if(isFull()){
      return;
    }
    S[sp++] = d;
  }
  void pop(){
    if(isEmpty()){
      return;
    }
    sp--;
  }
  int top(){
    if(isEmpty()){
      return -1;
    }
    return S[sp-1];
  }
};
 
int main(){
  Stack s;
  string expr;
  getline(cin, expr);
 
  istringstream is(expr);
 
  while(!is.eof()){
    string op;
    is >> op;
 
    int tmp1,tmp2;
 
    switch(op[0]){
      case'+':
        tmp1 = s.top();
        s.pop();
        tmp2 = s.top();
        s.pop();
        s.push(tmp2+tmp1);
        break;
      case'-':
        tmp1 = s.top();
        s.pop();
        tmp2 = s.top();
        s.pop();
        s.push(tmp2-tmp1);
        break;
      case'*':
        tmp1 = s.top();
        s.pop();
        tmp2 = s.top();
        s.pop();
        s.push(tmp2*tmp1);
        break;
      default:
        istringstream is2(op);
        is2 >> tmp1;
        s.push(tmp1);
        break;
    }
  }
  cout << s.top() << endl;
 
  return 0;
}


Measured memory_bytes: 3192
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <limits>
#include <algorithm>
#include <utility>
#include <sstream>
#include <numeric>
#include <iterator>

using namespace std;

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
// #define ll long long
typedef long long ll;
typedef pair<int, int> P;

int main(int argc, const char * argv[]) {

  int n;
  cin >> n;
  vector<long> h(n);
  rep(i, n) cin >> h[i];
  h[0]--;
  repd(i,1,n){
    if (h[i] - h[i-1] > 0){
      h[i]--;
    }else if (h[i] - h[i-1] < 0){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
// #define INF __INT32_MAX__
#define INF 1e9
#define LINF __LONG_LONG_MAX__

int main() {
    int K, T; cin >> K >> T;
    vi A(T); rep(i, T) cin >> A[i];

    sort(A.begin(), A.end());
    reverse(A.begin(), A.end());

    int x = A[0];
    for (int i = 1; i < T; i++) {
        x -= A[i];
    }

    if (x > 0) {
        cout << (x - 1) << endl;
    } else {
        cout << 0 << endl;
    }
}


Measured memory_bytes: 3640
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ms(i, j) memset(i, j, sizeof i)
#define LL long long
#define db double
//atcoder only 
#define rd(a) scanf("%d", &a)
#define rd2(a, b) scanf("%d%d", &a, &b)
#define pty printf("YES\n")
#define ptn printf("NO\n")
#define pt printf
using namespace std;
int n, ap[100000 + 5];
void clean() {
	ms(ap ,0);
}
void solve() {
	clean();
	for (int a, i =1; i <= n; i++) {
		rd(a);
		ap[a]++, ap[a - 1]++, ap[a + 1]++;
	}
	int maxa = 0, d = 0;
	for (int i = 0;  i <= 1e5; i++) {
		if (maxa < ap[i]) maxa = ap[i], d  = ap[i];
	}
	pt("%d", d);
}
int main() {
	rd(n), solve();
	return 0;
}

Measured memory_bytes: 512