akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define nout(ans) cout << (ans) << "\n"
#define sout(ans) cout << (ans) << " "
using namespace std;

const double pi = 3.14159265359;
const ll INF = 1e12;
const ll MOD = 1e9 + 7;
const ll N = 2e3+5; 
/*
Decimal Places: cout << fixed << setprecision(n) << ans << endl
*/

bool compare(const pair<int, int>&i, const pair<int, int>&j)
{
    return i.second < j.second;
}

ll raise(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}


ll s, dp[N];

void solve()
{
    cin >> s;
    dp[0]=1; dp[1]=-1; dp[2]=-1;
    for (int i=3; i<=s; ++i) {
    	for (int j=3; j<=i; j++) {
    		dp[i] += (dp[i-j]==-1 ? 0 : dp[i-j])%MOD;
    	}
    }
    nout(dp[s]==-1?0:dp[s]%MOD);
    
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    //cin >> t;
    for (int i=1; i<=t; i++)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1e9+7;
const int N=2e5+9;
int main()
{
    FASTINOUT;
    set<ll>s;
    ll x,y,z;
    cin>>x>>y>>z;
    s.insert(x);
    s.insert(y);
    s.insert(z);
    cout<<s.size()<<endl;
    return 0;
}


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

int main(){
  int h,w;
  cin>>h>>w;
  vector<vector<int> > a(h,vector<int>(w));
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin>>a[i][j];
    }
  }
  vector<int> ansx;
  vector<int> ansy;
  vector<int> aansx;
  vector<int> aansy;

  for(int i=0;i<h;i++){
    if(i%2==0){
      for(int j=0;j<w;j++){
        if(a[i][j]%2==1){
          if(i!=h-1||j!=w-1){
            ansx.push_back(j);
            ansy.push_back(i);
            a[i][j]--;
            if(j==w-1){
              aansx.push_back(j);
              aansy.push_back(i+1);
              a[i+1][j]++;
            }else{
              aansx.push_back(j+1);
              aansy.push_back(i);
              a[i][j+1]++;
            }
          }
        }
      }
    }else{
      for(int j=w-1;j>=0;j--){
        if(a[i][j]%2==1){
          if(i!=h-1||j!=0){
            ansx.push_back(j);
            ansy.push_back(i);
            a[i][j]--;
            if(j==0){
              aansx.push_back(j);
              aansy.push_back(i+1);
              a[i+1][j]++;
            }else{
              aansx.push_back(j-1);
              aansy.push_back(i);
              a[i][j-1]++;
            }
          }
        }
      }
    }
  }
  cout<<ansx.size()<<endl;
  for(int i=0;i<ansx.size();i++)cout<<ansy[i]+1<<" "<<ansx[i]+1<<" "<<aansy[i]+1<<" "<<aansx[i]+1<<endl;
}


Measured memory_bytes: 5224
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <bitset>
#include <fstream>
using namespace std;
typedef long long ll;

struct Test
{
	int a, b, c, r;
};

int A, B, C, N;

int main()
{
	while(cin>>A>>B>>C && (A || B || C) ){
		cin>>N;
		
		vector<int> res;
		vector<Test> test;

		for(int i = 0; i <= A+B+C; i++) res.push_back(2);

		for(int i = 0; i < N; i++){
			Test t;
			cin>>t.a>>t.b>>t.c>>t.r;
			if(t.r){
				res[t.a] = 1; res[t.b] = 1; res[t.c] = 1;
			}else{
				test.push_back(t);
			}
		}
		for(int i = 0; i < test.size(); i++){
			if(res[test[i].a] == 1 && res[test[i].b] == 1) res[test[i].c] = 0;
			if(res[test[i].b] == 1 && res[test[i].c] == 1) res[test[i].a] = 0;
			if(res[test[i].c] == 1 && res[test[i].a] == 1) res[test[i].b] = 0;
		}
		for(int i = 1; i <= A+B+C; i++) cout<<res[i]<<endl;
	}
}

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

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

        for(int i=0; i<s.size(); ++i){
                s=s[s.size()-1]+s.substr(0,s.size()-1);
                if(s==t){
                        cout<<"Yes"<<endl;
                        return 0;
                }
        }
        cout<<"No"<<endl;
        return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[]orgs){
	Scanner sc = new Scanner(System.in);
	int n = sc.nextInt();
		int a = 1;
		int b = n-1;
		int count = 0;
		while(a<b){
			a++;
			b= n-a;
			count++;
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 21844
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<Integer> list = new ArrayList<>();
        for(int i=0; i<n; i++) {
            list.add(sc.nextInt());
        }
        int max = Collections.max(list);
        int min = Collections.min(list);
        long ans = Long.MAX_VALUE;
        for(int i=min; i<=max; i++) {
            long total = 0;
            for(int j=0; j<list.size(); j++) {
                total += Math.pow(list.get(j) - i, 2);
            }
            if(total < ans) ans = total;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.Queue;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

public class Main {
	
	public static void main(String[] args) throws IOException {
		try(final Scanner sc = new Scanner(System.in)){
			final int D = sc.nextInt();
			final int N = sc.nextInt();
			
			long base = 1;
			for(int i = 0; i < D; i++) { base *= 100; }
			
			int cnt = 0;
			for(long x = 1; ; x++) {
				if(x % base == 0 && x % (base * 100) != 0) { cnt++; }
				
				if(cnt == N) {
					System.out.println(x);
					break;
				}
			}
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

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

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

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

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 23380
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define per1(i,n) for(int i=n;i>0;i--)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};
const int MOD = 1000000007;
using mint = Fp<MOD>;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    cin>>n;
    if(n==1){
        cout<<0;
        return 0;
    }
    mint ans=1,a=1,b=1;
    rep(i,n) ans*=10,a*=9,b*=8;
    cout<<ans-a-a+b;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s1,s2,s3;
    int v1,v2;
    cin >> s1 >> s2 >> v1 >> v2 >> s3;
    if(s3 == s1){
        v1--;
    }else{
        v2--;
    }
    cout << v1 << " " << v2 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<stdio.h>
#include<cctype>
#include<algorithm>
#include<climits>
#include<cmath>
#include<map>
#include<vector>
#define INF INT_MAX
using namespace std;

double D;
int T, S;


int main(){
	cin >> D >> T >> S;

	D = D / T;
	if (D <= S){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 3716
#include<bits/stdc++.h>
#define int long long
#define all(v) v.begin(), v.end()

using namespace std;

main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    int x;
    int mod4 = 0, mod2 = 0, mod1 = 0;
    for (int i = 0; i < n; i++){
        cin >> x;
        if (x % 4 == 0){
            mod4++;
            continue;
        }
        if (x % 2 == 0){
            mod2++;
            continue;
        }
        mod1++;
    }
    cerr << mod1 << ' ' << mod2 << ' ' << mod4 << endl;
    if (mod1 <= mod4 || mod1 - 1 == mod4 && mod2 == 0){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
vector<string> arr;
int n, l;
int main() {
  scanf("%d%d", &n, &l);
  for (int i = 0; i < n; i++) {
    string s; cin >> s;
    arr.push_back(s);
  }
  sort(arr.begin(), arr.end());
  for (int i = 0; i < n; i++) {
    cout << arr[i];
  }
  cout << endl;
}

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

int main() {
    string s, t;
    cin >> s >> t;
    s += s;
    for (int i = 0; i < s.size() - t.size() + 1; i++) {
        if (s.substr(i, t.size()) == t) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long ss(int a,int b,int n){ //对应什么数字 上限是多少  a个位 b十位 
	long long sum1=0;
	if(a==0)
	return 0;
	if(a==b)
	sum1++;
	int tmp1=10*a+b;
	if(tmp1>n)
	return sum1;
	else
	sum1++;
	for(int i=0;i<=9;i++){
		int tmp2=100*a+10*i+b;
		if(tmp2>n)
		return sum1;
		else
		sum1++;
	}
	for(int i=0;i<=99;i++){
		int tmp3=1000*a+10*i+b;
		if(tmp3>n)
		return sum1;
		else
		sum1++;
	}
	for(int i=0;i<=999;i++){
		int tmp3=10000*a+10*i+b;
		if(tmp3>n)
		return sum1;
		else
		sum1++;
	}
	for(int i=0;i<=9999;i++){
		int tmp4=100000*a+10*i+b;
		if(tmp4>n)
		return sum1;
		else
		sum1++;
	}   
}
long long ws(int n){
	if(n/10==0)
	return n%10;
	else
	ws(n/10);
}
int main(){
	int n;
	long long sums=0;
	cin>>n;
	for(int i=1;i<=n;i++){
		sums+=ss(i%10,ws(i),n);
	}
	cout<<sums;
	return 0;
}

Measured memory_bytes: 256
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N, W = map(int, input().split())
items = [list(map(int, input().split())) for _ in range(N)]


def solve():
    MaxV = 10**3*N+1
    dp = [[float('inf')]*MaxV for _ in range(N+1)]
    dp[0][0] = 0

    for i in range(1, N+1):
        for v in range(MaxV):
            if items[i-1][1] <= v:
                dp[i][v] = min(dp[i-1][v], dp[i-1]
                               [v-items[i-1][1]]+items[i-1][0])
            else:
                dp[i][v] = dp[i-1][v]
    ans = 0
    for i, v in enumerate(dp[N]):
        if v <= W:
            ans = i

    print(ans)


solve()


Measured memory_bytes: 303080
n = gets.to_i
arr = []
n.times { |i| arr << gets.chomp.to_i }

min = arr[0]
max_diff = arr[1] - min
(1...n).each_with_index do |i|
  diff = arr[i] - min
  min = arr[i] if arr[i] < min
  max_diff = diff > max_diff ? diff : max_diff
end

puts max_diff



Measured memory_bytes: 8876
#!/usr/bin/env python
import os
import re
import sys
from bisect import bisect, bisect_left, insort, insort_left
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from io import BytesIO, IOBase
from itertools import (
    accumulate, combinations, combinations_with_replacement, groupby,
    permutations, product)
from math import (
    acos, asin, atan, ceil, cos, degrees, factorial, hypot, log2, pi, radians,
    sin, sqrt, tan)
from operator import itemgetter, mul
from string import ascii_lowercase, ascii_uppercase, digits


def inp():
    return(int(input()))


def inlist():
    return(list(map(int, input().split())))


def instr():
    s = input()
    return(list(s[:len(s)]))


def invr():
    return(map(int, input().split()))


def main():
    n = inp()
    a = inlist()
    ans = 0
    for i in range(n):
        for j in range(i+1, n):
            for k in range(j+1, n):
                x = a[i]
                y = a[j]
                z = a[k]
                if x + y > z and y + z > x and z + x > y and (x != y and y != z and z != x):
                    ans += 1
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 10608
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define ss second
#define ff first
#define INF 30000000000001
#define ll_max 9000000000000000001
#define mod 1000000007
#define PI 3.14159265358979323846L
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
typedef vector<pair<ll,ll> > vll;
typedef vector<pair<int,int> > vii ;
typedef pair<ll,ll> pll;
const ll N = 100001;
const ll M = 1;

void update(ll BIT[], ll n, ll x, ll i)
{
    for(; i <= n; i += (i) & (-i)) BIT[i] += x;
}

ll query(ll BIT[], ll l)
{
    ll sum1 = 0;
    for(; l; l = l & (l - 1)) sum1 += BIT[l];
    return sum1;
}

int main()
{
    fast;
    int _ = 1;
    //cin >> _;
    while(_--)
    {
        ll n, x, y;
        cin >> n;
        pair<long double, pair<int,int> > a[2 * n];
        long double ans = 0;
        for(int i = 0; i < n; i++)
        {
            cin >> x >> y;
            a[i].ff = atan2(y, x);
            a[i].ss.ff = x;
            a[i].ss.ss = y;
        }
        sort(a, a + n);
        for(int i = n; i < 2 * n; i++) a[i] = a[i - n], a[i].ff += 2 * PI;
        for(int i = 0; i < 2 * n; i++)
        {
            x = 0, y = 0;
            for(int j = i; j < 2 * n; j++)
            {
                x += a[j].ss.ff;
                y += a[j].ss.ss;
                if(a[j].ff - a[i].ff < PI)
                {
                    ans = max((ll)ans, x * x + y * y);
                }
                else break;
            }
        }
        ans = sqrt(ans);
        cout << fixed << setprecision(11) << ans << "\n";
    }
    return 0;
}


Measured memory_bytes: 512
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub


import sys
# sys.setrecursionlimit(10**6)
# buff_readline = sys.stdin.buffer.readline
buff_readline = sys.stdin.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


def read_float():
    return float(buff_readline())


def read_float_n():
    return list(map(float, buff_readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()

def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, A):
    ans = 1
    l = 10**18
    A.sort()
    for a in A:
        ans *= a
        if ans > l:
            return -1
    return ans


def main():
    N = read_int()
    A = read_int_n()
    print(slv(N, A))


if __name__ == '__main__':
    main()


Measured memory_bytes: 93004
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


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

    vector<int> cnts(100, 0);

    for (int i = 0; i < 3; ++i) {
        int x;
        cin >> x;
        ++cnts[x];
    }

    if (cnts[5] == 2 && cnts[7] == 1) {
        cout << "YES\n";
    } else {
        cout << "NO\n";
    }

    return 0;
}

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

int main(){

  string str,z,x;

  while(1){

    stack < string > a;
    int count = -1,d;
    z = "0";
    a.push("0");
    d = a.size();
    getline(cin,str);

    if(str == ".") break;

    for(int i=0;i<str.size();i++){

      if((a.size() == d && str[i] == ')') || (a.size() == d && str[i] == ']')){
	count = 0;
        break;
      }
      if(str[i] == '('){
	x = str[i];
	a.push(x);
	z = a.top();
      }
      else if(str[i] == '['){
	x = str[i];
	a.push(x);
	z = a.top();
      }
      else if(z == "(" && str[i] == ')'){
	a.pop();
	z = a.top();
      }
      else if(z == "[" && str[i] == ']'){
	a.pop();
	z = a.top();
      }
      else if(z == "(" && str[i] == ']'){
	count = 0;
	break;
      }
      else if(z == "[" && str[i] == ')'){
	count = 0;
	break;
      }
    }
    
    if(count == 0 || a.size() != d) cout << "no" << endl;
    else cout << "yes" << endl;
  }
}

Measured memory_bytes: 1196
#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<ll,ll>;
const int mod = 1e9 + 7;
//const int mod = 998244353;
const ll infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;
void YesNo(bool j){cout << (j ? "Yes" : "No") << endl; return;}
void yesno(bool j){cout << (j ? "yes" : "no") << endl; return;}
template<class Head> void pt(Head&& head){cout << head << endl; return;}




int main() {
   
   string s,t;
  cin >> s >>t;
  int a=s.size();
  int ans=0;
  rep(i,a) {
    if(s[i]!=t[i]) ans++;
  }
  pt(ans);


    return 0;
}


Measured memory_bytes: 3864
#include <algorithm>
#include <array>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#include <cassert>

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

const uint64_t mod = 1000000000 + 7;

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

    uint64_t ret = 1;
    rep(i, N) {
        ret *= (i+1);
        ret %= mod;
    }
    cout << ret << endl;


    return 0;
}



Measured memory_bytes: 3096
import bisect
n,q = map(int, input().split(" "))
s = input()
lr = [list(map(int, input().split(" "))) for i in range(q)]
a = []
for i in range(n-1):
  if s[i] +s[i+1]== 'AC':
    a.append(i+1)
for l, r in lr:
  print(bisect.bisect(a, r-1) - bisect.bisect(a, l-0.1))

Measured memory_bytes: 29392
n, m = map(int, input().split())
s = set()
g = set()
for i in range(m):
    a, b = map(int, input().split())
    if a == 1:
        g.add(b)
    if b == n:
        s.add(a)
x = s & g
if x:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Measured memory_bytes: 102432
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <fstream>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
typedef long long ll;
#define REP(i, N) for (int i = 0; i < (int)N; i++)

struct edge { int dest, weight; };
struct result { int dest, distance; };

result dfs(int previous, int node, vector<vector<edge>> &adjacentList) {
  result r = {node, 0};
  for(edge e: adjacentList[node]) if(e.dest != previous){
      result t = dfs(node, e.dest, adjacentList);
      t.distance += e.weight;
      if(r.distance < t.distance) r = t;
  }
  return r;
}

int diameterOfTree(vector<vector<edge>> &adjacentList) {
  result r = dfs(-1, 0, adjacentList);
  result t = dfs(-1, r.dest, adjacentList);
  return t.distance;
}

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

  vector<vector<edge>> adjacentList(N);

  REP(i,N-1) {
    int s,t,w;
    cin >> s >> t >> w;
    adjacentList[s].push_back(edge {t,w});
    adjacentList[t].push_back(edge {s,w});
  }

  cout << diameterOfTree(adjacentList) << endl;
  return 0;
}

Measured memory_bytes: 14460
#include <cstdio>
#include <vector>
#include <cstring>
#include <algorithm>
using namespace std;
int n,m;
vector<int> al[605];
vector<int> f[605];
double _exp[605];
int num[605];
double exp_i[605];
double test(int i){
    memset(exp_i,0,sizeof(exp_i));
    memset(_exp,0,sizeof(_exp));
    memset(num,0,sizeof(num));

    num[n]=1;

    for (int x=n;x>0;x--){
        _exp[x]=exp_i[x]/num[x];
        for (vector<int>::iterator it=al[x].begin();it!=al[x].end();it++){
            if (*it==i && x==f[i][0]) continue;
            exp_i[*it]+=_exp[x]+1;
            num[*it]++;
        }
    }

    return _exp[1];
}

int main(){
    scanf("%d%d",&n,&m);
    int a,b;
    for (int x=0;x<m;x++){
        scanf("%d%d",&a,&b);
        al[b].push_back(a);
        f[a].push_back(b);
    }
    num[n]=1;

    for (int x=n;x>0;x--){
        _exp[x]=exp_i[x]/num[x];
        for (vector<int>::iterator it=al[x].begin();it!=al[x].end();it++){
            exp_i[*it]+=_exp[x]+1;
            num[*it]++;
        }
    }

    for (int x=1;x<=n;x++){
        sort(f[x].begin(),f[x].end(),[](int i,int j){
            return _exp[i]>_exp[j];
        });
    }

    double ans=_exp[1];
    for (int x=1;x<n;x++){
        ans=min(ans,test(x));
    }

    printf("%.8f\n",ans);
}


Measured memory_bytes: 2560
use std::io;
use std::io::BufRead;

fn main() {
  let stdin = io::stdin();
  let line = stdin.lock().lines().nth(1).unwrap().unwrap();
  let str = line.trim().split_whitespace()
    .rev()
    .collect::<Vec<_>>()
    .join(" ");
  println!("{}", str);
}


Measured memory_bytes: 5032
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define vi vector<int>

using ll = long long;
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
const ll DIV =1e9+7;
//const double PI = M_PI;
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}
inline ll inv(ll x, ll div){return pow(x, div - 2, div);}
#define chmax(a,b) a=max(a,b)

/*Coding Space*/
map<int,char> str;
int main(){
  string s; cin >> s;
  rep(i,s.size())  str[i] = s[i];
  int left = -1, right = s.size();
  bool flag = 0;
  int q; cin >> q;
  rep(i,q){
    int in; cin >> in;
    if(in == 1)  flag = !flag;
    else{
      int b; char c; cin >> b >> c;
      if(b == 2 && flag == 0) str[right++] = c;
      if(b == 1 && flag == 0) str[left--] = c;
      if(b == 2 && flag == 1) str[left--] = c;
      if(b == 1 && flag == 1) str[right++] = c;
    }
  }
  string ans;
  for(auto itr : str){
    cerr << itr.FST << ' ' << itr.SEC << endl;
    ans.pb(itr.SEC);
  }
  if(flag) reverse(ALL(ans));
  cout << ans << endl;
}


Measured memory_bytes: 15108
#include <bits/stdc++.h>
#define Task        "test"
#define pb          emplace_back
#define fi          first
#define se          second
#define mp          make_pair
#define ll          long long
//#define int         int64_t

using namespace std;

typedef pair<ll, ll> pii;
const int N = (int)3e3 + 2;
const int mod = (int)1e9 + 7;

int n, m, l, r, sum, f[N][N], cnt[N], jump[N];
string s;

void add(int& x, int y) {if((x += y) >= mod) x -= mod;}

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    if(fopen(Task".inp", "r")) {
        freopen(Task".inp", "r", stdin);
        freopen(Task".out", "w", stdout);
    }
    cin >> n >> m >> s; s = ' ' + s;
    for(int i = 1; i <= m; ++i) {
        cin >> l >> r;
        jump[l] = max(jump[l], r);
    }
    for(int i = 1; i <= n + 1; ++i) {
        jump[i] = max({jump[i], jump[i - 1], i});
        cnt[i] = cnt[i - 1] + (s[i] == '1');
    }
    f[1][cnt[jump[1]]] = 1;
    for(int i = 1; i <= n + 1; ++i) {
        l = jump[i], r = jump[i + 1];
        sum = cnt[r] - cnt[l];
        for(int j = 0; j <= cnt[n]; ++j) {
            if(f[i][j] == 0) continue;
            if(j) add(f[i + 1][j - 1 + sum], f[i][j]);
            if(jump[i] - i + 1 - j > 0) add(f[i + 1][j + sum], f[i][j]);
        }
    }
    cout << f[n + 1][0];
}


Measured memory_bytes: 33920
n,a,b= list(map(int, input().split()))
if a>b:
    print("0")
    exit(0)
if n==1:
    if a!=b:
        print("0")
    else:
        print("1")
    exit(0)
n-=2;b-=a;a=0
print(b*n+1)

Measured memory_bytes: 3060
// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <iostream>
#include <cstdlib>
#include <string>
#include <algorithm>
using namespace std;


long long calcu(long long num){
    //answer the time of the calculation
    if(num==1)
        return 1;
    else
        return 1 + 2 * calcu(num / 2);
    
}

int main()
{
    long long h;
    cin >> h;
    
    long long ans = calcu(h);
    
    
    
/*    
    int n,k;
    cin >> n >> k;   
    
    long long a[n];
    for(int i=0; i<n; i++){
        cin >> a[i] ;
    }
    
    sort(a, a+n);
    
    long long c=0;
    for(int i=0; i<n-k; i++){
        c += a[i] ;
    }
*/        
    cout << ans << endl;
}

// GCC reference:
//   https://gcc.gnu.org/

// C++ language references:
//   https://cppreference.com/
//   https://isocpp.org/
//   http://www.open-std.org/jtc1/sc22/wg21/

// Boost libraries references:
//   https://www.boost.org/doc/


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF 10000000000
using namespace std;
using ll = long long;
int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n){
        cin >> a[i];
    }
    rep(i,n){
        if(a[i]%2==0){
            if(!(a[i]%3==0||a[i]%5==0)){
                cout << "DENIED" << endl;
                return 0;
            }
        }
    }
    cout << "APPROVED" << endl;
}

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

using namespace std;
using ll = long long;

#define CIN(T, x) T x; cin >> x;
#define CINS(T, x, N) vector<T> x(N); for(int i = 0; i < (N); i++) { cin >> x.at(i); }

int main() {

    int n = 6;
    CINS(ll, a, n);

    ll min = a.at(1);

    for (int i = 1; i < n; i++) {
        if (min > a.at(i) ) {
            min = a.at(i);
        }
    }

    ll time;
    time = (a.at(0) + min - 1) / min;
    time += 4;
    

    cout << time;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

int main(){
	int n;
	ll m;
	while( cin >> n >> m, n || m ){
		vector<ll> vp(n+1);	// 入力用
		vp[0] = 0;
		for( int i = 0; i < n; i++ ){
			cin >> vp[i+1];
		}

		vector<ll> points;	// 2本投げた時のすべての得点の組み合わせを格納
		for( int i = 0; i <= n; i++ ){
			for( int j = i; j <= n; j++ ){
				points.push_back(vp[i]+vp[j]);
			}
		}
		sort(points.begin(), points.end());

		ll ans = 0;
		// 残りの2本を投げたときの最高得点を求めていく
		for( int i = 1; i < points.size(); i++ ){
			ll diff = m - points[i];
			if( diff < 0 || points[i] == points[i-1] ) continue;	// 初めの2本で既にm以上の場合と同点のものを無視する
			// 二分探索
			int left = 0, right = points.size()-1;
			while( 1 ){
				ll next = (left + right) / 2;
				if( next == left || next == right ){
					if( points[next] <= diff ) ans = max(ans, points[i] + points[next] );
					break;
				}
				if( points[next] == diff ){
					ans = points[i] + points[next];
					break;
				}else if( points[next] < diff ){
					left = next;
				}else{
					right = next;
				}
			}
		}
		cout << ans << endl;
	}
}

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

using namespace std;

int main(){

	string S;
	cin >> S;
	int num = 0;
	if (S == "RRR") num = 3;
	else if(S == "RRS" || S == "SRR") num = 2;
	else if(S == "RSS" || S == "SRS" || S == "RSR" || S == "SSR") num = 1;

	cout << num << "\n";
	return 0;
}

Measured memory_bytes: 3544
#![allow(unused_macros)]

macro_rules! line {
    () => {{
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        buf
    }};
}
macro_rules! line_as_vec {
    ( $t:ty ) => {
        line!()
            .trim()
            .split_whitespace()
            .map(|x| x.parse().unwrap())
            .collect::<Vec<$t>>()
    };
}
macro_rules! input {
    { $( $i:ident : $t:ty ),* } => {
        let ( $( $i ),* ) = match &line!().split_whitespace().collect::<Vec<_>>()[..] {
            &[ $( $i ),* ] => ( $( $i.parse::<$t>().unwrap() ),* ),
            _ => panic!(),
        };
    };
}

fn main() {
    input!(s: i8, w: i8);
    println!("{}safe", if s > w { "" } else { "un" })
}


Measured memory_bytes: 2052
#include<stdio.h>

int main ()
{
	int A,B,C;
	scanf("%d %d %d", &A, &B, &C);
	
	if(A==B && A==C && B==C){
		printf("No");
	}else if(A==B || A==C || B==C){
		printf("Yes");
	}else{
		printf("No");
	}
	
	return 0;
}

Measured memory_bytes: 3132
import java.util.Scanner;

class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		if(a>b) {
			System.out.println(2 * a -1);
		}else if(b>a) {
			System.out.println(2 * b -1);
		}else {
			System.out.println(a + b);
		}
	}
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
typedef long long int ll;


int main(){
  int a,b,ans=12;
  cin>>a>>b;
  ans-=(12-a);
  if(b<a) ans--;
  cout<<ans<<endl;
  

  return 0;
}



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

int main() {
  int a, b, k; cin >> a >> b >> k;
  int i = min(a, b), cnt = 0;
  while (i > 0) {
    if (a % i == 0 and b % i == 0) cnt++;
    if (cnt == k) break;
    i--;
  }
  cout << i << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ASC(vec) vec.begin(), vec.end()			// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
typedef long long ll;

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

	tuple<int, int, int> data[101000];

	for (int i = 0; i < M; i++)
	{
		int p, y; cin >> p >> y;
		data[i] = make_tuple(y, p, i);
	}

	// tupleをソートするときは第一要素がkeyとなる
	// つまりY_i(tuple宣言時の一番左側の引数)によって昇順にソートされる。
	sort(data, data + M);

	// 各県に今属している市の数
	int cnt[101000] = { 0 };
	
	// 各市の(属する県、県の中で誕生した順番)
	pair<int, int> id[101000];

	for (int i = 0; i < M; i++)
	{
		int y, p, idx;
		tie(y, p, idx) = data[i];
		++cnt[p];
		id[idx] = make_pair(p, cnt[p]);
	}

	for (int i = 0; i < M; i++)
	{
		cout << setw(6) << setfill('0') << id[i].first;
		cout << setw(6) << setfill('0') << id[i].second << endl;
	}
	return 0;
}

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

#define REP(i, s, n) for (ll i = s; i < n; i++)
#define setarr(arr, v) for (ll i = 0; i < sizeof(arr)/sizeof(arr[0]); ++i) {arr[i] = v;}
#define pvar(x) cout << #x << " = " << x << endl;
#define mset(x, v) memset(x, v, sizeof(x));
#define fi first
#define se second
#define pb push_back
#define be() begin()
#define en() end()
#define len() length()
#define mp(x, y) make_pair(x, y)

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<pll> vpll;
typedef set<ll> sll;
typedef queue<ll> qll;

template<class U, class V>
ostream& operator<<(ostream& os, const pair<U, V>& p) {os << "(" << p.first << ", " << p.second << ")";return os;}

template<class U, class V>
istream& operator>>(istream& in, pair<U, V>& p) {in >> p.first >> p.second;return in;}

namespace cp {
    template <typename T>
    T min (T first) {return first;}
    template <typename T, typename... Args>
    T min (T first, Args... args) {return std::min (first, min (args...));}

    template <typename T>
    T max (T first) {return first;}
    template <typename T, typename... Args>
    T max (T first, Args... args) {return std::max (first, max (args...));}
};

using cp::min;
using cp::max;

int main ()
{
    ll n, k; cin >> n >> k;
    ll H[n]; REP (i, 0, n) cin >> H[i];
    sort (H, H+n);
    cout << accumulate (H, H+ ((n-k < 0) ? ll(0) : (n-k)), ll (0)) << endl;
    return 0;
}


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

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
      reader = new BufferedReader(new InputStreamReader(in));
      tokenizer = null;
    }

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

    public String nextLine() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          return reader.readLine();
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }

      return tokenizer.nextToken("\n");
    }

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

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

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

    public int[] nextIntArray(int n) {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = nextInt();
      return a;
    }

    public long[] nextLongArray(int n) {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = nextLong();
      return a;
    }
  }

  private static final int mod = 1000000007;

  private static long[] fac;
  private static long[] finv;
  private static long[] inv;

  private static void comInit(int n) {
    fac = new long[n + 1];
    finv = new long[n + 1];
    inv = new long[n + 1];
    fac[0] = 1;
    fac[1] = 1;
    finv[0] = 1;
    finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i <= n; i++) {
      fac[i] = fac[i - 1] * i % mod;
      inv[i] = mod - inv[mod % i] * (mod / i) % mod;
      finv[i] = finv[i - 1] * inv[i] % mod;
    }
  }

  private static long com(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
  }

  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    int n = sc.nextInt();
    int k = Math.min(sc.nextInt(), n);
    comInit(n);
    long sum = 0L;
    for (int i = 0; i <= k; i++) {
      int zeroRooms = i;
      int remainRooms = n - i;
      sum += com(n, zeroRooms) * com(n - 1, remainRooms - 1);
      sum %= mod;
    }
    System.out.println(sum);
  }
}

Measured memory_bytes: 26836
def abc176_c():
    n = int(input())
    a = list(map(int, input().split(' ')))
    ans = 0
    most_h = 0

    for i in range(1, len(a)):
        if i == 1:
            most_h = max(a[i - 1], a[i])
            if a[i - 1] > a[i]:
                ans += a[i - 1] - a[i]
        else:
            if most_h > a[i]:
                ans += most_h - a[i]

        most_h = max(most_h, a[i])

    print(ans)

if __name__ == '__main__':
    abc176_c()


Measured memory_bytes: 32264
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin >>a >>b;
  if(1<=a,b<=100) {
    if((a+b)%2){
      cout <<(a+b+1)/2 <<endl;
    }else{
      cout <<(a+b)/2 <<endl;
    }
  }
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    static final Scanner sc    = new Scanner(System.in);
    static final int     MOD   = (int) 1E9 + 7;
    static final long    INF_L = (long) 4E18;
    static final int     INF   = Integer.MAX_VALUE;
    
    public static void main(String[] args) {
        long N = nlong();
        long A = nlong();
        long B = nlong();
        long d = B - A;
        if (d % 2 == 0) {
            System.out.println(d / 2);
        } else {
            long x = A + (B - A - 1) / 2;
            long A_ = N - B + 1;
            long B_ = N - A + 1;
            long x_ = A_ + (B_ - A_ - 1) / 2;
            System.out.println(min(x, x_));
        }
    }
    
    @Deprecated
    static int nint() {
        return sc.nextInt();
    }

    @Deprecated
    static int[] nints(int N) {
        return nints(N, 0, 0);
    }

    @Deprecated
    private static int[] nints(int N, int padL, int padR) {
        int[] a = new int[padL + N + padR];
        for (int i = 0; i < N; i++)
            a[padL + i] = nint();
        return a;
    }

    static long nlong() {
        return sc.nextLong();
    }

    static long[] nlongs(int N) {
        return nlongs(N, 0, 0);
    }

    static long[] nlongs(int N, int padL, int padR) {
        long[] a = new long[padL + N + padR];
        for (int i = 0; i < N; i++)
            a[padL + i] = nlong();
        return a;
    }

    static double ndouble() {
        return sc.nextDouble();
    }

    static double[] ndoubles(int N) {
        return ndoubles(N, 0, 0);
    }

    static double[] ndoubles(int N, int padL, int padR) {
        double[] d = new double[N + padL + padR];
        for (int i = 0; i < N; i++) {
            d[padL + i] = ndouble();
        }
        return d;
    }

    static String nstr() {
        return sc.next();
    }

    static char[] nchars() {
        return sc.next().toCharArray();
    }

    static char[] nchars(int padL, int padR) {
        char[] temp = sc.next().toCharArray();
        char[] ret = new char[temp.length + padL + padR];
        System.arraycopy(temp, 0, ret, padL, temp.length);
        return ret;
    }

    static char[][] nchars2(int H, int W) {
        return nchars2(H, W, 0, 0);
    }

    static char[][] nchars2(int H, int W, int padLU, int padRD) {
        char[][] a2 = new char[H + padLU + padRD][W + padLU + padRD];
        for (int i = 0; i < H; i++)
            System.arraycopy(nchars(), 0, a2[padLU + i], padLU, W);
        return a2;
    }

    static long min(long... ls) {
        return Arrays.stream(ls).min().getAsLong();
    }

    static long max(long... ls) {
        return Arrays.stream(ls).max().getAsLong();
    }

    static long abs(long a) {
        return Math.abs(a);
    }
}


Measured memory_bytes: 29396
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long X = sc.nextLong();
		long money = 100;
		int count = 0;
		while(true){
			money += money * 0.01;
			//System.out.println(money);
			count++;
			if(money >= X){
				System.out.println(count);
				return;
			}
		}
	}

}

Measured memory_bytes: 35796
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

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

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
int dp[1<<16][20];
int d[20][20];
int main(){
	int V,E;
	cin>>V>>E;
	for(int i =0;i <(1<<16);i++){
		for(int j =0;j < V;j++){
			dp[i][j]=INF;
		}
	}
	for(int i =0;i < V;i++){
		for(int j =0;j < V;j++){
			d[i][j]=INF;
		}
	}
	
	for(int i =0;i < E;i++){
		int x,y,c;
		cin>>x>>y>>c;
		d[x][y] =c;
	}
	dp[1][0]=0;
	for(int i =0;i <(1<<V);i++){
		for(int j =0;j <V;j++){
			if((i>>j&1)==0)continue;
			for(int k =0;k < V;k++){
				if((i>>k&1)==1)continue;
				dp[i|(1<<k)][k] =min(dp[i|(1<<k)][k],dp[i][j]+d[j][k]);
				//cout <<"dp = "<<dp[i|(1<<k)][k]<<endl;
			}
		}
	}
	int ans =INF;
	for(int i =0;i <V;i++){
		ans =min(ans,dp[(1<<V)-1][i]+d[i][0]);
	}
	if(ans>=INF){
		cout <<-1<<endl;
	}else{
		cout <<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 6284
using System;
class Prpgram
{
    static void Main(string[] args)
    {
        string input = Console.ReadLine();
        char[] kanri = input.ToCharArray();

        char k1 = kanri[0];
        char k2 = kanri[1];
        char k3 = kanri[2];

        if (k1 == k2)
        {
            if (k1 == k3) Console.Write("No");
            if (k2 != k3) Console.Write("Yes");
        }
        else Console.Write("Yes");
    }
}

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

int main() {
  // input
  int N,Y;
  cin >> N >> Y;
  
  int n_10k=-1;
  int n_5k =-1;
  int n_1k =-1;

  for(int i=0; i<=N; i++){ // i:fixedのとき、額面が安い順に調べていく
    if( n_10k != -1 || 10000*i > Y ) break;
    else{
  	  for(int j=0; j<=N-i; j++){
        int k= N-i-j;
  	    int total= 10000*i+ 5000*j+ 1000*k;
        if( total==Y ){
          n_10k=i; n_5k=j; n_1k= k;
          break;
        }
      }
    }
  }
  
  cout << n_10k << " " << n_5k <<" " << n_1k << endl;
}

Measured memory_bytes: 256
def get_divisors(num):
    """
    指定した整数のすべての約数を配列にして返す.

    :param num:
    :return:
    """
    import math
    max_num = math.floor(math.sqrt(num))
    re = set()
    for i in range(1, max_num + 1):
        if num % i == 0:
            re.add(i)
            re.add(num // i)
    return sorted(re)


def solve():
    N = int(input())
    result = 0

    ls = get_divisors(N)

    # x * m == N - y
    # x * m == N - x
    # x * m + x == N
    # (m + 1) * x == N
    for m in ls[1:]:
        m -= 1
        if N // m == N % m:
            result += m
    print(result)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 3828
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = (n-1); i >= 0; i--)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const ll INF = 1LL<<60;
const int IINF = 1000000000;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){

    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    ll N; cin >> N;

    for(ll h = 1; h <= 3500; h++){
        for(ll n = 1; n <= 3500; n++){
            ll numer = (N*h*n);
            ll denom = (4*h*n - N*n - N*h);
            if (denom <= 0) continue;
            ll w = numer / denom;
            ll m = numer % denom;
            if (m == 0){
                cout << h << " " << n << " " << w << endl;
                return 0;
            }
        }
    }
}

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

using namespace std;

int m;
int a[7], b[7];
int g;
int dp[8][1001];
int n;

int solve(){
  fill(dp[0], dp[8], 0);
  dp[0][0] = 1;
  for(int i=0;i<m;i++){
    for(int j=0;j<1001;j++){
      if(dp[i][j] == 0) continue;
      for(int k=0;k<=b[i];k++){
	int tmp = j+a[i]*k;
	if(tmp > 1000) continue;
	dp[i+1][tmp] += dp[i][j];
      }
    }
  }
}

main(){
  while(cin >> m && m){
    for(int i=0;i<m;i++){
      cin >> a[i] >> b[i];
    }
    cin >> g;
    solve();
    for(int i=0;i<g;i++){
      cin >> n;
      cout << dp[m][n] << endl;
    }
  }
  return 0;
}

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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define repr(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

const int IINF = 1e9 + 10;
const long long LLINF = (long long)1e18 + 10;
const long long MOD = (long long)1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, a, b;
    cin >> n >> a >> b;

    int ans1 = min(a, b), ans2 = max(0, a + b - n);

    cout << ans1 << " " << ans2 << endl;

    return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
using namespace std;
string alphabet = "abcdefghijklmnopqrstuvwxyz";
string ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main(){
 int k , n;
 cin >> k >> n;
 if(k % n == 0)cout << 0 << endl;
 else cout << 1 << endl;
}

Measured memory_bytes: 256