akhauriyash/Code-Regression huggingface dataset:
n, m = map(int,input().split())
mod = 10**9 +7
def solve(num):
    result = 1
    for i in range(1, num+1):
        result = (result*i)%mod
    return result
if abs(n-m) == 0:
    print((solve(n)*solve(m)*2)%mod)
elif abs(n-m) == 1:
    print((solve(n)*solve(m))%mod)
else:
    print(0)

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

typedef long int lint;
typedef long long int llint;
typedef pair<int, int> pii;
typedef pair<int, string> pis;
typedef pair<long, long> pll;

#define EACH(t, c) for (auto&& t : c)
#define ALL(c) begin(c), end(c)
#define FOR(i, s, e) for (int i = (s); i < (int)(e); ++i)
#define REP(i, n) FOR(i, 0, n)
#define endl '\n'
#define fk first
#define sv second

const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1}, dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int MOD = (int)1e9 + 7;
const int INF = 999999999;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  char str[3];

  cin >> str;

  sort(str, str + 3);
  if (str[0] == 'a' && str[1] == 'b' && str[2] == 'c') {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
import sys 
import re

input()
bsn = 0
aen = 0
cen = 0
t = 0
for line in sys.stdin:
    st = line.strip()
    t += st.count("AB")
    if st[0] == "B" and st[-1] == "A":
        cen += 1
    elif st[0] == "B":
        bsn += 1
    elif st[-1] == "A":
        aen += 1

if aen != 0:
    if bsn != 0:
        if cen != 0:
            x = min(bsn-1, aen-1)
            print(t+cen+1+x)
        else:
            x = min(bsn, aen)
            print(t+x)
    else:
        print(t+cen)
else:
    if bsn != 0:
        print(t+cen)
    else:
        if cen != 0:
            print(t+cen-1)
        else:
            print(t)




Measured memory_bytes: 39536
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <array>
#include <vector>

using namespace std;

int main() {
  while( true ) {
    int n, m;
    cin >> n >> m;
    if ( n == 0 and m == 0 ) break;
    vector<int> ns, ms;
    for ( int i = 0; i < 4; i++ ) {
      ns.push_back( n % 10 );
      n /= 10;
      ms.push_back( m % 10 );
      m /= 10;
    }
    int hit = 0;
    const int NONE = -1;
    for ( int i = 0; i < 4; i++ ) {
      if ( ns[ i ] == ms[ i ] ) {
	hit++;
	ns[ i ] = ms[ i ] = NONE;
      }
    }
    int brow = 0;
    for ( int val : ns ) {
      if ( val != NONE and find( ms.begin(), ms.end(), val ) != ms.end() ) {
	brow++;
      }
    }
    cout << hit << " " << brow << endl;
  }
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);
	int n;ll D;
	cin>>n>>D;
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		ll x,y;
		cin>>x>>y;
		if(x*x+y*y<=D*D)
			ans++;
	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 3528
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <fstream>
#include <bitset>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <iomanip>
#include <stdio.h>
#include <string.h>
#include <random>
#include <functional>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

using std::map;
using std::set;
using std::bitset;
using std::vector;
using std::string;
using std::multimap;
using std::multiset;
using std::deque;
using std::queue;
using std::stack;
using std::pair;
using std::iterator;

using std::sort;
using std::stable_sort;
using std::reverse;
using std::max_element;
using std::min_element;
using std::unique;
using std::ios_base;
using std::swap;
using std::fill;

using std::setprecision;
using std::fixed;

long long min(long long a, long long b) {return a < b ? a : b;}
long long min(int a, long long b) {return a < b ? a : b;}
long long min(long long a, int b) {return a < b ? a : b;}
long long min(int a, int b) {return a < b ? a : b;}

long long max(long long a, long long b) {return a > b ? a : b;}
long long max(int a, long long b) {return a > b ? a : b;}
long long max(long long a, int b) {return a > b ? a : b;}
long long max(int a, int b) {return a > b ? a : b;}

#define int long long

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef string S;

#define F(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define fi first
#define se second
#define re return
#define all(x) (x).begin(), (x).end()

const int N = 3100;
const int MOD = 1e9 + 7;
const double eps = 1e-8;

const int X = 5e8 + 4;

int n, q;
int a[N];
int dp[N][N];

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> q;
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            if (a[i] > a[j]) dp[i][j] = 1;
        }
    }
    for (int i = 0; i < q; i++)
    {
        int x, y;
        cin >> x >> y;
        x--, y--;
        vector<int> vars1(n), vars2(n);
        for (int j = 0; j < n; j++)
        {
            vars1[j] = (dp[j][x] + dp[j][y]) * X % MOD;
            vars2[j] = (dp[x][j] + dp[y][j]) * X % MOD;
        }
        for (int j = 0; j < n; j++)
        {
            if (j != x && j != y)
            {
                dp[j][x] = vars1[j];
                dp[x][j] = vars2[j];
                dp[j][y] = vars1[j];
                dp[y][j] = vars2[j];
            }
        }
        dp[x][y] = dp[y][x] = (dp[x][y] + dp[y][x]) * X % MOD;
    }
    long long ans = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j = i + 1; j < n; j++)
        {
            ans = (ans + dp[i][j]) % MOD;
        }
    }
    for (int i = 0; i < q; i++) ans = 2 * ans % MOD;
    cout << ans;
}


Measured memory_bytes: 74112
#include <iostream>
#include <numeric>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
using namespace std;
using ll=long long;
const ll MOD=1000003;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=b-1;i>=a;i--)
#define range(i) (i).begin(),(i).end()
#define rrange(i) (i).rbegin(),(i).rend()
inline ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
inline constexpr int intpow(ll a,ll b){
    if(b==0) return 1;
    ll ans=intpow(a,b/2);
    return ans*ans%MOD*(b&1?a:1)%MOD;
}
inline constexpr int modf(ll n){
    ll ans=1;
    rep(i,0,n) {ans=ans*(n-i)%MOD;}
    return ans;
}
inline long double median(vector<ll> v){
    ll size=v.size();
    sort(v.begin(),v.end());
    if (size % 2 == 1) return v[(size - 1) / 2];
    else return v[(size / 2) - 1] ;
}
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(){
    ll n,a,b,c,d;
    cin>>n>>a>>b>>c>>d;
    a--;b--;c--;d--;
    string s;
    cin>>s;
    ll i=a;
    while(i<max(c,d)){
        if(s[i]=='.'){i++;continue;}
        else if(s[i+1]=='.'){i+=2;continue;}
        else{
            cout<<"No";
            return 0;
        }
    }
    if(c<d) {
        cout<<"Yes";
        return 0;
    }
    else{
        i=b-1;
        while(i<min(c,d)){
            if(s[i]=='#'){i++;continue;}
            else if(s[i+1]=='#'){i+=2;continue;}
            else if(s[i+2]=='#'){i+=3;continue;}
            else {
                cout<<"Yes";
                return 0;
            }
        }        
    }
    cout<<"No";
}

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

int main() {
  int c[3][3];
  for (int i=0; i<3; i++) {
    for (int j=0; j<3; j++) {
      cin>>c[i][j];
    }
  }
  for (int a0=0; a0<=c[0][0]; a0++) {
    for (int a1=0; a1<=c[1][0]; a1++) {
      for (int a2=0; a2<=c[2][0]; a2++) {
        int b0 = c[0][0] - a0;
        int b1 = c[0][1] - a0;
        int b2 = c[0][2] - a0;
        int a[3] = {a0, a1, a2};
        int b[3] = {b0, b1, b2};
        bool ok = true;
        for (int i=0; i<3; i++) {
          for (int j=0; j<3; j++) {
            if (a[i] + b[j] != c[i][j]) {
              ok = false;
              break;
            }
          }
        }
        if (ok) {
          cout<<"Yes"<<endl;
          return 0;
        }
      }
    }
  }
  cout<<"No"<<endl;
}

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

// Loops
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define _rrep(i, n) rrepi(i, n, 0)
#define rrepi(i, a, b) for (int i = int(a) - 1; i >= int(b); --i)

#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__, rrepi, _rrep, )(__VA_ARGS__)
#define each(xi, x) for (auto &&xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)

// typedef
template <class T> using vec = vector<T>;
using ll = long long;
using vi = vec<ll>;
using vvi = vec<vi>;
using vvvi = vec<vvi>;
using pii = pair<ll, ll>;

// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define mp make_pair

// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase(unique(all(v)), v.end())
#define perm(c)                                                                \
  sort(all(c));                                                                \
  for (bool c##p = 1; c##p; c##p = next_permutation(all(c)))

template <class T> pair<T, size_t> max(vector<T> &x) {
  auto it = max_element(all(x));
  return mp(*it, it - x.begin());
}
template <class T> pair<T, size_t> min(vector<T> &x) {
  auto it = min_element(all(x));
  return mp(*it, it - x.begin());
}

template <class T> inline bool chmax(T &maxval, const T &newval) {
  if (maxval < newval) {
    maxval = newval;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &minval, const T &newval) {
  if (minval > newval) {
    minval = newval;
    return 1;
  }
  return 0;
}

// Utilities
// Grid world utilities
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
#define inside(H, W, y, x) 0 <= (x) && (x) < (W) && 0 <= (y) && (y) < (H)

// Debug
#ifdef LOCAL
#include "dump.hpp"
#define debug(x) cerr << #x << ": " << x << '\n'
#else
#define dump(...)
#define debug(x)
#endif

// Paste snippets here!!

//

void solve(long long N, long long K) {
  N -= (N/K) * K;
  cout << min(N, K-N) << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false); // Magic for faster cin
  cout.precision(12);
  long long N;
  std::cin >> N;
  long long K;
  std::cin >> K;
  solve(N, K);
  return 0;
}


Measured memory_bytes: 3660
#include<bits/stdc++.h>
const int maxn=300005;
int a[maxn],b[maxn];
using namespace std;
int main()
{
    int i,res=0,ans=maxn*10,len,n;
    memset(a,0,sizeof(a));
    memset(b,0,sizeof(b));
    scanf("%d",&n);
    char s[maxn];
    scanf("%s",s);
    if(s[0]=='E') a[0]=1,b[0]=0;
    else a[0]=0,b[0]=1;
    for(i = 1;s[i]!='\0';i++)
    {
        if(s[i]=='E') a[i]=a[i-1]+1,b[i]=b[i-1];
        else b[i]=b[i-1]+1,a[i]=a[i-1];
     }
     len=i;
    for(i = 0;i<len;i++)
    {
        int temp=b[i-1]+a[len-1]-a[i];
        //if(a[len-1]==a[i]) temp++;
        if(a[len-1]==len) temp=0;
       //cout<<b[i-1]<<' '<<a[len-1]<<' '<<a[i-1]<<endl;
       ans=min(ans,temp);
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 2816
def main():
    n,m = map(int,input().split())
    if n*m == 0: return False
    a = list(map(int, input().split()))
    w = list(map(int,input().split()))
    d = {0:1}
    for i in w:
        new_d = dict(d)
        for j in d.keys():
            new_d[j+i] = 1
            new_d[abs(j-i)] = 1
        new_d[i] = 1
        d = dict(new_d)
    nokori = []
    for i in a:
        if i in d.keys():
            pass
        else:
            nokori += [i]
    # print(nokori)
    nokorimono = len(nokori)
    if nokorimono == 0:
        print(0)
        return True
    ans_d = {}
    for i in nokori:
        new_d = {}
        for j in d.keys():
            new_d[abs(i-j)] = 1
            new_d[i+j] = 1
        for j in new_d.keys():
            if j in ans_d:
                ans_d[j] = ans_d[j] + 1
            else:
                ans_d[j] = 1
    ans = 10**12
    for i in ans_d.keys():
        if ans_d[i] == nokorimono:
            ans = min(ans, i)
    if ans == 10**12:
        ans = -1
    print(ans)
    return True

while main():
    pass


Measured memory_bytes: 182408
n, c = map(int, input().split())

s = [tuple(map(int, input().split()))for _ in range(n)]

normal = [s[0][1] - s[0][0]] # 
cur = normal[0]
n_max = max(0, normal[0])

for (s1_pos, s1_cal), (s2_pos, s2_cal) in zip(s, s[1:]):
    cur = cur + s2_cal - (s2_pos - s1_pos)
    if n_max < cur:
        n_max = cur
    normal.append(n_max)

reverse = [s[-1][1] - (c - s[-1][0])]
cur = reverse[0]
r_max = max(0, reverse[0])
         
for (s1_pos, s1_cal), (s2_pos, s2_cal) in zip(s[::-1], s[-2::-1]):
    cur = cur + s2_cal - (s1_pos-s2_pos)
    if r_max < cur:
        r_max = cur
    reverse.append(r_max)
         
res = 0
for i, (pos, cal) in enumerate(s[:-1]):
    res = max(res, normal[i], normal[i]-pos+reverse[n-2-i])
for i, (pos, cal) in enumerate(s[:0:-1]):
    res = max(res, reverse[i], reverse[i]-(c-pos)+normal[n-2-i])
res = max(res, normal[-1], reverse[-1])
         
print(res)

Measured memory_bytes: 25944
import math
from decimal import *
N=int(input())
insuuof10=0
cnt=0
if N%2==1:
    print("0")
else:
    for i in range(1,28,1):
        cnt=cnt+N//(2*pow(5,i))

    print(cnt)
#111111111111111111
#124999999999999995

Measured memory_bytes: 59500
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

n,q = mi()
A = [[]for _ in range(n)]
for _ in range(n-1):
    a,b = mi()
    A[a-1].append(b-1)
    A[b-1].append(a-1)
P = [0]*(2*(10**5))
for _ in range(q):
    p,x = mi()
    P[p-1] += x

from collections import deque
que = deque()
dp = [0]*(n)
que.append((0,0))

while que:
    ima,mae = que.popleft()
    dp[ima] = P[ima] + dp[mae]
    for i in A[ima]:
        if i!= mae:
            que.append((i,ima)) 

print(*dp)



Measured memory_bytes: 108436
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pcc pair<char,char>
#define vi vector <int>
#define vl vector <ll>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d",x)
#define plld(x) printf("%lld",x)
#define pds(x) printf("%d ",x)
#define pllds(x) printf("%lld ",x)
#define pdn(x) printf("%d\n",x)
#define plldn(x) printf("%lld\n",x)
#define INF 2e9
#define INFLL 4e18
using namespace std;
ll powmod(ll base,ll exponent,ll mod){ // with mod < 1e9
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%mod;
		base=(base*base)%mod;
		exponent/=2;
	}
	return ans;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b,a%b);
}
const int upperlimit = 1e6+1;
const int mod = 1e9+7;

int main() {
      int x ,y;
      cin  >> x >> y;
      cout << x*y;
	return 0;
}


Measured memory_bytes: 3624
#include<stdio.h>

int main(void){
int i,j,k,n,m,l,A[105][105],B[105][105];
long  int C[105][105];

   scanf("%d %d %d",&n,&m,&l);
   for(i=0;i<n;i++){
	   scanf("%d",&A[i][0]);
	   for(j=1;j<m;j++){
		   scanf(" %d",&A[i][j]);
	   }
   }
   for(i=0;i<m;i++){
	   scanf("%d",&B[i][0]);
	   for(j=1;j<l;j++){
		   scanf(" %d",&B[i][j]);
	   }
   }

   for(i=0;i<n;i++){
	   for(j=0;j<l;j++){
		   for(k=0;k<m;k++){
			   C[i][j]=C[i][j]+A[i][k]*B[k][j];
		   }
	   }
   }
   for(i=0;i<n;i++){
	   printf("%ld",C[i][0]);
	   for(j=1;j<l;j++){
		   printf(" %ld",C[i][j]);
	   }printf("\n");
   }

   return 0;
}

Measured memory_bytes: 776
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <vector>

static const int IINF = 1 << 30;
static const long long LINF = 1LL << 60;
static const long long MOD = 1.0e+9 + 7;

template <typename T> std::vector<T> vectors(std::size_t n, T val) {
  return std::vector<T>(n, val);
}

template <typename T, typename... Args>
auto vectors(std::size_t n, Args... args) {
  return std::vector<decltype(vectors<T>(args...))>(n, vectors<T>(args...));
}

template <class T> inline bool chmin(T &a, const T &b) {
  return (a > b) ? a = b, true : false;
}

template <class T> inline bool chmax(T &a, const T &b) {
  return (a < b) ? a = b, true : false;
}

template <class T> inline void chadd(T &a, const T &b) {
  a += b, a %= MOD;
  // TODO minus case
}

template <class T>
std::ostream &operator<<(std::ostream &s, const std::vector<T> &v) {
  if (v.empty())
    return s;
  s << *v.begin();
  for (auto iter = v.begin() + 1; iter != v.end(); ++iter)
    if (std::is_fundamental<T>::value)
      s << " " << *iter;
    else
      s << std::endl << *iter;
  return s;
}

int main() {
  // Input
  int N, M;
  std::cin >> N >> M;
  std::vector<int> L(M);
  std::vector<int> R(M);
  for (int i = 0; i < M; ++i)
    std::cin >> L[i] >> R[i];

  // Main
  int cr = N;
  int cl = -1;
  for (int i = 0; i < M; ++i) {
    if (cl < L[i])
      cl = L[i];
    if (R[i] < cr)
      cr = R[i];
  }

  // Output
  if (cr - cl + 1 >= 0)
    std::cout << cr - cl + 1 << std::endl;
  else
    std::cout << 0 << std::endl;

  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define fo(a,b,c) for (a=b; a<=c; a++)
#define fd(a,b,c) for (a=b; a>=c; a--)
#define ll long long
//#define file
using namespace std;

int n,m,i,j,k,l,x,y,ans;

int main()
{
	#ifdef file
	freopen("arc091D.in","r",stdin);
	#endif
	
	scanf("%d",&n);
	fo(i,1,n)
	{
		scanf("%d%d",&x,&y);
		while (x>=y && (x%y))
		{
			l=x/y;
			x-=((x-(y*l))/(1+l))*(1+l);
			if (x%y) x-=1+l;
		}
		ans^=x/y;
	}
	printf(ans?"Takahashi\n":"Aoki\n");
	
	fclose(stdin);
	fclose(stdout);
	return 0;
}

Measured memory_bytes: 3828
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<iomanip>


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front
#define all(x) (x).begin(),(x).end()


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

void YN(bool ans){
    if(ans)cout<<"Yes"<<endl;
    else cout <<"No"<<endl;
    return;
}

int main(){
    string S,T;
    cin>>S>>T;
    ll ans = 0;
    rep(i,0,S.size()){
        if(S[i] != T[i])ans++;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3848
import itertools

n = int(input())

speak = [[] for _ in range(n)]


for i in range(n):
    s = int(input())
    for j in range(s):
        a,b = map(int,input().split())
        tal = (a-1,b)
        speak[i].append(tal)

check = 0

b = [i for i in range(n)]
c = len(b)

b_pairs = []
for i in range(1,n+1):
    b_pairs += list(itertools.combinations(b,i))

for i in b_pairs:
    tru = []
    for j in i:
        tru.append(j)
    
    leng = len(tru)
    if leng <= check:
        continue
    
    for k in tru:
        z = 1
        for d,e in speak[k]:
            if d in tru:
                if e == 1:
                    continue
                else:
                    z = 0
            else:
                if e == 0:
                    continue
                else:
                    z = 0
        if z == 0:
            break
    else:
        check = leng
            
print(check)


Measured memory_bytes: 6960
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
    int N;
    cin >> N;
    
    if(N /100 == 7 || N /10%10 == 7 || N%10==7)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    
    return 0;
    /*
    vector<int> a(N);
    for(int i= 0;i<N;i++)
    {
        cin >> a[i];
    }
    */
    
}

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

int main() {
	int K, X;
	cin >> K >> X;

	int firstBlack = X - K;
	for (int i = 0; i < 2 * K - 1; i++) {
		firstBlack++;
		if (i < 2 * K - 2) {
			cout << firstBlack << " ";
		}
		else {
			cout << firstBlack << endl;
		}
	}


}


Measured memory_bytes: 256
/* Circle */
/* 20181119 */
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>

#define C 3.141592653589793

int main(void){
	double r;

	scanf("%lf", &r);
	printf("%lf %lf\n", C * (r * r), 2 * (C * r));

	return 0;
}


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

int n, m;
int a[9];
int b[9] = { 2, 5, 5, 4, 5, 6, 3, 7, 6 };
int dp[10001];

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

	dp[0] = 0;
	for (int i = 1; i < 10001; i++)
		dp[i] = -10000;

	for (int i = 0; i < m; i++)
		cin >> a[i];

	sort(a, a + m, greater<int>());

	for (int i = 0; i < m; i++) {
		for (int j = 1; j < n + 1; j++) {
			if (j - b[a[i] - 1] >= 0 && dp[j - b[a[i] - 1]] != -10000)
				dp[j] = max(dp[j], dp[j - b[a[i] - 1]] + 1);
		}
	}

	int k = n;
	while (k > 0) {
		for (int i = 0; i < m; i++) {
			if (k - b[a[i] - 1] >= 0 && dp[k] - dp[k - b[a[i] - 1]] == 1) {
				k -= b[a[i] - 1];
				cout << a[i];
				break;
			}
		}		
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <queue>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
#pragma warning (disable: 4996)

int N, A[12];

int main() {
	cin >> N;
	for (int i = 1; i <= N; i++) {
		int C; cin >> C;
		A[min(8, C / 400)] += 1;
	}
	int cnt = 0;
	for (int i = 0; i <= 7; i++) {
		if (A[i] >= 1) cnt++;
	}
	if (cnt == 0) cout << 1 << " " << A[8] << endl;
	else cout << cnt << " " << cnt + A[8] << endl;
	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;

using namespace std;



int main (int argc, char*argv[]) {
  int n;
  cin >> n;
  vector<pair<int,int>> a ;
  for(int i=0; i<n; i++) {
    int value;
    cin >> value;
    a.push_back(make_pair(value, i));
  }
  sort(a.begin(), a.end());

  vector<pair<int,int>> ans;
  int l = a[n/2-1].first;
  int r = a[n/2].first;

  for(int i=0; i<n; i++) {
    if(i * 2 < n) {
      ans.push_back(make_pair(a[i].second, r));
    } else {
      ans.push_back(make_pair(a[i].second, l));
    }
  }

  sort(ans.begin(), ans.end());
  for(auto elem : ans) {
    cout << elem.second << endl;
  }
  return 0;
}

Measured memory_bytes: 5488
letters = 'abcdefghijklmnopqrstuvwxyz'

N = int(input())


def solve(n):
    result = ''
    while n > 0:
        letter_index = n % 26
        result = letters[letter_index-1] + result
        n //= 26
        if letter_index == 0:
            n -= 1

    print(result)


solve(N)


Measured memory_bytes: 61744
#include <bits/stdc++.h>
using namespace std;
int n, m;
#define LL long long
#define pI pair <int, LL>
#define fr first
#define sc second
#define mp make_pair
struct convex
{
    deque <pI> Q;
    int w;
    LL calc(pI f)
    {
        return 1ll * f.fr * w + f.sc;
    }
    void insert(pI t)
    {
        while (Q.size() >= 2)
        {
            pI a = Q.front(); Q.pop_front(); pI b = Q.front();
            if ((t.fr - a.fr) * (b.sc - a.sc) < (a.sc - t.sc) * (a.fr - b.fr)) continue;
            Q.push_front(a); break;
        }
        Q.push_front(t);
    }
    void clear()
    {
        w = 0;
        Q.clear();
    }
    LL query(int i)
    {
        w = i;
        while (Q.size() >= 2)
        {
            pI a = Q.front(); Q.pop_front(); pI b = Q.front();
            if (calc(a) < calc(b)) continue;
            Q.push_front(a); break;
        }
        return calc(Q.front());
    }
} V;

const int N = 400000;
int ti[N];
LL lF[N], rF[N], sum;
LL ans[N], tmp[N];

void solve(int l, int r)
{
    if (l == r) return;
    int m = (l + r) / 2;
    V.clear();
    for (int i = l; i <= m; ++ i) V.insert(mp(-2 * i, lF[i] + 1ll * i * i - i));
    for (int i = m + 1; i <= r; ++ i) tmp[i] = V.query(i) + 1ll * i * i + i + rF[n - (i + 1) + 1];
    for (int i = r; i > m; -- i) ans[i] = max(ans[i], tmp[i]), tmp[i - 1] = max(tmp[i - 1], tmp[i]);
    solve(l, m); solve(m + 1, r);
}

void solve0()
{
    V.clear();
    V.insert(mp(0, 0));
    for (int i = 1; i <= n; ++ i)
    {
        lF[i] = max(lF[i - 1] + 2 * ti[i], V.query(i) + 1ll * i * i + i);
        V.insert(mp(-2 * i, lF[i] + 1ll * i * i - i));
    }
    V.clear();
    V.insert(mp(0, 0));
    for (int i = 1; i <= n; ++ i)
    {
        rF[i] = max(rF[i - 1] + 2 * ti[n - i + 1], V.query(i) + 1ll * i * i + i);
        V.insert(mp(-2 * i, rF[i] + 1ll * i * i - i));
    }
    solve(0, n);
}
int main()
{
    scanf("%d", &n);
    for (int i = 1; i <= n; ++ i) scanf("%d", &ti[i]);
    for (int i = 1; i <= n; ++ i) sum -= ti[i];

    for (int i = 1, j = n; i <= j; ++ i, -- j) swap(ti[i], ti[j]);
    solve0();
    for (int i = 1, j = n; i <= j; ++ i, -- j) swap(ans[i], ans[j]);
    for (int i = 1, j = n; i <= j; ++ i, -- j) swap(ti[i], ti[j]);
    solve0();

    scanf("%d", &m);
    for (int i = 1; i <= m; ++ i)
    {
        int p, x;
        scanf("%d%d", &p, &x);
        LL res = max((lF[p - 1] + rF[n - (p + 1) + 1]) / 2 + ti[p], ans[p] / 2 + ti[p] - x) + sum;
        printf("%lld\n", res);
    }
}


Measured memory_bytes: 16000
using System;

class program
{
    static void Main(string[] args)
    {
        string[] inputs = Console.ReadLine().Split();
        int N = int.Parse(inputs[0]);
        int M = int.Parse(inputs[1]);

        int[,] map = new int[N, N];

        for(int i = 0; i < M; i++)
        {
            inputs = Console.ReadLine().Split();
            int p = int.Parse(inputs[0]) - 1;
            int q = int.Parse(inputs[1]) - 1;
            map[p, q]++;
            map[q, p]++;
        }
        for(int i = 0; i < N; i++)
        {
            int ans = 0;
            for(int j = 0; j < N; j++)
            {
                ans += map[i, j];
            }
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 13140
using System;
class Program{
	static void Main(){
		long n=long.Parse(Console.ReadLine());
		int[][] arr=new int[n][];
		long ch=0;
		for(long i=0;i<n;i++){
			arr[i]=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
		}
		Array.Sort(arr,(a,b)=>b[2]-a[2]);
		for(long i=0;i<=100;i++){
			for(long j=0;j<=100;j++){
				ch=Math.Abs(i-arr[0][0])+Math.Abs(j-arr[0][1])+arr[0][2];
				bool b=false;
				for(long k=1;k<n;k++){

					if(ch!=Math.Abs(i-arr[k][0])+Math.Abs(j-arr[k][1])+arr[k][2]){
						if(arr[k][2]!=0||ch>Math.Abs(i-arr[k][0])+Math.Abs(j-arr[k][1])){
							b=true;
							break;
						}
					}
				}
				if(b==false){
					Console.WriteLine("{0} {1} {2}",i,j,ch);
					Environment.Exit(0);
				}
			}
		}
	}
}

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

public class Main {

	final static long MOD = 1000000007L;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static ArrayList<int[]> list = new ArrayList<>();
	public static void main(String[] args) throws Exception {

		String s =nextString();

		long ans = 0;

		for(int i=1;i*2<s.length()-1;i++){
			if(s.substring(0,i).equals(s.substring(i,2*i))){
				ans=i;
			}
		}


		System.out.println(ans*2);

	}

	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


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

using namespace std;

int main() {

	string s="";
	cin >> s;
	if (s == "Sunny") cout << "Cloudy" << endl;
	else if (s == "Cloudy") cout << "Rainy" << endl;
	else cout << "Sunny" << endl;
	return 0; 
}

Measured memory_bytes: 256
import sys

sentences = sys.stdin.readlines()

counter = {}
for c in range(ord('a'), ord('z') + 1):
    counter[chr(c)] = 0
for sentence in sentences:
    for c in sentence:
        if c.isalpha():
            if c.isupper():
                counter[c.lower()] += 1
            else:
                counter[c] += 1

for k, v in counter.items():
    print("{} : {}".format(k, v))



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

struct UnionFind{
    int num;
    vector<int> par,rank;
    UnionFind(int n):num(n),par(n),rank(n,1){
        iota(par.begin(),par.end(),0);
    }
    int root(int x){
        return (par[x]==x?x:par[x]=root(par[x]));
    }
    bool merge(int x, int y){
        x=root(x),y=root(y);
        if (x==y) return false;
        if (rank[x]<rank[y]) swap(x,y);
        par[y]=x;
        rank[x]+=rank[y];
        --num;
        return true;
    }
    bool same(int x, int y){return root(x)==root(y);}
    int size(int x){return rank[root(x)];}
    int count(){return num;}
};

int N,M;

void solve(){
    vector<pair<int,int>> H;
    for (int i=0;i<N;++i){
        int h; cin >> h;
        H.emplace_back(h,i);
    }
    sort(H.begin(),H.end(),[](auto a,auto b){return a>b;});
    struct edge{
        int a,b,c;
        edge(int a,int b,int c):a(a),b(b),c(c){}
        const bool operator<(const edge &other) const {
            return c<other.c;
        }
    };
    vector<edge> es;
    for (int i=0;i<M;++i){
        int a,b,c; cin >> a >> b >> c;
        es.emplace_back(--a,--b,c);
    }
    sort(es.begin(),es.end());
    vector<int> used(M,0);
    UnionFind uf(N);
    set<int> alive;
    int ans=0;
    for (int i=0;i<N;++i){
        while(i+1<N&&H[i+1].first==H[i].first) alive.emplace(H[i++].second);
        alive.emplace(H[i].second);
        UnionFind uf2(N);
        for (int i=0;i<M;++i){
            if (!alive.count(es[i].a)||!alive.count(es[i].b)) continue;
            uf2.merge(es[i].a,es[i].b);
        }
        int p=-1,ok=1;
        for (int v:alive){
            if (p<0) p=uf2.root(v);
            if (p!=uf2.root(v)) ok=0;
        }
        if (!ok){
            for (int i=0;i<M;++i) used[i]=0;
            for (int i=0;i<N;++i){
                uf.par[i]=i; uf.rank[i]=1;
            }
            ans=0; continue;
        }
        for (int i=0;i<M;++i){
            if (!alive.count(es[i].a)||!alive.count(es[i].b)) continue;
            if (!used[i]&&uf.merge(es[i].a,es[i].b)){
                used[i]=1;
                ans+=es[i].c;
            }
        }
    }
    cout << ans << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> N >> M,N){
        solve();
    }
}


Measured memory_bytes: 3516
#include<iostream>
#include<string>
#include<vector>
#include <cstdlib>
#include<cctype>
#include <algorithm>    
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define VCOUT(num) for(auto& num:vec)
#define GET_ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0]))
#define LLINF 1000000000000000000//10^18
#define INF 1000000000000 //10^12
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000
#define MAX 100
#define MX 10

//int main(int argc, char const* argv[]){

int main(){ 
    vector<int>vec;
     vector<char>cvec;
      vector<string>svec;
    
   int a,b,x,y,z,count=0;
   string str1,str2;
   char c;
   cin>>x;
  
   
    
  //std::sort(vec.begin(),vec.end());
  //for(auto& num:vec)cout<<num<<endl;
  auto answer=x+(x*x)+(x*x*x);
  cout<<answer<<endl;
    return 0;
}



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

bool digit[10];

bool check(int n){
    while(n){
        if(digit[n%10]) return false;
        n/=10;
    }
    return true;
}

int main(){
    int n,k;
    scanf("%d %d",&n,&k);
    for(int i=0;i<k;i++){
        int num;
        scanf("%d",&num);
        digit[num]=true;
    }
    while(true){
        if(check(n)) break;
        n++;
    }
    printf("%d\n",n);
    return 0;
}


Measured memory_bytes: 256
import std.conv, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.container, std.math, std.range, std.regex, std.typecons;
import core.bitop, core.thread;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) throw new EOFException; tokens = readln.split; } auto token = tokens[0]; tokens.popFront; return token; }
int readInt() { return readToken().to!int; }
long readLong() { return readToken().to!long; }
real readReal() { return readToken().to!real; }

void chmin(T)(ref T t, in T f) { if (t > f) t = f; }
void chmax(T)(ref T t, in T f) { if (t < f) t = f; }

int binarySearch(T)(in T[] as, in bool delegate(T) test) { int low = -1, upp = cast(int)(as.length); for (; low + 1 < upp; ) { int mid = (low + upp) >> 1; (test(as[mid]) ? low : upp) = mid; } return upp; }
int lowerBound(T)(in T[] as, in T val) { return as.binarySearch((T a) => (a < val)); }
int upperBound(T)(in T[] as, in T val) { return as.binarySearch((T a) => (a <= val)); }


immutable INF = 10^^9 + 10;

int N, K;
int[] H;

void main() {
  try {
    for (; ; ) {
      N = readInt();
      K = 2;
      H = new int[N];
      foreach (i; 0 .. N) {
        H[i] = readInt();
      }
      auto dp = new int[N];
      dp[] = INF;
      dp[0] = 0;
      foreach (i; 0 .. N) {
        foreach (j; i + 1 .. i + 1 + K) {
          if (j < N) {
            chmin(dp[j], dp[i] + abs(H[i] - H[j]));
          }
        }
      }
      writeln(dp[N - 1]);
    }
  } catch (EOFException e) {
  }
}


Measured memory_bytes: 4468
#include<iostream>
#include<cstdio>
#include<cstring>
#define maxn 200020
#define ll long long
using namespace std;
int l,n,x[maxn];ll ans,s[maxn],s2[maxn],t[maxn],t2[maxn];
inline ll getpre(int x) {return s2[x]-s[x]*(n-x);}
inline ll getpre_seg(int ql,int qr){return s2[qr]-s2[ql]-(s[qr]-s[ql])*(n-qr);}
inline ll getsuf(int x){return t2[x]-t[x]*(x-1);}
inline ll getsuf_seg(int ql,int qr){return t2[ql]-t2[qr]-(t[ql]-t[qr])*(ql-1);}
int main(){
	cin>>l>>n;
	x[0]=0;
	for(int i=1;i<=n;++i)scanf("%d",&x[i]),s[i]=s[i-1]+x[i]-x[i-1],s2[i]=s2[i-1]+1ll*(n-i+1)*(x[i]-x[i-1]);
	x[n+1]=l;
	for(int i=n;i;--i)t[i]=t[i+1]+x[i+1]-x[i],t2[i]=t2[i+1]+1ll*i*(x[i+1]-x[i]);
	ans=0;
	for(int i=0;i<=n;++i){
		int l=i,r=n-i;
		if(l<r){
			ans=max(ans,getpre(l)*2+getsuf_seg(l+1,l*2+2)*2-(t[l+1]-t[l*2+2])+t[l*2+2]*(l*2+1));
			ans=max(ans,getpre(l)*2-s[l]+getsuf_seg(l+1,l*2+1)*2+t[l*2+1]*l*2);
		}
		else if(l==r){
			ans=max(ans,getpre(l)*2+getsuf(l+1)*2-t[l+1]);
			ans=max(ans,getpre(l)*2-s[l]+getsuf(l+1)*2);
		}
		else{
			ans=max(ans,getpre_seg(l-r,l)*2+s[l-r]*r*2+getsuf(l+1)*2-t[l+1]);
			ans=max(ans,getpre_seg(l-r-1,l)*2-(s[l]-s[l-r-1])+s[l-r-1]*(r*2+1)+getsuf(l+1)*2);
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> h(n);
    for (int i = 0; i < n; ++i) {
        cin >> h.at(i);
    }
    vector<set<int>> children(n);
    for (int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        children.at(a-1).insert(b-1);
        children.at(b-1).insert(a-1);
    }
    int ans = n;
    for (int i = 0; i < n; ++i) {
        for (int j : children.at(i)) {
            if (h.at(i) <= h.at(j)) {
                ans--;
                break;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 17776
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<utility>
#include<functional>
#include<stack>
#include<queue>
#include<cmath>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
# define MOD 1000000000+7
# define INF 1e9
typedef long long ll;

using namespace std;
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }

int tgt[8] = {}, d[200][200] = {};

int main() {

	int n = 0, m = 0, r = 0, ans = INF, umaru = 0;
	
	cin >> n >> m >> r;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			d[i][j] = INF;
			if (i == j) {
				d[i][j] = 0;
			}
		}
	}



	for (int i = 0; i < r; i++) {
		cin >> tgt[i];
	}

	sort(tgt, tgt + r);

	for (int i = 0; i < m; i++) {
		int a, b, c;
		cin >> a >> b >> c;
		d[a-1][b-1] = c;
		d[b-1][a-1] = c;
	}

	for (int k = 0; k < n; k++) {
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}
	
	do {
		
		umaru = 0;

		for (int i = 1; i < r; i++) {
			umaru += d[tgt[i - 1]-1][tgt[i]-1];
		}

		ans = min(ans, umaru);

	} while (next_permutation(tgt, tgt + r));

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 384
from collections import deque
import sys
x,n = map(int,input().split())
p = []
if n != 0:
    p = list(map(int, input().split()))
tmp1 = x
if tmp1 not in p:
    print(tmp1)
    sys.exit()
i = 1
while True:
    tmp1 = x - i
    tmp2 = x + i
    if tmp1 not in p:
        print(tmp1)
        sys.exit()
    if tmp2 not in p:
        print(tmp2)
        sys.exit()
    i += 1

Measured memory_bytes: 9448
#include<iostream>
using namespace std;
string str,str2,str3;
int a,b;
int main(){
  while(1){
    cin>>str;
    if(str=="0")break;
    cin>>str2>>str3;

    a=b=0;
    for(int i=1;i<(int)str.size();i++){
      if(str[i]=='A')a++;
      else b++;
    }
    if(str2[0]=='A')a++;
    else b++;
    cout<<a<<' '<<b<<endl;
    


    a=b=0;
    for(int i=1;i<(int)str2.size();i++){
      if(str2[i]=='A')a++;
      else b++;
    }
    if(str3[0]=='A')a++;
    else b++;
    cout<<a<<' '<<b<<endl;


    a=b=0;
    for(int i=1;i<(int)str3.size();i++){
      if(str3[i]=='A')a++;
      else b++;
    }

    if(a>b)a++;
    else b++;
    
    cout<<a<<' '<<b<<endl;


  }
  return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
#define FOR(i, a, b) for(ll i=(ll)(a); i!=(ll)(b); i++)
#define RFOR(i, a, b) for(ll i=(ll)(a); i!=(ll)(b); i--)
#define REP(i, n) FOR(i, 0, n)
using namespace std;
using ll = long long;

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

  FOR(h, 1, 3501)FOR(n, h, 3501){
    ll s = N * h * n;
    ll t = 4*n*h - N*h - N*n;
    if(t == 0) continue;
    if(s % t == 0 && s/t > 0){
      cout << h << " " << n << " " << s/t << endl;
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use num_traits::clamp;
use ordered_float::OrderedFloat;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout()]
fn main() {
    input! {
        mut k: usize,
    }

    let mut set = BTreeSet::new();
    let mut rem = 7;
    for i in 1.. {
        if rem % k == 0 {
            println!("{}", i);
            return;
        } else if set.contains(&rem) {
            println!("-1");
            return;
        }
        set.insert(rem);
        rem = (rem * 10 + 7) % k;
    }

}


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

int main(){
    ll n , a,b;
    cin >> n >> a >> b;
    ll set = a + b;
    ll ans = n /(set);
    ans *= a;
    set = n % set;
    if(a>set){
        ans +=set;
    }else{
        ans +=a;
    }
    cout<< ans <<endl;
    return 0;
}

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

int main(){
  int i,j,n,A[N],minj,temp,c=0;

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


  //selectionsort 
  
  for(i=0;i<n;i++){
    minj=i;
    for(j=i;j<n;j++){
      if (A[j] < A[minj]){
	minj=j;
      }
    }
    if(i!=minj){
      temp=A[i];
      A[i]=A[minj];
      A[minj]=temp;
      c=c+1;
      
    }
  }
  
  for(i=0;i<n;i++){
    printf("%d",A[i]);
    if(i<n-1)printf(" ");
  }
  printf("\n%d\n",c);
  return 0;
}



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

int main()
{
    int N;
    cin>>N;
    int x,temp;
    int count[N]={0,};
    for(int n=1;n<=N;++n)
    {x=ceil(sqrt((float)n));
        for(int i=1;i<x;++i)
       {
        for(int j=1;j<x;++j)
        {
            for(int k=1;k<x;++k)
            {
                temp=(i*i+j*j+k*k+i*j+i*k+j*k);
                if(temp==n)
                    ++count[n-1];
                else if(temp>n)
                    break;
            }
        }
       }
       cout<<count[n-1]<<"\n";
    }

    return 0;
}



Measured memory_bytes: 3652
#include <stdio.h>
 
int main()
{
	int N,M,a,b,total;
    scanf("%d %d",&N,&M);
 
    a= (N-1)*N/2;
    b= (M-1)*M/2;
    total= a + b;
 
    printf("%d",total);
 
    return 0;

}

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

using namespace std;

int main(int argc, const char * argv[]) {
    
    string S;
    cin >> S;
    
    vector<int> vec(S.size());
    
    
    
    for (int i=0; i<S.size(); ++i)
    {
        int cnt = 0;
        for (int j=i; j<S.size(); ++j)
        {
            if (S[j] == 'G' || S[j] == 'T' || S[j] == 'A' || S[j] == 'C')
            {
                ++cnt;
            }
            else
            {
                break;
            }
        }
        vec[i] = cnt;
    }
    
    cout << *max_element(vec.begin(),vec.end()) << endl;
    
    
    
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <algorithm>
using namespace std;
typedef long long LL;
int x, y;

int main() {
	while(~scanf("%d %d", &x, &y)) {
		int ans;
		if(x % y == 0) {
			puts("-1");
			continue;
		}
		else {
			for(int i = 1; i <= 1e9; i++) {
				ans = x * i;
				if(ans % y != 0) break;
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 128
N,MA,MB = map(int,raw_input().split())
src = []
sum_a = sum_b = 0
for i in range(N):
  a,b,c = map(int,raw_input().split())
  src.append((a,b,c))
  sum_a += a
  sum_b += b

INF = 10**9
dp = [[[INF for b in range(sum_b+1)] for a in range(sum_a+1)] for i in range(N+1)]
dp[0][0][0] = 0

for i in range(N):
  ai,bi,ci = src[i]
  for a in range(sum_a+1 - ai):
    for b in range(sum_b+1 - bi):
      if dp[i][a][b] == INF: continue
      dp[i+1][a][b] = min(dp[i+1][a][b], dp[i][a][b])
      dp[i+1][a+ai][b+bi] = min(dp[i][a+ai][b+bi], dp[i][a][b] + ci)

ans = INF
n = 1
while True:
  a,b = n*MA,n*MB
  if a > sum_a or b > sum_b: break
  ans = min(ans, dp[N][a][b])
  n += 1

print(ans if ans != INF else -1)

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

typedef long long ll;
typedef unsigned long long ull;
#define fr first
#define sc second
#define pii pair<int, int>
#define all(v) v.begin(), v.end()

using namespace std;

const ll MOD = 1000000007;

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

    int h, w, k;
    cin >> h >> w >> k;
    vector<string> v(h);
    for (int i = 0; i < h; i++) {
        cin >> v[i];
    }
    vector<bool> row(h, false), col(w, false);

    int ans = 0;

    for (int msk1 = 0; msk1 < (1 << h); msk1++) {
        for (int i = 0; i < h; i++) {
            if (msk1 & (1 << i))
                row[i] = true;
            else
                row[i] = false;
        }
        for (int msk2 = 0; msk2 < (1 << w); msk2++) {
            for (int i = 0; i < w; i++) {
                if (msk2 & (1 << i))
                    col[i] = true;
                else
                    col[i] = false;
            }
            int rem = 0;
            for (int i = 0; i < h; i++) {
                for (int j = 0; j < w; j++) {
                    if (v[i][j] == '#' && !(col[j] || row[i])) rem++;
                }
            }
            if (rem == k) ans++;
        }
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 3596
#include<iostream>
#include<algorithm>
#include<vector>
#include <numeric>
#include <math.h>
using namespace std;
int main(int argc, char const *argv[]) {

    long long N=0;
    long long ts[5] = {0};

    std::cin >> N;
    long long tmp=0;
    std::cin >> tmp;
    long long min=tmp;
    int index = 0;
    for (size_t i = 1; i < 5; i++) {
        std::cin >> tmp;
        if(min>tmp){
            min=tmp;
            index=i;
        }
    }
    long long Ans = ceil(N/double(min));
    Ans += 4;
    std::cout << Ans << '\n';
    return 0;
}
 


Measured memory_bytes: 256
/* *Your Love Makes me STRONG,
   You'r Hate Makes Me UNSTOPABBLE.*

  *HOPE is a good thing,Maybe The BEST of Things.
   And No Good Things Ever Dies.*

  *Keep calm,Be patient And Chase Your DREAM*

*/


#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define MN7 ios::sync_with_stdio(0);cin.tie(nullptr);
using namespace std;
ll t, n, i, j, k, a, b, c, d, p, q, r, x, y, z, m, cnt, flag, ans,rem,reversed;
string s1, s2;
void nahid()
{ 
  cin >> x >> y;
  for (i = x; i <= y; i++)
  {
    cnt = i;
    reversed = 0;
    while (cnt)
    {
      rem = cnt % 10;
      cnt /= 10;
      reversed =(reversed * 10) + rem;
    } 
    if (i == reversed)
    {
      ans++;
    }
  
  }
  cout << ans << endl;



}
int main()
{ MN7 //cin>>t;while(t--)
  nahid();
}


Measured memory_bytes: 3556
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
using namespace std;

struct Node {
int key;
Node *right, *left, *parent;
} ;

Node *root, *NIL;

void insert(int k) {
Node *y = NIL;
Node *x = root;
Node *z;

z = (Node *)malloc(sizeof(Node));
z->key = k;
z->left = NIL;
z->right = NIL;

while ( x != NIL ) {
y = x;
if ( z->key < x->key ) {
x = x->left;
} else {
x = x->right;
}
}

z->parent = y;
if ( y == NIL ) {
root = z;
} else {
if ( z->key < y->key ) {
y->left = z;
} else {
y->right = z;
}
}
}

void inorder(Node *u) {
if ( u == NIL ) return;
inorder(u->left);
printf(" %d", u->key);
inorder(u->right);
}

void preorder(Node *u) {
if ( u == NIL ) return;
printf(" %d", u->key);
preorder(u->left);
preorder(u->right);
}

int main() {
int n, i, x;
string com;

scanf("%d", &n);

for( i= 0; i<n; i++ ){
cin >> com;
if ( com == "insert" ) {
scanf("%d", &x);
insert(x);
} else if ( com == "print" ) {
inorder(root);
printf("\n");
preorder(root);
printf("\n");
}
}

return 0;
}


Measured memory_bytes: 26620
import math
x=0
y=0
angle=0
while True:
    r,c=map(int, input().split(","))
    if r == c == 0:
        break

    y += r*math.cos(angle)
    x += r*math.sin(angle)
    angle -= c*math.pi/180


print(int(-x))
print(int(y))

Measured memory_bytes: 6852