akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(true){
            int m = sc.nextInt();
            int f = sc.nextInt();
            int r = sc.nextInt();
            if (m == -1 && f == -1 && r == -1){
                break;
            }else if (m == -1 || f == -1) {
                System.out.printf("F\n");
            }else if (m + f >= 80) {
                System.out.printf("A\n");
            }else if (m + f >= 65 && m + f < 80) {
                System.out.printf("B\n");
            }else if (m + f >= 50 && m + f < 65) {
                System.out.printf("C\n");
            }else if (m + f >= 30 && m + f < 50 && r >= 50) {
                System.out.printf("C\n");
            }else if (m + f >= 30 && m + f < 50 && r < 50) {
                System.out.printf("D\n");
            }else{
                System.out.printf("F\n");
            }
        }
        sc.close();
    }
}


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

int main(void)
{
    int x, n;

    cin >> x >> n;

    vector<int> p(n,0);

    for(int i = 0; i < n; ++i)
    {
        int tmp;
        cin >> tmp;
        p[i] = tmp;
    }

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

    int ans=0;
    int ans_d=200;
    for(int j = 0; j <= 101; ++j)
    {
        int ds = abs(x-j);
        if(ans_d > ds && !binary_search(p.begin(), p.end(), j))
        {
            ans_d = ds;
            ans = j;
        }
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3628
#include <cstdlib>
#include <iostream>
#include <iterator>
#include <set>
#include <utility>
using namespace std;

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

	int n;
	double r;
	cin >> n >> r;

	set<pair<int, int> > exists;
	while(n--) {
		double x, y;
		cin >> x >> y;
		exists.insert(make_pair((int)(x / r), (int)(y / r)));
	}

	int ans = 0;
	set<pair<int, int> >::iterator it, en = exists.end();
	for(it = exists.begin(); it != en; exists.erase(it++)) {
		++ans;
		const int x = it->first, y = it->second;
		for(int i = -1; i <= 1; ++i) {
			for(int j = -1; j <= 1; ++j) {
				if(!(i || j))
					continue;

				set<pair<int, int> >::iterator it2 = exists.find(make_pair(x + i, y + j));
				if(it2 != en) {
					exists.erase(it2);
				}
			}
		}
	}

	cout << ans << endl;

	return EXIT_SUCCESS;
}

Measured memory_bytes: 9772
#include <iostream>
#include <cstring>
using namespace std;
int cntw[500000],cntb[500000];
int main(){
	int n;
	cin>>n;
	char s[500000];
	for(int i=0;i<n;i++){
		cin>>s[i];
	}
	memset(cntw,0,sizeof(cntw));
	memset(cntb,0,sizeof(cntb));
	for(int i=0;i<n;i++){
		if(s[i]=='.'){
			cntw[i+1]=cntw[i]+1;
			cntb[i+1]=cntb[i];
		}else{
			cntb[i+1]=cntb[i]+1;
			cntw[i+1]=cntw[i];
		} 
	}
	int minn=1000000;
	for(int i=0;i<=n;i++){
		if(cntb[i]+cntw[n]-cntw[i]<=minn){
			minn=cntb[i]+cntw[n]-cntw[i];
		}
	}
/*	for(int i=0;i<n;i++){
		cout<<cntw[i]<<" ";
	}
	cout<<endl;
	for(int i=0;i<n;i++){
		cout<<cntb[i]<<" ";
	}
*/	cout<<minn;
	return 0;
}

Measured memory_bytes: 4352
#define DIN freopen("input.txt","r",stdin);
#define DOUT freopen("output.txt","w",stdout);
#include <bits/stdc++.h>
#define mem(a,b) memset(a,b,sizeof(a))
#define REP(i,a,b) for(int i=(a);i<=(int)(b);i++)
#define REP_(i,a,b) for(int i=(a);i>=(b);i--)
#define pb push_back
using namespace std;
typedef long long LL;
typedef vector<int> VI;
typedef pair<LL,LL> P;
int read()
{
    int x=0,flag=1; char c=getchar();
    while((c>'9' || c<'0') && c!='-') c=getchar();
    if(c=='-') flag=0,c=getchar();
    while(c<='9' && c>='0') {x=(x<<3)+(x<<1)+c-'0';c=getchar();}
    return flag?x:-x;
}

const int maxn=16;
LL n,x[maxn],y[maxn],p[maxn],ans[maxn],m[maxn];
LL xx[maxn],yy[maxn];
int a[maxn],nx,ny;

void solve(int q)
{
    int tot=0;
    REP(i,1,n)
    {
        a[i]=q%3; q/=3;
        if(a[i]>0) tot++;
    }

    nx=ny=0;
    REP(i,1,n)
        if(a[i]==1) xx[++nx]=x[i];
        else if(a[i]==2) yy[++ny]=y[i];
    REP(i,1,n) m[i]=3e18;
    LL t=0;
    REP(i,1,n)
    {
        REP(j,1,nx) m[i]=min(m[i],abs(xx[j]-x[i]));
        REP(j,1,ny) m[i]=min(m[i],abs(yy[j]-y[i]));
        m[i]=min(m[i],abs(x[i]));
        m[i]=min(m[i],abs(y[i]));
        t+=m[i]*p[i];
        if(t>=ans[tot]) return;
    }
    ans[tot]=min(ans[tot],t);

}

int main()
{
    n=read();
    REP(i,1,n) x[i]=read(),y[i]=read(),p[i]=read();
    REP(i,0,n) ans[i]=3e18;
    int q=1;
    REP(i,1,n) q*=3;
    REP(i,0,q-1) solve(i);
    REP(i,0,n) printf("%lld\n",ans[i]);

    return 0;
}


Measured memory_bytes: 3784
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
int vis[1100000];
signed main(){
    int x,n;cin >> x >> n;
    vector<P> res;
    rep(i,n){
        int p;cin >> p;
        vis[p] = 1;
    }
    
    for(int i = 0;i <= 1000;i++){
        if(!vis[i])res.emplace_back(abs(i - x),i);
        
    }
    sort(res.begin(),res.end());
    cout << res[0].second << endl;

    return 0;
}

Measured memory_bytes: 3656
N,M=map(int, input().split())

D={} 
for i in range(N):
  D[i+1]=0
for i in range(M):
  a,b=map(int, input().split())
  D[a]+=1
  D[b]+=1

odds=0
evens=0
for v in D.values():
    if v%2==0:
        evens+=1
    else:
        odds+=1
if odds>0:
    print("NO")
else:
    print("YES")

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

//#include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
// using cint = cpp_int;
//#pragma GCC optimize("", on)
//#pragma GCC optimization_level 3

// Define
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const ll MOD = 1e9 + 7;
const ll INF = LONG_MAX;
const ull MAX = ULONG_MAX;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define x first
#define y second
#define endl '\n'
#define space ' '
#define def inline auto
#define func inline constexpr ll
#define run __attribute__((constructor)) def _
#define all(v) begin(v), end(v)
#define input(a) scanf("%lld", &(a))
#define print(a) printf("%lld\n", (a))

// Debug
#define debug(...)                                                             \
    {                                                                          \
        cerr << __LINE__ << ": " << #__VA_ARGS__ << " = ";                     \
        for (auto &&X : {__VA_ARGS__}) cerr << "[" << X << "] ";               \
        cerr << endl;                                                          \
    }

#define dump(a, h, w)                                                          \
    {                                                                          \
        cerr << __LINE__ << ": " << #a << " = [" << endl;                      \
        rep(i, h) {                                                            \
            rep(j, w) cerr << a[i][j] << space;                                \
            cerr << endl;                                                      \
        }                                                                      \
        cerr << "]" << endl;                                                   \
    }

#define lldump(a, n) dump(vector<vector<ll>>{a}, 1, n)

// Loop
#define inc(i, a, n) for (ll i = (a), _##i = (n); i <= _##i; ++i)
#define dec(i, a, n) for (ll i = (a), _##i = (n); i >= _##i; --i)
#define each(i, a) for (auto &&i : a)
#define rep(i, n) inc(i, 0, n - 1)
#define loop() for (;;)

// Stream
#define fout(n) cout << fixed << setprecision(n)
#define fasten cin.tie(0), ios::sync_with_stdio(0)

// Speed
run() { fasten, fout(10); }
#pragma GCC optimize("O3")
#pragma GCC target("avx")

// Math
func gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
func lcm(ll a, ll b) { return a * b / gcd(a, b); }
func sign(ll a) { return a ? abs(a) / a : 0; }

def in() {
    ll A;
    cin >> A;
    return A;
}

signed main() {
    ll A, B, C;
    cin >> A >> B >> C;
    cout << ((A - B - C) * (B - C - A) * (C - A - B) ? "No" : "Yes") << endl;
}

// for compilation: g++ -Ofast -march=native -o _ _.cpp -std=c++17


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

int main() {
  int a, b;
  bool stF = false;

  while( cin >> a >> b && (a|b) ) {
    if( stF ) cout << endl;
    stF = true;
    map<int, bool> mp;
    for( int i=a; i<=b; i++ ) {
      if( ( i % 4 == 0 && i % 100 != 0 ) || ( i % 400 == 0 ) ) 
	mp[i] = true;
    }
  
    if( mp.size() ) {
      for( map<int, bool>::iterator it = mp.begin(); it != mp.end(); it++ ) {
	cout << it->first << endl;
      }
    }
    else {
      cout << "NA" << endl;
    }
  }
  
  return 0;
}

Measured memory_bytes: 1228
require 'pp'
S=gets.chomp.split('')
T=gets.chomp.split('')
hS = {}
hT = {}
for i in 0..(S.size-1)
	if(hS[S[i]].nil? && hT[T[i]].nil?)
		hS[S[i]] = T[i]
		hT[T[i]] = S[i]
	else
		if(hS[S[i]]!=T[i] || hT[T[i]]!=S[i])
			puts "No"
			exit(0)
		else
			hS[S[i]] = T[i]
			hT[T[i]] = S[i]
		end
	end
end
puts "Yes"


Measured memory_bytes: 23036
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
using namespace std;

template<typename A, typename B> bool chmin(A &a, const B &b){ return b < a && (a = b, true); }
template<typename A, typename B> bool chmax(A &a, const B &b){ return a < b && (a = b, true); }

int main(){
  int a,b,x;
  cin >> a >> b >> x;
  if (a + b >= x && a <= x){
    cout << "YES\n";
  }
  else{
    cout << "NO\n";
  }
  return 0;
}

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

int n,s;

int mySet(int d,int sum,int c){
  int count=0;
  if(d==n){
    if(sum==s){
      return 1;
    }else{
      return 0;
    }
  }
  for(int i=c;i<=9;i++){
    count+=mySet(d+1,sum+i,i+1);
  }
  return count;
}

int main(void){
  while(cin>>n>>s,n){
    cout<<mySet(0,0,0)<<endl;
  }
  return 0;
}

Measured memory_bytes: 3016
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

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

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back
#define REP(i,a,b) for(int i=a; i<=b; i++)
#define MOD 1000000007

void solve(int test_case) {//209
	string s;
	cin>>s;
	int mi = INT_MAX;
	REP(i,0,(int)s.length()-3) {
		mi=min(mi,abs(753-stoi(s.substr(i,3))));
	}
	cout<<mi;
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	//prefill();
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int x, y, z;
  cin >> x >> y >> z;
  printf("%d %d %d\n", z, x, y);
  return 0;
}

Measured memory_bytes: 3736
#include<iostream>
#include<cstring>
using namespace std;
char ss[1001];
int main()
{
	cin>>ss;
	if(ss[0]=='S')
	{
		cout<<"Cloudy"; 
	}
	else if(ss[0]=='R')
	{
		cout<<"Sunny";
	}
	else
	{
		cout<<"Rainy"; 
	}
	return 0;
 } 

Measured memory_bytes: 256
/*
"Won't stop untill I'm Phenomenal"
- Phenomenal, EMINEM
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define ff first
#define Shazam ios_base::sync_with_stdio(false);   cin.tie(NULL); cout.tie(NULL);
#define ss second
#define all(c) c.begin(),c.end()
#define endl "\n"
#define test() int t; cin>>t; while(t--)
#define fl(i,a,b) for(int i = a ; i <b ;i++)
#define get(a) fl(i,0,a.size())  cin>>a[i];
#define pra(a) fl(i,0,a.size()) cout<<a[i]<<" ";	cout<<endl;
#define pr(a,n) fl(i,0,n) cout<<a[i]<<" ";	cout<<endl;
const ll INF = 2e18;
const int inf = 2e9;
const int mod1 = 1e9 + 7;



int main(){
    Shazam;
    int n; cin>>n;
    vector<int> a(n);
    get(a);
    sort(all(a), greater<int>());
    ll ans = 0;
    deque<int> avail;
    avail.push_back(a.front());
    for(int i = 1; i< n; i++){
        ans+= avail.front();
        avail.pop_front();
        avail.push_back(a[i]);
        avail.push_back(a[i]);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4796
//int1_topic1_d
#include<bits/stdc++.h>
using namespace std;
int main(){
     int x;
     cin>>x;
     int h = x / 3600;
     int m = (x / 60) % 60;
     int s = x % 60;
     cout<<h<<":"<<m<<":"<<s<<endl;
     return 0;
}


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

#define rp(i, k, n) for (ll i = k; i < n; i++)
#define ll  long long

ll mod = 1e9 + 7;

int main() {
    int n, t, a;
    cin >> n >> t >> a;
    int h;
    int ans;
    int count = 1;
    int now = 100000000;
    rp(i, 0, n) {
        cin >> h;
        if (now > abs(t * 1000 - h * 6 - a * 1000)) {
            ans = count;
            now = abs(t * 1000 - h * 6 - a * 1000);
        }
        count++ ;
    }
    printf("%d", ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 1; i <= (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n;
  cin >> n;
  ll ans = 0;

  //最大公約数を求める
  rep(i,n)rep(j,n)rep(k,n) ans += gcd(i,gcd(j,k));

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

Measured memory_bytes: 3620
def equ(a, b):
    if a == b:
        return 1
    else:
        return 0


s = input()
t = input()
max_equ = 0

for i in range(len(s) - len(t) + 1):
    count = 0
    for j in range(len(t)):
        count += equ(s[i + j], t[j])
    if count > max_equ:
        max_equ = count
print(len(t) - max_equ)


Measured memory_bytes: 8932
import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class Main {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);
	static boolean debug = false;

	static int n, m;
	static int[][][] t;

	static int put(int y, int x, int bw) {
		int h = 0;
		while (t[y][x][h] != 0) h++;
		t[y][x][h] = bw;
		return h;
	}

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

	static boolean f(int y, int x, int z, int bw, int cnt, int d) {
		if (cnt == m) return true;
		if (t[y][x][z] != bw) return false;
		int ny = y + dy[d];
		int nx = x + dx[d];
		int nz = z + dz[d];
		if (ny < 0 || nx < 0 || nz < 0 || n <= nx || n <= ny || n <= nz) return cnt == m-1;
		return f(ny, nx, nz, bw, cnt+1, d);
	}

	static boolean win(int y, int x, int z, int bw) {
		if (t[y][x][z] != bw) return false;
		for (int d=0; d<26; d++) {
			int ny = y + dy[d];
			int nx = x + dx[d];
			int nz = z + dz[d];
			if (ny < 0 || nx < 0 || nz < 0 || n <= nx || n <= ny || n <= nz) continue;
			if (f(ny, nx, nz, bw, 1, d)) return true;
		}
		return false;
	}

	static boolean solve() {
		n = in.nextInt();
		m = in.nextInt();
		int p = in.nextInt();
		if (n + m + p == 0) return false;

		t = new int[n][n][n];
		int win = -1;

		boolean f = false;
		for (int turn=0; turn<p; turn++) {
			int y = in.nextInt() - 1;
			int x = in.nextInt() - 1;
			int z = put(y, x, turn%2 + 1);
			if (f) continue;
			for (int i=0; i<n; i++) {
				for (int j=0; j<n; j++) {
					for (int k=0; k<n; k++) {
						if (win(i, j, k, turn%2 + 1)) {
							win = turn;
							f = true;
						}
					}
				}
			}
		}

		out.println(win == -1 ? "Draw" : (win%2 == 0 ? "Black "+(win+1) : "White "+(win+1)));

		return true;
	}

	public static void main(String[] args) {
		debug = args.length > 0;
		long start = System.nanoTime();

		while(solve());
		out.flush();

		long end = System.nanoTime();
		dump((end - start) / 1000000 + " ms");
		in.close();
		out.close();
	}

	static void dump(Object... o) { if (debug) System.err.println(Arrays.deepToString(o)); }
}

Measured memory_bytes: 72932
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;

typedef long long ll;

int MOD=1000000007;


int main(){
    int N,K;
    cin >> N >> K;
    double ans=0;
for(int i=1; i<=N; i++){
        double tmp=1.0/N;
        int now=i;
        while(now<K){
            now*=2;
            tmp/=2;
        }
    ans+=tmp;
}
printf("%.12f\n",ans);
}


Measured memory_bytes: 256
const Main = (input) =>{
	var xs = input.trim().split(' ').map(v=>parseInt(v,10));
	var ans = xs[0] - xs[1];
    if(ans >= 0){
    console.log(ans+0);
    }else if(ans < 0){
    console.log(0+0);
    }
}

Main(require("fs").readFileSync("/dev/stdin","utf8"));

Measured memory_bytes: 7372
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
#define FOR(i, n) for(int i = 1; i<=n; i++)
#define F0R(i, n) for(int i = 0; i<n; i++)
#define mp make_pair
#define pb push_back
#define f first
#define s second


//var 
LL n, a, b, ans;

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

	cin >> n >> a >> b;
	ans = (a) * (n / (a+b));
	n %= (a + b);
	ans += min(a, n);
	cout << ans << endl;

	cout.flush();
	return 0;
}

Measured memory_bytes: 3660
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#if defined(DAIJOBU)
#include "/home/ichigo/includes.hpp"
#include "/home/ichigo/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#include <bits/stdc++.h>
#define deb(x...)
#endif
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}

using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


int main(){
	FIO
	
	string s;
	cin >> s;
	s[3] = '8';
	cout << s << '\n';
	return 0; 
}


Measured memory_bytes: 256
n = input()

if (int(n[0]) + int(n[1]) + int(n[2]) + int(n[3]) == 7):
    print("{0}+{1}+{2}+{3}=7".format(n[0], n[1], n[2], n[3]))
elif (int(n[0]) + int(n[1]) + int(n[2]) - int(n[3]) == 7):
    print("{0}+{1}+{2}-{3}=7".format(n[0], n[1], n[2], n[3]))
elif (int(n[0]) + int(n[1]) - int(n[2]) + int(n[3]) == 7):
    print("{0}+{1}-{2}+{3}=7".format(n[0], n[1], n[2], n[3]))
elif (int(n[0]) + int(n[1]) - int(n[2]) - int(n[3]) == 7):
    print("{0}+{1}-{2}-{3}=7".format(n[0], n[1], n[2], n[3]))
elif (int(n[0]) - int(n[1]) + int(n[2]) + int(n[3]) == 7):
    print("{0}-{1}+{2}+{3}=7".format(n[0], n[1], n[2], n[3]))
elif (int(n[0]) - int(n[1]) + int(n[2]) - int(n[3]) == 7):
    print("{0}-{1}+{2}-{3}=7".format(n[0], n[1], n[2], n[3]))
elif (int(n[0]) - int(n[1]) - int(n[2]) + int(n[3]) == 7):
    print("{0}-{1}-{2}+{3}=7".format(n[0], n[1], n[2], n[3]))
elif (int(n[0]) - int(n[1]) - int(n[2]) - int(n[3]) == 7):
    print("{0}-{1}-{2}-{3}=7".format(n[0], n[1], n[2], n[3]))


Measured memory_bytes: 3192
from math import sqrt
from fractions import gcd


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)

    return divisors


def is_prime(n):
    if n == 1:
        return True

    for k in range(2, int(sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True


A, B = map(int, input().split(' '))
N = gcd(A, B)
divisors = make_divisors(N)
# print(N)
# print(divisors)

# divisors.sort()
# print(divisors)

cnt = 0
for n in divisors:
    if is_prime(n):
        cnt += 1

print(cnt)

Measured memory_bytes: 5216
#include <bits/stdc++.h>
#define N 200050
using namespace std;
typedef long long LL;
inline int rd() {
	int x=0,f=1;char ch=getchar();
	while (ch>'9'||ch<'0') {if(ch=='-')f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}
	return x*f;
}

struct HbFS{int a,b,c;}Q[N];
bool cmp(HbFS p1, HbFS p2) {return p1.a-p1.b > p2.a-p2.b;}
priority_queue<int, vector<int>, greater<int> > q1,q2;
int x,y,z,n;
LL L[N],R[N];

int main() {
	x = rd(), y = rd(), z = rd();
	n = x + y + z;
	for (int _=1;_<=n;_++)
		Q[_].a = rd(), Q[_].b = rd(), Q[_].c = rd();
	sort(Q+1,Q+n+1,cmp);
	
	for (int _=1;_<=x;_++)
		q1.push(Q[_].a - Q[_].c), L[_] = L[_-1] + Q[_].a;
	for (int _=x+1;_<=n;_++) {
		int cur = Q[_].a - Q[_].c;
		L[_] = L[_-1];
		if (cur > q1.top()) {
			int tmp = q1.top();
			q1.pop();
			q1.push(cur);
			L[_] -= tmp;
			L[_] += Q[_].a;
		} else
			L[_] += Q[_].c;
	}
	
	for (int _=n;_>=n-y+1;_--)
		q2.push(Q[_].b - Q[_].c), R[_] = R[_+1] + Q[_].b;
	for (int _=n-y;_>=1;_--) {
		int cur = Q[_].b - Q[_].c;
		R[_] = R[_+1];
		if (cur > q2.top()) {
			int tmp = q2.top();
			q2.pop();
			q2.push(cur);
			R[_] -= tmp;
			R[_] += Q[_].b;
		} else
			R[_] += Q[_].c;
	}
	
	LL ans = 0LL;
	for (int _=x;_<=n-y;_++) ans = max(ans, L[_]+R[_+1]);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4236
#include <bits/stdc++.h>
using std::cout;
using std::endl;
using std::cin;

int main(){
	int n; cin >> n; std::string s; cin >> s;
	
	int ma = 0;
	for(int i = 0; i < s.size(); i++){
		std::set<char> st, stt;
		
		for(int j = 0; j < i; j++) st.insert(s[j]);
		for(int j = i; j < n; j++) if(st.count(s[j])) stt.insert(s[j]);
		ma = std::max(ma, (int)stt.size());
	}
	
	cout << ma << endl;
	return 0;
}


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

using namespace std;

//#define TEST

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

    int n = s.length();

    /*
            RR...RLL...LRR...RLL...L....
                 ^           ^
        のように、RLの境界(のR側)のインデックスをまとめる.
     */
    vector<int> indRL;
    for (int i = 0;i < n - 1;++i)
        if (s[i] == 'R' && s[i + 1] == 'L')
            indRL.push_back(i);
    
#ifdef TEST
    cout << "----------indRL----------" << endl;
    for (int i = 0;i < indRL.size();++i)
        cout << indRL[i] << " ";
    cout << endl;
#endif

    /*
            RR...RLL...LRR...RLL...L....LRR...RLL...L
           ^           ^                ^           ^
        のように、LRの境界(のL側)のインデックスをまとめる.
     */
    vector<int> indLR;
    indLR.push_back(-1);
    for (int i = 0;i < n - 1;++i)
        if (s[i] == 'L' && s[i + 1] == 'R')
            indLR.push_back(i);
    indLR.push_back(n - 1);

#ifdef TEST
    cout << "----------indLR----------" << endl;
    for (int i = 0;i < indLR.size();++i)
        cout << indLR[i] << " ";
    cout << endl;
#endif

    /*
            RR...........RLL..........L
            ^indLR[i]+1  ^indRL[i]    ^indLR[i+1]
        のとき、
            indRL[i]番
             -> (indRL[i]-indLR[i]+1)/2 + (indLR[i+1]-indRL[i])/2
            indRL[i]+1番
             -> (indRL[i]-indLR[i])/2 + (indLR[i+1]-indRL[i]+1)/2
            その他
             -> 0
        となる.
     */
    int* ans = new int[n];
    int m = indRL.size();
    for (int i = 0;i < n;++i) ans[i] = 0;
    for (int i = 0;i < m;++i){
        ans[indRL[i]] = (indRL[i]-indLR[i]+1)/2 + (indLR[i+1]-indRL[i])/2;
        ans[indRL[i]+1] = (indRL[i]-indLR[i])/2 + (indLR[i+1]-indRL[i]+1)/2;
    }

#ifdef TEST
    cout << "----------ans------------" << endl;
#endif
    for (int i = 0;i < n;++i)
        cout << ans[i] << " ";
    cout << endl;

    delete[] ans;
    return 0;
}

Measured memory_bytes: 1596
import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
import copy as cp
import sys
def sinput(): return sys.stdin.readline()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(n=0):
    if n: return [0 for _ in range(n)]
    else: return list(imap())
def farr(): return list(fmap())
def sarr(n=0):
    if n: return ["" for _ in range(n)]
    else: return sinput().split()
def barr(n): return [False for _ in range(n)]


n,m = imap()
g = [[] for i in range(n+1)]
for i in range(m):
    a,b = imap()
    g[a].append(b)
    g[b].append(a)

q = col.deque([1])
know = barr(n+1); know[1] = True
anss = iarr(n+1)
while q:
    now = q.popleft()
    for next in g[now]:
        if know[next]: continue
        else: know[next] = True; q.append(next); anss[next] = now

print("Yes")
for ans in anss[2:]: print(ans)


Measured memory_bytes: 64044
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define until(x) while(!(x))
#define unless(x) if(!(x))
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define pc __builtin_popcount


int32_t main(){
	string s;
	cin>>s;
	if(s[2]==s[3] && s[4]==s[5]){
		cout<<"Yes";
	}
	else {
		cout<<"No";
	}
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int W,H,x,y,r;
    cin >> W >> H >> x >> y >> r;
    if(x-r<0 || x+r>W || y+r>H || y-r<0){cout << "No" << endl;}
    else{cout << "Yes" << endl;}
    
}



Measured memory_bytes: 3096
def main():
    N, A, B = map(int, input().split())
    lc = 0
    for x in range(1, N + 1):
        H = list(str(x))
        c = 0
        for h in H:
            c += int(h)
        if A <= c <= B:
            lc += x
    print(lc)


if __name__ == "__main__":
    main()

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

int main()
{
    string T;

    cin >> T;

#if 0
    for(int i = 0; i < (T.size()-1); i++) {
        // PDが少しでも多く、PDが作れない場合はDを多く
        // PD -> PDx1 , Dx1 = 2
        // PP -> PDx0 , Dx0 = 0
        // DP -> PDx0 , Dx1 = 1
        // DD -> PDx0 , Dx2 = 2
        // PD -> PD -> 2point
        // P? -> PD -> 2point
        // D? -> D? -> D? にして、DPDを狙う。ただし、最後の?はDにする
        // ?P -> DP -> 1point
        // ?D -> PD -> 2point
        // ?? -> PD -> 2point
        if(T[i] == 'P' && T[i+1] == '?') {
            T[i+1] = 'D';
        } else if(T[i] == 'D' && T[i+1] == '?') {
            if(i+2 == T.size()) {
                T[i+1] = 'D';
            }
        } else if(T[i] == '?' && T[i+1] == 'D') {
            T[i] = 'P';
        } else if(T[i] == '?' && T[i+1] == 'P') {
            T[i] = 'D';
        } else if(T[i] == '?' && T[i+1] == '?') {
            T[i] = 'P';
            T[i+1] = 'D';
        }
        //cout << T << endl;
    }
#endif
    for(int i = 0; i < T.size(); i++) {
        if(T[i] == '?') {
            T[i] = 'D';
        }
    }

    cout << T << endl;

    return 0;
}

Measured memory_bytes: 3724
#include <bits/stdc++.h>
#define LIM 1<<17
/// TONI BO$$ was here
/// #MLC

using namespace std;
char BUF[LIM];
int poz;

inline char getChar(){
    poz++;
    if(poz>=LIM){
    	fread(BUF,LIM,1,stdin);
    	poz=0;
    }
    return BUF[poz];
}

inline int getNr(){
    int r=0, semn=1;
    char ch=getChar();
    while(isdigit(ch)==0 && ch!='-') ch=getChar();
    if(ch=='-'){
        semn=-1;
        ch=getChar();
    }
    while(isdigit(ch)!=0){
        r=r*10+semn*(ch-'0');
        ch=getChar();
    }
    return r;
}

int main()
{
    long long n,p,d,e,rez;
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
    scanf("%lld%lld",&n,&p);
    d=2;
    rez=1;
    while(d*d<=p)
    {
        e=0;
        while(p%d==0)
            e++,p/=d;
        e/=n;
        while(e--)
            rez*=d;
        d++;
    }
    if(p>1 && n==1)
        rez*=p;
    printf("%lld",rez);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep0(i, n) for (long long i = 0; i < (long long)(n); i++)
#define rep1(i,n) for(long long i=1;i<=(long long)(n);i++)
#define all(v) v.begin(),v.end()
#define Sort(v) sort(all(v))
#define Reverse(v) reverse(all(v))
#define Rsort(v) sort(all(v),greater)
#define pub(v) push_back(v)
#define pob(v) pop_back(v)
typedef long long ll;
typedef vector<ll> vel;
typedef vector<vector<ll>> vel2d;
typedef string str;
typedef pair<ll,ll> pal;
typedef vector<str> ves;


int main() {
    str A,B;
    cin>>A>>B;
    bool flag=false;
    ll M=max(A.size(),B.size());
    rep0(i,max(A.size(),B.size())){
        if(A.size()>B.size()){cout<<"GREATER"<<endl;flag=true; break;}
        else if(A.size()<B.size()){cout<<"LESS"<<endl; flag=true; break;}
        if(A[i]>B[i]){cout<<"GREATER"<<endl;flag=true; break;}
        else if(A[i]==B[i]){continue;}
        else{cout<<"LESS"<<endl; flag=true; break;}
    }
    if(1-flag){cout<<"EQUAL"<<endl;}
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int h = s.nextInt();
		int w = s.nextInt();
		if (h + w < 10) {
			int a = h + w;
			System.out.println(a);
		} else {
			System.out.println("error");
		}

	}

}

Measured memory_bytes: 20052
#N, M = map(int, input().split())
#A = list(map(int, input().split()))
#S = str(input())
N = str(input())
hon = ["2", "4", "5", "7", "9"]

#print(N[-1])

if N[-1] in hon:
  print("hon")
elif N[-1] == str(3):
  print("bon")
else:
  print("pon")


Measured memory_bytes: 9032
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for(int i=a; i<n; i++)
#define repq(i,a,n) for(int i=a; i<=n; i++)
#define repr(i,a,n) for(int i=a; i>=n; i--)
typedef long long ll;
typedef pair<int, int> pii;
#define int ll

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

#define X real()
#define Y imag()
typedef complex<double> P;
typedef vector<P> Poly;

signed main() {
    int n,dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};
    while(cin >> n, n){
        int m0, m;
        double x, y;
        cin >> m0;
        Poly o;
        for(int i = 0; i < m0; ++i){
            cin >> x >> y;
            o.push_back(P(x,y));
        }
        for(int i = 0; i < n; ++i){
            cin >> m;
            Poly p;
            for(int j = 0; j < m; ++j){
                cin >> x >> y;
                p.push_back(P(x,y));
            }
            if(m == m0){
                for(int j = 0; j < 4; ++j){
                    bool f = true;
                    for(int k = 0; k < m; ++k){
                        P a = o[k]-o[0], b = p[k] - p[0];
                        if(b != P(a.X*dx[j]-a.Y*dy[j], a.X*dy[j]+a.Y*dx[j])){
                            f = false;
                            break;
                        }
                    }
                    if(f){
                        cout << i+1 << endl;
                        break;
                    }
                    f = true;
                    for(int k = m-1; k >= 0; --k){
                        P a = o[m-1-k] - o[0], b = p[k] - p[m-1];
                        if(b != P(a.X*dx[j]-a.Y*dy[j], a.X*dy[j]+a.Y*dx[j])){
                            f = false;
                            break;
                        }                        
                    }
                    if(f){
                        cout << i+1 << endl;
                        break;
                    }                    
                }
            }
        }
        cout << "+++++" << endl;
    }
    return 0;
}

Measured memory_bytes: 3064
program main
  implicit none
  integer :: n, i, res
  integer, allocatable :: a(:)
  read(*, *) n
  allocate(a(n))
  read(*, *) a(:)
  res = 0
  do i = 1, n
    res = res + count_two(a(i))
  end do
  write(*, "(i0)") res
  deallocate(a)
  contains
  function count_two(d)
    implicit none
    integer, intent(in) :: d
    integer :: count_two, i, d2
    count_two = 0
    d2 = d
    do i = 1, 100
      if (mod(d2, 2) == 0) then
        count_two = count_two + 1
        d2 = d2 / 2
      else
        exit
      end if
    end do
  end function count_two
end program main


Measured memory_bytes: 800
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N;
  cin >> N;
  vector<int> as(N);
  i64 psum = 0;
  int pmin = INT32_MAX;
  bool zero = false;
  F0R(i, N) {
    cin >> as[i];
    psum += abs(as[i]);
    chmin(pmin, abs(as[i]));
    zero |= !as[i];
  }
  if (zero) {
    cout << psum;
  }
  else {
    F0R(i, N - 1) {
      if (as[i] < 0) {
        as[i] = -as[i];
        as[i + 1] = -as[i + 1];
      }
    }
    if (as.back() >= 0) {
      cout << psum;
    }
    else {
      cout << (psum - pmin * 2);
    }
  }
}
#endif


Measured memory_bytes: 3680
#include <bits/stdc++.h>
using namespace std;
int n,num[101];
 

bool check(int l,int r){
  for(int i=l;i<=r;i++) if(num[l]!=num[i])return 0;
  return 1;
}

int used[101][101],mem[101][101]; 
int dfs(int l,int r){
  if(l==r)return 0;
  if(check(l,r))  return 1;
  if(used[l][r]++)return mem[l][r];
  
  int res=0;
  for(int i=l;num[l]==num[i];i++)
    for(int j=r;num[l]==num[j];j--){
      res|=dfs(l+1,r-1);
      for(int k=i+1;k<j;k++)
	res|=num[l]==num[k]&&dfs(i+1,k-1)&&dfs(k+1,j-1);
    }
   
  for(int i=l;i<r;i++) res|=dfs(l,i)&&dfs(i+1,r);
  return mem[l][r]=res;
}
 
int main(){
  cin>>n;
  for(int i=0;i<n;i++)cin>>num[i];
  cout<<(dfs(0,n-1)?"yes":"no")<<endl;;
  return 0;
}

Measured memory_bytes: 3144
#!/usr/bin/env python3
n, k = map(int, input().split())
a = []
b = []
c = 0
for i in range(k, n + k):
    a.append(abs(i))
    b.append(i)
if abs(min(b)) <= min(a):
    print(sum(b) - min(a))
else:
    print(sum(b) + min(a))

Measured memory_bytes: 3060
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<cmath>
#include<string>
#include<sstream>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<memory.h>
#include<ctime>
#include<cassert>
#include<limits.h>
#include<unordered_map>
#include<unordered_set>
#include<numeric>
#include<bitset>
#include<list>

#define sz(a) (int)a.size()
#define np next_permutation
#define mp make_pair
#define all(a) a.begin(),a.end()
#define forn(i, n) for (int i = 0; i < n; ++i)
#define forv(i, v) for (int i = 0; i < sz(v); ++i)
#define forab(i, a, b) for (int i = a; i <= b; i++)
#define forabd(i, a, b) for (int i = a; i >= b; i--)
#define _(a, b) memset(a, b, sizeof a)
#define pii pair<int, int>
#define pll pair<long long, long long>

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

template<class T> inline T sqr(T x) { return x * x; }

const double pi = acos(-1.0), eps = 1e-9, e = exp(1.0);
const int INF = 1000 * 1000 * 1000 + 7, MAXN = 100005, MOD = 1000000007, MAXBIT = 30, pHash = 53;
const ll INFL = 1e+18;

void prepare(string s) {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	//freopen("output.txt","w",stdout);
#else
	if (sz(s) != 0) {
		freopen((s + ".in").c_str(), "r", stdin);
		freopen((s + ".out").c_str(), "w", stdout);
	}
#endif
}

string s;
int a[5];

void read() 
{
	cin >> s;
}

void solve() 
{
	forv(i, s) {
		a[i] = s[i] - '0';
	}
	for (int mask = 0; mask <= 7; mask++) {
		int res = a[0], indx = 1;
		for (int i = 0; i <= 2; i++) {
			int bit = (mask >> i) & 1;
			bit == 0 ? res -= a[indx] : res += a[indx];
			indx++;
		}
		if (res == 7) {
			int curBit = 0;
			forn(i, 4) {
				cout << a[i];
				if (i != 3) {
					int bit = (mask >> curBit) & 1;
					bit == 0 ? cout << "-" : cout << "+";
					curBit++;
				}
			}
			cout << "=7";
			exit(0);
		}
	}
}

int main()
{
	srand(time(NULL));
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	prepare("");

	read();
	solve();

	return 0;
}

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

int main(void)
{
    string s;
    vector<char> result;
    cin >> s;
    for(int i{0}; i<s.size(); ++i){
        if(s[i]=='B' and result.size()!=0)
            result.pop_back();
        else if(s[i]=='0' or s[i]=='1')
            result.push_back(s[i]);
    }

    for(int i{0}; i<result.size(); ++i)
        cout << result[i];
    cout << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#define N 100000

int partition(int A[], int p, int r)
{
  int x,i,j,tmp;

  x = A[r];
  i = p - 1;
  for(j=p; j<=r-1; j++){
    if(A[j] <= x){
      i++;
      tmp = A[i];
      A[i] = A[j];
      A[j] = tmp;
    }
  }

  tmp = A[i+1];
  A[i+1] = A[r];
  A[r] = tmp;

  return i+1;
}

int main()
{
  int n,i,q;
  int A[N];

  scanf("%d",&n);

  for(i=0; i<n; i++)
    scanf("%d",&A[i]);

  q = partition(A, 0, n-1);

  for(i=0; i<n-1; i++){
    if(i == q)
      printf("[%d] ",A[i]);

    else
    printf("%d ",A[i]);
  }
  printf("%d\n",A[n-1]);

  return 0;
}


Measured memory_bytes: 2084
#include <stdio.h>
#include <iostream>

using namespace std;

int main()
{int e,s;
char op;
cin >>e>>op>>s;
switch(op){
case '+':
    cout << e+s;
break;
case '-':
    cout << e-s;
break;
default:
    cout << "wrong";
}

   return 0;
}

Measured memory_bytes: 256
#abc129_b
N = int(input())
W_list_str = input().split()
W_list_int = []
for w in W_list_str:
    W_list_int.append(int(w))
split_index = 0
abs_value = 9999999
for i in range(N):
    tmp_abs_value = abs(sum(W_list_int[:i])-sum(W_list_int[i:]))
    if tmp_abs_value < abs_value:
        abs_value = tmp_abs_value
print(abs_value)

Measured memory_bytes: 3064
N = int(input())
h = list(map(int, input().split()))
cnt = 0
while True:
    if max(h) == 0:
        print(cnt)
        break
    i = 0
    while i < N:
        if h[i] == 0:
            i += 1
        else:
            cnt += 1
            while i < N and h[i] > 0:
                h[i] -= 1
                i += 1

Measured memory_bytes: 3060
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n;
        long ans = 100000;
        
        n = sc.nextInt();
        for(int i=0;i<n;i++){
	      	ans = ans+(ans/20);
		    if(ans%1000>1){
		    	ans /= 1000;
		    	ans *= 1000;
		    	ans += 1000;
		    }
        }        
        System.out.println(ans);
    }
}

Measured memory_bytes: 17160
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define pint pair<int,int>
using namespace std;

ll dp[1001][1001];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int h,w,i,j;    cin>>w>>h;
	char s[w+1][h+10];
	for(i=1;i<=w;i++){
	    cin>>s[i]+1;
	}
	dp[w][h]=1;
	for(i=w-1;i>=1;i--){
	    if(s[i][h]=='.')    dp[i][h]=dp[i+1][h];
	    else    dp[i][h]=0;
	}
	for(i=h-1;i>=1;i--){
	    if(s[w][i]=='.')    dp[w][i]=dp[w][i+1];
	    else    dp[w][i]=0;
	}
	for(i=w-1;i>=1;i--){
	    for(j=h-1;j>=1;j--){
	        dp[i][j]=0;
	        if(s[i+1][j]=='.')  dp[i][j]+=dp[i+1][j];
	        if(s[i][j+1]=='.')  dp[i][j]+=dp[i][j+1];
	        dp[i][j]%=mod;
	    }
	}
	cout<<dp[1][1]<<endl;
	return 0;
}

Measured memory_bytes: 9088
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define ALL(c) (c).begin(), (c).end()
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s; cin >> s;
    if (s=="ABC") cout << "ARC" << endl;
    else
    {
        cout << "ABC" << endl;
    }
    
}




Measured memory_bytes: 3656
s = $stdin.gets.strip.split(//)
$stdin.gets
rev = false
$stdin.each_line do |line|
  t, f, c = *line.strip.split(/\s+/)
  case t
  when "1"
    rev = !rev
  when "2"
    if rev ^ (f == "1")
      s.unshift(c)
    else
      s.push(c)
    end
  end
end
if rev
  s.reverse_each {|c| print c }
else
  s.each {|c| print c }
end
puts


Measured memory_bytes: 36604
#include <bits/stdc++.h>
using namespace std;
 
#define     all(x) x.begin(),x.end()
#define     ff first
#define     ss second
#define     ll long long
#define     ld long double
#define     pb push_back
#define     MOD 1000000007
#define     REP(i,n) for(ll i=0;i<(n);i++)
#define     FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define     FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define     BLOCK 555

typedef     vector <ll> vll;
typedef     vector <pair<ll,ll>> vp;
typedef     vector<vector<ll> >vvll;

// log(y) power calculation
ll power_mod(ll x, ll y, ll m){
    ll ans = 1;
    x%=m;
    while(y){
        if(y&1){
            ans=(ans*x)%m;
        }
        y>>=1;
        x=(x*x)%m;
    }
    return ans;
}

ll power(ll x, ll y){
    ll ans = 1;
    while(y){
        if(y&1){
            ans*=x;
        }
        y>>=1;
        x = x*x;
    }
    return ans;
}


ll mod_inv(ll x,ll m){
    return power_mod(x,m-2,m);
}


// customized hash function for lowering the collision in UNORDERED_MAP
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
       
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
 
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
 
 

bool comp(const pair<ll,ll> &a, const pair<ll,ll> &b) { 
    if(a.ff == b.ff){
        return (a.second < b.second); 
    }
    return (a.ff < b.ff); 
} 

struct hash_pair { 
    template <class T1, class T2> 
    size_t operator()(const pair<T1, T2>& p) const
    { 
        auto hash1 = hash<T1>{}(p.first); 
        auto hash2 = hash<T2>{}(p.second); 
        return hash1 ^ hash2; 
    } 
};



void solve(){
    int n,m;
    cin>>n>>m;
    int ans = (n*(n-1)/2) + (m*(m-1)/2);
    cout<<ans<<endl;
}


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


    // ll t;
    // cin>>t;
    // while(t--){
        solve();
    // }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int r = scanner.nextInt();
    if (r < 1200) {
      System.out.println("ABC");
    } else if (r < 2800) {
      System.out.println("ARC");
    } else {
      System.out.println("AGC");
    }
  }
}


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

namespace _154C
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var A = Console.ReadLine().Split(' ');
            var temp = A.GroupBy(x => x).FirstOrDefault(x => x.Count() > 1);
            if(temp == null)
                Console.WriteLine("YES");
            else
                Console.WriteLine("NO");
        }
    }
}


Measured memory_bytes: 52916
s = input()

s1=int(s[0:2])
s2=int(s[2:4])

flag1=False
flag2=False
if 13>s1 and s1>0:
    flag1 = True
if 13>s2 and s2>0:
    flag2 = True
    
if flag1:
    if flag2:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if flag2:
        print("YYMM")
    else:
        print("NA")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int a[25], b[25], c[25];
int main(){
	int n, sum = 0;
	cin >> n;
	for(int i=1; i<=n; i++)
		cin >> a[i];
	for(int i=1; i<=n; i++){
		cin >> b[i];
		sum += b[i];
	}
	for(int i=1; i<n; i++)
		cin >> c[i];
	for(int i=2; i<=n; i++){
		if(a[i]-a[i-1]==1){
			sum += c[a[i-1]];
		}
	}
	cout << sum;
	return 0;
}

Measured memory_bytes: 256
#include <queue>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
#define N 100100
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define rep(x, a, b) for(int x=a; x<=b; x++)
#define drp(x, a, b) for(int x=a; x>=b; x--)
int deg[N], d[N], n, vis[N], a[N], num[N], l[N], ans=1, fac[N], inv[N];
vector<pair<int, int> > fu;
queue<int> q;
int power(int a, int k){
	int ret=1;
	while(k)
	{
		if(k&1) ret=1ll*ret*a%mod;
		a=1ll*a*a%mod; k>>=1;
	}
	return ret;
}
int C(int n, int m){
	return 1ll*fac[n]*inv[m]%mod*inv[n-m]%mod;
}
int pr(int n){
	return 1ll*fac[2*n]*inv[n]%mod*power((mod+1)>>1, n)%mod;
}
void init(){
	fac[0]=1;
	rep(i, 1, n) fac[i]=1ll*fac[i-1]*i%mod;
	inv[n]=power(fac[n], mod-2);
	drp(i, n, 1) inv[i-1]=1ll*inv[i]*i%mod;
}
int st[N<<1];
int main(){
	scanf("%d", &n);
	init();
	rep(i, 1, n)
	{
		scanf("%d", a+i);
		deg[a[i]]++;
	}
	rep(i, 1, n) if(deg[i]>2) return puts("0"), 0;
	rep(i, 1, n) d[i]=deg[i];
	rep(i, 1, n) if(!d[i]) q.push(i);
	while(!q.empty())
	{
		int u=q.front(); q.pop();
		vis[u]=1;
		if(--d[a[u]]==0) q.push(a[u]);
	}
	rep(i, 1, n) if(vis[i] && deg[i]>1) return puts("0"), 0;
	rep(i, 1, n) if(vis[i] && !deg[i])
	{
		int x=i, cnt=0;
		for(; vis[x]; x=a[x]) cnt++;
		l[x]=cnt;
	}
	rep(i, 1, n) if(!vis[i])
	{
		int x=i, fl=0, ass=1, tot=0;
		for(; !vis[x]; x=a[x]) st[++tot]=x, fl|=bool(l[x]), vis[x]=1;
		if(!fl){ num[tot]++; continue; }

		fu.clear();
//		if(l[i]) fu.pb(mp(l[i], 1));
//		for(int p=2, x=a[i]; x!=i; x=a[x]) if(l[x]) fu.pb(mp(l[x], p));
		
		int p=1; x=i;
		do{
			if(l[x]) fu.pb(mp(l[x], p));
			x=a[x]; p++;
		}while(x!=i);
		
		//rep(p, 1, tot) if(l[st[p]]) fu.pb(mp(l[st[p]], p));
		fu.pb(mp(fu[0].fi, fu[0].se+tot));
		int sz=fu.size();
		rep(j, 1, sz-1)
		{
			if(fu[j].fi>fu[j].se-fu[j-1].se) ass=0;
			if(fu[j].fi<fu[j].se-fu[j-1].se) ass=2ll*ass%mod;
		}
		ans=1ll*ans*ass%mod;
	}
	rep(i, 1, n) if(num[i])
	{
		int m=num[i], ass=0;
		rep(j, 0, m/2)
		{
			int tmp=1ll*C(m, 2*j)*pr(j)%mod*power(i, j)%mod;
			if(i>1 && (i&1)) tmp=1ll*tmp*power(2, m-2*j)%mod;
			ass=(ass+tmp)%mod;
		}
		ans=1ll*ans*ass%mod;
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 3616