akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int N;
int A[20];
int x[20][20];
int y[20][20];

int counter(int x) {
  if(x == 0) return 0;
  return counter(x >> 1) + (x & 1);
}


int main() {
  cin >> N;
  for(int i = 1; i <= N; i++) {
    cin >> A[i];
    for(int j = 1; j <= A[i]; j++) {
      cin >> x[i][j] >> y[i][j];
    }
  }
  int ans = 0;
  for(int bits = 1; bits < (1 << N); bits++) {
    bool ok = true;
    for(int i = 1; i <= N; i++) {
      if(!(bits & (1 << (i-1)))) continue;
      for(int j = 1; j <= A[i]; j++) {
        if(((bits >> (x[i][j]-1)) & 1) ^ y[i][j]) ok = false;
      }
    }
    if(ok) ans = max(ans, counter(bits));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a, b, c, d;
int main() {
	cin >> a >> b >> c >> d;
	if (abs(a - c) <= d || (abs(a - b) <= d && abs(c - b) <= d))
		cout << "Yes";
	else
		cout << "No";
}

Measured memory_bytes: 768
#include<stdio.h>
int main(void){
  int N,L,i,c=-1,sum=0;
  scanf("%d%d",&N,&L);
  int tas[N],abtas[N];
  for(i=0;i<N;i++){
    tas[i]=L+i;
    sum+=tas[i];
    if(tas[i]>0)
      abtas[i]=tas[i];
    else
      abtas[i]=-tas[i];
  }
  int min=1000;
  for(i=0;i<N;i++){
    if(abtas[i]<min)
      min=abtas[i];
  }
  for(i=0;i<N;i++){
    c++;
    if(min==abtas[i])
      break;
  }
  printf("%d",sum-tas[c]);
  return 0;
}
  
  

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
using namespace std;
long long n,sum,a[13]; 
long long dfs(long long x,long long sum,long long sum1)
{
    if(x==1)
        return 2*sum+sum1+a[x]+sum1*10+a[x];
    return dfs(x-1,sum,sum1*10+a[x])+dfs(x-1,sum+sum1,a[x]); 
}
int main()
{
    cin>>n;
    while(n!=0)
        sum++,a[sum]=n%10,n/=10;
    cout<<dfs(sum,0,0)/2;
    return 0;
}

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

public class Main{

	public static void main(String args[]){
		new Main().mainrun();
	}

	private Scanner scan;

	private long N,overflow_num = 80;

	private void mainrun() {
		scan = new Scanner(System.in);

		N = scan.nextLong();

		for(int i = 0;i < N;i++) {
			char[] n1,n2;

			n1 = scan.next().toCharArray();
			n2 = scan.next().toCharArray();


			int n = Math.max(n1.length, n2.length);

			if(n > overflow_num) {
				System.out.println("overflow");
				continue;
			}

			char[] num1,num2;

			if(n1.length > n2.length) {

				num1 = n1;
				num2 = new char[n];
				Arrays.fill(num2, '0');

				for(int j = 0;j < n2.length;j++) {
					num2[n-j-1] = n2[n2.length-j-1];
				}

			}else if(n1.length < n2.length) {

				num2 = n2;
				num1 = new char[n];
				Arrays.fill(num1, '0');

				for(int j = 0;j < n1.length;j++) {
					num1[n-j-1] = n1[n1.length-j-1];
				}

			}else {
				num1 = n1;
				num2 = n2;
			}

			char[] ans = new char[n];
			int next = 0;

			for(int j = n-1;j >= 0;j--) {
				int sum = (num1[j] - '0') + (num2[j] - '0') + next;
				next = sum / 10;
				ans[j] = (char)(sum % 10 + '0');
			}

			if(next + n > overflow_num) {

				System.out.println("overflow");

			}else {
				if(next == 1) {
					System.out.print(1);
				}
				System.out.println(ans);
			}


		}

		scan.close();

	}
}


Measured memory_bytes: 25904
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
# def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  a,b=LS()

  a=int(a)
  b=int(b.replace('.',''))

  x=str(a*b)[:-2]
  if x=='':
    return 0
  return x

# main()
print(main())


Measured memory_bytes: 10496
import java.util.*;
 
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		double all = Math.pow(3, N);
		int count = 1;
		for(int i=0; i<N; i++){
			int A = sc.nextInt();
			if(A%2==0){
				count *=2;
			}
		}
		System.out.println((int)all-count);
    }
}


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
	for(auto &e:u) fill_v<T>(e,v...);
}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int64 K, X;
	cin >> X;
	int64 lcm = 360 / __gcd(X, (int64)360);
	cout << lcm << endl;
}


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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define log_2(a) (log((a)) / log(2))
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    int N;
    cin >> N;

    int b = 0;
    LL res = 0;
    for(int i = 0; i < N; ++i) {
        LL a;
        cin >> a;
        if(a == 0) {
            b = 0;
        } else {
            if(b == 1) {
                ++res;
                --a;
            }
            res += a / 2;
            b = a % 2;
        }
    }
    cout << res << endl;
    return 0;
}



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

#define pout(n)  printf ("%d\n", n)

#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());

const int d4x[4] = {1, 0, -1, 0};
const int d4y[4] = {0, 1, 0, -1};
const int d8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const int d8y[8] = { 0,1,1,1,0,-1,-1,-1 };

#define MAX_N (int)2e5+20
#define INF 1e12+20

typedef long long ll;
using namespace std;

string s,ans;
int main(){
	cin >> s;
	rep(i,0,s.size()){
		if(i%2 == 0) ans += s[i];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
vector<int> dia; // 餅の直径
int N; //餅の数
 int main(){
     cin >> N;
     dia.resize(N);
     for(int i=0; i<N; i++){
         cin >> dia[i];
     }
     sort(dia.begin(),dia.end());
     dia.erase(unique(dia.begin(),dia.end()),dia.end());
    
    cout << dia.size() << endl;
 }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M,p,y; cin >> N >> M;
  vector<pair<int, int> > c[N];pair<int, int> ans[M];
  for (int i = 0; i < M; i++) {
    cin >> p >> y;
    c[p-1].push_back({y, i});
  }
  for (int i = 0; i < N; i++) {
    sort(c[i].begin(), c[i].end());
    for (int j = 0; j < (int) c[i].size(); j++) {
      ans[c[i][j].second] = {i+1, j+1};
    }
  }
  for (int i = 0; i < M; i++) {
    printf("%06d%06d\n", ans[i].first, ans[i].second);
  }
}

Measured memory_bytes: 7680
#include <iostream>
#include <queue>
#include <cstring>
#include <cstdlib>
using namespace std;

#define ADD 102

int sx, sy, gx, gy, lx, ly;
int n;
bool wall[210][210];

class State{
public:
  int x, y, step, mushi;

  State(){}
  State(int _x, int _y, int _step, int _mushi){
    x = _x;
    y = _y;
    step = _step;
    mushi = _mushi;
  }

  bool operator<(const State &st)const{
    return mushi > st.mushi;
  }
};

int dx[2][7] = {
  {0, 1, 1, 0, -1, -1, 0},
  {0, 1, 1, 0, -1, -1, 0},
};

int dy[2][7] = {
  {1, 0, -1, -1, -1, 0, 0},
  {1, 1, 0, -1, 0, 1, 0},
};

bool closed[210][210][6];

void solve(){
  priority_queue<State> open;
  memset(closed, 0, sizeof(closed));

  open.push(State(sx, sy, 0, 0));

  while(!open.empty()){
    State st = open.top();
    open.pop();

    if(closed[st.x + ADD][st.y + ADD][st.step]) continue;
    closed[st.x + ADD][st.y + ADD][st.step] = true;

    if(st.x == gx && st.y == gy){
      cout << st.mushi << endl;
      return;
    }

    int d = abs(st.x * st.y * st.step) % 6;
    int nx = st.x + dx[abs(st.x) % 2][d];
    int ny = st.y + dy[abs(st.x) % 2][d];

    if(-lx <= nx && nx <= lx && -ly <= ny && ny <= ly && !wall[nx + ADD][ny + ADD]){
      open.push(State(nx, ny, (st.step + 1) % 6, st.mushi));
    }

    for(int i = 0; i < 7; i++){
      if(d == i) continue;

      nx = st.x + dx[abs(st.x) % 2][i];
      ny = st.y + dy[abs(st.x) % 2][i];

      if(-lx <= nx && nx <= lx && -ly <= ny && ny <= ly && !wall[nx + ADD][ny + ADD]){
        open.push(State(nx, ny, (st.step + 1) % 6, st.mushi + 1));
      }
    }
  }

  cout << -1 << endl;
}

int main(){
  while(cin >> sx >> sy >> gx >> gy){
    cin >> n;

    memset(wall, 0, sizeof(wall));

    for(int i = 0; i < n; i++){
      int x, y;
      cin >> x >> y;
      wall[x + ADD][y + ADD] = true;
    }

    cin >> lx >> ly;

    solve();
  }
}

Measured memory_bytes: 2356
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, a, b) for(int i = a; i < b; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define debug(x) cerr <<__LINE__<< ": " <<#x<< " = " << x << endl
#define debug_vec(v) cerr<<__LINE__<<": "<<#v<<" = ";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
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; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

void solve() {
    int n;
    cin >> n;
    vector<int> A(n);
    rep(i, n) cin >> A[i];
    int now = 1, ans = 0;
    rep(i, n) {
        while(A[i] != now) {
            i++, ans++;
            if (i >= n) break;
        }
        now++;
    }
    cout << (ans == n ? -1 : ans) << endl;
}

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


Measured memory_bytes: 3972
#include<stdio.h>


int main(void)
{
     int a, b, c, d, e, f;
     scanf("%d %d %d", &a, &b, &c);
     if(a > c){
         d = a;
         a = c;
         c = d;
     } if(b > c){
         e = b;
         b = c;
         c = e;
     } if(a > b){
         f = a;
         a = b;
         b = f;
     }
    printf("%d %d %d\n", a, b, c);
     return 0;
 }

         
         

Measured memory_bytes: 596
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
using namespace std;

int main(void)
{
	vector<vector<int>> c(3, vector<int>(3));
	for(int i=0; i<c.size(); i++)
		for(int j=0; j<c[i].size(); j++)
			cin >> c[i][j];

	string ret;
	int n0 = c[0][0] + c[1][1] + c[2][2];
	int n1 = c[0][1] + c[1][2] + c[2][0];
	int n2 = c[0][2] + c[1][0] + c[2][1];
	if(n0 == n1 && n0 == n2)
		ret = "Yes";
	else
		ret = "No";

	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a) for (int i = (int)0; i < (int)a; ++i)
#define rrep(i, a) for (int i = (int)a - 1; i >= 0; --i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RREP(i, a, b) for (int i = (int)a - 1; i >= b; --i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define popcount __builtin_popcount
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

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

ll gcd(ll n, ll m)
{
	ll tmp;
	while (m != 0)
	{
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m)
{
	return abs(n) / gcd(n, m) * abs(m); //gl=xy
}

using namespace std;

void solve()
{
	int n;
	cin>>n;
	vector<ll>a(n);
	rep(i,n)cin>>a[i];
	ll ans=0;
	for(int i=1;i<n;++i){
		ll x=0;
		x=max(0LL,a[i-1]-a[i]);
		ans+=x;
		a[i]+=x;
	}
	cout<<ans;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 4764
// finish date: 2018/07/22
#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
typedef vector<vector<vector<double>>> vvvd;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, pair<int, int>> plii;
const int bigmod = 1000000007;
const int INF = 1050000000;
const long long INFll = 100000000000000000;


int main() {
    int N;
    cin>>N;
    int a;
    int ans = 0;
    rep(i,N) {
        cin>>a;
        ans += a-1;
    }
    cout<<ans<<endl;


    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N=0;
  long long d=0;
  int ans=0;
  cin>>N>>d;
   for(int i=0;i<N;i++){
     long long x,y;
     cin>>x>>y;
     if(x*x+y*y<=d*d){
      ans++;
     }
       
   }
   cout<<ans<<endl;
}

Measured memory_bytes: 3532
#include<bits/stdc++.h>
#define N 309
using namespace std;

int n,m,a[N][N],num[N]; bool ban[N];
int main(){
	scanf("%d%d",&n,&m);
	int i,j,k,mx,ans=n;
	for (i=1; i<=n; i++)
		for (j=1; j<=m; j++) scanf("%d",&a[i][j]);
	for (i=1; i<=m; i++){
		memset(num,0,sizeof(num));
		for (j=1,mx=0; j<=n; j++){
			for (k=1; k<=m; k++) if (!ban[a[j][k]]) break;
			num[a[j][k]]++; mx=max(mx,num[a[j][k]]);
		}
		ans=min(ans,mx);
		for (j=1; j<=m; j++) if (!ban[j] && num[j]==mx) break;
		ban[j]=1;
	}
	printf("%d\n",ans);
	return 0;
}


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

l=make_divisors(n)
m=len(l)
ans=10**100
for i in range(min(m//2+1,m)):
    a,b=len(str(l[i])),len(str(n//l[i]))
    ans=min(ans,max(a,b))
print(ans)



Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define Little 1
const long long INF = 1LL<<60;
#define pairint pair<int,int>
signed main(){
  int x=0,y=0,z=0,w=0,n=0,m=0,o=0;
  std::cin >> x;
  std::vector<int> v;
  rep(i,26){
    Rep(j,15){
      v.pb(i*4+j*7);
    }
  }
  rep(i,v.size()){
    if(v[i]==x){
      std::cout << "Yes" << '\n';
      return 0;
    }
  }
  std::cout << "No" << '\n';  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	set<int>a;
	int n;cin>>n;
	for(int i=1;i<=n;i++)
	{
		int nn;cin>>nn;
		a.insert(nn);
	} 
	cout<<a.size();
	
	return 0;
} 

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


 const int N = 1000;

int lcs(string X, string Y) {
	int c[N + 1][N + 1];
	int m = X.size();
	int n = Y.size();
	int maxl = 0;
	X = ' ' + X;
	Y = ' ' + Y;
	for (int i = 0; i <= m; i++) {
		c[i][0] = 0;
	}
	for (int j = 1; j <= n; j++)c[0][j] = 0;

	for (int i = 1; i <= m; i++) {
		for (int j = 1; j <= n; j++) {
			if (X[i] == Y[j]) {
				c[i][j] = c[i - 1][j - 1] + 1;
			}
			else {
				c[i][j] = max(c[i - 1][j], c[i][j - 1]);
			}
			maxl = max(maxl, c[i][j]);
		}
	}
	return maxl;

}

int main() {
	string s1, s2;
	int n; cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> s1 >> s2;
		cout << lcs(s1, s2) << endl;
	}
	return 0;
}


Measured memory_bytes: 7068
INF = 10 ** 9 + 7
N = int(input())
A = list(map(int, input().split()))
S = [sum(A)]#A[0]~A[N-1]の総和を求める

ans = 0
for i in range(N-1):
    key = S[-1]#Sの一番後ろの配列をとる(要素は一つしかない)
    S.append(key - A[i])#総和からA[i]を引いてあげたものをS配列に加えてあげるS配列はみぎに行くにつれて値が小さくなる
    #print(S)
    ans += (A[i] * S[-1])#Ansは実際の総和計算に当たるもの

print(ans%INF)

Measured memory_bytes: 31576
def main():
    import sys
    import heapq
    heap = []
    input = sys.stdin.readline
    
    X,Y,Z,K = map(int, input().split())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    C = list(map(int, input().split()))
    A = sorted(A)[::-1]
    B = sorted(B)[::-1]
    C = sorted(C)[::-1]
    S = A[0]+B[0]+C[0]
    mA = A[0]
    mB = B[0]
    mC = C[0]
    for i in range(X):
        A[i] -= mA
    for i in range(Y):
        B[i] -= mB
    for i in range(Z):
        C[i] -= mC
    
    for i in range(Z):
        heapq.heappush(heap, [-C[i],-C[i],0])
    
    answer = []
    
    AB = []
    for i in range(X):
        for j in range(Y):
            AB.append(A[i]+B[j])
    AB = sorted(AB)[::-1]
    for i in range(K):
        c = heapq.heappop(heap)
        answer.append(S-c[0])
        if c[2]+1 < len(AB):
	        heapq.heappush(heap,[c[1]-AB[c[2]+1],c[1],c[2]+1])
        
    print(*answer,sep="\n")
        
            
    
    

main()

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

#define rep(i,n) for(int i = 0;i<n;i++)
#define vv(Type,Name, n,m,d)vector<vector<Type>> Name(n, vector<Type>(m, d))
#define P pair
using namespace std;
using ll = long long;


int main(void) {

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



	int n;
	cin >> n;
	
	vector<int> a(n);
	rep(i, n) cin >> a[i];

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

	int ans = 0;
	for (int i = 0; i < n-2; i++) {
		for (int j = i+1; j < n-1; j++) {
			if (a[i] == a[j]) continue;
			int k = j + 1;
			for (; k < n; k++) if (a[j] != a[k]) break;
			int cnt = lower_bound(a.begin() + k, a.end(), a[i] + a[j]) - a.begin();
			ans += cnt - k;
		}
	}


	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 3596
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define res(i,n) for(int i=n;;i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define REV(i,n) for(int i=n-1;i>0;i--)
#define req(i,n,m) for(int i=n;i<m;i++)
#define REQ(i,n,m,l) for(int i=n;i<m;i+=l) 
#define _GLIBCXX_DEBUG
int INF = 1e9 + 7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
    unsigned day;
    if (dow < dow1) dow += 7;
    day = dow - dow1;
    day += 7 * n - 6;
    return day;
}
signed gcd(long long x, long long y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
signed lcm(long long x, long long y) {
    return x / gcd(x, y) * y;
}
unsigned DayToWeekNumber(unsigned day)
{
    return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
    return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
signed main() {
    int N; cin >> N;
    REP(i, 8) {
        if (N < pow(2, i)) {
            cout << pow(2, i - 1) << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 4024
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;
import java.util.Stack;

public class Main {
	private static FastScanner sc = new FastScanner();

	public static void main(String[] args) {
		Stack<Integer> s = new Stack<Integer>();
		
		while(sc.hasNext()) {
			String str = sc.next();
			if(str.equals("+")) {
				int b = s.pop();
				int a = s.pop();
				s.push(a+b);			
			} else if(str.equals("-")) {
				int b = s.pop();
				int a = s.pop();
				s.push(a-b);
			} else if(str.equals("*")) {
				int b = s.pop();
				int a = s.pop();
				s.push(a*b);
			} else {
				s.push(Integer.parseInt(str));
			}
		}
		
		System.out.println(s.pop());

	}

	static class FastScanner {
	    private final InputStream in = System.in;
	    private final byte[] buffer = new byte[1024];
	    private int ptr = 0;
	    private int buflen = 0;
	    private boolean hasNextByte() {
	        if (ptr < buflen) {
	            return true;
	        }else{
	            ptr = 0;
	            try {
	                buflen = in.read(buffer);
	            } catch (IOException e) {
	                e.printStackTrace();
	            }
	            if (buflen <= 0) {
	                return false;
	            }
	        }
	        return true;
	    }
	    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
	    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
	    private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
	    public boolean hasNext() { skipUnprintable(); return hasNextByte();}
	    public String next() {
	        if (!hasNext()) throw new NoSuchElementException();
	        StringBuilder sb = new StringBuilder();
	        int b = readByte();
	        while(isPrintableChar(b)) {
	            sb.appendCodePoint(b);
	            b = readByte();
	        }
	        return sb.toString();
	    }
	    public long nextLong() {
	        return Long.parseLong(next());
	    }
	    public int nextInt(){
	    	return Integer.parseInt(next());
	    }
	}
}

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

using namespace std;

const int md = 1e9 + 7;

inline int add(int a, int b) {
  return (a + b) % md;
}

inline int sub(int a, int b) {
  return (a + md - b) % md;
}

inline int mul(int a, int b) {
  return (int) ((long long) a * b % md);
}

inline int power(int a, int p) {
  if (p == 0) return 1;
  if (p % 2 == 0) {
    int h = power(a, p / 2);
    return mul(h, h);
  } else {
    return mul(a, power(a, p - 1));
  }
}

inline int divide(int a, int b) {
  return mul(a, power(b, md - 2));
}

inline int gcd(int a, int b) {
  if (a % b != 0) return gcd(b, a % b);
  return b;
}

inline int lcm(int a, int b) {
  return a / gcd(a, b) * b;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int h, w, a, b;
  cin >> h >> w >> a >> b;
  vector<int> f(h + w + 1, 1);
  for (int i = 1; i <= h + w; i++) {
    f[i] = mul(f[i - 1], i);
  }
  int ans = 0;
  for (int d = 0; d < w - b; d++) {
    int i1 = h - a - 1;
    int j1 = b + d;
    int c1 = divide(f[i1 + j1], mul(f[i1], f[j1]));
    int i2 = h - i1 - 2;
    int j2 = w - j1 - 1;
    int c2 = divide(f[i2 + j2], mul(f[i2], f[j2]));
    ans = add(ans, mul(c1, c2));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;

int H,W;
int sx,sy;
int bcnt;
bool field[7][7];
bool res = false;
int dx[]={0,1,0,-1};
int dy[]={-1,0,1,0};

void solve(int nowx,int nowy,int ncnt){
  if(res) return;
  if(bcnt-1 == ncnt){
    for(int i=0;i<4;i++){
      int gx=nowx+dx[i],gy=nowy+dy[i];
      if(sx == gx && sy == gy){
	res = true;
	return;
      }
    }
  }
  int neigh_cnt = 0;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(field[i][j]) continue;
      neigh_cnt = 0;
      for(int k=0;k<4;k++){
	int nx=j+dx[k],ny=i+dy[k];
	if(sx == nx && sy == ny) {
	  neigh_cnt++;
	  continue;
	}
	if(nowx == nx && nowy == ny){
	  neigh_cnt++;
	  continue;
	}
	if(nx>=0 && nx<W && ny>=0 && ny<H && field[ny][nx] == false){
	  neigh_cnt++;
	}
      }
      if(neigh_cnt == 1) {
	return;
      }
    }
  }
  for(int i=0;i<4;i++){
    int nx=nowx+dx[i],ny=nowy+dy[i];
    if(nx>=0 && nx<W && ny>=0 && ny<H && field[ny][nx] == false){
      field[ny][nx] = true;
      solve(nx,ny,ncnt+1);
      field[ny][nx] = false;
    }
  }
  return;
}

int main(){
  while(cin >> W >> H, H){
    res = false;
    bcnt = 0;
    for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
	cin >> field[i][j];
	if(!field[i][j]){
	  if(bcnt==0){
	    sx = j;
	    sy = i;
	  }
	  bcnt++;
	}
      }
    }
    if(0) cout << "No" << endl;
    else {
      bool flg = true;
      int neigh_cnt;
      for(int i=0;i<H;i++){
	for(int j=0;j<W;j++){
	  if(field[i][j]) continue;
	  neigh_cnt = 0;
	  for(int k=0;k<4;k++){
	    int nx = j+dx[k],ny = i+dy[k];
	    if(nx>=0&&nx<W&&ny>=0&&ny<H&&field[ny][nx] == false) {
	      neigh_cnt++;
	    }
	  }
	  if(neigh_cnt == 1){
	    flg = false;
	    break;
	  }
	}
	if(!flg) break;
      }
      if(!flg){
	cout << "No" << endl;
      } else {
	field[sy][sx] = true;
	solve(sx,sy,0);
	if(res) cout << "Yes" << endl;
	else cout << "No" << endl;
      }
    }
  }
}

Measured memory_bytes: 3084
N = int(input())
S = input()

E = 0
W = S.count("W")
a, ans = 0, len(S)

for i in range(len(S)):
  if S[i] == "W":
    W -= 1
  a = len(S) - 1 - W - E
  if a < ans:
    ans = a
  if S[i] == "E":
    E += 1

print(ans)

Measured memory_bytes: 3672
W, H, N = map(int, input().split())
xya = []
for i in range(N):
    xya.append(list(map(int, input().split())))

x = [False]*(W)
y = [False]*(H)
for i in range(N):
    if xya[i][2] == 1:
        for j in range(xya[i][0]):
            x[j] = True
    elif xya[i][2] == 2:
        for j in range(xya[i][0], W):
            x[j] = True
    elif xya[i][2] == 3:
        for j in range(xya[i][1]):
            y[j] = True
    elif xya[i][2] == 4:
        for j in range(xya[i][1], H):
            y[j] = True

print(x.count(False)*y.count(False))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define _GLIBCXX_DEBUG
static const int MAX = 50;


int main(){
  int N, v[MAX];
  cin >> N;
  rep(i, N) cin >> v[i];
  sort(v, v+N);
  double x = v[0];
  rep(i, N-1){
    x = (x + v[i+1]) / 2.0;
  }
  cout << x << endl;
}

Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
X = int(input())

#コインの個数
num = 0

for i in range(A+1):
    for j in range(B+1):
        for q in range(C+1):
            if i*500 + j*100 + q*50 == X:
                num += 1
print(num)

Measured memory_bytes: 3060
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<iostream>
#include<algorithm>
#include<stack>
using namespace std;
typedef long long ll;
int main()
{
    string s;
    cin>>s;
    if(s[0]=='S')
        cout<<"Cloudy"<<endl;
    else if(s[0]=='C')
        cout<<"Rainy"<<endl;
    else cout<<"Sunny"<<endl;
    return 0;
}


Measured memory_bytes: 256
def main():
    n, k = map(int, input().split())
    answer = 0
    for i in range(k + 1, n + 1):
        answer += (n // i) * (i - k)
        add = 1
        if k == 0:
            add = 0
        answer += max(n % i - k + add, 0)
    print(answer)


if __name__ == '__main__':
    main()



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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)

ll V[100];

ll C[101][101];
void comb_table(int N){
    for(int i = 0; i <= N; i++){
        for(int j = 0; j <= i; j++){
            if(j == 0 || j == i)
                C[i][j] = 1LL;
            else
                C[i][j] = C[i-1][j-1] + C[i-1][j];
        }
    }
}

int main(){
    ll N, A, B;
    cin >> N >> A >> B;
    REP(i,N){
        ll v;
        cin >> v;
        V[i] = v;
    }
    sort(V, V+N, greater<ll>());

    double ans1 = 0.0;
    REP(i,A){
        ans1 += V[i];
    }
    ans1 /= A;
    printf("%.25lf\n", ans1);

    comb_table(N);

    ll ans2 = 0;
    //if(V[0] == V[A-1]){
    //    ll v = V[0];
    //    sort(V, V+N);
    //    int num = upper_bound(V,V+N,v) - lower_bound(V,V+N,v);
    //    for(int i = A; i <= B; i++){
    //        ans2 += C[num][i];
    //    }
    //}
    //else{
    //    ll v = V[A-1];
    //    sort(V, V+N);
    //    int num = upper_bound(V,V+N,v) - lower_bound(V,V+N,v);
    //    int num2 = upper_bound(V,V+A,v) - lower_bound(V,V+A,v);
    //    ans2 += C[num][num2];
    //}

    int a_th_val_num=0,a_th_val_pos=0;
    for(int i=0;i<N;++i){
        if(V[i]==V[A-1]){
            a_th_val_num++;
            if(i<A){
                a_th_val_pos++;
            }
        }
    }

    if(a_th_val_pos==A){
        for(a_th_val_pos=A;a_th_val_pos<=B;++a_th_val_pos){
            ans2+=C[a_th_val_num][a_th_val_pos];
        }
    }
    else{
        ans2+=C[a_th_val_num][a_th_val_pos];
    }


    cout << ans2 << endl;
    return 0;
}


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

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		while(true){
			int n=scan.nextInt();
			int r=scan.nextInt();
			int[] list=new int[n];
			if(n==0 && r==0){
				break;
			}
			for(int i=0;i<n;i++){
				list[i]=n-i;
			}
			
			for(int i=0;i<r;i++){
				int p=scan.nextInt();
				int c=scan.nextInt();
				int[] nextList=Arrays.copyOf(list,list.length);
				
				for(int j=0;j<p+c-1;j++){
					list[j]=nextList[(p-1+j)%(p+c-1)];
				}
				for(int j=p+c-1;j<n;j++){
					list[j]=nextList[j];
				}
			}
			System.out.println(list[0]);
		}
	}
}

Measured memory_bytes: 37128
#include<iostream>

using namespace std;

int main(void){

    int a, b, tmp = 0;
    int ans = 0;

    cin >> a >> b;

    int i = 0;
    while(1){
        if(tmp < b-1){
            tmp += a-1;
        }else{
            break;
        }

        ans++;

    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
def get_input():
    while True:
        try:
            yield ''.join(input())
        except EOFError:
            break

# Convert String to List
def String2List(s):
    L = []; tmp = ""
    for i in s:
        if i.isdigit():
            tmp += i
        else:
            if tmp != "":
                L.append(tmp)
                tmp = ""
            L.append(i)
    if tmp != "":
        L.append(tmp)

    return L

# generate Reverse Polish Notation
def Generate_RPN(L):
    S, L2 = [], []
    table = {"*": 1, "/": 1, "+": 0, "-": 0, "(": -1, ")": -1}
    for i in L:
        if i.isdigit():
            L2.append(i)
        elif i == "(":
            S.append(i)
        elif i == ")":
            while S[-1] != "(":
                L2.append(S.pop())
            S.pop()
        else:
            while len(S) != 0 and (table[S[-1]] >= table[i]):
                L2.append(S.pop())
            S.append(i)

    while len(S) != 0:
        L2.append(S.pop())

    return L2

Nline = int(input())
for ll in range(Nline):

    S = input()
    p = Generate_RPN(String2List(S[0:-1]))
    N = len(p)

    s = []
    for i in range(len(p)):
        if p[i] == "+":
            a = int(s.pop())
            b = int(s.pop())
            s.append(str(b+a))
        elif p[i] == "-":
            a = int(s.pop())
            b = int(s.pop())
            s.append(str(b-a))
        elif p[i] == "*":
            a = int(s.pop())
            b = int(s.pop())
            s.append(str(b*a))
        elif p[i] == "/":
            a = int(s.pop())
            b = int(s.pop())
            s.append(str(int(b/a)))
        else:
            s.append(p[i])
    print(s[0])



Measured memory_bytes: 5616
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	x := nextInt()

	for i := 1; i <= x; i++ {

		if i*100 <= x && x <= i*105 {
			fmt.Println(1)
			return
		}
	}

	fmt.Println(0)

}

// ---- readfunc
func scanInit() {
	const cap = 200 * 1024 // Default=64
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1780
S = input()

NS = ""
i = 0
while i < len(S):
    if S[i] == "A":
        NS += "A"
    elif i + 1 < len(S) and S[i] == "B" and S[i + 1] == "C":
        NS += "X"
        i += 1
    else:
        NS += "Z"
    i += 1

NS = NS[::-1]
res = 0
pos = -1

for i, s in enumerate(NS):
    if pos != -1 and s == "A":
        res += i - pos
        pos += 1
    elif pos == -1 and s == "X":
        pos = i
    elif s == "Z":
        pos = -1

print(res)


Measured memory_bytes: 3560
import java.util.*;

public class Main{
	private static final Scanner scan = new Scanner(System.in);

	public static void main(String[] args){
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		int cnt = 0;
		for(int i = a; i <= b; i++){
			if(c % i == 0){
				cnt++;
			}
		}
		System.out.printf("%d\n", cnt);
	}
}

Measured memory_bytes: 26448
def cnct(lint,lim):
    global list753
    global list357
    global list333
    lint1int=lint*10+3
    if lint1int<=lim and not lint1int in list357:
        list357.add(lint1int)
        cnct(lint1int,lim)
    lint2int=lint*10+5
    if lint2int<=lim and not lint2int in list357:
        list357.add(lint2int)
        cnct(lint2int,lim)
    lint3int=lint*10+7
    if lint3int<=lim and not lint3int in list357:
        list357.add(lint3int)
        cnct(lint3int,lim) 

def D(lint):
    lista=list(str(lint))
    if lista.count("3") and lista.count("5") and lista.count("7"):
        return True
    else:
        return False

list753=[3,5,7]
list357=set()
k=int(input())
for b in list753:
    cnct(b,k)
for c in [x for x in list357]:
    if not D(c):
        list357.remove(c)
print(len(list357))

Measured memory_bytes: 48104
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007 // 10^9+7
#define INF 99999999999 //10^12-1
#define dev 998244353 //tenka1
#define P pair<int,int>
#define F first
#define S second
int n,start;
int ans=1;
bool b=true;
string s,t;
signed main(){
    cin>>n>>s>>t;
    if(s[0]==t[0]){
        start=1;
        ans*=3;
    }
    else{
        start=2;
        ans*=6;
    }
    for(int i=start;i<n;i++){
        if(s[i-1]==t[i-1])ans*=2;
        else if(s[i]!=t[i])ans*=3;
        if(s[i]!=t[i])i++;
        ans%=mod;
    }
    cout<<ans<<endl;
    return 0;
}





Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication6
{
    class Program
    {
        static List<List<long>> ls = new List<List<long>>();
        static long X;
        static long M;
        static long N;
        static void Main(string[] args)
        {
            //var length = c2i(RL());
            var rl = spr(RL()).Select(x=>c2i(x)).ToList();

            N = rl[0];
            M = rl[1];
            X = rl[2];
            for (int i = 0; i < N; i++)
            {
                ls.Add(spr(RL()).Select(x => c2i(x)).ToList());
            }
            var sum = new List<long>();
            for (int i = 0; i < M; i++) sum.Add(0);
            
            long ret=-1;
            foreach (var lst in ls)
            {
                for (int i = 1; i < M+1; i++)
                {
                    sum[i-1] += lst[i];
                }
            }
            bool ok = isOver(sum);
            if (!ok)
            {
                sum.Clear();
                for (int i = 0; i < M; i++) sum.Add(0);

                ret=fs(0, sum, 0,10000000000);
            }



            Console.WriteLine(ret);
            Console.ReadLine();
        
        }
        static long fs(int current,IEnumerable<long> sum,long pay,long cheap)
        {
            var min = 10000000000;
            if (current >= N)
            {
                if (isOver(sum)) return min;
                return pay;
            }
            var next = sum.Select((x, i) => x + ls[current][i+1]).ToList();
            if (isOver(next))
            {
                cheap=Math.Min(fs(current + 1, next,pay+ls[current][0],cheap),cheap);
            }
            else
            {
                cheap = Math.Min(pay + ls[current][0], cheap);
            }
                
            return Math.Min(fs(current + 1, sum, pay,cheap),cheap);
            

            
        }
        static bool isOver(IEnumerable<long> l)
        {
            return l.Any(x => x < X);
        }
        static string RL() { return Console.ReadLine().Trim(); }
        static IEnumerable<string> spr(string s) { return s.Split(' '); }
        static Int64 c2i(string c) { return Int64.Parse(c); }
        //static double c2d(string c) { return double.Parse(c); }
        static string bool2ret(bool b) { return b ? "Yes" : "No"; }
    }
}


Measured memory_bytes: 30616
import java.util.*;
import static java.lang.System.out;

public class Main {
    public static void main(String... args) {
        Scanner sc = new Scanner(System.in);
        //int a = Integer.parseInt(sc.next());
        //int b = Integer.parseInt(sc.next());
        //int c = Integer.parseInt(sc.next());
        String in = sc.nextLine();
        if(in.length() >= 4 &&
                in.substring(2,3).equals(in.substring(3,4))
                &&
            in.length() >= 6 &&
                    in.substring(4,5).equals(in.substring(5,6))) {
            out.println("Yes");
        } else {
            out.println("No");
        }
        //System.out.println(a + " " + b + " " + c);

    }
}

Measured memory_bytes: 25172
import java.util.*;
public class Main{

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int cnt = 0;


        for(int i =0;i<n;i++){
            int a = sc.nextInt();
            int b = sc.nextInt();
            cnt+=(b-a+1);

        }
        System.out.println(cnt);

    }
}



Measured memory_bytes: 25044
import string

def fun(x):
    for c in x:
        if c not in string.digits:
            return -1
    return int(x)

while(1):
    [W,H]=map(int, raw_input().split())
    if W==0: break
    A=[]
    for i in range(H):
        A.append(raw_input())
    B=[['a' for i in range(W+1)] for j in range(H+1)]
    ans=-1
    for p in range(2, H+2):
        for q in range(2, W+2):
            [j,k]=[-p,-q]
            C= map(lambda x: A[j+1][k+1]+x, ['', B[j+1][k] , B[j][k+1] ]    )
            D=sorted(sorted(C, key = lambda x: len(x) ), key= lambda x: fun(x)) [-1]
            if fun(D)!=-1:
                B[j][k]=D
                ans=max(ans,int(B[j][k]))
    print ans

Measured memory_bytes: 4920
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, begin, end) for(ll i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(ll i=(begin)-1;i>=(end);i--)
#define IREP(i, n) IFOR(i,n,0)
#define SORT(a) sort(a.begin(), a.end())
#define ISORT(a) sort(a.begin(), a.end(),greater<ll>())
#define REVERSE(a) reverse(a.begin(), a.end())
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=(" << v[0]; FOR(i_debug, 1, v.size()){ cout << "," << v[i_debug]; } cout << ")" << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)

#define ll long long
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define INF 1000000000000000000

using vec = vector<ll>;
using mat = vector<vec>;
using Pii = pair<ll, ll>;
using PiP = pair<ll, Pii>;
using PPi = pair<Pii, ll>;
using bvec = vector<bool>;
using Pvec = vector<Pii>;


template<typename T> void readv(vector<T> &a) { REP(i, a.size()) cin >> a[i]; }
void readv_m1(vector<int> &a) { REP(i, a.size()) {cin >> a[i]; a[i]--;} }

ll mod = 1000000007;

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

	ll minx = max((ll)-1000000, X - K + 1);
	ll maxx = min((ll)1000000, X + K - 1);

	FOR(i, minx, maxx) {
		cout << i << " ";
	}
	cout << maxx << endl;

	return 0;
}

Measured memory_bytes: 256
def main():
    k = int(input())
    if k & 0:
        print(-1)
        return

    r = 7 % k
    l = 0
    while r and l < k:
        r = (r * 10 + 7) % k
        l += 1

    print([l+1, -1][l == k])


if __name__ == '__main__':
    main()


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

int main(){
               string S;cin >> S;
               if (S == "Sunny")cout << "Cloudy" <<endl;
               if (S == "Cloudy")cout << "Rainy" <<endl;
               if (S == "Rainy")cout << "Sunny" <<endl;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var N = int.Parse(Console.ReadLine());

        var X = new List<int>();
        var Y = new List<int>();
        for(int i = 0; i < N; i++)
        {
            var input = Console.ReadLine().Split(" ");
            var x = int.Parse(input[0]);
            var y = int.Parse(input[1]);
            X.Add(x);
            Y.Add(y);
        }

        double sum = 0;
        var permutation = GetPermutation(Enumerable.Range(1, N));
        foreach (var item in permutation)
        {
            for(int i = 0; i < N - 1; i++)
            {
                var xi = X[item[i] - 1];
                var yi = Y[item[i] - 1];

                var xj = X[item[i+1] - 1];
                var yj = Y[item[i+1] - 1];

                sum += Math.Sqrt(Math.Pow(xi - xj, 2) + Math.Pow(yi - yj, 2));
            }

        }

        var average = (double)sum / permutation.Count();
        Console.WriteLine(average);

    }

    public static IEnumerable<T[]> GetPermutation<T>(IEnumerable<T> collection)
    {
        // 未確定要素が一個のみ
        if (collection.Count() == 1)
        {
            yield return new T[] { collection.First() };
        }

        foreach (var item in collection)
        {
            var selected = new T[] { item };
            var unused = collection.Except(selected);

            // 確定した要素以外の組み合わせを再帰で取り出し連結
            foreach (var rightside in GetPermutation(unused))
            {
                yield return selected.Concat(rightside).ToArray();
            }
        }
    }
}



Measured memory_bytes: 47300
extern crate core;

use std::fmt;
use std::cmp::{Ordering, min, max};
use std::fmt::{Display, Error, Formatter};
use std::ops::{Index, IndexMut, Add, AddAssign, Sub, SubAssign, Mul, MulAssign};
use std::collections::VecDeque;
use std::f32::MAX;

fn show<T: Display>(vec: &Vec<T>) {
    if vec.is_empty() {
        println!("[]");
    }else {
        print!("[{}", vec[0]);
        for i in 1 .. vec.len() {
            print!(", {}", vec[i]);
        }
        println!("]");
    }
}
macro_rules! read_line{
    () => {{
        let mut line = String::new();
        std::io::stdin().read_line(&mut line).ok();
        line
    }};
    (delimiter: ' ') => {
        read_line!().split_whitespace().map(|x|x.to_string()).collect::<Vec<_>>()
    };
    (delimiter: $p:expr) => {
        read_line!().split($p).map(|x|x.to_string()).collect::<Vec<_>>()
    };
    (' ') => {
        read_line!(delimiter: ' ')
    };
    ($delimiter:expr) => {
        read_line!(delimiter: $delimiter)
    };
    (' '; $ty:ty) => {
        read_line!().split_whitespace().map(|x|x.parse::<$ty>().ok().unwrap()).collect::<Vec<$ty>>()
    };
    ($delimiter:expr; $ty:ty) => {
        read_line!($delimiter).into_iter().map(|x|x.parse::<$ty>().ok().unwrap()).collect::<Vec<$ty>>()
    };
}
macro_rules! let_all {
    ($($n:ident:$t:ty),*) => {
        let line = read_line!(delimiter: ' ');
        let mut iter = line.iter();
        $(let $n:$t = iter.next().unwrap().parse().ok().unwrap();)*
    };
}

struct Circle {
    radius: f64
}
impl Circle {
    fn new(radius: i32) -> Circle {
        Circle {radius: radius as f64}
    }
}
struct Cylinder {
    radius: f64, position: f64
}
impl Cylinder {

    fn horizontal_distance(&self, other: &Circle) -> f64 {
        let diff = self.radius - other.radius;
        let sum = self.radius + other.radius;
        (sum * sum - diff * diff).sqrt()
    }
}
fn main() {
    let_all!(n: usize);
    let circles: Vec<_> = (read_line!(' '; f64) as Vec<f64>).iter().map(|&r| Circle {radius: r}).collect();
    let mut cylinders = Vec::new();
    for c in &circles {
        if cylinders.is_empty() {
            cylinders.push(Cylinder{radius: c.radius, position: c.radius});
        }else {
            let mut max = c.radius;
            for o in &cylinders {
                let new_pos = o.horizontal_distance(c) + o.position;
                if max < new_pos {
                    max = new_pos;
                }
            }
            cylinders.push(Cylinder{radius: c.radius, position: max});
        }
    }
    let mut result = 0_f64;
    for c in &cylinders {
        if result < c.position + c.radius {
            result = c.position + c.radius;
        }
    }
    println!("{:.*}", 15, result);
}


Measured memory_bytes: 5072
#include <queue>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <ctype.h>
#include <algorithm>
#define mp make_pair

using namespace std;

typedef long long LL;
typedef pair<int, int> pii;
typedef pair<int, LL> pil;

const int MAXN = 1e5 + 7;

template<typename T> inline T read() {
	T res = 0, flag = 1; char in = getchar();
	while(!isdigit(in)) { if(in == '-') flag = -1; in = getchar(); }
	while(isdigit(in)) { res = (res << 1) + (res << 3) + in - '0'; in = getchar(); }
	return res * flag;
}

template<typename T> inline void chkmax(T &a, T b) { if(a < b) a = b; }
template<typename T> inline void chkmin(T &a, T b) { if(a > b) a = b; }

int n, m;
int dex, head[MAXN], to[MAXN], nxt[MAXN];
int rod[MAXN], dis[MAXN], ans;
queue<int> Q;

inline void Link(int x, int y) { ++dex; nxt[dex] = head[x]; to[dex] = y; head[x] = dex; }

inline void init() {
	n = read<int>(); m = read<int>();
	for(int i = 1; i <= m; ++i) {
		int x = read<int>();
		int y = read<int>();
		++rod[x]; Link(y, x);
	}
	for(int i = 1; i <= n; ++i) if(!rod[i]) Q.push(i);//, dis[i] = 0;
}

inline void solve() {
	while(!Q.empty()) {
		int u = Q.front(); Q.pop();
		for(int i = head[u]; i; i = nxt[i]) {
			int v = to[i];
			--rod[v];
			if(rod[v] == 0) Q.push(v);
			chkmax(dis[v], dis[u] + 1);
		}
	}
	for(int i = 1; i <= n; ++i) chkmax(ans, dis[i]);
	cout << ans << endl;
}

int main() {

	init();
	solve();

	return 0;
}



Measured memory_bytes: 2432