akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
typedef struct 
{
	char team[21];
	int w, l, d;
	int s;
}TEAM;

void bubble_sort(TEAM *p, int n)
{
	int i, j;
	TEAM t;
	for (i = 0; i < n - 1; i++)
	{
		for (j = 0; j < n - i - 1; j++)
		{
			if (p[j].s < p[j + 1].s)
			{
				t = p[j];
				p[j] = p[j + 1];
				p[j + 1] = t;
			}
		}
	}
}
int main(void)
{
	int i;
	int n;
	int c;
	TEAM pck[10];
	c = 0;
	while (1)
	{
		scanf("%d", &n);
		if (n == 0)
		{
			break;
		}
		for (i = 0; i < n; i++)
		{
			scanf("%s%d%d%d", pck[i].team, &pck[i].w, &pck[i].l, &pck[i].d);
			pck[i].s = pck[i].w * 3 + pck[i].d;
		}
		if (c != 0)
		{
			printf("\n");
		}
		bubble_sort(pck, n);
		for (i = 0; i < n; i++)
		{
			printf("%s,%d\n", pck[i].team, pck[i].s);
		}
		c = 1;
	}
	return 0;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
#define mset(arr, val) memset((arr), (val), sizeof(arr))
#define For(i, init, n) for (int64_t (i) = (init); (i) < (n); (i)++)
#define ___ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

// const double PI = acos(-1.0), E = exp(1.0), EPS = 1e-9;
const int MOD = (int)1e9 + 7, N = (int)1e5;

int main()
{   
#ifdef MY_PREPROCESSOR
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
    ___
    
    string n, m;
    cin >> n >> m;
    if (n.length() > m.length())
    {
        cout<< "GREATER";
    }
    else if (n.length() < m.length())
    {
        cout<< "LESS";
    }
    else
    {
        if (n.compare(m) > 0)
            cout<< "GREATER";
        else if (n.compare(m) < 0)
            cout<< "LESS";
        else
            cout<< "EQUAL";
    }
    
    return 0;
}

Measured memory_bytes: 3620
from itertools import *
def f(s):
 for a,b,c,d in permutations(s):
  for x,y,z in product('+-*',repeat=3):
   for t in[f"({a} {x} {b}) {y} ({c} {z} {d})",f"(({a} {x} {b}) {y} {c}) {z} {d}",f"{a} {x} ({b} {y} ({c} {z} {d}))",f"({a} {x} ({b} {y} {c})) {z} {d}",f"{a} {x} (({b} {y} {c}) {z} {d})"]:
    if eval(t)==10:return'('+t+')'
 else:return 0
for e in iter(input,'0 0 0 0'):print(f(list(map(int,e.split()))))


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

int main(){
    int count[4][3][10] = {};
    int n;
    
    cin >> n;
    
    for(int i = 0; i < n; i++){
        int b, f, r, v;
        cin >> b >> f >> r >> v;
        count[b-1][f-1][r-1] += v;
    }
    
    for(int i = 0; i < 4; i++){
        for (int j = 0; j < 3; j++){
            for (int k = 0; k < 10; k++){
                cout << " " << count[i][j][k];
            }
            cout << endl;
        }
        if(i != 3) cout<< "####################" << endl;
    }
    return 0;
}



Measured memory_bytes: 3076
#include<bits/stdc++.h>
using namespace std;
#define int long long
map<char,map<int,int> > m;
map<char,int> l;
int dfs(string s,int p){
  int x=0;
  if(isdigit(s[p])){
    for(int i=p;i<(int)s.size()&&isdigit(s[i]);i++) x=x*10+s[i]-'0';
    return x;
  }
  if(isdigit(s[p+2]))
    for(int i=p+2;i<(int)s.size()&&isdigit(s[i]);i++) x=x*10+s[i]-'0';
  else x=dfs(s,p+2);
  if(p) return  (x<0||x>=l[s[p]])?-1:
	  (m[s[p]].find(x)==m[s[p]].end()?-1:m[s[p]][x]);
  else return x;
}
signed main(){
  string s;
  while(cin>>s,s!="."){
    m.clear();l.clear();
    vector<string> v;
    v.push_back(s);
    while(cin>>s,s!=".") v.push_back(s);
    int n=v.size(),i;
    for(i=0;i<n;i++){
      int p=v[i].find("=");
      if(p<0){
	int x=dfs(v[i],0);
	if(x<0) break;
	l[v[i][0]]=x;
      }else{
	int x=dfs(v[i],0),y=dfs(v[i],p+1);
	if(x<0||l[v[i][0]]<=x||y<0) break;
	m[v[i][0]][x]=y;
      }
    }
    cout<<(i==n?0:i+1)<<endl;
  }
  return 0;
}

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

using namespace std;

struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}init;

typedef long long LL;

template<typename T>void chmin(T &a,T b){a=min(a,b);}
template<typename T>void chmax(T &a,T b){a=max(a,b);}
template<typename T>
istream& operator>>(istream &is,vector<T> &v){
    for(auto &it:v)is>>it;
    return is;
}

int main(){
    string S,s,t;
    cin >> S;
    s = S.substr(0,4);
    t=S.substr(4,8);
    cout << s <<" "<<t << endl;
    return(0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000  //  9.0 * 10^18
#define MOD 1000000007  //  10^9 + 7
#define PAI 3.14159265358979
// ver1.7
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main() {
  cout << fixed << setprecision(14);
  map<int,int> kind;
  Vi a2(2,0),a4(2,0);
  int n,qw;
  cin >> n;

  rep(i,0,n) {
    cin >> qw;
    kind[qw]++;
  }
  
  for (auto p : kind) {
    auto k = p.first;
    auto v = p.second;
    if(v>=4) a4.pb(k);
    if(v>=2) a2.pb(k);
  }
  reverse(ALL(a2));
  reverse(ALL(a4));
  int ans = 0;
  ans = max({a4[0]*a4[0],a4[0]*a2[0],a2[0]*a2[1]});
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
using LL = int64_t;
using ULL = uint64_t;
using P = pair<string, LL>;
#define rep(i, n) for (LL i = 0; i < (n); ++i)
//#define DEBUG

int main() {
  string s;
  cin >> s;
 
  LL len = s.size();

  stack<P> exp;
  exp.push(make_pair<string, LL>(string() + s[0], 1LL));
  LL sum = 0;
  while (!exp.empty()) {
    auto current_exp = exp.top().first;
    auto current_depth = exp.top().second;
    #ifdef DEBUG
    //cout << current_exp << endl;
    if (current_depth > len) return -1;
    #endif
    exp.pop();
    if (current_depth == len) {
      LL exp_head = 0;
      while (current_exp.find('+', exp_head) != string::npos) {
        auto plus_pos = current_exp.find('+', exp_head);
        sum += stoll(current_exp.substr(exp_head, plus_pos - exp_head));
        exp_head = plus_pos + 1;
      }
      sum += stoll(current_exp.substr(exp_head, current_exp.size() - exp_head));
    } else {
      exp.push(make_pair<string, LL>(current_exp + "+" + s[current_depth], current_depth + 1));
      exp.push(make_pair<string, LL>(current_exp + s[current_depth], current_depth + 1));
      #ifdef DEBUG
      cout << current_exp + "+" + s[current_depth] << endl;
      cout << current_exp + s[current_depth] << endl;
      #endif
    }
  }
  cout << sum << endl;

  #ifdef DEBUG
  #endif
}



Measured memory_bytes: 256
#include<math.h>
#include<iostream>
#include <algorithm>
#include <string>
#include<vector>
#include<array>
#include<tuple>
#include<queue>
#include<stack>
#include<iomanip>
#include<bitset>
//AtCoderC++.cpp

using namespace std;

int main() {
	int N; cin >> N;
	auto as = vector<int>(N);
	int max_abs = 0;
	bool plus = false; int index = 0;
	for (size_t i = 0; i < N; i++) {
		cin >> as[i];
		if (max_abs < abs(as[i])) {
			max_abs = abs(as[i]);
			plus = (as[i] >= 0);
			index = i;
		}
	}
	auto steps = vector<pair<int, int>>();
	for (size_t i = 0; i < N; i++) {
		if (i != index) {
			as[i] += as[index];
			steps.push_back({ index + 1, i + 1 });
		}
	}
	if (plus) {
		for (size_t i = 0; i < N - 1; i++) {
			if (as[i] > as[i + 1]) {
				as[i + 1] += as[i];
				steps.push_back({ i + 1, i + 2 });
			}
		}
	} else {
		for (size_t i = N - 1; i > 0; i--) {
			if (as[i - 1] > as[i]) {
				as[i - 1] += as[i];
				steps.push_back({ i + 1, i });
			}
		}
	}
	cout << steps.size() << endl;
	for (size_t i = 0; i < steps.size(); i++) cout << steps[i].first << " " << steps[i].second << endl;
}


Measured memory_bytes: 256
////////////////////////////////////////////////////////////////
//
//    (☝ ՞ਊ ՞)☝ << Be accept!!
//
//    C++ format for competitive professional v1.0
//
//    need gcc & boost::c++
//
////////////////////////////////////////////////////////////////
#define BOOST
#define CGCC
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower
#include <cstdint>   // int66_t, int*_t
#include <cstdio>    // printf
#include <deque>     // deque
#include <iomanip>   //setfill(char)
#include <ios>       //left,right
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector
#ifdef BOOST
//#include <boost/multiprecision/cpp_int.hpp> // cpp_int
//using namespace boost::multiprecision;
#endif
#define rep(i, n) for (int i = 0; i < n; i++)
using ll = long long;
using namespace std;
#ifdef CGCC
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#endif
int setup(void) { // set
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  return 0;
}
int lenght(char *str) { // getcharlengh
  int i = 0;
  while (str[i]) {
    i++;
  }
  return i;
}
int gcd(long long a, long long b) {
  if (a < b)
    return gcd(b, a);
  long long r;
  while ((r = a % b)) {
    a = b;
    b = r;
  }
  return b;
}
int iinput(void) {
  int a = 0;
  cin >> a;
  return a;
}
int dinput(void) {
  double a = 0;
  cin >> a;
  return a;
}
string sinput(void) {
  string a = "";
  cin >> a;
  return a;
}
int kuriup(double a) {
  int b = int(a);
  if (a != b) {
    return b + 1;
  } else {
    return b;
  }
}
int kuridown(double a) {
  int b = int(a);
  return b;
}
int run(void);
int main(){
  setup();
  run();
  return 0;
}
int run(void){

  ll n,k;
  cin>>n>>k;
  ll num=1;
  ll ans=0;
  while(n >= num){
    num*=k;
    ans++;
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const int MAX = 1000001;
/* global variables */
vector<int> p(MAX, 0);
/* function */
void eratos() {
    for (int i = 1; i < MAX; i++) {
        if (p[i] == 0) continue;
        for (int tmp = i*2; tmp < MAX; tmp += i) {
            p[tmp] = 0;
        }
    }
}
/* main */
int main(){
    int N, a;
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> a;
        p[a]++;
    }

    eratos();
    int ans = 0;
    for (int i = 1; i < MAX; i++) {
        if (p[i] == 1) ans++;
    }
    cout << ans << '\n';
}


Measured memory_bytes: 7072
import sys
import math
import time
sys.setrecursionlimit(int(1e6))
if False:
    dprint = print
else:
    def dprint(*args):
        pass

n, k = list(map(int, input().split()))
A = list(map(int, input().split()))
dprint("n, k = ", n, k)

lx = int(0)   # NG
rx = int(1e9) # OK
#ans = 0
while ((rx-lx)>1):
    x = (rx + lx) // 2
    dprint("lx, x, rx = ", lx, x, rx)
    n = 0
    for i in range(len(A)):
        #n += math.ceil(A[i] / x) - 1
        n += (A[i]-1) // x
        if n > k: break
    dprint("n = ", n)
    if n <= k:
        dprint(" smaller x")
        rx = x
    else:
        dprint(" cut less, bigger x")
        lx = x

#ans = math.ceil(rx)
print(rx)


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

using namespace std;

int main(void) {
    int H, W;
    char a[110][110];
    cin >> H >> W;

    for (int i = 0; i < W + 2; i++) {
        a[0][i] = '#';
        a[H + 1][i] = '#';
    }

    for (int i = 1; i <= H; i++)
        for (int j = 0; j <= W + 1; j++) {
            if (j == 0 || j == W + 1) a[i][j] = '#';
            else cin >> a[i][j];            
        }

    for (int i = 0; i < H + 2; i++) {
        for (int j = 0; j < W + 2; j++)
            cout << a[i][j];
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 256
using System;
using static System.Console;
using static System.Math;
using System.IO;
using System.Collections.Generic;
namespace I_am_the_green_coder{
    class Inonoa{
        static void Main(){
            long n = ILongs()[0];
            long[] p = ILongs();
        bool muri_ = false;
            for(int k=1;k<n;k++){
                        if(p[k]<=p[k-1]){
                            muri_ = true;
                            break;
                        }
                    }
                    if(!muri_){
                        Console.WriteLine("YES");
                        return;
                    }
            for(int i=0;i<n-1;i++){
                for(int j=i+1;j<n;j++){
                    long tmp = p[i];
                    p[i] = p[j];
                    p[j] = tmp;
                    bool muri = false;
                    for(int k=1;k<n;k++){
                        if(p[k]<=p[k-1]){
                            muri = true;
                            break;
                        }
                    }
                    if(!muri){
                        Console.WriteLine("YES");
                        return;
                    }
                    tmp = p[i];
                    p[i] = p[j];
                    p[j] = tmp;
                }
            }
            Console.WriteLine("NO");
        }

        static readonly long MOD = 1000000007;

        ///<summary>a_1, a_2, a_3, ...みたいなの</summary>
        static long[] ILongs(){
            string[] s = ReadLine().Split();
            long[] re = new long[s.Length];
            for(long i=0;i<s.Length;i++){
                re[i] = long.Parse(s[i]);
            }
            return re;
        }

        ///<summary>xooxoxoxxoxo...みたいなの</summary>
        static char[] IChars(){
            return ReadLine().ToCharArray();
        }

        ///<summary>n m とかをちょっとはやくかくだけ</summary>
        static string[] IStrings(){
            return ReadLine().Split();
        }

        ///<summary>n行の入力を取ったり</summary>
        static long[][] ILongLongs(long n){
            long[][] re = new long[n][];
            for(long i=0;i<n;i++){
                string[] s = ReadLine().Split();
                re[i] = new long[s.Length];
                for(long j=0;j<s.Length;j++){
                    re[i][j] = long.Parse(s[j]);
                }
            }
            return re;
        }

        ///<summary>n行の文字列を取ったり</summary>
        static char[][] ICharsChars(long n){
            char[][] re = new char[n][];
            for(long i=0;i<n;i++){
                re[i] = ReadLine().ToCharArray();
            }
            return re;
        }
    }
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double dbl;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<long long> vl;
typedef vector< pair<int, int> > vii;
#define mp make_pair
#define pb push_back
#define invec(a, n) for(ll i = 0; i < n; i++) {cin >> a[i];}
#define rep(n) for(ll i = 0; i < n; i++)
#define fr(i,j,k) for(ll i = j; i < k; i++)
#define FR(i,j,k) for(ll i = j; i >= 0; i--)
#define MOD 1000000007
#define all(v) v.begin(), v.end()
#define INF 1000000
#define xx first
#define yy second
#define pl cout<<endl;
template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
        return os<<"("<< p.first << "," << p.second<<")";
}
template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
os << "{";
typename vector< T > :: const_iterator it;
for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
}
return os << "}";
}
template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
os << "[";
typename set< T > :: const_iterator it;
for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
os << *it;
}
return os << "]";
}
template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
        os << "[";
        typename map< F , S >::const_iterator it;
for( it = v.begin(); it != v.end(); it++ ) {
if( it != v.begin() ) os << ", ";
os << it -> first << " = " << it -> second ;
}
return os << "]";
}
#define deb(x) cout << #x << " = " << x << endl;

#define er(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
cerr << *it << " = " << a << endl;
err(++it, args...);
}
 
void fast()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}
 
 
int main()
{
    ll n;
    cin>>n;

    vl dp(3);

    for(ll i=0;i<n;i++)
    {
        ll a,b,c;
        cin>>a>>b>>c;
        if(i==0)
        {
            dp[0]=a;
            dp[1]=b;
            dp[2]=c;
        }
        else
        {
            ll x=dp[0];
            ll y=dp[1];
            ll z=dp[2];
            
            dp[0]=max(y+a,z+a);
            dp[1]=max(x+b,z+b);
            dp[2]=max(y+c,x+c);
        }
    }
   // cout<<dp[0]<<" "<<dp[1]<<" "<<dp[2]<<endl;
    ll ans=max(dp[0],max(dp[1],dp[2]));
    cout<<ans<<endl;
}

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

typedef long long lint;
typedef pair<int, int> ii;

const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;

int n, a[200005], pos[200005];
vector<int> b;

struct Node{
	int lo, hi, mn;
	Node *lchi, *rchi;
	Node(int l, int r){
		lo = l, hi = r;
	}
};

void segbuild(Node *u, int k){
	if(u->lo == u->hi){
		u->mn = (u->lo & 1) == k ? a[u->lo] : INF;
	}else{
		int mi = u->lo + u->hi >> 1;
		u->lchi = new Node(u->lo, mi);
		u->rchi = new Node(mi+1, u->hi);
		segbuild(u->lchi, k); segbuild(u->rchi, k);
		u->mn = min(u->lchi->mn, u->rchi->mn);
	}
}

int segquery(Node *u, int l, int r){
	if(l == u->lo && r == u->hi)
		return u->mn;
	int mi = u->lo + u->hi >> 1;
	if(r <= mi)
		return segquery(u->lchi, l, r);
	else if (l > mi)
		return segquery(u->rchi, l, r);
	else{
		int resl = segquery(u->lchi, l, mi);
		int resr = segquery(u->rchi, mi+1, r);
		return min(resl, resr);
	}
}

Node *tr[2];
vector<int> g[200005];
ii thissit[200005];
int waitforit = 0;

ii getthingy(int l, int r){
	int ll = pos[segquery(tr[l&1], l, r)];
	int rr = pos[segquery(tr[~l&1], ll+1, r)];
	return {ll, rr};
}

int debugit(ii l){
	auto fl = getthingy(l.first, l.second);
	return a[fl.first];
}

int gogogo(int l, int r){
	int u = waitforit++;

	auto res = getthingy(l, r);
	int ll = res.first, rr = res.second;

	thissit[u] = {a[ll], a[rr]};

	vector<ii> needgo, out;
	if(ll - l) needgo.push_back({l, ll - 1});
	if(rr - r) needgo.push_back({rr+1, r});
	if(rr - ll > 1) needgo.push_back({ll+1, rr-1});
	/*
	sort(needgo.begin(), needgo.end(), [](ii l, ii r){
		auto fl = getthingy(l.first, l.second);
		auto fr = getthingy(r.first, r.second);
		return a[fl.first] < a[fr.first];
	});
	*/
	for(auto x: needgo) g[u].push_back(gogogo(x.first, x.second));

	return u;
}

typedef pair<ii, int> wtf;

int solve(){
	cin >> n; for(int i=0;i<n;i++) cin >> a[i], pos[a[i]] = i;
	tr[0] = new Node(0, n - 1); tr[1] = new Node(0, n - 1);
	segbuild(tr[0], 0); segbuild(tr[1], 1);
	gogogo(0, n-1);
	priority_queue<wtf, vector<wtf>, greater<wtf>> q; q.push({thissit[0], 0});
	while(!q.empty()){
		int u = q.top().second; q.pop();
		b.push_back(thissit[u].first), b.push_back(thissit[u].second);
		for(int v: g[u]) q.push({thissit[v], v});
	}
	for(int i=0;i<n;i++) cout << b[i] << " \n"[i==n-1];
	return 0;
}


int main(){
	ios::sync_with_stdio(0);
	// int t; cin >> t; while(t--)
	solve();
	// cout << (solve() ? "YES" : "NO") << endl;
	return 0;
}


Measured memory_bytes: 59508
### subroutines

def over?(ovws, m, i, k)
  for j in (0...m)
    if ovws[i][j]
      return true if j == k
      return true if over?(ovws, m, j, k)
    end
  end
  false
end

### main

n = gets.to_i

n.times do
  h, w = gets.split.map(&:to_i)
  lines = Array.new(h){gets.strip}
  
  m = 0
  mchs = []
  mchhash = {}
  mrects = []

  for y in (0...h)
    for x in (0...w)
      ch = lines[y][x]
      if ch >= 'A' && ch <= 'Z'
        if mchhash[ch].nil?
          mchhash[ch] = m
          mchs[m] = ch
          mrects[m] = [x, y, x, y]
          m += 1
        end

        k = mchhash[ch]
        mrects[k][0] = x if mrects[k][0] > x
        mrects[k][1] = y if mrects[k][1] > y
        mrects[k][2] = x if mrects[k][2] < x
        mrects[k][3] = y if mrects[k][3] < y
      end
    end
  end
  #p mrects

  ovws = Array.new(m){Array.new(m){false}}
  ok = true

  for i in (0...m)
    mch = mchs[i]
    x0, y0, x1, y1 = mrects[i]
    for y in (y0..y1)
      for x in (x0..x1)
        ch = lines[y][x]
        if ch != mch
          if ch == '.'
            ok = false
            break
          end

          k = mchhash[ch]
          if over?(ovws, m, k, i)
            ok = false
            break
          end
          ovws[i][k] = true
        end
      end

      break if ! ok
    end
  end

  puts ok ? "SAFE" : "SUSPICIOUS"
end

Measured memory_bytes: 6132
#include<bits/stdc++.h>
using namespace std;
#define FasterIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
const int MX=200000+5;
const int inf=1e9;
typedef long long ll;


int main()
{
    FasterIO;
    int n, k, m, p;
    string s;
    cin>>n>>s;
    for(int i=0; i<s.size(); i++)
    {
        int d=s[i]-'A';
        d+=n;
        s[i]=('A'+d%26);
    }
    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

int main() {
  vector<int> a(3);
  REP(i, 3) cin >> a[i];
  sort(a.begin(), a.end());
  cout << abs(a[1] - a[0]) + abs(a[1] - a[2]) << endl;
}


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

A.sort()  #元のリスト昇順にする
flag=0
for i in range(0,N-1):
    if A[i]==A[i+1]:
        flag=1
        break

if flag==0:
    print("YES")
    
else:
    print("NO")

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

#define ll unsigned long long
#define inf 1e18
#define mod 1e9+7
#define w(x) int x; cin >> x; while(x--)
#define sp(x, y) fixed << setprecision(y) << x;
#define pb push_back


const int maxn = 1e6;
const ll mx = 1e18;

int n;
vector<int> arr;
void solve() {
    cin >> n;
    arr.resize(n);
    for (int i = 0; i < n; i++) {
        int temp;
        cin >> temp;
        temp--;
        arr[i] = temp;
    }
    int ans = 0, i = 0;
    while (ans <= n) {
        if (i == 1) {
            cout << ans << '\n';
            return;
        }
        ans++;
        i = arr[i];
    }
    cout << -1 << '\n';
}

int main() {
    solve();
    return 0;
}



Measured memory_bytes: 640
n,m = map(int, input().split())
# 場合の数
# ans = perm(n, 2, exact=True)//perm(2, 2, exact=True)+perm(m, 2, exact=True)//perm(2, 2, exact=True)
ans = n * (n-1) // 2 + m * (m - 1) // 2
print(ans)

Measured memory_bytes: 9160
//Go home

#include<stdio.h>

typedef long long int ll;

ll MIN(ll a, ll b){return a>b?b:a;}

int main(void){
    ll x;
    scanf("%lld", &x);

    ll s[100001];
    
    s[0] = 0;
    for(int i=1; i<100001; i++){
        s[i] = s[i-1] + i;
    }
 
    int s_idx = 0;
    while(s[s_idx] < x){
        s_idx += 1;
    }

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

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

#define N 3
#define S 9

typedef struct P{
  int f[S],space,m;
}Puzzle;

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

int MDT[S][S];

int limit;
int path[100];
Puzzle st;

int get(Puzzle Z){
  int i,sum=0;
  for(i=0;i<S;i++){
    if(Z.f[i] == S) continue;
    sum+=MDT[i][Z.f[i]-1];
  }
  return sum;
}

int max(int a,int b){
  if(a<b) return b;
  else return a;
}
int min(int a,int b){
  if(a<b) return a;
  else return b;
}
void swap(int *a,int *b){
  int t;
  t=*a;
  *a=*b;
  *b=t;
}

char dfs(int df,int p){
  int sx,sy,tx,ty,i;
  Puzzle tmp;

  if(st.m==0)return 1;
  if(df+st.m>limit)return 0;

  sx=st.space/N;
  sy=st.space%N;

  for(i=0;i<4;i++){
    tx=sx+dx[i];
    ty=sy+dy[i];

    if(tx<0||tx>=N||ty<0||ty>=N) continue;
    if(max(p,i)-min(p,i)==2)continue;
    tmp=st;

    st.m-=MDT[tx*N+ty][st.f[tx*N+ty]-1];
    st.m+=MDT[sx*N+sy][st.f[tx*N+ty]-1];

    //printf("st.m=%d\n",st.m);

    swap(&st.f[tx*N+ty],&st.f[sx*N+sy]);

    st.space=tx*N+ty;
    if(dfs(df+1,i)){
      path[df]=i;
      return 1;
    }
    st=tmp;
  }
  return 0;
}

int id(Puzzle in){
  int i;
  int ans=0;

  in.m=get(in);

  for(limit=in.m;limit<=100;limit++){
      //  printf("aaa\n");
    st=in;
    if(dfs(0,-100)){
      ans=0;;
      for(i=0;i<limit;i++) ans++;
      return ans;
    }
  }
  return -1;
}

int main(){
  int i,j;
  Puzzle in; 
  for(i=0;i<S;i++) for(j=0;j<S;j++) MDT[i][j]=abs(i/N-j/N)+abs(i%N-j%N);
  for(i=0;i<S;i++){
    //printf("aaa\n");
    scanf("%d",&in.f[i]);
    if(in.f[i]==0){
      in.f[i]=S;
      in.space=i;
    }
  }
  printf("%d\n",id(in));

  return 0;
}











Measured memory_bytes: 2108
/*********************** B ***************************/
#include <iostream>
#include <string> 
using namespace std;

int main()
{
	string s_a, s_b, s_c;
	cin >> s_a >> s_b >> s_c;
	char winner = 'd';
	char current = 'a'; /* start with alice */
	while(winner == 'd'){
		switch (current){
			case 'a':
				if(s_a.empty()){
					winner = 'A';
				}
				current = s_a.front();
				s_a.erase(0, 1);
				break;
			case 'b':
				if(s_b.empty()){
					winner = 'B';
					break;
				}
				current = s_b.front();
				s_b.erase(0, 1);
				break;
			case 'c':
				if(s_c.empty()){
					winner = 'C';
					break;
				}
				current = s_c.front();
				s_c.erase(0, 1);
				break;
			default:
				cerr << "Invalid char" << endl;
				break;
		}
	}
	cout << winner << endl;
	return 0;
}	


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <math.h>
#include <cmath>
#include <numeric>
#include <iomanip>


#define log(x) cout<<x<<endl
#define pb push_back
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
using namespace std;


// <<fixed<<setprecision(6)<<


int gcd(lint x, lint y){
  return y==0 ? x:gcd(y,x % y);
}


int combi(int n, int r){
  int num = 1;
  for(int i = 1; i <= r; i++){
    num = num * (n - i + 1) / i;
  }
  return num;
}


int main(){
  int k,n;
  int h;
  cin>>k>>n;
  vector<int> a(n),b;
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  sort(all(a));
  for(int i=0;i<n;i++){
    if(i==0){
      int g=a[n-1]-a[0];
      b.pb(g);
    }
    else{
      int g=k-a[i]+a[i-1];
      b.pb(g);
    }
  }
  sort(all(b));
  cout<<b[0];

}

Measured memory_bytes: 2168
#include <iostream>
#include <cstring>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
  int w, h, x, y, flagx=0, flagy=0, flagz=0;
  int i, j;
  cin >> w >> h >> x >> y;
  double tate, yoko;
  cout <<fixed<< setprecision(12)<<0.5*h*w << " ";
  if(x==0||x==w||y==0||y==h){
    cout << 0;
    return 0;
  }
  if(2*x<w) tate=1.0*x*h;
  else tate=1.0*(w-x)*h;
  if(2*x==w) flagx++;

  if(2*y<h) yoko=1.0*y*w;
  else yoko=1.0*(h-y)*w;
  if(2*y==h) flagy++;

  if(tate==yoko) flagz++;
  if((flagx>0&&yoko>=tate)||(flagy>0&&tate>=yoko)||flagz>0) cout << " " << 1;
  else cout << " " << 0;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
int main() {
  char c;
  int ans = 0;
  int tmp = 0;
  REP(i, 3) {
    cin >> c;
    if (c == 'R') {
      tmp++;
    } else {
      tmp = 0;
    }
    ans = max(tmp, ans);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3596
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;
 
class Salesman {
    private long sales;
    boolean isAchieved;
 
    Salesman(long price, long goodsnum){
        this.sales += price * goodsnum;
        this.isAchieved = this.sales >= 1000000;
    }
    void addSales(long price, long number) {
        this.sales += price * number;
        this.isAchieved = this.sales >= 1000000;
    }
}
 
public class Main{
    public static void main(String[] args) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();
        StringTokenizer st;
        try {
            while (true) {
                String line;
                long price,goodsnum;
                int num;
                int n = Integer.parseInt(br.readLine());
                if(n ==0){
                    break;
                }
                LinkedHashMap<Integer, Salesman> list = new LinkedHashMap<>();
 
                for (int i = 0; i < n; i++) {
                    line = br.readLine();
                    st = new StringTokenizer(line);
                    num = Integer.parseInt(st.nextToken());
                    price = Long.parseLong(st.nextToken());
                    goodsnum= Long.parseLong(st.nextToken());
                    if(list.containsKey(num)){
                        list.get(num).addSales(price,goodsnum);
                    }else{
                        list.put(num,new Salesman(price,goodsnum));
                    }
                }
 
                boolean isExist = false;
                for (Map.Entry<Integer, Salesman> entry : list.entrySet()) {
                    if(entry.getValue().isAchieved){
                        System.out.println(entry.getKey());
                        isExist = true;
                    }
                }
                if (!isExist){
                    System.out.println("NA");
                }
            }
 
 
        } catch (Exception e) {
            e.printStackTrace();
        }
 
    }
}

Measured memory_bytes: 25880
using System;

class Program
    {

        static double div;

        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string[] vals = Console.ReadLine().Split();

            int[] nums = new int[N];

            for (int i = 0; i < N; i++)
            {
                nums[i] = int.Parse(vals[i]);
            }


            for (int i = 0; i < N; i++)
            {
                div += (1.0 / nums[i]);
        
            }

            var ans = 1 / div;

            Console.WriteLine(ans);

        }
    }

Measured memory_bytes: 11092
#include <stdio.h>

int main(void)
{
	double w;
	
	while (scanf("%lf", &w) != EOF){
		
		if (w > 91.00){
			printf("heavy\n");
		}
		else if (w > 81.00){
			printf("light heavy\n");
		}
		else if (w > 75.00){
			printf("middle\n");
		}
		else if (w > 69.00){
			printf("light middle\n");
		}
		else if (w > 64.00){
			printf("welter\n");
		}
		else if (w > 60.00){
			printf("light welter\n");
		}
		else if (w > 57.00){
			printf("light\n");
		}
		else if (w > 54.00){
			printf("feather\n");
		}
		else if (w > 51.00){
			printf("bantam\n");
		}
		else if (w > 48.00){
			printf("fly\n");
		}
		else {
			printf("light fly\n");
		}
	}
	return (0);
}

Measured memory_bytes: 608
# -*- coding: utf-8 -*-
from heapq import heappush, heapreplace
from itertools import count, product, combinations
from functools import partial, reduce
from math import floor, ceil, sqrt
from collections import defaultdict, deque

def Primes_fnct():
    def b_search(L,t):
        #増大列LについてL[:+1]の要素すべてがt以下であるような最大のi<len(L)を返す。
        search_range = [-1, len(L)]
        update_range = lambda mid: search_range.__setitem__(t<L[mid], mid)
        for _ in [0]*search_range[1].bit_length():
            update_range(sum(search_range)//2)
        return search_range[0]
    
    P = [2,]
    Pappend = P.append
    Q = deque([])
    Qappend = Q.append
    Qpopleft = Q.popleft
    hq = [] 
    integer = count(3,2)
    current_i = 1
    valid_range = 1
    def Primes(*, max_int=None):
        nonlocal valid_range, current_i
        if max_int is None:
            return P[:]

        if  max_int - current_i <= 1:
            return P[:b_search(P,max_int)+1]

        for i in integer:
            if i >= valid_range:
                if Q:
                    q = Qpopleft()
                    heappush(hq, (q**2,q))
                valid_range = Q[0]**2 if Q else i**2

            m,r = hq[0] if hq else (0,0)
            if i != m:
                Pappend(i)
                Qappend(i)

            while m == i:
                heapreplace(hq, (m+2*r, r))
                m,r = hq[0]

            current_i = i
            if max_int - current_i <=1:
                break 
        return P[:]
    return Primes

def factorization(m, Primes=None):
    F = defaultdict(int)
    if m < 2:
        return F

    while not m&1:
        F[2] += 1
        m >>= 1

    if Primes is None:
        Primes = Primes_fnct()

    Primes = deque(Primes(max_int=ceil(sqrt(m))+1))
    Primespopleft = Primes.popleft

    while m > 1 and Primes:
        p = Primespopleft()
        while not m%p:
            m //= p
            F[p] += 1

    if m > 1:
        F[m] += 1
    return F

def solve():
    N = int(input())
    Primes = Primes_fnct()
    F = defaultdict(int)
    for i in range(1,N+1):
        f = factorization(i)
        for k in f.keys():
            F[k] += f[k]
    P = defaultdict(set)
    for k in F.keys():
        for n in (2,4,14,24,74):
            if F[k] >= n:
                P[n] = P[n]|{k,}
    res = 0
    for Q in (((2,1),(4,2)), ((2,1),(24,1)), ((4,1),(14,1)), ((74,1),)):
        R = set()
        if all(len(P[q[0]]) >= q[1] for q in Q):
            for r in product(*(combinations(P[q[0]],q[1]) for q in Q)):
                r_ = [i for j in r for i in j]
                if len(r_) == len(set(r_)):
                    R |= {r,}
        res += len(R)

    return res



if __name__ == '__main__':
    print(solve())

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

typedef ostringstream OSS;
typedef istringstream ISS;

typedef long long LL;
typedef pair<int, int> PII;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<double> VD;
typedef vector<VD> VVD;
typedef vector<string> VS;
typedef vector<VS> VVS;
typedef vector<bool> VB;
typedef vector<VB> VVB;
typedef vector<PII> VPII;

#define fst first
#define snd second
// #define Y first
// #define X second
#define MP make_pair
#define PB push_back
#define EB emplace_back 
#define ALL(x) (x).begin(),(x).end()
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define rep(i, N) for (int i = 0; i < (N); i++)
#define rep2(i, j, N, M) rep(i, N) rep(j, M)
#define rep3(i, j, k, N, M, L) rep(i, N) rep(j, M) rep(k, L)
#define REP(i, init, N) for (int i = (init); i < (N); i++)

template < typename T > inline T fromString(const string &s) { T res; ISS iss(s); iss >> res; return res; };
template < typename T > inline string toString(const T &a) { OSS oss; oss << a; return oss.str(); };

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double DINF = 0x3f3f3f3f;
const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

int N, R;

VI XLS, XRS;
VI HS;

VVI find_max_hs() {
    VVI max_hs(41, VI(2));
    
    rep(i, N) {
        REP(x, XLS[i], XRS[i] + 1) {
            rep(lr, 2) {
                if (!lr && x == XLS[i]) continue;
                if (lr && x == XRS[i]) continue;

                max_hs[20 + x][lr] = max(max_hs[20 + x][lr], HS[i]);
            }
        }
    }

    return max_hs;
}

double calc(double h, double x) {
    double r = R;
    double A = h + r;

    double a = 1;
    double b = -2. * A;
    double c = A * A + x * x - r * r;

    double p = b * b - 4. * a * c;
    if (p < 0) return DINF;

    double ans = (-1. * b - sqrt(p)) / 2.;

    return ans;
}

double solve() {
    VVI max_hs = find_max_hs();

    double anst = DINF;

    for (int x = -1 * R; x <= R; x++) {
        for (int lr = 0; lr < 2; lr++) {
            if (!lr && x == -1 * R) continue;
            if (lr && x == R) continue;

            int h = max_hs[20 + x][lr];
            double t = calc(h, abs(x));
            anst = min(anst, t);
        }
    }

    return anst;
}

int main(void) {
    while (cin >> R >> N, R) {
        XLS.clear();
        XRS.clear();
        HS.clear();

        XLS.resize(N);
        XRS.resize(N);
        HS.resize(N);

        for (int i = 0; i < N; i++) {
            cin >> XLS[i] >> XRS[i] >> HS[i];
        }

        printf("%.4f\n", solve());
    }

	return 0;
}

Measured memory_bytes: 1224
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX;
#define INFL LLONG_MAX;
typedef long long ll;
using namespace std;

int main(){
  int n,k;
  cin >> n >> k;
  vector<bool> have(n,false);
  rep(i,k){
    int d; cin >> d;
    rep(i,d){
      int a; cin >> a;
      if(have.at(a-1)==false){
        have.at(a-1)=true;
      }
    }
  }

  int ans =0;

  rep(i,n){
    if(have.at(i)==false) ans++;
  }

  cout << ans << endl;

}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define watch(x) cout<<(#x)<<"="<<(x)<<'\n'
#define mset(d,val) memset(d,val,sizeof(d))
#define setp(x) cout<<fixed<<setprecision(x)
#define forn(i,a,b) for(int i=(a);i<(b);i++)
#define fore(i,a,b) for(int i=(a);i<=(b);i++)
#define pb push_back
#define F first
#define S second
#define pqueue priority_queue
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
void amin(ll &a, ll b){ a=min(a,b); }
void amax(ll &a, ll b){ a=max(a,b); }
void SD(int t=0){ cout<<"PASSED "<<t<<endl; }
const ll INF = ll(1e18);
const int MOD = 998244353;

bool DEBUG=0;
const int MAXN = 100005;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	ll n; cin>>n; n--;
	string s;
	while(1){
		s+=char('a'+n%26);
		n/=26; n--;
		if(n<0) break;
	}
	reverse(s.begin(),s.end());
	cout<<s<<'\n';
	
	return 0;
}


Measured memory_bytes: 3652
#include<stdio.h>
#include<string.h>
int main(){
  int n,m,o=0,i;
  char s[10010][300];
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%s",s[i]);
  scanf("%d",&m);
  while(m--){
    scanf("%s",s[n]);
    for(i=0;strcmp(s[i],s[n]);i++);
    if(i==n)printf("Unknown %s\n",s[n]);
    else printf("%s by %s\n",(o=1-o)?"Opened":"Closed",s[n]);
  }
  return 0;
}

Measured memory_bytes: 2656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;

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

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <sstream>
#include <queue>
#include <deque>
#define ll long long
#define MP make_pair
#define PII pair<int, int>
#define F first
#define S second
using namespace std;
int n;
ll a[100010];
ll d[100010][2];
int main()
{
	cin >>n;
	for (int i=0;i<n;i++) cin >>a[i];
	d[0][0]=a[0],d[0][1]=-a[0];
	for (int i=1;i<n-1;i++)
	{
		//cout <<i<<" #########################\n";
		for (int j=0;j<2;j++)
		{
			d[i][0]=max(d[i][0],d[i-1][j]+(j ? -a[i] : a[i]));
			d[i][1]=max(d[i][1],d[i-1][j]+(j ? a[i] : -a[i]));
	    	//cout <<d[i][0]<<" "<<d[i][1]<<"\n";
		}
	}
	cout <<max(d[n-2][0]+a[n-1],d[n-2][1]-a[n-1]);
	return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
const int N=305;
int a,b,c,tmp;
double n,dp[N][N][N];
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>tmp;
		if(tmp==1) a++;
		if(tmp==2) b++;
		if(tmp==3) c++;
	}
	for(int i=0;i<=n;i++){
		for(int j=0;j<=n;j++){
			for(int k=0;k<=n;k++){
				if(!i&&!j&&!k) continue;
				if(i) dp[i][j][k]+=dp[i-1][j+1][k]*i;
				if(j) dp[i][j][k]+=dp[i][j-1][k+1]*j;
				if(k) dp[i][j][k]+=dp[i][j][k-1]*k;
				dp[i][j][k]=dp[i][j][k]/(i+j+k);
				dp[i][j][k]+=n/(i+j+k);			}
		}
	}
	cout<<fixed<<setprecision(12)<<dp[c][b][a]<<endl;
	return 0;
}

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

int main()
{
    int n, sum = 0;
    cin>>n;
    int arr[n], arrb[n];
    for(int i = 0; i < n; i++)
    {
        cin>>arr[i];
        if(arr[i] % 2 == 0)
        {
            if(arr[i] % 3 == 0 || arr[i] % 5 == 0)
            {
                continue;
            }
            else
            {
                sum++;
                break;
            }
        }
    }
    if(sum != 0)
    {
        cout<<"DENIED";
    }
    else
    {
        cout<<"APPROVED";
    }
    return 0;
}

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

using namespace std;



void solve()
{
	int n;
	cin >> n;
	if(n%2==0)
	{
		cout <<"-1";
		return;
	}
	else if(n%5==0)
	{
		cout <<"-1";
		return;
	}
	int divisor = n;
	int divident = 7;
	int result = 1;
	unordered_set<int> remainder;
	while(1)
	{
		int rem = divident%divisor;
		if(rem==0)
		{
			cout << result;
			return;
		}
		else if(remainder.find(rem)==remainder.end())
		{
			remainder.insert(rem);
			divident = rem*10+7;
			result++;
		}
		else{
			cout <<"-1";
			return;
		}

	}
}


int main()
{
	solve();
}

Measured memory_bytes: 42696
"""
重さと価値がそれぞれw_i,v_iであるようなn個の品物がある.
これらの品物の中から, 重さの総和がWを超えないように選んだ時の,
価値の総和の最大値を求めよ.
1<=n<=100, 1<=w_i<=10^7, 1<=v_i<=100, 1<=W<=10^9
"""
#-------------------------------------------------------------------------------

#入力
INF=float('inf')
n ,W= map(int, input().split())
w=[0]*n
v=[0]*n
for i in range(n):
    w[i],v[i] = map(int, input().split())
V=sum(v)
dp = [[INF for i in range(V+1)] for j in range(n+1)]

#ここからメイン
dp[0][0]=0
for i in range(n):
    for j in range(V+1):
        if j<v[i]:
            dp[i+1][j]=dp[i][j]
        else:
            dp[i+1][j]=min(dp[i][j],dp[i][j-v[i]]+w[i])
ans=0
for i in range(V+1):
    if dp[n][i]<=W:
        ans=i
print(ans)


Measured memory_bytes: 315064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}

template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

int main()
{
  int x, y;
  cin >> x >> y;

  int ans = INT32_MAX;
  if (x - y <= 0)
    ans = min(ans, -(x - y));
  if (x + y >= 0)
    ans = min(ans, x + y + 1);
  if (x + y <= 0)
    ans = min(ans, -(x + y) + 1);
  if (x - y >= 0)
    ans = min(ans, x - y + 2);

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

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

using namespace std;

int main()
{
	double a, b;
	cin >> a >> b;
	if (a > b)
		cout << "GREATER" << endl;
	else if (a < b)
		cout << "LESS" << endl;
	else
		cout << "EQUAL" << endl;

	return 0;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF 0x6fffffff
#define INFL 0x6fffffffffffffffLL

int main() {
	ll		a,b,c,h,i,j,k,l,m,n,x,y;
	ll		ans = 0;
	string	s;
	cin >> n >> m;
	vector<ll>	aa(m);
	for(i=0;i<m;i++) cin >> aa[i];
	vector<ll> dp(n+1);
	dp[0] = 1;
	for(i=1,a=0;i<=n;i++) {
		if (a<m)
			if (aa[a] == i) {
				a++;
				continue;
			}
		dp[i] = dp[i-1];
		if (i>1) dp[i] += dp[i-2];
		dp[i] %= 1000000007;
	}

	cout << dp[n] << endl;
	return 0;
}


Measured memory_bytes: 1792
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ans=0
for i in range(n):
    if b[i]<=a[i]:
        ans=ans+b[i]
    elif b[i]<=a[i]+a[i+1]:
        ans=ans+b[i]
        a[i+1]=a[i]+a[i+1]-b[i]
    else:
        ans=ans+a[i]+a[i+1]
        a[i+1]=0
print(ans)

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////

ll A[5][5],N,B[11];
ll i, j, k;
ll ok(){
    if(j==3){
        printf("Yes");
        exit(0);
    }
}
int main(){
    fornum(i,0,3){
        fornum(j,0,3){
            scanf("%lld", &A[i][j]);
        }
    }
    scanf("%lld", &N);
    fornum(i,0,N){
        scanf("%lld", &B[i]);
        fornum(j,0,3){
            fornum(k,0,3){
                if(B[i]==A[j][k]){
                    A[j][k] = 0;
                }
            }
        }
    }
    ll ans = 0;
    fornum(j,0,3){
        if(0!=A[j][j]){
            break;
        }
    }
    ok();
    fornum(j,0,3){
        if(0!=A[2-j][j]){
            break;
        }
    }
    ok();
    fornum(i,0,3){
        fornum(j,0,3)
        {
            if(0!=A[i][j]){
                break;
            }
        }
        ok();
        fornum(j,0,3){
            if(0!=A[j][i]){
                break;
            }
        }
        ok();
    }

    printf("No");
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<math.h>
#include<numeric>
#include<iomanip>
#define rep(i, n) rep2(i,0,n)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define PI acos(-1);
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
//scanf("%d", &a); '\n'; cout << fixed << setprecision(10);

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a, b;
	cin >> a >> b;
	int ans = 1;
	while (true) {
		if (floor(ans*0.08) == a && floor(ans*0.10) == b) {
			cout << ans; return 0;
		}
		else if (ans*0.05 > a) {
			cout << "-1"; return 0;
		}
		++ans;
	}

}

Measured memory_bytes: 256
from collections import defaultdict
from copy import deepcopy
import sys
sys.setrecursionlimit(1000000)
input = sys.stdin.readline
n, m = list(map(int, input().split()))

if m%2==1:
  print(-1)
  exit()

graph = defaultdict(set)
grapht = defaultdict(set)
for i in range(m):
  a, b = list(map(int, input().split()))
  a -= 1
  b -= 1
  graph[a].add(b)
  graph[b].add(a)
  grapht[a].add(b)
  grapht[b].add(a)

graph2 = defaultdict(set)
visited = [0 for i in range(n)]
num = [1 for i in range(n)]

def dfs(x):
  visited[x] = 1

  for nx in graph[x]:
    if not visited[nx]:
      dfs(nx)

  t = set()
  if num[x]==1 and len(grapht[x])%2==0:
    for e in grapht[x]:
      graph2[x].add(e)
      t.add(e)
  elif num[x]==-1 and len(grapht[x])%2==0:
    for j, e in enumerate(grapht[x]):
      if j==len(grapht[x])-1:
        graph2[e].add(x)
        num[e] *= -1
      else:
        graph2[x].add(e)
      t.add(e)
  elif num[x]==1 and len(grapht[x])%2==1:
    for j, e in enumerate(grapht[x]):
      if j==len(grapht[x])-1:
        graph2[e].add(x)
        num[e] *= -1
      else:
        graph2[x].add(e)
      t.add(e)
  elif num[x]==-1 and len(grapht[x])%2==1:
    for e in grapht[x]:
      graph2[x].add(e)
      t.add(e)
  for e in t:
    grapht[x].remove(e)
    grapht[e].remove(x)

dfs(0)

for i in range(n):
  if len(graph2[i])%2==1:
    print(-1)
    exit()

for i in range(n):
  for e in graph2[i]:
    print(i+1, e+1)


Measured memory_bytes: 170368