akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class A { public static void Main() => (new Solver()).Solve(); }

public class Solver
{
	public void Solve()
	{
		long X = GetLong();
		for(long i = 1; ; i++)
		{
			if(X * i % 360 == 0)
			{
				WriteLine(i);
				return;
			}
		}
	}
}

public static class MyIO
{
	private static string[] args = new string[0];
	private static int cnt = 0;
	private static IEnumerable<string> getArgs(long N) => Range(0, N).Select(_ => getArg());
	private static string getArg()
	{
		if(cnt == args.Length) { args = Console.ReadLine().Split(); cnt = 0; }
		return args[cnt++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => getArgs(N).Select(int.Parse).ToArray();
	public static long[] GetLongs(long N) => getArgs(N).Select(long.Parse).ToArray();
	public static double[] GetDoubles(long N) => getArgs(N).Select(double.Parse).ToArray();
	public static decimal[] GetDecimals(long N) => getArgs(N).Select(decimal.Parse).ToArray();
	public static string[] GetStrings(long N) => getArgs(N).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) < 0) x = y; }
	public static void chmin<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) > 0)	x = y; }
	public static void swap<T>(ref T x, ref T y) { T tmp = x; x = y; y = tmp; }
	public static long rightShift(long x, long y) => (x >> (int)y);
	public static long leftShift(long x, long y) => (x << (int)y);
	public static bool contains(long s, long x) => (rightShift(s, x) & 1L) == 1L;
	public static long gcd(long x, long y) => (y == 0) ? x : gcd(y, x % y);
	public static long lcm(long x, long y) => (x / gcd(x,y)) * y;	
	public static IEnumerable<int> Range(long start, long count) => Enumerable.Range((int)start, (int)count);
	public static void Sort(this List<string> source) => source.Sort(StringComparer.Ordinal);
}


Measured memory_bytes: 27564
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e17 // 4倍しても(4回足しても)long longを溢れない
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())

int main() {
  ll x,y;
  cin >> x >> y;
  ll ans = 0, total = 1;
  ll mmax = y / x;

  while (total <= mmax) {
    ans += 1;
    total *= 2;
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main() {
	string S;
	int cash=700;
	int count = 0;
	cin >> S;
	if (S[0] == 'o') {
		cash+=100;
	}
	if (S[1]== 'o') {
		cash+=100;
	}
	if (S[2] == 'o') {
		cash+=100;
	}
	cout << cash << endl;
}

Measured memory_bytes: 256
/**
 *    author:  tourist
 *    created: 25.11.2017 13:06:49       
**/
#include <bits/stdc++.h>

using namespace std;

int d[4242];
int taken[4242];
int n;
int ans;

void dfs(int v) {
  if (v == n) {
    int gap = 26;
    int last = 0;
    for (int i = 1; i < 24; i++) {
      if (taken[i]) {
        gap = min(gap, i - last);
        last = i;
      }
    } 
    gap = min(gap, 24 - last);
    ans = max(ans, gap);
    return;
  }
  if (!taken[d[v]]) {
    taken[d[v]]++;
    dfs(v + 1);
    taken[d[v]]--;
  }
  int other = (24 - d[v]) % 24;
  if (other != d[v] && !taken[other]) {
    taken[other]++;
    dfs(v + 1);
    taken[other]--;
  }
}

int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &d[i]);
  }
  d[n++] = 0;
  if (n > 24) {
    puts("0");
  } else {
    ans = 0;
    dfs(0);
    printf("%d\n", ans);
  }
  return 0;
}


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

#ifdef _DEBUG
#define debug(x) cerr << "line: " << __LINE__ << ", func: " << __func__ << " ->  " << #x << " = " << x << endl
#else
#define debug(x)
#endif

#define all(s) begin(s), end(s)
#define rall(s) rbegin(s), rend(s)
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = ((a)-1); i >= (b); i--)
#define pb push_back
#define sz(a) int((a).size())

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_ll = pair<ll, ll>;
using d_ll = pair<double, ll>;
using ll_d = pair<ll, double>;
using d_d = pair<double, double>;

static constexpr ll LL_INF = 1LL << 60;
static constexpr int I_INF = 1 << 28;
static constexpr double PI = static_cast<double>(3.14159265358979323846264338327950288);
static constexpr double EPS = numeric_limits<double>::epsilon();

static map<type_index, const char* const> scanType = {
    {typeid(int), "%d"}, {typeid(ll), "%lld"}, {typeid(double), "%lf"}, {typeid(char), "%c"}};

template <class T> static void scan(vector<T>& v);
[[maybe_unused]] static void scan(vector<string>& v, bool isWord = true);
template <class T> static inline bool chmax(T& a, T b);
template <class T> static inline bool chmin(T& a, T b);
template <class A, size_t N, class T> static void Fill(A (&arr)[N], const T& val);

bool dist(vector<ll>& a, vector<ll>& b) {
  int l = sz(a);
  double d = 0.0;
  rep(i, 0, l) { d += pow(a[i] - b[i], 2); };
  d = sqrt(d);

  return abs(ceil(d) - d) <= EPS;
}

int main(int argc, char* argv[]) {
  long long N;
  scanf("%lld", &N);
  long long D;
  scanf("%lld", &D);
  std::vector<std::vector<long long>> X(N, std::vector<long long>(D));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < D; j++) {
      scanf("%lld", &X[i][j]);
    }
  }

  ll ans = 0;
  rep(i, 0, N) rep(j, i + 1, N) { ans += dist(X[i], X[j]); }

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

template <class T> static void scan(vector<T>& v) {
  auto tFormat = scanType[typeid(T)];
  for (T& n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string>& v, bool isWord) {
  if (isWord) {
    for (auto& n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

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

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

template <class A, size_t N, class T> void Fill(A (&arr)[N], const T& val) {
  std::fill((T*)arr, (T*)(arr + N), val);
}


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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

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

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int h, w;
    cin >> h >> w;
    vs s(h);
    rep(i, h) cin >> s[i];
    vector<vi> cnt(h, vi(w));
    rep(i, h) {
        vector<bool> done(w);
        rep(j, w) {
            if (s[i][j]!='.') continue;
            if (done[j]) continue;
            int l = 0;
            while (j + l < w) {
                if (s[i][j+l]!='.') break;
                done[j+l] = true;
                ++l;
            }
            rep(k, l) cnt[i][j+k] += l;
        }
    }
    rep(j, w) {
        vector<bool> done(h);
        rep(i, h) {
            if (s[i][j]!='.') continue;
            if (done[i]) continue;
            int l = 0;
            while (i + l < h) {
                if (s[i+l][j]!='.') break;
                done[i+l] = true;
                ++l;
            }
            rep(k, l) cnt[i+k][j] += l;
        }
    }
    int ans = 0;
    rep(i, h) rep(j, w) {
        ans = max(ans, cnt[i][j]-1);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 20096
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	int r = sc.nextInt();
    	int g = sc.nextInt();
      	int b = sc.nextInt();
	    
      	if(((100*r)+(10*g)+b) % 4 == 0){
        	System.out.println("YES");
        }else{
        	System.out.println("NO");
        }
    }
}

Measured memory_bytes: 35332
#include<stdio.h>

static const int MAX = 100;
static const int IN = (1<<21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n;
int m[100][100];

int prim(){ 
  int u,min,t,i, k[MAX],q[MAX],clr[MAX];

  for(i=0;i<n;i++){
    k[i]=IN;
    q[i]=-1;
    clr[i]=WHITE;
  }

  k[0]=0;

  while(1){
    min=IN;
    u=-1;
    for(i=0;i<n;i++){
      if(min>k[i] && clr[i] != BLACK){
	u=i;
	min=k[i];
      }
    }
    if(u==-1)break;
    clr[u]=BLACK;
    for(t=0;t<n;t++){
      if(clr[t]!=BLACK && m[u][t] != IN){
	if(k[t]>m[u][t]){
	  k[t]=m[u][t];
	  q[t]=u;
	  clr[t]=GRAY;
	}
      }
    }
  }
  int sum = 0;
  for(i=0;i<n;i++){
    if(q[i]!=-1) sum+=m[i][q[i]];
  }
  return sum;
}

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

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&e);
      m[i][j]=(e==-1)?IN:e;
    }
  }
  printf("%d\n",prim());
  return 0;
}




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

#define int long long

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int N;
  cin >> N;

  vector<string> s(N);
  vector<int> t(N);

  for ( int i = 0; i < N; i++ ) {
    cin >> s[i] >> t[i];
  }

  string X;
  cin >> X;

  int ans = 0;
  for ( int i = 0; i < N; i++ ) {
    if ( ans >= 0 ) ans += t[i];
    if ( s[i] == X ) ans = 1;
  }

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


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

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int d, g;
  cin >> d >> g;
  vector<int> p(d);
  vector<int> c(d);
  for (int i = 0; i < d; ++i) {
    cin >> p[i] >> c[i];
  }
  int ans = 1e9;
  for (int bit = 0; bit < (1 << d); ++bit) {
    int score = 0, count = 0;
    int ex = -1;
    for (int i = 0; i < d; ++i) {
      if (bit >> i & 1) {
        score += 100 * (i + 1) * p[i] + c[i];
        count += p[i];
      } else {
        ex = i;
      }
    }
    if (score < g && ex != -1) {
      int need = (g - score + (100 * (ex + 1)) - 1) / (100 * (ex + 1));
      if (p[ex] < need) continue;
      score += 100 * (ex + 1) * need;
      count += need;
    }
    if (score < g) continue;
    if (count < ans) ans = min(ans, count);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
N = int(input())
if N % 1000 == 0:
    print(0)
elif N < 1000:
    i = 1000
    print(i-N)
elif N < 2000:
    i = 2000
    print(i-N)
elif N < 3000:
    i = 3000
    print(i-N)
elif N < 4000:
    i = 4000
    print(i-N)
elif N < 5000:
    i = 5000
    print(i-N)
elif N < 6000:
    i = 6000
    print(i-N)
elif N < 7000:
    i = 7000
    print(i-N)
elif N < 8000:
    i = 8000
    print(i-N)
elif N < 9000:
    i = 9000
    print(i-N)
elif N < 10000:
    i = 10000
    print(i-N)

Measured memory_bytes: 9240
//ProblemD

#ifdef _MYPC
#include "mypc.h"
#endif // _MYPC

#include <iostream>
#include <string>
#include <vector>
#include <bitset>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <functional>
#include <memory>
#include <complex>
#include <cstdio>
#include <cstring>
#include <cmath>

using namespace std;

//ProblemD

class Solve {
private:

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

		unsigned long long rst = 0;
		for (int i = k + 1; i <= n; i++) {
			if (k == 0) rst += n;
			else {
				rst += n + 1;
				rst -= (n + 1) / i * k;

				if ((n + 1) % i > k) rst -= k;
				else rst -= (n + 1) % i;
			}
		}
		cout << rst << endl;
	}

public:
	Solve() { solve(); }
};

int main(int argc, char* argv[]) {
	unique_ptr<Solve> solve = make_unique<Solve>();
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<stdio.h>
#include<set>
#include<vector>
using namespace std;


int main(){
    int n;
    cin>>n;
    
    vector<pair<int,int>> v;
    v.push_back(make_pair(2,1));
    for(int i=3;i<=n;i++){
        int vv=v.size();
        int flag=0;
        int ii=i;
        for(int j=0;j<vv;j++){
             if(i%v[j].first==0){
                 while(ii%v[j].first==0){
                v[j].second+=1;
                 flag=1;
                     ii=ii/v[j].first;
             }
                }
            if(j==vv-1&&flag==0){
                v.push_back(make_pair(i,1));
            }
            }
        }
    int kk[5];
   
    for(int i=0;i<5;i++){
        kk[i]=0;
    }
    for(int i=0;i<v.size();i++){
        
        if(v[i].second>=74){
            kk[4]+=1;
        }
        if(v[i].second>=24){
            kk[3]+=1;
        }
        if(v[i].second>=14){
            kk[2]+=1;
        }
        if(v[i].second>=4){
            kk[1]+=1;
        }
        if(v[i].second>=2){
            kk[0]+=1;
        }
    }
    int ans=0;
    ans+=kk[4];
    if(kk[3]!=0){
        ans+=kk[3]*(kk[0]-1);
    }
    if(kk[2]!=0){
    ans+=kk[2]*(kk[1]-1);
    }
    
    
  /*  if(kk[1]==2){
        ans+=kk[0];
    }*/
   
        int y=kk[0]-2;
        int j=kk[1]*(kk[1]-1)/2;

        ans+=j*y;
        
    
    cout<<ans<<endl;
   /* for(int i=0;i<v.size();i++){
        cout<<v[i].first<<v[i].second<<endl;
    }
    
    cout<<"b"<<endl;
    for(int i=0;i<5;i++){
        cout<<kk[i]<<endl;
    }*/
}


Measured memory_bytes: 256
#pragma comment(linker, "/stack:20000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
 
#define mp make_pair
#define f first
#define s second
#define ll long long
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
 
using namespace std;
 
using namespace __gnu_pbds;
template <typename T> using ordered_set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
const int inf = 2e9+7, mod=1e9+7;
const int N = 3e5+134, N1=1e7+134;
 
ll xx[8]={1, 1, -1, -1, 1, -1, 0, 0};
ll yy[8]={1, -1, 1, -1, 0, 0, 1, -1};

int a[N];
 
int main(){
    ios_base :: sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
	int n, x, y;
	cin >> n >> x >> y;
	int k=0;
	for(int i=0; i<n; i++)
		for(int j=i+1; j<n; j++)
			a[min(j-i, max(j,y-1)-min(j,y-1)+max(i,x-1)-min(i,x-1)+1)]++;
	for(int i=1; i<n; i++)
		cout << a[i] << endl;
		
    return 0;
}

Measured memory_bytes: 256
from collections import deque as dq
s = input()
nq = int(input())

s = dq(s)

jun = True
for i in range(nq):
  query = input().split()
  if query[0] == '1':
    jun = not jun
    continue
  if jun:
    if query[1] == '1':
      s.appendleft(query[2])
    else:
      s.append(query[2])
  else:
    if query[1] == '1':
      s.append(query[2])
    else:
      s.appendleft(query[2])
if jun:
  print(''.join(s))
else:
  print(''.join(list(s)[::-1]))

Measured memory_bytes: 10228
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define UM unordered_map
#define ALL(a) (a).begin(), (a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
typedef pair<ll, ll> pii;
const long long INF = 1LL << 58;
struct Edge
{
    ll s, t, d;
};
typedef vector<vector<Edge>> Graph;
typedef vector<pii> vpii;
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;
}

int check(vi a, vi b)
{
    int ans;
}

signed main()
{
    int A, B;
    cin >> A >> B;
    int ans;
    if (A > 9)
    {
        ans = -1;
    }
    else if (B > 9)
        ans = -1;
    else
        ans = A * B;
    cout << ans << endl;
    return 0;
    // system("pause");
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;
use std::mem;

fn main() {
    let mut s: Vec<char> = read::<String>().chars().collect();
    s[3] = '8';
    let s: String = s.into_iter().collect();
    println!("{}",s);
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
string s, ans;
int n;
int main(){
	cin >> s >> n;
	rep(i,s.size()) if(i%n==0) ans.push_back(s[i]);
	cout << ans << "\n";
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;


public class Main {

    int[][] c;

    private void solve() {
        c = new int[3][3];

        for(int i = 0;i < 3;i++) {
            for(int j = 0;j < 3;j++) {
                c[i][j] = nextInt();
            }
        }

        boolean ans = false;
        out:
        for(int a1 = 0;a1 < 101;a1++) {
            for(int a2 = 0;a2 < 101;a2++) {
                for(int a3 = 0;a3 < 101;a3++) {
                    int[] a = {a1, a2, a3};
                    int[] b = new int[3];

                    for(int i = 0;i < 3;i++) {
                        for(int j = 0;j < 3;j++) {
                            b[j] = c[i][j] - a[i];
                        }
                    }

                    boolean flag = true;
                    for(int i = 0;i < 3;i++) {
                        for(int j = 0;j < 3;j++) {
                            if (a[i] + b[j] != c[i][j]) {
                                flag = false;
                            }

                            if (b[j] < 0 || b[j] > 100) {
                                flag = false;
                            }
                        }
                    }

                    if (flag) {
                        ans = true;
                        break out;
                    }
                }
            }
        }

        if (ans) out.println("Yes");
        else out.println("No");
    }
    public static void main(String[] args) {
        out.flush();
        new Main().solve();
        out.close();
    }

    /* Input */
    private static final InputStream in = System.in;
    private static final PrintWriter out = new PrintWriter(System.out);
    private final byte[] buffer = new byte[4096];
    private int p = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (p < buflen)
            return true;
        p = 0;
        try {
            buflen = in.read(buffer);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (buflen <= 0)
            return false;
        return true;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrint(buffer[p])) {
            p++;
        }
        return hasNextByte();
    }

    private boolean isPrint(int ch) {
        if (ch >= '!' && ch <= '~')
            return true;
        return false;
    }

    private int nextByte() {
        if (!hasNextByte())
            return -1;
        return buffer[p++];
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = -1;
        while (isPrint((b = nextByte()))) {
            sb.appendCodePoint(b);
        }
        return sb.toString();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 60240
using System;

namespace AOJ.Volume1
{
    public class CarryCheese
    {
        public static void Main()
        {
            while (true)
            {
                var input = Console.ReadLine().Split(' ');
                var length = new int[3];
                length[0] = int.Parse(input[0]);
                length[1] = int.Parse(input[1]);
                length[2] = int.Parse(input[2]);
                if (length[0] == 0) { break; }

                Array.Sort(length);
                int x = length[0];
                int y = length[1];
                double dia = Math.Sqrt((x * x) + (y * y));

                int cnt = int.Parse(Console.ReadLine());
                for (int i = 0; i < cnt; i++)
                {
                    int r = int.Parse(Console.ReadLine());
                    if (dia < 2 * r) { Console.WriteLine("OK"); }
                    else { Console.WriteLine("NA"); }
                }
            }
        }
    }
}

Measured memory_bytes: 9024
import sys
sys.setrecursionlimit(10**7)
def input(): return sys.stdin.readline().rstrip()

def main():
  K = int(input())
  S = input()

  if len(S) <= K:
    print(S)
  else:
    print(S[0:K] + '...')

if __name__ == '__main__':
  main()

Measured memory_bytes: 9168
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n;
vvi g;

int dfs(int v,int p){
	vi a;
	for(auto u:g[v]) if(u!=p) a.push_back(dfs(u,v));
	int m=a.size(),t;
	if(!m) return 1;
	for(int i=30;i>=0;i--){
		int cnt=0;
		for(auto j:a) if(j&1<<i) cnt++;
		if(cnt>1) break;
		if(!cnt) t=1<<i;
	}
	int res=t;
	for(auto i:a) res|=i;
	return (res|t-1)-t+1;
}

int main(){
	cin>>n;
	g=vvi(n);
	for(int i=0;i<n-1;i++){
		int u,v;
		cin>>u>>v;
		u--;v--;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	int t=dfs(0,-1);
	for(int i=30;i>=0;i--) if(t&1<<i){
		cout<<i<<endl;
		break;
	}
}

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

string s;

int main()
{
  int n,k;
  cin >> n >> k;
	cin >> s;
  for(int i = 0; i<n; i++)
  {
if(i == k-1) cout << char(s[i] + 32);
    else cout << s[i];
  }
}
  

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

using namespace std;

bool Bsearch(int key, int A[], int len) {
	int l = 0, r = len - 1;
	while (l <= r) {
		int mid = l + (r - l) / 2;
		if (A[mid] > key)
			r = mid - 1;
		else if (A[mid] < key)
			l = mid + 1;
		else
			return true;
	}
	return false;
}

int main() {
	int n, *S;
	int q, *T;
	int ans = 0;
	cin >> n;
	S = new int[n];
	for (int i = 0; i < n; i++)
		cin >> S[i];
	cin >> q;
	T = new int[q];
	for (int i = 0; i < q; i++)
		cin >> T[i];

	sort(S, S + n);
	for (int i = 0; i < q; i++)
		if (Bsearch(T[i], S, n) == true)
			ans++;
	cout << ans << endl;

	delete[] S;
	delete[] T;
	return 0;
}

Measured memory_bytes: 1248
const t={input:require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/),n:(arg:number=0):any=>{if(arg){const a:number[]=[];for(let i=0;i<arg;i++) {a.push(t.n());}return a;}else{const a = t.input[0];t.input.shift();return Number(a);}},s:(arg:number=0):any=>{if(arg){const a:string[]=[];for(let i=0;i<arg;i++){a.push(t.s());}return a;}else{const a=t.input[0];t.input.shift();return String(a);}},c:(arg:number=0):any=>{if(arg) {const a:string[]=[];for(let i=0;i<arg;i++) {a.push(t.c());}return a;}else{let a=t.input[0].split('');const b=a[0];a.shift();if(a.length>0){t.input[0]=a.join('');}else{t.input.shift();}return String(b);}},o: (...arg)=>{console.log(...arg);},abs:(a)=>{return Math.abs(a);},min:(...a)=>{return Math.min(...a);},max:(...a)=>{return Math.max(...a);},floor:(a)=>{return Math.floor(a);},asc:(ar:number[])=>{return ar.sort((a,b)=>{return a-b});},desc:(ar:number[])=>{ return ar.sort((a,b)=>{return b-a});},sw:(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length;i+=2){if(eval(a+op+arr[i]))return arr[i+1]}return arr[arr.length-1];}}
const main = ()=>{
  let [a,b] = t.n(2)
  t.o(a%3==0||b%3==0||(a+b)%3==0?'Possible':'Impossible')
}
main()

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

public class Main{

static BufferedReader s1;
static BufferedWriter out;
static String read() throws IOException{String line="";while(line.length()==0){line=s1.readLine();continue;}return line;}
static int int_v (String s1){return Integer.parseInt(s1);}
static long long_v(String s1){return Long.parseLong(s1);}
static int[] int_arr() throws IOException{String[] a=read().split("\\s+");int[] b=new int[a.length];for(int i=0;i<a.length;i++){b[i]=int_v(a[i]);}return b;}
static long[] long_arr() throws IOException{String[] a=read().split("\\s+");long[] b=new long[a.length];for(int i=0;i<a.length;i++){b[i]=long_v(a[i]);}return b;}
static void assign(){s1=new BufferedReader(new InputStreamReader(System.in));out=new BufferedWriter(new OutputStreamWriter(System.out));}
static long Modpow(long a,long p,long m){long res=1;while(p>0){if((p&1)!=0){res=(res*a)%m;}p >>=1;a=(a*a)%m;}return res;}
//......................................@uthor_Alx..............................................
static long mod=(long)1e9+7;

public static void main(String[] args) throws  IOException{
                assign();
                int[] x=int_arr();
                int d=x[0],t=x[1],s=x[2];
                double xx=(double)d/s;
                if(xx<=(double)t){out.write("Yes");}
                else{out.write("No");}

                out.flush();

    }
}

Measured memory_bytes: 33904
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string N; cin >> N;
    int ans = 0;
    rep(i, N.length()) {
        ans += N[i] - '0';
    }
    if(ans % 9 == 0) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


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

int main(){
    int M,N;
    cin >> N >> M;
    int A[M];
    long long int sum =0;
    for(int i=0;i<M;i++){
        cin >> A[i];
        sum += A[i];
    }
    if(sum > N){cout << -1 << endl;}
    else {cout << N-sum << endl;}
    return 0;

}

Measured memory_bytes: 3632
import sys
input=sys.stdin.readline


def solve():
    M = int(input())
    ans, s = 0, 0

    for _ in range(M):
        d, c = map(int, input().split())
        s += d*c
        ans += c

    ans += (s-1)//9 - 1
    print(ans)

solve()


Measured memory_bytes: 3060
import java.util.*;
import java.lang.*;

class Main {
	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int openArea = A - B*2;



        if(openArea > 0){
            System.out.println(openArea);
        }else{
            System.out.println(0);
        }


    }
}






Measured memory_bytes: 23124
#pragma GCC optimize (3)
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/hash_policy.hpp>
#include<ext/pb_ds/trie_policy.hpp>
#include<ext/pb_ds/priority_queue.hpp>
#define PII pair<int,int>
#define ll long long
#define ull unsigned long long
#define INFI 2147483647
#define INFL 9223372036854775807
#define INFU 18446744073709551615
using namespace std;
using namespace __gnu_pbds;
const double PI=acos(-1.0);
const double eps=1e-6;
inline int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0' || ch>'9'){
        if(ch=='-') f=-1;
        ch=getchar();
    }
    while(ch>='0' && ch<='9'){
        x=x*10+ch-'0';
        ch=getchar();
    }
    return x*f;
}
int main()
{
	//ios_base::sync_with_stdio(false);
    //cin.tie(0);
    //cout.tie(0);
	int a,b;
	while(cin>>a>>b){
        if(2*b>=a) cout<<0<<endl;
        else printf("%d\n",a-2*b);
	}
	return 0;
}


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

typedef  long long ll;
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//
//
#define int long long

using namespace std;

int ctoi(char c) {
 switch (c) {
 case '0': return 0;
 case '1': return 1;
 case '2': return 2;
 case '3': return 3;
 case '4': return 4;
 case '5': return 5;
 case '6': return 6;
 case '7': return 7;
 case '8': return 8;
 case '9': return 9;
 default: return 0;
 }
}


 ll a,b,c,s,t,x,y,z;
 ll A,B,C,S,T,X,Y,Z;

 ll count;

 long double pi=3.14159265358979323846;

 string N,M;

unsigned long long D;

signed main(){

	cin>>a;

	b=0;

	int cm[a];

	REP(i,a) cin>>cm[i];

	for(int i=1;i<a;i++){
		if(cm[i]<cm[i-1]){
	b=b+(cm[i-1]-cm[i]);
	cm[i]=cm[i-1];
}
	}


	cout<<b;



	return 0;

}


Measured memory_bytes: 5172
#include<iostream>
#include<vector>
#include<string>
#include<bitset>
#include<algorithm>
#include<map>
#include<queue>
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> data(n);
	rep(i, n)
		cin >> data[i];

	sort(data.begin(), data.end());

	int sum = 0;
	rep(i, k)
		sum += data[i];

	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

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; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }

struct Tmp
{
public:
  Tmp(int N);
};

Tmp::Tmp(int N){}

void solve(void)
{
  int N; cin >> N;
  vector<char> P(N); for(auto& p : P) cin >> p;
  vector<char> Q(N); for(auto& q : Q) cin >> q;
  // string Ps(P.begin(), P.end());
  // string Qs(Q.begin(), Q.end());

#if 1
  vector<char> vc{};
  for (int i = 1; i <= N; ++i) {
    vc.push_back('0' + i);
  }

  int a{}, b{};
  int i = 1;
  do {
    // string s(vc.begin(), vc.end());
    if (vc == P) {
      a = i;
    }
    if (vc == Q) {
      b = i;
    }
    ++i;
  } while (std::next_permutation(vc.begin(), vc.end()));
  auto ans = std::abs(a - b);
#else
  std::deque<string> que{};
  que.push_back("");
  vector<string> res{};
  while (!que.empty()) {
    auto s = que.front();
    que.pop_front();
    if ((int)s.size() == N) {
      res.push_back(s);
      continue;
    }
    for (int i = 1; i <= N; ++i) {
      char c = '0' + i;
      if (s.find(c) == s.npos) {
        que.push_back(s + c);
      }
    }
  }
  boost::sort(res, std::less<string>());

  auto Pitr = boost::lower_bound(res, Ps);
  auto Qitr = boost::lower_bound(res, Qs);
  auto Pindex = std::distance(res.begin(), Pitr);
  auto Qindex = std::distance(res.begin(), Qitr);
  auto ans = std::abs(Pindex - Qindex);
#endif

  cout << ans << CRLF;
  return;
}

int main(void)
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);

  solve();

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>
#define INF 1000000000
#define LINF 9000000000000000000
#define mod  1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pi;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int main(){
  string s;
  cin >> s;
  for(int i = 0; i < s.size(); i++){
    for(int j = 0; j < s.size() - i; j++){
      string ss = s;
      ss.erase(i, j);
      //cerr << ss << endl;
      if(ss == "keyence"){
	cout << "YES" << endl;
	return 0;
      }
    }
  }
  cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF=0x3f3f3f3f;
const int N=16,M=1<<N;
int n,m,x,c[N],a[N][N];
int res[16];
int f[M][N];
int main()
{
	cin>>n>>m>>x;
	for(int i=1;i<=n;i++)
	{
		cin>>c[i];
		for(int j=1;j<=m;j++) cin>>a[i][j];
	}
	int ans=INF;
	for(int i=1;i<(1<<n);i++)
	{
		
		memset(res,0,sizeof res);
		for(int j=0;j<n;j++)
		{
			if(i&(1<<j))
			{
				for(int k=1;k<=m;k++)
					res[k]+=a[j+1][k];
			}
		}
		int f=1;
		int cnt=0;
		for(int j=1;j<=m;j++)
		{
			if(res[j]<x)
			{
				f=0;
				break;
			}
		}
		if(f)
		{
			for(int j=0;j<n;j++)
			{
				if(i&(1<<j))
					cnt+=c[j+1];
			}
			ans=min(ans,cnt);
		}
	}
	if(ans==INF) puts("-1");
	else cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 3636
using System;
using System.Linq;

class Program
{
	static void Main()
	{
		var numbers = Array.ConvertAll(Console.ReadLine().Split(new[] { ' ' }), number => int.Parse(number));
		var n = numbers[0];
		var m = numbers[1];

		var studentPoints = Enumerable.Range(0, n).Select(number => {
			var ab = Array.ConvertAll(Console.ReadLine().Split(new[] { ' ' }), number => long.Parse(number));
			return new { A = ab[0], B = ab[1] };
		}).ToArray();
		var checkPoints = Enumerable.Range(0, m).Select(number => {
			var ab = Array.ConvertAll(Console.ReadLine().Split(new[] { ' ' }), number => long.Parse(number));
			return new { C = ab[0], D = ab[1] };
		}).ToArray();

		foreach (var studentPoint in studentPoints) {
			var nearestCheckPoint = 0;
			var nearestDistance = long.MaxValue;
			for (var i = 0; i < m; ++i) {
				var checkPoint = checkPoints[i];
				var distance = Math.Abs(checkPoint.C - studentPoint.A) + Math.Abs(checkPoint.D - studentPoint.B);
				if (distance < nearestDistance) {
					nearestCheckPoint = i + 1;
					nearestDistance = distance;
				}
			}

			Console.WriteLine(nearestCheckPoint);
		}
	}
}


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

#define endl "\n"
#define IOS                \
  ios::sync_with_stdio(0); \
  cin.tie(0);              \
  cout.tie(0);

using namespace std;

const int MAX_NUM = 1e5;
int a[MAX_NUM];
int dp[MAX_NUM];
int n;

int rec (int i) {
  if (i == n - 1) return 0;
  if (dp[i] != -1) return dp[i];
  int cost = abs(a[i] - a[i + 1]) + rec(i + 1);
  if (i + 2 <= n - 1) {
    cost = min(cost, abs(a[i] - a[i + 2]) + rec(i + 2));
  }
  return dp[i] = cost;
}

int main() {
  IOS;
  cin >> n;
  memset(dp, -1, sizeof(dp));
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  cout << rec(0) << endl;
  return 0;
}

Measured memory_bytes: 5760
using System;


namespace hello_world
{
	class Program
	{

		static void Main(string[] args)
		{
			string s = Console.ReadLine();
			string a = s.Substring(2,1);
			string b = s.Substring(3, 1);
			string c = s.Substring(4, 1);
			string d = s.Substring(5, 1);
			string xx = a == b && c == d ? "Yes" : "No";
			Console.WriteLine(xx);

		}
	}

}

Measured memory_bytes: 13140
#include<iostream>
#include<cstdio>
#include<cstring>
#define LL long long
using namespace std;
int const mod=1e9+7;
int const maxn=1e5+10;
int a[maxn];
int main()
{
    int n,i,j,k;
    int ans=0;
    cin>>n;
    for (i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    for (i=1;i<=n-1;i++)
    {
        if (a[i]==i) 
        {
            swap(a[i],a[i+1]);
            ans++;
        }
    }
    if (a[n]==n)
    {
        ans++;
        swap(a[n-1],a[n]);
    }
    cout<<ans<<endl;
}


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

typedef long long ll;
#define mp make_pair
#define pb push_back
#define pi pair<ll,ll>
#define ff first
#define ss second
#define MAX 100005
const ll MOD = 1000000007;

struct an{
	int sy,sx,gy,gx;
};

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

	int t=1;
//	cin>>t;
	while(t--){
	int h,w;
	cin>>h>>w;
	int a[h+5][w+5];
	
	for(int i=0;i<h;i++)
	{
	   for(int j=0;j<w;j++)	
	   cin>>a[i][j];
	}
	w--;
	vector<an>ans;
	
	for(int i=0;i<h;i++)
	{
		 for(int j=0;j<w;j++)
		 {
		 	if(a[i][j]%2==0) continue;
		 	a[i][j+1]++;
		 	ans.pb({i+1,j+1,i+1,j+2});
		 }
		 if(i>=h-1 || a[i][w]%2==0) continue;
		 a[i+1][w]++;
		 ans.pb({i+1,w+1,i+2,w+1});
	}
	cout<<ans.size()<<endl;
	for(auto i:ans)
	{
		cout<<i.sy<<" "<<i.sx<<" "<<i.gy<<" "<<i.gx<<endl;
	}
	}		
}

Measured memory_bytes: 6264
#include "bits/stdc++.h"
#include<unordered_map>
#pragma warning(disable:4996)
using namespace std;

struct aa {
	int now;
	int dis;
	int gas;
};
class Compare {
public:
	//keiroが昇順に並ぶ
	bool operator()(const aa&l, const aa&r) {
		return l.dis> r.dis;
	}
};
int main() {
	while (1) {
		int N, M, cap; cin >> N >> M >> cap;
		cap *= 10;
		if (!N)break;
		map<string, int>mp;
		int num = 2;
		vector<vector<pair<int, int>>>edges(6000);
		string sta, goa; cin >> sta >> goa; mp[sta] = 0; mp[goa] = 1;
		for (int i = 0; i < N; ++i) {
			string f, t; cin >> f >> t;
			int dis; cin >> dis;
			if (!mp.count(f)) {
				mp[f] = num++;
			}
			if (!mp.count(t)) {
				mp[t] = num++;
			}
			const int fid = mp[f];
			const int tid = mp[t];
			edges[fid].push_back(make_pair(tid, dis));
			edges[tid].push_back(make_pair(fid, dis));
		}
		edges.resize(mp.size());
		vector<bool>stat(edges.size(),false);
		for (int i = 0; i < M; ++i) {
			string st; cin >> st;
			if (mp.count(st)) {
				stat[mp[st]] = true;
			}
		}
		vector<vector<int>>mindiss(mp.size(), vector<int>(cap + 1, 99999999));
		priority_queue<aa, vector<aa>, Compare>que;
		que.push(aa{ 0,0,cap });
		mindiss[0][cap] = 0;

		while (!que.empty()) {
			aa atop(que.top());
			que.pop();
			const int pregas = atop.gas;
			const int nowdis = atop.dis;
			
			for (auto i : edges[atop.now]) {
				if (pregas >= i.second) {
					const int newid = i.first;
					const int newgas = stat[newid]?cap:atop.gas - i.second;
					const int newdis = nowdis + i.second;
					if (mindiss[newid][newgas]> newdis) {
						mindiss[newid][newgas] = newdis;
						que.push(aa{ newid, newdis ,newgas });
					}
				}
			}
		}
		int ans = 99999999;
		for (int i = 0; i < cap + 1; ++i) {
			ans = min(mindiss[1][i], ans);
		}
		if (ans == 99999999) {
			cout << -1 << endl;
		}
		else {
			cout << ans << endl;

		}
	}
	return 0;
}

Measured memory_bytes: 51680
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.function.Consumer;

public class Main {
    private static final Scanner scanner = new Scanner(System.in);
    private static final Consumer<List<String>> consumer = solve();

    public static void main(String[] args) {
        consumer.accept(readInput());
    }

    private static List<String> readInput() {
        final List<String> lineList = new ArrayList<>();
        while (scanner.hasNextLine()) {
            lineList.add(scanner.nextLine());
        }
        return lineList;
    }

    static Consumer<List<String>> solve() {
        return args -> {
            int N = Integer.parseInt(args.get(0).split(" ")[0]);
            int A = Integer.parseInt(args.get(0).split(" ")[1]);
            int B = Integer.parseInt(args.get(0).split(" ")[2]);
            int[][] items = new int[N][3];
            for (int i = 0; i < N; i++) {
                items[i] = Arrays.stream(args.get(1 + i).split(" "))
                        .mapToInt(Integer::parseInt).toArray();
            }

            int[][][] dp = new int[N + 1][401][401];
            for (int[][] a : dp) {
                for (int[] b : a) {
                    Arrays.fill(b, Integer.MAX_VALUE / 2);
                }
            }
            dp[0][0][0] = 0;
            int min = Integer.MAX_VALUE;
            for (int i = 1; i <= N; i++) {
                for (int a = 0; a < 401; a++) {
                    for (int b = 0; b < 401; b++) {
                        if (a >= items[i - 1][0] && b >= items[i - 1][1]) {
                            dp[i][a][b] = Math.min(
                                    dp[i - 1][a][b],
                                    dp[i - 1][a - items[i - 1][0]][b - items[i - 1][1]] + items[i - 1][2]);
                        } else {
                            dp[i][a][b] = dp[i - 1][a][b];
                        }
                        if (a > 0 && A * b == B * a) {
                            min = Math.min(min, dp[i][a][b]);
                        }
                    }
                }
            }

            System.out.println(min == Integer.MAX_VALUE / 2 ? -1 : min);
        };
    }
}

Measured memory_bytes: 56912
T1, T2 = map(int, input().split())
A1, A2 = map(int, input().split())
B1, B2 = map(int, input().split())

if A1 < B1:
    A1, B1 = B1, A1
    A2, B2 = B2, A2


if A1 * T1 + A2 * T2 > B1 * T1 + B2 * T2:
    print (0)
    exit()
if A1 * T1 + A2 * T2 == B1 * T1 + B2 * T2:
    print ('infinity')
    exit()

bunshi = (B1 - A1) * T1
bunbo = (A1 * T1 + A2 * T2) - (B1 * T1 + B2 * T2)

# print (bunshi)
# print (bunbo)

n = 1 + bunshi // bunbo

if bunshi % bunbo == 0:
    print (int(n) * 2 - 2)
else:
    print (int(n) * 2 - 1)

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;

int main() {
	double d = 0.0;
	int ans;
	double n;

	while (cin >> d) {
		n = (4.9*pow((d / 9.8), 2) + 5) / 5;
		ans = ceil(n);
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 1228
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  s=list(S())
  s=collections.deque(s)
  f=True
  q=I()

  for _ in range(q):
    l=LS()
    if l==['1']:
      f=not f
    else:
      if l[1]=='1':
        if f:
          s.appendleft(l[2])
        else:
          s.append(l[2])
      else:
        if f:
          s.append(l[2])
        else:
          s.appendleft(l[2])

  s=list(s)

  if f:
    return ''.join(s)
  s.reverse()
  return ''.join(s)

# main()
print(main())


Measured memory_bytes: 93700
import javax.management.monitor.CounterMonitor;
import java.lang.reflect.Array;
import java.math.BigDecimal;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        //
        //Euclid e1=new Euclid();//ユークリッドの互除法
        //Compute c1=new Compute();//累積和，
        //変数
        int count = 0;
        boolean sw = false;
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        double dMax = Double.MIN_VALUE;
        double dMin = Double.MAX_VALUE;
        int answer = 0;
        //StringBuilder answer=new StringBuilder();
        //List<Integer> list = new ArrayList<>();
        //int array[] = new int[];

        //入力
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();

        answer=180*(N-2);
        //出力
        //BigDecimal bd = new BigDecimal(answer);
        //System.out.println(bd.setScale(12,BigDecimal.ROUND_DOWN));
        //System.out.println(String.format("%.0f",answer));
        System.out.println(answer);
    }
}

Measured memory_bytes: 21204
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
	int a,b;
	char op;
	scanf("%d %c %d", &a, &op, &b);
	if(op=='+')
	printf("%d",a+b);
	else if(op=='-')
	printf("%d",a-b);
	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int ok[28], i, m;
	for(i=0; i<28; i++)
	{
		scanf("%d", &ok[i]);
	}
	for(m=1; m<=30; m++)
	{
		for(i=0; i<28; i++)
		{
			if(m==ok[i])
			{
				break;
			}
			else if(m!=ok[i]&&i==27)
			{
				printf("%d\n", m);
			}
		}
	}
	
	return 0;
}


Measured memory_bytes: 2744
N = int(input())
l = [int(input()) for _ in range(N)]

def gcd(a, b):  # a,bの最大公約数
    while b:
        a, b = b, a % b
    return a

def lcm(a, b):  # a,bの最小公倍数
    return a * b // gcd(a, b)

ans = lcm(l[0], l[1]) if N >= 2 else l[0]
for i in range(2, N):
    ans = lcm(ans, l[i])
print(ans)

Measured memory_bytes: 3064