akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main {
	
	static long N, A, B, C, D, ans, INF = Long.MAX_VALUE;
	static Map<Long, Long> m;

	static long dfs(long N) {
		if(m.containsKey(N))
			return m.get(N);
		if(N < INF / D)
			ans = N * D;
		else
			ans = INF;
		for(int i = -1; i <= 1; i++)
			if((N + i) % 2 == 0)
				ans = Math.min(ans, dfs((N+i)/2) + A + Math.abs(i*D));
		for(int i = -1; i <= 1; i++)
			if((N + i) % 3 == 0)
				ans = Math.min(ans, dfs((N+i)/3) + B + Math.abs(i*D));
		for(int i = -2; i <= 2; i++)
			if((N + i) % 5 == 0)
				ans = Math.min(ans, dfs((N+i)/5) + C + Math.abs(i*D));
		m.put(N, ans);
		return ans;
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int T = sc.nextInt();
		for(int i = 0; i < T; i++) {
			N = sc.nextLong();
			A = sc.nextInt();
			B = sc.nextInt();
			C = sc.nextInt();
			D = sc.nextInt();
			m = new HashMap<>();
			m.put(0L, 0L);
			m.put(1L, D);
			System.out.println(dfs(N));
		}
	}

}

Measured memory_bytes: 62720
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int happiness_points[100001][4], v[4];

int main() {
    int n;
    cin >> n;
    cin >> happiness_points[1][1] >> happiness_points[1][2] >> happiness_points[1][3];

    for(int i = 2; i <= n; i++) {
        cin >> v[1] >> v[2] >> v[3];
        happiness_points[i][1] = max(happiness_points[i - 1][2], happiness_points[i - 1][3]) + v[1];
        happiness_points[i][2] = max(happiness_points[i - 1][3], happiness_points[i - 1][1]) + v[2];
        happiness_points[i][3] = max(happiness_points[i - 1][1], happiness_points[i - 1][2]) + v[3];
    }

    cout << max(happiness_points[n][1], max(happiness_points[n][2], happiness_points[n][3]));
    return 0;
}


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

int cal(int n)
{
    int ans = 0;
    while(n>0)
    {
        ans+=n%10;
        n/=10;
    }
    return ans;
}

int main()
{
    int n;
    cin>>n;
    int temp = cal(n);
    //cout<<temp<<endl;
    if(n%temp==0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}



Measured memory_bytes: 256
N,P=map(int,input().split())
S=input()
if P==2 or P==5:
    x=0
    for j in range(N):
        if int(S[j])%P==0:
            x+=j+1
    print(x)
else:
    A=[0]*P
    a=0
    b=1
    for i in range(N):
        a=(a+int(S[(N-1-i)])*b)%P
        A[a]+=1
        b=(b*10)%P
    x=A[0]
    for k in range(P):
        x+=int(A[k]*(A[k]-1)/2)
    print(x)
    

Measured memory_bytes: 41180
import java.util.*;
 
class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int d[] = new int[n];
		int c = 0;
		
		for(int i = 0;i<n;i++) {
	
			d[i] = sc.nextInt();
		}
		
		for(int i = 0;i<n-1;i++) {
			for(int j =i+1;j<n;j++) {

			c+= d[i]*d[j];

		}
		}

		

		System.out.println(c);
 
		sc.close();
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <iomanip>
#include <cmath>

using namespace std;

//距離を計算する
double distance(double x1, double y1, double x2, double y2)
{
	double dist;

	dist = sqrt( pow(x2 - x1, 2) + pow(y2 - y1, 2) );

	return dist;
}

int main(void)
{
	double x1, y1;
	double x2, y2;
	double dist;

	//座標入力
	cin >> x1 >> y1 >> x2 >> y2;
	
	cout << fixed;
	cout << setprecision(6) << distance(x1, y1, x2, y2) << endl;

	return 0;
}



Measured memory_bytes: 3208
#include <bits/stdc++.h>
using namespace std;
#define all(V) V.begin(),V.end()
#define ll long long
#define MOD 1000000007

vector<int> XS[100010];

int main() {
	int N, M, X;
	cin >> N >> M;
	for (int i = 0;i < N;i++) {
		cin >> X;
		XS[X % M].push_back(X);
	}
	int ans = XS[0].size() / 2, t, cnt, cmax;
	if (M % 2 == 0)ans += XS[M / 2].size() / 2;
	for (int i = 1;i < (M + 1) / 2;i++) {
		cmax = 0, cnt = 1;
		if (XS[M - i].size() > XS[i].size()) {
			t = XS[M - i].size() - XS[i].size();
			sort(all(XS[M - i]));
			for (int j = 1;j < XS[M - i].size();j++) {
				if (XS[M - i][j] == XS[M - i][j - 1])cnt++;
				else cmax += cnt / 2, cnt = 1;
			}
			cmax += cnt / 2;
			ans += XS[i].size() + min(t / 2, cmax);
		}
		else {
			t = XS[i].size() - XS[M - i].size();
			sort(all(XS[i]));
			for (int j = 1;j < XS[i].size();j++) {
				if (XS[i][j] == XS[i][j - 1])cnt++;
				else cmax += cnt / 2, cnt = 1;
			}
			cmax += cnt / 2;
			ans += XS[M - i].size() + min(t / 2, cmax);
		}
	}
	cout << ans << endl;
}

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

using namespace std;

int main(){
  int n;
  int min=0;
  int ans=0;
  cin >> n;
  vector<int> p(n);
  for(int i=0;i<n;i++){
    cin >> p.at(i);
  }
  min=p.at(0);
  for(int i=0;i<n;i++){
    if( p.at(i) <= min ){
      ans++;
      min=p.at(i);
      // cout << i << endl;
    }
  }
  cout << ans << endl;
  return 0;
}


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

typedef struct _road {
  int a;
  int b;
} road;

int main(void) {
  int n, m;
  int* h;
  road* r; // 道
  _Bool* isBad;
  scanf("%d %d", &n, &m);
  h = (int*)malloc(sizeof(int)*n);
  // 良い天文台: 0, 悪い天文台: 1
  isBad = (_Bool*)malloc(sizeof(_Bool)*n);
  r = (road*)malloc(sizeof(road)*m);
  int i, tmp1, tmp2;
  for(i=0; i<n; i++) {
    scanf("%d", &h[i]);
  }
  for(i=0; i<m; i++) {
    scanf("%d %d", &tmp1, &tmp2);
    r[i].a = tmp1; r[i].b = tmp2;
  }
  for(i=0; i<m; i++) {
    // r[i].aとr[i].b個目の天文台がつながっている．
    // h[r[i].a-1]とh[r[i].b-1]を比較し，小さい方は悪確定
    if(h[r[i].a-1] > h[r[i].b-1]) {
      isBad[r[i].b-1] = 1;
      //printf("%d: bad\n", r[i].b);
    }
    else if(h[r[i].a-1] < h[r[i].b-1]) {
      isBad[r[i].a-1] = 1;
      //printf("%d: bad\n", r[i].a);
    }
    else {
      isBad[r[i].a-1] = 1;
      isBad[r[i].b-1] = 1;
    }
    //printf("%d %d\n", r[i].a, r[i].b);
    //printf("%d %d\n", h[r[i].a-1], h[r[i].b-1]);
    //printf("\n");
  }
  int count=0;
  for(i=0; i<n; i++) {
    if(isBad[i] == 0) {
      count++;
    }
  }
  printf("%d\n", count);
  return 0;
}

Measured memory_bytes: 2996
#include <bits/stdc++.h>
#define INF 1e7
#define mod 1000000007

using namespace std;
typedef long long int ll;
typedef tuple<int,int,int> tii;
typedef tuple<long long int,long long int,long long int> tll;
typedef tuple<double,double,double> tdd;


int main()
{
    ll M; cin >> M;
    ll S = 0;
    ll N = 0;
    for(int i = 0; i < M; i++)
    {
        ll c,d; cin >> d >> c;
        S += c*d;
        N += c;
    }
    ll last = S % 9;
    if(last == 0) last = 9;
    ll b = 9*N+S;
    ll e = 9+last;
    ll ans = (b-e)/9;
    cout << ans << endl;
}

Measured memory_bytes: 3620
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		FastScanner in = new FastScanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		ProblemE solver = new ProblemE();
		solver.solve(1, in, out);
		out.close();
	}

	static class ProblemE {
		public void solve(int testNumber, FastScanner in, PrintWriter out) {
			int n = in.nextInt();
			int m = in.nextInt();
			boolean[][] g = new boolean[n][n];
			for (boolean[] arr : g) {
				Arrays.fill(arr, true);
			}
			for (int i = 0; i < n; i++) {
				g[i][i] = false;
			}
			for (int i = 0; i < m; i++) {
				int a = in.nextInt() - 1;
				int b = in.nextInt() - 1;
				g[a][b] = false;
				g[b][a] = false;
			}

			int[] col = new int[n];
			int[] q = new int[n];
			int[] a = new int[n];
			int[] b = new int[n];
			int numComps = 0;
			for (int s = 0; s < n; s++) {
				if (col[s] != 0) {
					continue;
				}
				int qt = 0;
				int qh = 0;
				col[s] = 1;
				q[qh++] = s;
				while (qt < qh) {
					int v = q[qt++];
					for (int u = 0; u < n; u++) {
						if (!g[v][u]) {
							continue;
						}
						if (col[u] == 0) {
							col[u] = 3 - col[v];
							q[qh++] = u;
						} else if (col[u] == col[v]) {
							// Not bipartite.
							out.println(-1);
							return;
						}
					}
				}
				for (int i = 0; i < qt; i++) {
					int v = q[i];
					if (col[v] == 1) {
						++a[numComps];
					} else {
						++b[numComps];
					}
				}
				++numComps;
			}
			a = Arrays.copyOf(a, numComps);
			b = Arrays.copyOf(b, numComps);

			boolean[] f = new boolean[n * n + 1];
			boolean[] nf = new boolean[n * n + 1];
			f[0] = true;
			for (int i = 0; i < a.length; i++) {
				Arrays.fill(nf, false);
				for (int s = 0; s < f.length; s++) {
					if (f[s]) {
						nf[s + a[i]] = true;
						nf[s + b[i]] = true;
					}
				}
				boolean[] t = f;
				f = nf;
				nf = t;
			}
			int ans = n * n;
			for (int i = 0; i < f.length; i++) {
				if (f[i]) {
					int j = n - i;
					ans = Math.min(ans, i * (i - 1) / 2 + j * (j - 1) / 2);
				}
			}
			out.println(ans);
		}

	}

	static class FastScanner {
		private BufferedReader in;
		private StringTokenizer st;

		public FastScanner(InputStream stream) {
			in = new BufferedReader(new InputStreamReader(stream));
		}

		public String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					String rl = in.readLine();
					if (rl == null) {
						return null;
					}
					st = new StringTokenizer(rl);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return st.nextToken();
		}

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

	}
}



Measured memory_bytes: 47568
#include <bits/stdc++.h>
using namespace std;
#define PI 3.14159265358979323
#define ll long long int
#define vi vector <int>
#define vl vector <ll>
#define all(v) (v).begin(),(v).end()
#define pb push_back
 
ll power(ll a, ll b){//a^b
    ll res=1;
    while(b>0){
        if(b&1){res=(res*a);b--;}
        a=(a*a);
        b>>=1;
    }
    return res;
}
 
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}
 
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string s;
	string t;
	cin>>s;
	cin>>t;
	ll ans=0;
	ll n=s.length();
	for(ll i=0;i<n;i++){
		if(s[i]!=t[i])
			ans++;
	}
	cout<<ans<<"\n";
}


Measured memory_bytes: 3772
#include <algorithm>
#include <cctype>
#include <cmath>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
using namespace std;

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

    for (int i = 1; i <= 9; i++) {
        for (int j = 1; j <= 9; j++) {
            if (i * j == n) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

#define inRange(x, y, w, h) (0 <= x && x < w && 0 <= y && y < h)

using namespace std;

int main( void )
{
	enum {
		U, D, L, R
	};
	char p[] = { '^', 'v', '<', '>' };
	int dx[] = { 0, 0, -1, 1 };
	int dy[] = { -1, 1, 0, 0 };
	int t;
	cin >> t;
	while(t--) {
		int w, h, px, py, drct;
		char map[21][21];
		cin >> h >> w;
		for(int y=0; y < h; ++y)
			for(int x=0; x < w; ++x) {
				cin >> map[y][x];
				switch(map[y][x]) {
					case '^':	px = x; py = y; drct = U;	break;
					case '<':	px = x; py = y; drct = L;	break;
					case '>':	px = x; py = y; drct = R;	break;
					case 'v':	px = x; py = y; drct = D;	break;
				}
			}
		map[py][px] = '.';
		int n;
		cin >> n;
		for(int i=0; i < n; ++i) {
			char c;
			cin >> c;
			int mx, my;
			switch(c) {
				case 'U':
					drct = U;
					mx = px + dx[drct]; my = py + dy[drct];
					if(inRange(mx, my, w, h) && map[my][mx] == '.') {
						px = mx; py = my;
					}
					break;
				case 'D':
					drct = D;
					mx = px + dx[drct]; my = py + dy[drct];
					if(inRange(mx, my, w, h) && map[my][mx] == '.') {
						px = mx; py = my;
					}
					break;
				case 'L':
					drct = L;
					mx = px + dx[drct]; my = py + dy[drct];
					if(inRange(mx, my, w, h) && map[my][mx] == '.') {
						px = mx; py = my;
					}
					break;
				case 'R':
					drct = R;
					mx = px + dx[drct]; my = py + dy[drct];
					if(inRange(mx, my, w, h) && map[my][mx] == '.') {
						px = mx; py = my;
					}
					break;
				case 'S':
					mx = px + dx[drct]; my = py + dy[drct];
					while(inRange(mx, my, w, h)) {
						char info = map[my][mx];
						if		(info == '*') {
							map[my][mx] = '.';
							break;
						}
						else if	(info == '#') break;
						mx += dx[drct]; my += dy[drct];
					}
					break;
			}
		}
		map[py][px] = p[drct];
		for(int y=0; y < h; ++y, cout << endl)
			for(int x=0; x < w; ++x)
				cout << map[y][x];
		if(t) cout << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <string.h>
#include <string>
#include <map>
#include <algorithm>

using namespace std;

int
main(void)
{
	char line[1002];

	if (fgets(line, sizeof line, stdin) == NULL) {
		return 0;
	}

	char* token = strtok(line, " \n");

	map<string, int> s;
	int m = 0;
	string ms;

	while (token) {
		string ts(token);

		if (s.find(ts) == s.end()) {
			s[ts] = 0;
		}
		s[ts] ++;

		if (m < (int)(ts.size())) {
			m = ts.size();
			ms = ts;
		}
		
		token = strtok(NULL, " \n");
	}

	if (!s.empty()) {
		auto itr = max_element(s.begin(), s.end(),
			[](const pair<string, int>& a, const pair<string, int>& b)
				-> bool {
					return (a.second < b.second);
				});
				
		printf("%s %s\n", (*itr).first.c_str(), ms.c_str());
	}

	return 0;
}

Measured memory_bytes: 1020
import heapq

n = int(input())
a = [int(i) for i in input().split()]
q = int(input())
bc = [[int(i) for i in input().split()] for j in range(q)]

dp = [0 for _ in range(100001)]

for i in a:
    dp[i] += 1

total = sum(a)

for i in range(q):
    total += (bc[i][1] - bc[i][0]) * dp[bc[i][0]]
    print(total)
    dp[bc[i][1]] += dp[bc[i][0]]
    dp[bc[i][0]] = 0

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

int main(int argc, char *argv[]) {
  uint64_t a, b, c, d;
  cin >> a >> b >> c >> d;
 
  uint64_t m = d, n = c;
  if (c > d) {
    m = c;
    n = d;
  }

  uint64_t r = m % n;
  while (r != 0) {
    m = n;
    n = r;
    r = m % n;
  }
  uint64_t l = (c * d) / n; // 最小公倍数

  // c で割り切れる数
  uint64_t ac = a / c;
  if (a % c > 0) {
    ac++;
  }
  uint64_t bc = b / c;
  
  // d で割り切れる数
  uint64_t ad = a / d;
  if (a % d > 0) {
    ad++;
  }
  uint64_t bd = b / d;
 
  // cとdどちらでも割り切れる数
  uint64_t acd = a / l;
  if (a % l > 0) {
    acd++;
  }
  uint64_t bcd = b / l;

  cout << ((b - a + 1) - ((bc - ac + 1) + (bd - ad + 1) - (bcd - acd + 1))) << endl;

  return 0;
}

Measured memory_bytes: 256
import math


def koch(p1, p2, count):
    """Find points in koch curve after count times operations.

    >>> ps = koch((0, 0), (100, 0), 1)
    >>> cs = ["({:.4f}, {:.4f})".format(*p) for p in ps]
    >>> print("\\n".join(cs))
    (0.0000, 0.0000)
    (33.3333, 0.0000)
    (50.0000, 28.8675)
    (66.6667, 0.0000)
    (100.0000, 0.0000)
    """

    if count == 0:
        return []

    (x1, y1) = p1
    (x2, y2) = p2

    r, t = cartesian_to_polar(x2-x1, y2-y1)

    x3, y3 = polar_to_cartesian(r/3, t)
    p3 = (x3+x1, y3+y1)

    x4, y4 = polar_to_cartesian(r / (2*math.cos(math.pi/6)), t + math.pi/6)
    p4 = (x4+x1, y4+y1)

    x5, y5 = polar_to_cartesian(2*r/3, t)
    p5 = (x5+x1, y5+y1)

    return (koch(p1, p3, count-1)
            + [p3] + koch(p3, p4, count-1)
            + [p4] + koch(p4, p5, count-1)
            + [p5] + koch(p5, p2, count-1))


def polar_to_cartesian(x, y):
    return (x * math.cos(y), x * math.sin(y))


def cartesian_to_polar(x, y):
    return (math.sqrt(x**2 + y**2), math.atan2(y, x))


def run():
    n = int(input())
    p1 = (0.0, 0.0)
    p2 = (100.0, 0.0)
    ps = [p1] + koch(p1, p2, n) + [p2]

    # plot(ps)
    print("\n".join(["{:.5f} {:.5f}".format(*p) for p in ps]))


def plot(ps):
    import pylab
    xs = [x for x, y in ps]
    ys = [y for x, y in ps]

    pylab.plot(xs, ys)
    pylab.xlim(0, 100)
    pylab.ylim(0, 100)
    pylab.show()


if __name__ == '__main__':
    run()



Measured memory_bytes: 6576
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize(4)
#include<bits/stdc++.h>
using namespace std;
#define y1 y11
#define fi first
#define se second
#define pi acos(-1.0)
#define LL long long
//#define mp make_pair
#define pb emplace_back
#define ls rt<<1, l, m
#define rs rt<<1|1, m+1, r
#define ULL unsigned LL
#define pll pair<LL, LL>
#define pli pair<LL, int>
#define pii pair<int, int>
#define piii pair<pii, int>
#define pdd pair<double, double>
#define mem(a, b) memset(a, b, sizeof(a))
#define debug(x) cerr << #x << " = " << x << "\n";
#define add(x) (x > MOD ? x-MOD :(x<0 ? x+MOD:x))
#define fio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//head 

const int N = 1e5 + 5;
vector<tuple<int, int, int>> g[N];
vector<tuple<int, int, int, int>> vc[N];
int n, m, a, b, c, d, x, y, u, v;
int anc[N][18], deep[N], len[N], ans[N];
int cur_cnt[N], cur_sum[N];
void dfs(int u, int o) {
    deep[u] = deep[o] + 1;
    anc[u][0] = o;
    for (int i = 1; i < 18; ++i) anc[u][i] = anc[anc[u][i-1]][i-1];
    for (auto t : g[u]) {
        int v = get<0>(t), w = get<2>(t);
        if(v != o) {
            len[v] = len[u] + w;
            dfs(v, u);
        }
    }
}
void DFS(int u, int o) {
    for (auto t : vc[u]) {
        int id = get<0>(t), c = get<1>(t), w = get<2>(t), f = get<3>(t);
        ans[id] -= f*cur_sum[c];
        ans[id] += f*cur_cnt[c]*w;
    }
    for (auto t : g[u]) {
        int v = get<0>(t), c = get<1>(t), w = get<2>(t);
        if(v != o) {
            cur_cnt[c]++;
            cur_sum[c] += w;
            DFS(v, u);
            cur_cnt[c]--;
            cur_sum[c] -= w;
        }
    }
}
inline int lca(int u, int v) {
    if(deep[u] < deep[v]) swap(u, v);
    for (int i = 17; i >= 0; --i) if(deep[anc[u][i]] >= deep[v]) u = anc[u][i];
    if(u == v) return u;
    for (int i = 17; i >= 0; --i) if(anc[u][i] != anc[v][i]) u = anc[u][i], v = anc[v][i];
    return anc[u][0];
}
int main() {
    scanf("%d %d", &n, &m);
    for (int i = 1; i < n; ++i) scanf("%d %d %d %d", &a, &b, &c, &d),  g[a].pb(b, c, d), g[b].pb(a, c, d);
    dfs(1, 1);
    for (int i = 1; i <= m; ++i) {
        scanf("%d %d %d %d", &x, &y, &u, &v);
        int a = lca(u, v);
        ans[i] = len[u]+len[v]-2*len[a];
        vc[u].pb(i, x, y, 1);
        vc[v].pb(i, x, y, 1);
        vc[a].pb(i, x, y, -2);
    }
    DFS(1, 1);
    for (int i = 1; i <= m; ++i) printf("%d\n", ans[i]);
    return 0;
}


Measured memory_bytes: 29428
#include <iostream>
#define llint long long

using namespace std;

llint n, k;

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> k;
	llint ans = k;
	for(int i = 2; i <= n; i++){
		ans *= k-1;
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;
public class Hello
{
    private const long INF = 1000000007;
    private struct Pair { public long x, y; public Pair(long xx, long yy) { x = xx; y = yy; } }
    public static void Main()
    {
        int N = NextInt();
        Dictionary<string, Dictionary<int, int>> d = new Dictionary<string, Dictionary<int, int>>();
        HashSet<string> name = new HashSet<string>();
        for (int i = 0; i < N; i++)
        {
            string S = NextString();
            int P = NextInt();
            if (!d.ContainsKey(S)) d[S] = new Dictionary<int, int>();
            if (!name.Contains(S)) name.Add(S);
            d[S][P] = i + 1;
        }

        string[] s = name.ToArray();
        Array.Sort(s);

        foreach (string ss in s)
        {
            var e = d[ss];
            var sorted = e.OrderByDescending(v => v.Key);
            foreach (var f in sorted) {
                Console.WriteLine(f.Value);
            }
        }
    }
}

public class Input
{
    private static Queue<string> queue = new Queue<string>();
    private static void Confirm() { if (queue.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) queue.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(queue.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(queue.Dequeue()); }
    public static string NextString() { Confirm(); return queue.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(queue.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


Measured memory_bytes: 13792
#include<bits/stdc++.h>
#define pi 3.1415
#define ll long long
#define pii pair<int,int>
#define debug(a) cout<<a<<'\n'
#define maxn 200009
#define MOD 200009
#define inp freopen("input.txt", "r", stdin)
#define out freopen("out.txt", "w", stdout)
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    cout<<3*pow(n,2)<<endl;

    return 0;
}   


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;
use std::cmp;
use std::collections::HashMap;
use std::collections::HashSet;
use std::char;
use std::cmp::{min, max};
use itertools::Itertools;
use std::ops::{Add, AddAssign};
use num_integer::{Integer, gcd, lcm};
use std::collections::VecDeque;
use smallvec::alloc::collections::LinkedList;
use regex::internal::Char;

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")
}

fn read_tuple2<T: FromStr, S: FromStr>() -> (T, S) {
    let a = read();
    let b = read();
    (a, b)
}

fn read_tuple3<T: FromStr, S: FromStr, R: FromStr>() -> (T, S, R) {
    let a = read();
    let b = read();
    let c = read();
    (a, b, c)
}

fn lower_bound<T: Copy, F>(v: &Vec<T>, f: F) -> Option<usize> where
    F: Fn(T) -> bool
{
    let mut left = 0;
    let mut right = v.len() - 1;
    if !f(v[left]) {
        return None;
    }
    if f(v[right]) {
        return Some(right);
    }
    loop {
        if right - left == 1 {
            return Some(left);
        }
        let mid = (left + right) / 2;
        if f(v[mid]) {
            left = mid;
        } else {
            right = mid;
        }
    }
}

fn main() {
    let (h, w, k):(u32, u32, u32) = read_tuple3();
    let mut vec:Vec<Vec<char>> = Vec::new();
    for _ in (0..h) {
        let n:String = read();
        let a = n.chars().collect_vec();
        vec.push(a);
    }
    let mut ans = 0_u32;
    for h_sel in 0..2_u32.pow(h) {
        for w_sel in 0..2_u32.pow(w) {
            let mut counter = 0;
            for h_use in 0..h {
                if h_sel & (1<<h_use) > 0 {
                    continue;
                }
                for w_use in 0..w {
                    if w_sel & (1<<w_use) > 0 {
                        continue;
                    }
                    if (vec[h_use as usize][w_use as usize] == '#') {
                        counter += 1;
                    }
                }
            }
            if counter == k {
                ans += 1;
            }
        }
    }
    println!("{}", ans);

}



Measured memory_bytes: 2136
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int tot = 0;
  for (int x = a; x <= b; x++)
    if (c % x == 0)
      ++tot;
  cout << tot << endl;
  return 0;
}


Measured memory_bytes: 3100
def inv(x, mod):
    return pow(x, mod - 2, mod)


def main() -> None:
    N, M, K = map(int, input().split())
    MOD = 10 ** 9 + 7
    ans = 0
    for d in range(1, N):
        ans += M * M * (N - d) * d
        ans %= MOD
    for d in range(1, M):
        ans += N * N * (M - d) * d
        ans %= MOD

    for i in range(K - 2):
        ans = (ans * (N * M - 2 - i)) % MOD
    for i in range(K - 2):
        ans = (ans * inv(i + 1, MOD)) % MOD
    print(ans)


if __name__ == '__main__':
    main()


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

#define LL long long

#define FOR(INDEX, START, END) for (int INDEX = (START); INDEX < (END); ++INDEX)
#define REP(INDEX, COUNT) for (int INDEX = 0; INDEX < (COUNT); ++INDEX)

int H, W;
int counter[50][50] = {};

void Add(int cx, int cy) {
	for (int oy = -1; oy <= 1; ++oy) {
		int y = cy + oy;
		if (y < 0 || y >= H) {
			continue;
		}
		for (int ox = -1; ox <= 1; ++ox) {
			int x = cx + ox;
			if (x < 0 || x >= W) {
				continue;
			}
			counter[y][x] += 1;
		}
	}
}

int main()
{
	cin >> H >> W;

	vector<string> field(H);
	REP(i, H) {
		cin >> field[i];
	}

	FOR(y, 0, H) {
		FOR(x, 0, W) {
			if (field[y][x] == '#') {
				Add(x, y);
			}
		}
	}

	FOR(y, 0, H) {
		FOR(x, 0, W) {
			if (field[y][x] == '#') {
				cout << '#';
			}
			else {
				cout << counter[y][x];
			}
		}
		cout << endl;
	}

	return 0;
}


Measured memory_bytes: 256
N,x = map(int, raw_input().split())
a = map(int, raw_input().split())

S = sum(a)
if x>S:
  print N-1
elif x==S:
  print N
else:
  a.sort()
  ans = 0
  for t in a:
    if x>=t:
      x -= t
      ans += 1
  print ans


Measured memory_bytes: 2568
using System;


namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split();
            int a = int.Parse(s[0]) * int.Parse(s[1]);
            int b = (int.Parse(s[0]) + int.Parse(s[1])) * 2;

            Console.WriteLine("{0} {1}",a,b);
        }
    }
}

Measured memory_bytes: 5624
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;
const ll INF = 1e9;

#define rep(i, n) for(ll i = 0; i < n ; i++ )
#define For(i, a, b) for(ll i = (a); i < (b) ; i++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

const ll MAX_N = 10;

int main(void){
    ll N;
    double x[MAX_N];
    string u[MAX_N];
    double answer = 0;
    double btc = 380000.0;
    cin >> N;
    
    rep(i, N) cin >> x[i] >> u[i];

    rep(i, N){
        if (u[i] == "JPY") answer += x[i];
        else answer += btc * x[i];
    }

    cout << answer << endl;

    return 0;
}

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

int main(){
  int a;
  cin >> a;
  for(int i = 1; i <= 9; i++){
    if(a % i == 0 && a / i >= 1 && a / i <= 9){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3648
#include<iostream>
#include<string>
int main(){
    std::string S,T;
    std::cin>>S>>T;
    int ans = 0;
    for(int i=0;i<3;++i){
        if(S[i]==T[i]){
            ans++;
        }
    }
    std::cout<<ans<<std::endl;
}

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

using namespace std;

int main()
{
	for (int i = 4; i > 1; i++) {
		int n;
		cin >> n;
		if (n == 0) break;
		vector<int> s(n);
		for (int b = 0; b < n; b++) {
			cin >> s[b];

		}
		
		int sum = 0;      // ????¨?????±????????????°
		for (int t = 0; t < n; t++) {
			// ??¨??¨???????´?????????????
			sum += s[t];    // ????¨??????????
		}
		
		int ma;
		int mi;
		ma = *max_element(s.begin(), s.end());
		mi = *min_element(s.begin(), s.end());
		
		double score;
		score = (sum - ma - mi) / (n - 2);
		cout << score << endl;
		

	}
}

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

 using namespace std;

 int main() {
   int N;
   cin >> N;

   vector<long long> Lucas(N + 1);

   Lucas.at(0) = 2;
   Lucas.at(1) = 1;
   for(int i = 2; i <= N; i++) {
     Lucas.at(i) = Lucas.at(i - 2) + Lucas.at(i - 1);
   }

   cout << Lucas.at(N) << endl;
 }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5, mod = 998244353;
int n, k, f[N], t[N << 2], tag[N << 2];
struct info{
	int l, r;
}b[N], d[N];
inline bool comp(info x, info y) {
	return x.l < y.l;
}
inline void build(int p, int l, int r) {
	t[p] = f[l]; tag[p] = 0;
	if (l == r) return;
	else {
		int mid = l + r >> 1;
		build(p << 1, l, mid);
		build(p << 1 | 1, mid + 1, r);
	}
}
inline void down(int p) {
	if (!tag[p]) return;
	tag[p << 1] = (tag[p << 1] + tag[p]) % mod;
	tag[p << 1 | 1] = (tag[p << 1 | 1] + tag[p]) % mod;
	t[p << 1] = (t[p << 1] + tag[p]) % mod;
	t[p << 1 | 1] = (t[p << 1 | 1] + tag[p]) % mod;
	tag[p] = 0;
}
inline void add(int p, int l, int r, int ql, int qr, int k) {
	if (ql <= l && r <= qr) {
		t[p] = (t[p] + k) % mod;
		tag[p] = (tag[p] + k) % mod;
	}
	else {
		down(p);
		int mid = l + r >> 1;
		if (mid >= ql) add(p << 1, l, mid, ql, qr, k);
		if (mid < qr) add(p << 1 | 1, mid + 1, r, ql, qr, k);
	}
}
inline void ask(int p, int l, int r, int pos) {
	if (l == r) f[l] = t[p];
	else {
		down(p);
		int mid = l + r >> 1;
		if (mid >= pos) ask(p << 1, l, mid, pos);
		else ask(p << 1 | 1, mid + 1, r, pos);
	}
}
int main() {
	scanf("%d%d", &n, &k);
	for (int i = 1; i <= k; i ++) {
		scanf("%d%d", &b[i].l, &b[i].r);
	}
	sort(b + 1, b + k + 1, comp);
	int cnt = 1;
	d[1] = b[1];
	for (int i = 2; i <= k; i ++) {
		if (d[cnt].r >= b[i].l) {
			d[cnt].r = max(d[cnt].r, b[i].r);
		}
		else {
			cnt ++;
			d[cnt] = b[i];
		}
	}
	build(1, 1, n);
	add(1, 1, n, 1, 1, 1);
	for (int i = 1; i <= n; i ++) {
		ask(1, 1, n, i);
		for (int j = 1; j <= cnt; j ++) {
			if (i + d[j].l > n) break;
			else {
				add(1, 1, n, i + d[j].l, min(i + d[j].r, n), f[i]);
			}
		}
	}
	cout << f[n] << endl;
	return 0;
}

Measured memory_bytes: 8596
#h=int(input())
a,b,m=map(int,input().split())
al=list(map(int,input().split()))
bl=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]

ans=min(al)+min(bl)

for i in range(m):
    x,y,c=map(int,input().split())
    ans=min(ans,al[x-1]+bl[y-1]-c)

print(ans)


Measured memory_bytes: 18608
#include <stdio.h>
  
int  main(void){
         int h,w,i,j;
          while(1){
          scanf("%d %d",&h,&w);
           if( h==0 && w==0)
              break;
           for(i=1; i<=h; i++){
            for(j=1; j<=w; j++){
              if(i==1 || i==h || j==1 || j==w)
              printf("#");
             else
              printf(".");
             }printf("\n");
            }printf("\n");
           }
            return 0;
}




Measured memory_bytes: 2048
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.141592653589793238462643383279502884L
#define make_unique(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define Sort(vec) sort(vec.begin(),vec.end())
#define RSort(vec) sort(vec.rbegin(),vec.rend())
#define endl "\n"
#define tr1(i) cout<<i<<endl;
#define tr2(i,j) cout<<i<<" "<<j<<endl;
#define tr3(i,j,k) cout<<i<<" "<<j<<" "<<k<<endl;
#define vvi vector<vector<int> > 
#define vvl vector<vector<ll> >
#define all(st) st.begin(),st.end()
#define vpl vector<pair<ll,ll> >
#define vpi vector<pair<int,int> >
#define pi pair<int,int>
#define pl pair<ll,ll>
#define al vector<list<int> >
#define vs vector<string>
#define vb vector<bool>
#define vi vector<int>
#define vl vector<ll>
#define vc vector<char>
#define rep(i,l,r) for(int i=l;i<r;i++)
#define repit(st) for(auto it=st.begin();it!=st.end();it++)
#define cs(ans); cout<<setprecision(20)<<fixed<<ans<<endl;
#define ull unsigned long long int
#define eb emplace_back
#define pb push_back
#define ll long long int
#define minf -(1e18)
#define inf 1e18
#define f first
#define se second
#define mod 1000000007
using namespace std;
using namespace __gnu_pbds; 
ll mi(ll n,ll m){ll pw=n%m;ll ex=m-2;ll ans=1;while(ex){if(ex&1) ans = ans*pw%m;pw = pw*pw%m;ex>>=1;}return ans%mod;}
ll pw(ll a,ll n){ll pw=a;ll ex=n;ll ans=1;while(ex){if(ex&1) ans = ans*pw;pw = pw*pw;ex>>=1;}return ans;}
ll pwm(ll a,ll n){ll pw=a%mod;ll ex=n;ll ans=1;while(ex){if(ex&1) ans = ans*pw%mod;pw = pw*pw%mod;ex>>=1;}return ans%mod;}
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
template<typename T> using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
//st.order_of_key(num)->number of elements < num
//st.find_by_order(i)->iterator of ith element in sorted order starting from zero
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
ll Abs(ll x){return x>0?x:(-x);}
ll Ceil(ll a,ll b){return a/b+(a%b!=0);}
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define mkp make_pair
//#define int long long int
//Binary_Search->dp->greedy
//auto check = [&](ll x){};
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
int X[]={2,1,-1,-2,-2,-1,1,2}; 
int Y[]={1,2,2,1,-1,-2,-2,-1}; 
struct comp{
	bool operator()(const pair<int,int>&a,const pair<int,int>&b) const {
		if(a.first>b.first) return true;
		if(a.first<b.first) return false; 
		if(a.second<b.second) return true;
		return false;
	}
};	
void solve(){
	ll a,b;
	cin>>a>>b;
	cout<<a*b<<endl;
		
	
	
	
}
int32_t main(){
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
int t=1;
//scanf("%d",&t);
while(t--){
	solve();
}
return 0;
}    


Measured memory_bytes: 3632
n,m = map(int,input().split())
ans = [0 for _ in range(n+2)]
for i in range(m):
  l,r = map(int,input().split())
  ans[l] += 1
  ans[r+1] += -1
  
from itertools import accumulate
ans = list(accumulate(ans))
count = 0
for a in ans:
  if a == m:
    count +=1
print(count)



Measured memory_bytes: 8100
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    ll N,A,B;
    cin >> N >> A >> B;
    ll ans;
    if(A % 2 == B % 2){
        ans = (B - A) / 2;
    }else{
        //cerr << "hogehoge" << endl;
        ll mini = min(A, B);
        ll maxi = max(A, B);
        ll l = maxi - 1;
        ll r = N - mini;
        ans = min(l, r);

        ll l2 = mini + (B-mini) / 2;
        ll r2 = (N - maxi + 1) + (N - (A + (N - maxi + 1)) ) / 2;
        //cerr << ans << "," << l2 << "," << r2 << endl;
        ans = min({ans, l2, r2});
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
b= list(map(int,input().split()))

b_tmp = list(b)
reverse_ans = []
a = []
while b_tmp:
    for i in reversed(range(len(b_tmp))):
        if b_tmp[i] == i+1:
            reverse_ans.append(i+1)
            b_tmp.pop(i)
            break
    else:
        print(-1)
        exit()

print("\n".join(map(str,reversed(reverse_ans))))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long
using namespace std;
template<typename tn> void read(tn &a){
	tn x=0,f=1; char c=' ';
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	a=x*f;
}
const int N = 510;
int f[N][N],g[N][N],n,K,mod,C[N][N];
int main(){
	read(n);read(K);read(mod);
	for(int i=0;i<=n;i++){
		C[i][0]=1;
		for(int j=1;j<=i;j++)
			C[i][j]=(C[i-1][j]+C[i-1][j-1])%mod;
	}
	for(int i=0;i<=K;i++) f[1][i]=1,g[1][i]=K-i+1;
	for(int i=2;i<=n+1;i++)
		for(int j=K;~j;j--){
			ll res=0;
			for(int p=1;p<i;p++)
				res=(res+1ll*g[p][j+1]*f[i-p][j]%mod*C[i-2][p-1])%mod;
			f[i][j]=res;
			g[i][j]=(res+g[i][j+1])%mod;
		}
	cout<<f[n+1][0]<<'\n';
	return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
#include <ctype.h>
using namespace std;
 
int main(){
  string a,b,c;
cin >> a >> b >> c;
if(a.at(a.size()-1) == b.at(0)){
if(b.at(b.size()-1) == c.at(0)){
cout << "YES" << endl;
}
else cout << "NO" << endl;
}
else cout << "NO" << endl;
}


Measured memory_bytes: 256
n = gets.to_i

bit = []
digit = -2

if n.odd?
  bit.unshift("1")
  n -= 1
else
  bit.unshift("0")
end

while n != 0
  if n % (digit * 2) == 0
    bit.unshift "0"
  else
    bit.unshift "1"
    n -= digit
  end
  digit *= -2
end

puts bit.join


Measured memory_bytes: 1788
#include <assert.h>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
 
using ll = long long;
using P = std::pair<ll, ll>;

#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug " << i << std::endl
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}

template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}

template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}

ll pow_mod(ll a, ll b, ll mod=-1) {
  if ((a == 0)||(mod!=-1&&a%mod==0)) {
    return 0;
  }

  ll x = 1;

  while (b > 0) {
    if (b & 1) {
      x = (mod!=-1)?(x * a) % mod:x*a;
    }
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}

// const ll MOD = 998244353;
const ll MOD = 1e9 + 7;



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

  ll q;
  std::cin>>q;

  rep(_,0,q){
    ll a,b;
    std::cin>>a>>b;

    if(a>b)std::swap(a,b);

    if(a==b||a+1==b){
      std::cout<<2*a-2<<"\n";
    }else{
      ll as=1;
      while(as*as<a)as++;
      as--;

      ll bs=1;
      while(bs*bs<b)bs++;
      bs--;


      ll sq=as*bs;

      while(sq*sq<a*b)sq++;

      sq--;

      if(sq*(sq+1)>=a*b){
        std::cout<<2*sq-2<<"\n";
      }else{
        std::cout<<2*sq-1<<"\n";
      }
    }
  }

  return 0;
}

Measured memory_bytes: 256
def solve():
    a = read()
    result = think(a)
    write(result)


def read():
    n = read_int(1)[0]
    a = []
    for _ in range(n):
        a.append(read_int(1)[0])
    return a


def read_int(n):
    return list(map(lambda x: int(x), read_line().split(' ')))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(a):
    dummy = -1
    flag_for_not_visited = 0
    flag_for_visited = 1

    buttons_flash_info = list(a)
    buttons_flash_info.insert(0, dummy)

    index = 1
    visited = [flag_for_not_visited for i in range(len(buttons_flash_info))]
    visited[index] = flag_for_visited
    push_count = 1
    while True:
        next_index = buttons_flash_info[index]
        index = next_index
        if index == 2:
            return push_count
        if visited[index] == flag_for_visited:
            return -1
        visited[index] = flag_for_visited
        push_count += 1
    return -1


def write(result):
    print(result)


if __name__ == '__main__':
    solve()

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

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

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

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

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; }return false; }
template <class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; }return false; }

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

	int N; cin >> N;
	string S; cin >> S;
	int K; cin >> K;
	char c = S[K - 1];
	rep(i, 0, N) {
		if (S[i] != c)S[i] = '*';
	}
	cout << S << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
 
using namespace std;
 
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
 
//container util
//------------------------------------------
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

int main(){
    LL N,H;
    cin>>N>>H;
    vector<LL>a(N),b(N);
    REP(i,N){
        cin>>a[i]>>b[i];
    }
    sort(a.begin(),a.end(),greater<LL>());
    sort(b.begin(),b.end(),greater<LL>());
    int res=0;
    LL sum=0;
    REP(i,N)if(b[i]>=a[0]&&sum<H){
        sum+=b[i];res++;
    }
    if(sum<H){
        res+=(H-sum)/a[0]+((H-sum)%a[0]!=0);
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 1792
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int N = in.nextInt();
            String S = in.next();

            if (N % 2 != 0) {
                out.println("No");
                return;
            }

            String l = S.substring(0, S.length() / 2);
            String r = S.substring(S.length() / 2);
            String ans = "No";
            if (l.equals(r)) {
                ans = "Yes";
            }
            out.println(ans);
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

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

    }
}



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

int main() {
    string S;
    cin >> S;
    int m = 0;
    int count = 0;
    for(int i = 2; i>=0; i--){
        if(S[i] == 'R'){
            count++;
        }
        else{
            count = 0;
        }
        m = max(m, count);
    }
    cout << m << "\n";
    return 0;
}

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

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

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

ll x[200010],y[200010];

int main(){
	int n;
	cin>>n;
	ll a[200010];
	
	for (int i = 0; i < n; i++){
		cin>>a[i];
		x[i+1]=x[i]+a[i];
	}

	for (int i = n-1; i >= 0; i--){
		y[i]=a[i]+y[i+1];
	}

	ll mm=3000000000;
	for (int i = 1; i < n; i++){
		mm=min(mm,abs(x[i]-y[i]));
	}

	cout<<mm<<endl;


	return 0;
}

Measured memory_bytes: 4992
#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

int main(int argc, char *argv[])
{
  int A, B, C, D, E, F, aa = 0, bb = 0, tw, ts;
  float maxv = 0.0;
  cin >> A >> B >> C >> D >> E >> F;

  for (int a = 0; a <= F; a += (100*A)) {
    for (int b = 0; b + a <= F; b += (100*B)) {
      tw = a + b;
      if (tw > 0) {
        for (int c = 0; c + tw <= F; c += C) {
          for (int d = 0; c + d + tw <= F; d += D) {
            ts = c + d;
            if (ts * 100 <= E * tw) {
              float v = (100.0 * ts) / (ts + tw + 0.0);
              if (maxv <= v) {
                aa = ts + tw;
                bb = ts;
                maxv = v;
              }
            }
          }
        }
      }
    }
  }
  printf("%d %d\n", aa, bb);
  return 0;
}


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

inline int parent(int i){
  return i / 2;
}

inline int left(int i){
  return 2 * i;
}

inline int right(int i){
  return 2 * i + 1;
}

int main(){
  int A[251], n;
  cin >> n;
  for(int i = 1; i <= n; i++) cin >> A[i];
  for(int i = 1; i <= n; i++){
    cout << "node " << i << ": key = " << A[i] << ", ";
    if(i != 1) cout << "parent key = " << A[parent(i)] << ", ";
    if(left(i) <= n) cout << "left key = " << A[left(i)] << ", ";
    if(right(i) <= n) cout << "right key = " << A[right(i)] << ", ";
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 3088
mod=1000000007
def Fib(n):
  a, b = 1, 2
  if n == 1 or n==0:
    return a
  elif n == 2:
    return b
  else:
    for i in range(n-2):
      a, b = b%mod, (a+b)%mod
    return b
n,m=map(int,input().split())
al=[]
zeroflag=0
fa=-1
cnt=0
for iii in range(m):
  a=int(input())
  cnt+=1
  al.append(a)
  if abs(fa-a)==1:
    zeroflag=1
  fa=a

if zeroflag==1:
  print(0)
else:
  ans=1
  if m==0:
    print(Fib(n))
  else:
    for iii in range(m):
      if iii==0:
        ans=Fib(al[iii]-1)
      if iii==m-1:
        break
      if len(al)>1:  
        num=Fib(al[iii+1]-al[iii]-2)
        ans*=num%mod
    ans*=Fib(n-al[-1]-1)%mod
    print(ans%mod)
    


Measured memory_bytes: 7084
#include <iostream>
#include <string>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <bitset>
#include <map>
#include <math.h>
#include <utility>

using namespace std;

int main(){

    int N, L;
    cin >> N >> L;

    if (L > 0) cout << (N - 1) * (N + 2*L) / 2 << endl;
    else if (N + L - 1 < 0) cout << (N - 1) * (N + 2*L -2) / 2 << endl;
    else cout << N * (N + 2*L - 1) / 2 << endl;

    return 0;
}


Measured memory_bytes: 256