akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=22,mod=998244353;
ll fc[N],ifc[N],p[N],col[N][N][3],row[N][N][3];
ll inv(ll x){return x<=1?x:(mod-mod/x)*inv(mod%x)%mod;}
ll C(int n,int m)
{
    return fc[n]*ifc[n-m]%mod*ifc[m]%mod;
}
ll iC(int n,int m)
{
    return inv(C(n,m));
}
int n,m,r[N],c[N];
char s[N][N];
void init()
{
    fc[0]=fc[1]=ifc[0]=ifc[1]=p[0]=1;
    for(int i=2;i<N;i++) fc[i]=fc[i-1]*i%mod,ifc[i]=(mod-mod/i)*ifc[mod%i]%mod;
    for(int i=2;i<N;i++) ifc[i]=ifc[i]*ifc[i-1]%mod;
    for(int i=1;i<N;i++) p[i]=p[i-1]*2%mod;
}
void Dp()
{
    for(int j=1;j<=m;j++)
        col[n][j][2]=C(m,j)*p[m-j]%mod;
    ll ans=p[m];
    for(int i=n;i>=1;i--)
        for(int j=m;j>=1;j--)
    {
        col[i][j][0]=(col[i][j][1]+col[i][j][2])%mod;
        for(int k=1;k<i;k++)
        {
            int d=i-k;
            (row[k][j][1]+=C(i,d)*(col[i][j][2]*2+col[i][j][1])%mod)%=mod;
            (row[k][j][2]+=C(i,d)*(p[d]-2)%mod*col[i][j][2]%mod)%=mod;
        }
        ans=(ans+col[i][j][2]*(p[i]-2))%mod;
        row[i][j][0]=(row[i][j][1]+row[i][j][2])%mod;
        for(int k=1;k<j;k++)
        {
            int d=j-k;
            (col[i][k][1]+=C(j,d)*(row[i][j][2]*2+row[i][j][1])%mod)%=mod;
            (col[i][k][2]+=C(j,d)*(p[d]-2)%mod*row[i][j][2]%mod)%=mod;
        }
        ans=(ans+row[i][j][2]*(p[j]-2))%mod;
    }
    int upn=1<<n,upm=1<<m;
    for(int i=1;i<upn;i++)
        for(int j=1;j<upm;j++)
    {
        bool flag=true;
        for(int k=0;k<n;k++)
            if(i>>k&1)
        {
            int w=r[k+1]&j;
            if(w==j||w==0) flag=false;
        }
        for(int k=0;k<m;k++)
            if(j>>k&1)
        {
            int w=c[k+1]&i;
            if(w==i||w==0) flag=false;
        }
        if(!flag) continue;
        int x=__builtin_popcount(i),y=__builtin_popcount(j);
        ans=(ans+(row[x][y][0]+col[x][y][0])*iC(n,x)%mod*iC(m,y))%mod;
    }
    printf("%lld\n",ans);
}
int main()
{
    init();
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++) scanf("%s",s[i]+1);
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
        if(s[i][j]=='.') r[i]|=1<<j>>1,c[j]|=1<<i>>1;
    Dp();
}


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

int main()
{
	int n;
	int t;
	int h,ph;
	int maxup,maxdown;

	cin >> t;	
	for(int i=0;i<t;i++){
		maxup=0;
		maxdown=0;
		cin >> n;
		cin >> ph;
		for(int j=1;j<n;j++){
			cin >> h;
			if(maxup<h-ph)maxup=h-ph;
			if(maxdown>h-ph)maxdown=h-ph;
			ph=h;
		}
		cout << maxup << " " << -1*maxdown << endl;
	}
	return 0;
}
			

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

int main() {
  string s;
  cin>>s;
  
  for(int i=0;i<3;++i){
    if(s[i]=='1')
      s[i]='9';
    else if(s[i]=='9')
      s[i]='1';
  }
  
  cout<<s<<endl;
  
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxn=305;
int dis[maxn][maxn];
bool notneed[maxn][maxn];
int main(){
  int n;scanf("%d",&n);
  for(int i=1;i<=n;++i){
    for(int j=1;j<=n;++j){
      scanf("%d",&dis[i][j]);
    }
  }
  bool flag=true;
  for(int i=1;i<=n;++i){
    for(int j=1;j<=n;++j){
      for(int k=1;k<=n;++k){
    if(i!=j&&j!=k&&k!=i){
      if(dis[i][j]+dis[j][k]<dis[i][k])flag=false;
      if(dis[i][j]+dis[j][k]==dis[i][k])notneed[i][k]=true;
    }
      }
    }
  }
  if(!flag){
    printf("-1\n");
  }else{
    long long ans=0;
    for(int i=1;i<=n;++i){
      for(int j=i+1;j<=n;++j){
    if(!notneed[i][j])ans+=dis[i][j];
      }
    }
    printf("%lld\n",ans);
  }
  return 0;
}

Measured memory_bytes: 640
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#define Rint register int
#define mem(a,b) memset(a,(b),sizeof(a))
using namespace std;
typedef long long LL;
template<typename T>inline void read(T &x){
    x=0;T w=1,ch=getchar();
    while(!isdigit(ch)&&ch!='-')ch=getchar();
    if(ch=='-')w=-1,ch=getchar();
    while(isdigit(ch))x=(x<<3)+(x<<1)+(ch^'0'),ch=getchar();
    x=x*w;
}
inline void File(){
    freopen("fuck.in","r",stdin);
    freopen("fuck.out","w",stdout);
}

int a,b;
int ans;

int main(){
    //File();
	read(a);read(b);
	ans+=a;
	if(b<a)ans--;
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if (a%3 == 0 || b%3 == 0 || (a+b) % 3 == 0) {
            System.out.println("Possible");
        } else {
            System.out.println("Impossible");
        }
    }
}

Measured memory_bytes: 23636
using System;

namespace TorT
{
    class BProgram
    {
        static void Main(string[] args)
        {
            string[] list = Console.ReadLine().Split(' ');

            int N = int.Parse(list[0]);
            int A = int.Parse(list[1]);
            int B = int.Parse(list[2]);

            Console.WriteLine((N * A) > B ? B : N * A);
        }
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;


int main(void) {
    
    ll n,k;
    cin>>n>>k;
    ll ans=0;
    for(int b=1;b<=n;b++){
        ans+=n/b*max(0LL,b-k)+max(0LL,n%b-k+1);
    }
    if(k == 0) ans -= n;
    fin(ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int max(int a,int b)
{
    return (a>b)?a:b;
}
int main()
{
    int n,w;
    cin>>n>>w;
    long long int a[n],b[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i]>>b[i];
    }
    long long int dp[n+1][w+1];
    for(int i=0;i<n+1;i++)
    {
        dp[i][0]=0;
    }
    for(int j=0;j<w+1;j++)
    {
        dp[0][j]=0;
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=w;j++)
        {
            if(j<a[i-1])
            {
                dp[i][j]=dp[i-1][j];
            }
            else
            {
                dp[i][j]=max(dp[i-1][j],b[i-1]+dp[i-1][j-a[i-1]]);
            }
        }
    }
    cout<<dp[n][w]<<endl;
    return 0;
}

Measured memory_bytes: 79104
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define ctoi(x) x-'0'
#define pshb(a) cin >> x;a.push_back(x)
#define fr(i,n) for(ll i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(false);
using namespace std;
bool a[3] ;
int main()
{
     ll n ; cin>>n ;
     string a , b ;
     cin>>a>>b ;
     for (int i =0 ; i< n ; i++)
        cout<<a[i]<<b[i] ;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define REP(i,j) for(int i=0;i<j;i++)
#define FORN(i,j,k) for(int i=j;i<k;i++)
#define vi vector<int>
#define vvi vector<vi >
#define pii pair<int,int>
#define vpii vector<pii >
using namespace std;
int A,B,M;
int a[100005],b[100005],x[100005],y[100005],c[100005];
int main(void){
	cin>>A>>B>>M;
	int minn_a=1e5,minn_b=1e5;
	REP(i,A){
		cin>>a[i];
		minn_a=min(minn_a,a[i]);
	}
	REP(i,B){
		cin>>b[i];
		minn_b=min(minn_b,b[i]);
	}
	int ans=minn_a+minn_b;
	REP(i,M){
		cin>>x[i]>>y[i]>>c[i];
		x[i]--;
		y[i]--;
		ans=min(ans,a[x[i]]+b[y[i]]-c[i]);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> V;
#define rep(cnt,e) for(ll cnt=0;cnt<e;cnt++ )
typedef pair<ll,ll> P;
const ll mod = 1e9+7;
const ll INF = INT64_MAX;
typedef tuple<ll,ll,ll,ll> T;


ll i,j,k;


int main(){
  ll N,M,X;
  cin>>N>>M>>X;
  V C(N);
  vector<V> A(N,V(M));
  rep(i,N){
      cin>>C[i];
      rep(j,M)cin>>A[i][j];
  }
  ll ans=-1;
  for(ll bit=0;bit<(1<<N);bit++){
      ll point[M];
      ll cost=0;
      rep(i,M)point[i]=0;
      for(ll w=0;w<N;w++){
          if(bit>>w&1){
              cost+=C[w];
              rep(i,M)point[i]+=A[w][i];
          }
      }
      ll jud=false;
      rep(k,M){
          if(point[k]<X){
              jud=true;
              break;
          }
      }
      if(jud)continue;
      if(ans==-1)ans=cost;
      else ans=min(ans,cost);
  }
  cout<<ans<<endl;

}


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

int main()
{
    double  a,b;
    cin>>a>>b;
    long long int  a1 = a;
    long long int  a2 = b;
    long long int  ans_1 = a1 * a2;
    b = b - double(a2);
    double ans_2 = b * double(a1);
    double ans = ans_2 + double(ans_1);
    long long int ans_3 = ans_2 + ans_1;
    cout<<ans_3<<"\n";
    return 0;
}


Measured memory_bytes: 3708
n, m = gets.split.map(&:to_i)
s = gets.chomp

d = Array.new(n+1)
i = 0
j = 1
while j <= n
    j += 1 while s[j] == ?1
    i += 1 while s[i] == ?1 || i + m < j

    break if i == j
    d[j] = i
    j += 1
end

if d[n]
    ans = []
    while n != 0
        ans.unshift(n - d[n])
        n = d[n]
    end
    puts ans * " "
else
    puts -1
end

Measured memory_bytes: 4092
# N = int(input())
# A = [int(x) for x in input().split()]
# V = [[0] * 100 for _ in range(100)]

A, B = [int(x) for x in input().split()]

ans = 0
if A >= 13:
    ans = B
elif 6 <= A and A <= 12:
    ans = B // 2

print(ans)


Measured memory_bytes: 2940
//ｺｯwwｺｯwwｺｹｯwwwｺｯwwｺｹｯwwwｺｹｯｺｯwwwｺｯwwｺｯwwｺｹｯwwwｺｯwwｺｹｯwwwｺｹｯｺｯwwwｺｹｰｰｰｰｯ!!!wwwwwｺｯwwｺｯwwｺｹｯwwwｺｯwwｺｹｯwwwｺｹｯｺｯwwwｺｯwwｺｯwwｺｹｯwwwｺｯwwwｺｹｯwwwｺｹｯｺｯwwwｺｹｰｰｰｰｯ!!!wwwwwｺｹｯｺｯｯｺｰｰｰｰ!!!!!!wwwwwwwwwww
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        char[] a = new char[4];
        for(int i = 0 ; i < 4 ; i++){
            a[i] = s.charAt(i);
        }
        sc.close();
        Arrays.sort(a);
        if(a[0] == a[1] && a[1] != a[2] && a[3] == a[2]){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

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

int main() {
    string S, T;
    int64_t q;
    cin >> S >> T >> q;
    vector<int64_t> a(q), b(q), c(q), d(q);
    for (int64_t i = 0; i < q; i++) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }

    //B->AA->BBBB->Bと戻せるのでBを一度全てAAに変換して考える
    //結局Aの数を3で割った余りが一致していれば変換可能
    //累積和を計算
    vector<int64_t> sum_S(S.size() + 1), sum_T(T.size() + 1);
    sum_S[0] = sum_T[0] = 0;
    for (uint64_t i = 0; i < S.size(); i++) {
        sum_S[i + 1] = sum_S[i] + (S[i] == 'A' ? 1 : 2);
    }
    for (uint64_t i = 0; i < T.size(); i++) {
        sum_T[i + 1] = sum_T[i] + (T[i] == 'A' ? 1 : 2);
    }

    for (int64_t i = 0; i < q; i++) {
        int64_t num_S = sum_S[b[i]] - sum_S[a[i] - 1];
        int64_t num_T = sum_T[d[i]] - sum_T[c[i] - 1];
        cout << (num_S % 3 == num_T % 3 ? "YES" : "NO") << endl;
    }
}

Measured memory_bytes: 5632
N = int(input())
c = -1
s = 0
for i in range(N):
    ai,bi = map(int,input().split())
    s += ai
    if ai > bi:
        if c == -1:
            c = bi
        if bi < c:
            c = bi
if c == -1:
    print(0)
else:
    print(s-c)

Measured memory_bytes: 3060
#include <iostream>
#include <utility>
#include <stdint.h>
#include <vector>
#include <algorithm>

using namespace std;

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

  vector<unsigned> A,B;

  for (unsigned n=0; n<N; ++n) {
    unsigned a, b;
    cin >> a >> b;
    A.push_back(a);
    B.push_back(b);
  }

  sort(A.begin(), A.end());
  sort(B.begin(), B.end());

  if (N%2==1) {
    cout << B[N/2] - A[N/2] + 1 << endl;
  } else {
    unsigned min = A[N/2-1] + A[N/2];
    unsigned max = B[N/2-1] + B[N/2];
    cout << max - min + 1 << endl;
  }

  return 0;
}


Measured memory_bytes: 5096
#include <stdio.h>
#include <stdlib.h>

int main(void){
    int n, m, x, y, i, xx, yy;
    scanf("%d %d %d %d", &n, &m, &x, &y);
    int xmax = x, ymin = y;
    for(i=0; i<n; i++){
        scanf("%d", &xx);
        if(xx > xmax) xmax = xx;
    }
    for(i=0; i<m; i++){
        scanf("%d", &yy);
        if(yy < ymin) ymin = yy;
    }
//    printf("%d %d\n", xmax, ymin);
    if(ymin-xmax > 0) printf("No War");
    else printf("War");
}


Measured memory_bytes: 128
#include<iostream>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
const int N=50000005;
int s,len[N],p[N];
ll qpow(ll a,ll n)
{
    ll ans=1;
    while(n)
    {
        if(n&1) ans=ans*a%mod;
        a=a*a%mod;
        n>>=1;
    }
    return ans;
}
int main()
{
    p[0]=1;
    scanf("%d",&s);
    ll ans=0;
    int sum=0;
    for(int l=1,r=0;l<10000000;l++)
    {
        while(sum<s)
        {
            r++;
            p[r]=p[r-1];
            len[r]=len[r-1];
            if(r/p[r]!=0) p[r]*=10,len[r]++;
            sum+=len[r];
        }
        if(sum==s) ans++;
        sum-=len[l];
    }
    for(int t=1;t<=s/8;t++)
    {
        if(s%t) ans=(ans+1)%mod;
        else ans=(ans+(qpow(10,s/t)-qpow(10,s/t-1)-t+1))%mod;
    }
    ans=(ans+mod)%mod;
    printf("%lld\n",ans);
}

Measured memory_bytes: 178432
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;
//debug 
#ifdef _DEBUG
#define debug(var)  do{cout << #var << " :";view(var);}while(0)
#else
#define debug(...)
#endif
template<typename T> void view(T e){cout << e << endl;}
template<typename T> void view(const vector<T>& v){for(const auto& e : v){ cout << e << " "; } cout << endl;}
template<typename T> void view(const vector<vector<T> >& vv){ for(const auto& v : vv){ view(v); } }


int main(){
  int n, l;
  cin >> n >> l;
  vector<string> s(n);
  REP(i,n) cin >> s[i];
  sort(ALL(s));
  REP(i,n) cout << s[i] << ((i == n-1) ? "\n": "");
  return 0;
}

Measured memory_bytes: 3612
#include<iostream>
using namespace std;
int main()
{
  char a, b;
  cin >> a >> b;
  if(b == 'H')
  {
    if(a == 'H')
      cout << "H";
    else 
      cout << "D";
  }
  if(b == 'D')
  {
    if(a == 'D')
      cout << "H";
    else
      cout << "D";
  }
  return 0;
}

Measured memory_bytes: 256
S = input()
T = input()
slist = []
for i in range(0, len(S)):
	slist.append(S[i])
slist.sort()
newS = ''
for i in range(0, len(slist)):
	newS = newS + slist[i]
tlist = []
for i in range(0, len(T)):
	tlist.append(T[i])
tlist.sort(reverse = True)
newT = ''
for i in range(0, len(tlist)):
	newT = newT + tlist[i]
if newS < newT:
	print('Yes')
else:
	print('No')

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

using namespace std;

#define REP(var, n)  for (decltype(n) var = 0; var < (n); var++)
#define RREP(var, n)  for (auto var = n - 1; var != static_cast<decltype(var)>(-1); var--)
#define FOR(var, a, b)  for (auto var = (a); var < (b); var++)
#define RFOR(var, a, b)  for (auto var = b - 1; var != a; var--)

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;

#define all(c) begin(c),end(c)

#define D(x) do { std::cerr << x << " "; } while (0)
#define D2(x) do { std::cerr << #x << ": " << x << std::endl; } while (0)


template<typename T>
std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
    if (!v.empty()) {
        out << '[';
        std::copy(v.begin(), v.end(), std::ostream_iterator<T>(out, ", "));
        out << "\b\b]";
    }
    return out;
}


template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    return os << '(' << p.first << ',' << p.second << ')';
}


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

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


auto solve() {
    ll K, A, B;
    cin >> K >> A >> B;
    if (B - A <= 2) {
        return K + 1;
    }

    ll diff = B - A;
    ll inc = A - 1;
    ll c = K;
    c -= inc;
    if (c <= 0)
        return K + 1;

    ll mul = c / 2;
    ll add = c % 2;

    return A + mul * diff + add;
}


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

//    cout << (solve() ? "even" : "odd") << endl;
//    cout << (solve() ? "YES" : "NO") << endl;
    cout << solve() << endl;
//    solve();

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std; 
#define int long long int
#define loop for(int i=0;i<n;i++)
#define pb push_back	
int32_t main()
{
string a,b;
cin>>a>>b;
int flag=1;
for(int i=0;i<b.size()-1;i++)
if(a[i]!=b[i])
flag=0;
if(flag)
puts("Yes");
else
puts("No");





}
		
		
				
			
			
		

		
				


Measured memory_bytes: 3596
n = gets.to_i

c = []
s = []
f = []
(n-1).times do 
    x,y,z = gets.split.map(&:to_i)
    c << x
    s << y
    f << z
end

n.times do |i|
    now = i
    t = 0

    while now < n - 1
        if t < s[now]
            t = s[now]
        else
            t = (t.to_f / f[now]).ceil * f[now]
        end
        
        t += c[now]
        now += 1
    end

    puts t
end

Measured memory_bytes: 3836
#include <stdio.h>

int Abs(int x, int y){
	if(x > y){
		return x - y;
	}
	else{
		return y - x;
	}
}

int main(){
	int N, M, i, j, min, dis, ans;
	scanf("%d%d", &N, &M);
	int a[N], b[N], c[M], d[M];
	for(i = 0; i < N; i++){
		scanf("%d%d", &a[i], &b[i]);
	}
	for(i = 0; i < M; i++){
		scanf("%d%d", &c[i], &d[i]);
	}
	for(i = 0; i < N; i++){
		min = (int)(1e9);
		for(j = 0; j < M; j++){
			dis = Abs(a[i], c[j]) + Abs(b[i], d[j]);
			if(dis < min){
				min = dis;
				ans = j;
			}
		}
		printf("%d\n", ans + 1);
	}
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main
{
	public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);
		
		for(; ;)
		{
			int n = scanner.nextInt();
			int m = scanner.nextInt();
			if(n==0 && m==0)
			{
				break;
			}
			
			boolean[] pass = new boolean[n];
			
			int p = -1;
			for(int i=0; i<n-1; i++)
			{
				for(int j=0; j<m;)
				{
					p = ++p%n;
					
					if(!pass[p])
					{
						j++;
					}
				}
				pass[p] = true;
			}
			
			for(int i=0; i<n; i++)
			{
				if(!pass[i])
				{
					System.out.println(String.valueOf(i+1));
					break;
				}
			}
		}
	}
}

Measured memory_bytes: 26876
#include<bits/stdc++.h>
#define ll long long
using namespace std;
struct yu
{
	ll p,v;
}a[100001];
int n;
ll s,ans,l,r;
bool cmp(yu x,yu y)
{
	return x.p<y.p;
}
int main()
{
	scanf("%d %lld",&n,&s);
	for (int i=1;i<=n;i++)scanf("%lld %lld",&a[i].p,&a[i].v);
	sort(a+1,a+1+n,cmp);
	l=1;r=n;
	while (r>=l)
	{
		if (a[r].p<=s)
		{
			ans+=s-a[l].p;
			break;
		}
		if (a[l].p>=s)
		{
			ans+=a[r].p-s;
			break;
		}
		ans+=a[r].p-a[l].p;
		if (a[l].v>=a[r].v)
		{
			while (l<r&&a[l].v>=a[r].v)a[l].v+=a[r--].v;
		}
		else
		{	
			while (l<r&&a[r].v>a[l].v)a[r].v+=a[l++].v;
		}
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 5360
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=200005;
ll n,m,k,x,suma[maxn],sumb[maxn];
int ans=0;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	cin>>n>>m>>k;
	for(int i=1; i<=n; i++)
		cin>>x,suma[i]=suma[i-1]+x;
	for(int i=1; i<=m; i++)
		cin>>x,sumb[i]=sumb[i-1]+x;
	for(int i=0;i<=n&&suma[i]<=k;i++){
		ll rem=k-suma[i];
		int id=upper_bound(sumb,sumb+m+1,rem)-sumb;
		ans=max(ans,i+id-1);
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 6724
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define ff first
#define ss second
#define vll vector<ll>
#define pii pair<ll,ll>
#define sz(v) (v).size()
#define srt(v) sort(v.begin(),v.end())
#define ull unsigned long long
#define tell(a) cout<<a<<" "
#define el cout<<endl
#define rev(v) reverse(v.begin(),v.end())
#define rep(i,a,n) for(int i=a;i<n;i++)
#define M 1000000007
ll power(ll x, ll y, ll p){ll res = 1;x = x % p;while (y > 0){   if (y & 1)res = (res*x) % p;y = y>>1;
x = (x*x) % p;}return res;}



int main()
{
	IOS;
	map<int,int>m;
	int n,mx=-1;
	cin>>n;
	vll v(n);
	rep(i,0,n)
	{
	  cin>>v[i];
	  mx=max((ll)mx,v[i]);
	  m[v[i]]++;
	}
	srt(v);
	int ans=0;
	for(int i=0;i<n;i++)
	{
		if(m.find(v[i])!=m.end())
		for(int j=v[i]*2;j<=mx;j+=v[i])
		{
			if(m.find(j)!=m.end())
			m.erase(j);
		}
	}
	for(auto it=m.begin();it!=m.end();it++)
	{
		if(it->second==1)
		ans++;
	}
	cout<<ans;
	
	
	
}



Measured memory_bytes: 14212
/*
Code by b21
Time: 19:00 Sun 01/03/2020
*/

#include <bits/stdc++.h>

using namespace std;

const int mn = 1 * (int)(1e5) + 10;
const int mod = 1 * (int)(1e9) + 7;
const int mm = 1 * (int)(1e3) + 10;
const int base = 1 * (int)(1e9);
const bool aNs = 0;

int tt, ntest = 1;
void docfile()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    if (ifstream("test.inp"))
    {
       freopen("test.inp", "r", stdin);
       if (!aNs) freopen("test.out", "w", stdout);
       else freopen ("test.ans", "w", stdout);
    }
   else if (ifstream("abc157a.inp"))
    {
        freopen("abc157a.inp", "r", stdin);
        freopen("abc157a.out", "w", stdout);
    }
}

template <typename T>
void read(T& x)
{
    x = 0; T f = 1;
    char ch = getchar();
    while (!isdigit(ch)) f = ch == '-' ? - f : f, ch = getchar();
    while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
    x *= f;
}

template <typename T>
void write (T a)
{
    if (a < 0)
    {
        putchar ('-');
        write (-a);
        return;
    }
    if (a < 10)
    {
        putchar ('0' + a);
        return;
    }
    write (a / 10);
    putchar ((char)('0' + (a % 10)));
}

void enter()
{
    int n;
    cin >> n;
    cout << n / 2 + n % 2;
}

void solve()
{

}

void print_result()
{

}

main()
{
    docfile();
    //cin>>ntest;
    for (tt = 1; tt <= ntest; ++ tt)
    {
        enter();
        solve();
        print_result();
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
	#include <cstdio>
	#include <cstring>
	#include <cmath>
	#include <cstring>
	#include <chrono>
	#include <complex>
	#define endl "\n"
	#define ll long long int
	#define vi vector<int>
	#define vll vector<ll>
	#define vvi vector < vi >
	#define pii pair<int,int>
	#define pll pair<long long, long long>
	#define mod 1000000007
	#define inf 1000000000000000001;
	#define all(c) c.begin(),c.end()
	#define mp(x,y) make_pair(x,y)
	#define mem(a,val) memset(a,val,sizeof(a))
	#define eb emplace_back
	#define f first
	#define s second
	
	using namespace std;
	int main()
	{
		std::ios::sync_with_stdio(false);
		ll n,k;
		cin>>n>>k;
		cout<<min(n%k,abs(n%k-k));
		return 0;
	}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int find(char *a, char *b, int i, int bl){
  int j;

  for(j = 0; j < bl; j++){
    if(a[i+j] != b[j]){
      return 0;
    }
  }
  return -1;
}

int main(){
  char a[1000], b[1000];
  int i, bl, al;

  scanf("%s", a);
  scanf("%s", b);

  al = strlen(a);
  bl = strlen(b);

  for(i = 0; i <al; i++){
    if(find(a, b, i, bl)){
      printf("%d\n", i);
    }
  }
  return 0;
}

Measured memory_bytes: 540
n, m = map(int,input().split())
a = [[0]*m for i in range(n)]
b = [0]*m

for i in range(n):
    a[i] = list(map(int,input().split()))
for j in range(m):
    b[j] = int(input())

c = [0]*n
for i in range(n):
    for j in range(m):
        c[i] += a[i][j] * b[j]

for i in c:
    print(i)


Measured memory_bytes: 5956
import java.util.*;

public class Main{
    void solve(){
        Scanner scan = new Scanner(System.in);
        int sum = scan.nextInt() + scan.nextInt();
        if(sum < 0){
            System.out.println(-1);
        }else if(sum == 0){
            System.out.println(0);
        }else{
            System.out.println(1);
        }
    }
    
    public static void main(String[] args){
        new Main().solve();
    }
}


Measured memory_bytes: 26300
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define re(i,a,b) for(int i=(a);i<(b);i++)
#define repd(i,a,b) for(int i=(a);i>=(b);i--)
#define run(v) for(int k=head[v];k;k=e[k].ne)
#define v e[k].t
#define clr(a) memset(a,0,sizeof(a));
#define il inline
#define sz(a) ((int)a.size())
#define all(a) a.begin(),a.end()
#define mp make_pair
#define pb push_back 
#define w1 first
#define w2 second
#define adm(a,b,c) {a=a+b;if(a>=c)a-=c;else if(a<0)a+=c;}
typedef long long ll;typedef long double ld;typedef unsigned long long ull;
typedef pair<ll,ll> pa;
const int N=5e5+5,M=1e7+5,INF=1e9,mod=1e9+7;
const ll linf=1e18;const double eps=1e-8,pi=acos(-1);
il int gmin(int &a,int b){if(a>b)a=b;}il ll gmin(ll &a,ll b){if(a>b)a=b;}il int gmax(int &a,int b){if(a<b)a=b;}il ll gmax(ll &a,ll b){if(a<b)a=b;}
il void read(ll&x){ll f=1,t=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){t=t*10+ch-'0';ch=getchar();}x=t*f;}il ll read(ll&x,ll&y){read(x);read(y);}
il void read(int&x){int f=1,t=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){t=t*10+ch-'0';ch=getchar();}x=t*f;}il int read(int&x,int&y){read(x);read(y);}
il void read(int&a,int&b,int&c){read(a);read(b);read(c);}il void read(ll&a,ll&b,ll&c){read(a);read(b);read(c);}
il int read(){int x;read(x);return x;}
il ll qpow(ll a,ll b,ll p){ll ret=1;for(;b;b>>=1,a=a*a%p)if(b&1)ret=ret*a%p;return ret;}il ll qpow(ll a,ll b){ll ret=1;for(;b;b>>=1,a=a*a%mod)if(b&1)ret=ret*a%mod;return ret;}
il ll qmul(ll a,ll b,ll p){ll ret=0;for(;b;b>>=1,a=(a<<1)%p)if(b&1)adm(ret,a,p);return ret;}il ll qmul(ll a,ll b){ll ret=0;for(;b;b>>=1,a=(a<<1)%mod)if(b&1)adm(ret,a,mod);return ret;}
il void judge(){
	freopen("data.in","r",stdin);
	freopen("data.out","w",stdout);}
il void gen(){freopen("data.in","w",stdout);}
ll b[N],f[N],n,m,k;
int main(){
	read(n,k);
	for(int i=1;i*i<=n;i++)if(n%i==0){
		b[++m]=i;
		if(i!=n/i)b[++m]=n/i;
	}sort(b+1,b+1+m);ll ans=0;
	rep(i,1,m)f[i]=qpow(k,(b[i]+1)/2);
	rep(i,1,m)rep(j,i+1,m)if(b[j]%b[i]==0)f[j]=(f[j]-f[i]+mod)%mod;
	rep(i,1,m)if(b[i]&1)ans=(ans+f[i]*b[i])%mod;
		else ans=(ans+f[i]*b[i]/2)%mod;
	cout<<ans<<endl;
}

Measured memory_bytes: 2304
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <queue>
#include <list>
#define rep(i,n) for(int i=0;i<(n);i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define All(x) (x).begin(),(x).end()
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8



int main() {
    ll N,M,Ax[57],Ay[57],Bx[57],By[57],t,C[57],distance=MOD;cin >> N >> M;
    rep(i,N){
        cin >> Ax[i] >> Ay[i];
        }
    rep(i,M){
        cin >> Bx[i] >> By[i];
    }
    rep(i,N){
        distance=MOD;
        rep(j,M){
            t=abs(Ax[i]-Bx[j])+abs(Ay[i]-By[j]);
            if(distance>t){
                distance=t;
                C[i]=j+1;
            }
        }
    }
    rep(i,N){
        cout << C[i] <<endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include <math.h>
#define ll long long 
// to increase precision
// std::cout<<std::fixed;
// 	std::cout<<std::setprecision(6)<<z;
#define max1 100001
long long int mod=1000000007;

vector<vector<int> > adjl(max1);
int dist[max1];
int vis[max1];

void dfs(int a){
	vis[a]=1;
	for (int i = 0; i <adjl[a].size(); ++i)
	{
		int ch=adjl[a][i];
		if(!vis[ch])
			dfs(ch);
		dist[a]=max(dist[a],dist[ch]+1);
	}

}

int main(){	
	memset(vis,0,sizeof(vis));
	for (int i = 0; i <max1; ++i)
	{
		dist[i]=0;
	}
	int n,m;
	cin>>n>>m;
	for (int i = 0; i < m; ++i)
	{
		int a,b;
		cin>>a>>b;
		adjl[a].push_back(b);
	}
	for (int i = 1; i <=n; ++i)
	{
		if(!vis[i])
			dfs(i);
		
	}
	int ans=0;
	for (int i = 1; i <=n; ++i)
	{
		ans=max(ans,dist[i]);
	}
	cout<<ans<<endl;






		
}
	
	
	
	





Measured memory_bytes: 8576
#include<stdio.h>
#include<string.h>

#define M 1000003
#define L 13

char H[M][L]; /* Hash Table */

int Getchar(char ch){//計算
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
  return 0;
}

long long Getkey(char str[]){//計算
  long long sum = 0, p = 1, i;
  
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(Getchar(str[i]));
    p *= 5;
  }
  return sum;
}

int H1(int key){ return key%M; }//計算
int H2(int key){ return 1+key%(M-1); }

int Insert(char str[]){
  long long key=Getkey(str);
  long long i;
  long long m;
  
  for(i=0;;i++){
      m=(H1(key)+i*H2(key))%M;

      if(strcmp(H[m],str)==0)return 0;//すでにある　失敗//同じ文字列はいらない
      else if (strlen(H[m])==0){//空きスペース発見、insertできる
	  strcpy(H[m],str);
	  return 1;//成功
	}
    }
}

int Find(char str[]){
  long long key = Getkey(str);
  long long m;
  long long i;
  
  for(i=0;;i++){
      m=(H1(key)+i*H2(key))%M;
      if(strcmp(H[m],str)==0)  return 1; //FOUND
      else if(strlen(H[m])==0)return 0; //NOT FOUND
    }
  return 0;//ありえないけど、一応
}

int main()
{
  int i, n, h;
  char str[L], com[7];
  
  for ( i = 0; i < M; i++ ) H[i][0] = '\0';//一列目ヌル文字
  
  scanf("%d", &n);
  
  for ( i = 0; i < n; i++ ){
      scanf("%s%s", com, str);
	
      if ( com[0] == 'i' )Insert(str);//insert
      else{//find
	  if (Find(str))printf("yes\n");
	  else printf("no\n");
	}
    }
  return 0;
}

/*
コマンド数
insert AAA
find AAA

yesとnoで結果出力
あくまで検索だから、同じ文字列はいらない
*/



Measured memory_bytes: 14488
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;

int main() {
    ll n;
    cin >> n;
    ll a[n];
    for (ll i = 0; i < n; i++) cin >> a[i];

    ll ans[n];
    for (ll i = 0; i < n; i++) {
        ans[i] = 0;
    }
    for (ll i = 0; i < n; i++) {
        if (i % 2 == 0) ans[0] += a[i];
        else ans[0] -= a[i];
    }
    for (ll i = 1; i < n; i++) {
        ans[i] = 2 * (a[i - 1] - ans[i - 1] / 2);
    }
    for (ll i = 0; i < n; i++) {
        if (ans[i] >= 0) {    
            cout << ans[i] << endl;
        } else cout << 0 << endl;
    }
}


Measured memory_bytes: 2816
# -*- coding: utf-8 -*-
def main():
    N = int(input())
    X = list(map(int, input().split()))
    min = 10000000000
    for venue in range(1, 101):
        sum = 0
        for i in range(N):
            if sum > min:
                break
            # print((venue - X[i])**2)
            sum += (venue - X[i])**2
        if sum < min:
            min = sum
    print(min)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9052
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define FOR0(i,n) for(i=0;i<n;i++)
#define FOR(i,j,n) for(i=j;i<n;i++)
#define FORD(i,j,k) for(i=j;i>=k;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 1000000000
#define ninf -1000000000
#define endl '\n' 
#define she_told_me_dont_worry ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// Use cout.flush() for interactive problems.
// Use this for increased stack size: g++ -o a.exe -Wl,--stack=256000000 -O2 source.cpp
inline long long  MAX2(long long  a, long long int b){return (a)>(b)?(a):(b);}
inline long long  MAX3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  MIN2(long long  a, long long  b){return (a)<(b)?(a):(b);}
inline long long  MIN3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< ii > vii;
int main()
{
    she_told_me_dont_worry
    int x, y, z;
    cin>>x>>y>>z;
    cout<<z<<" "<<x<<" "<<y<<endl;
    cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
}

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

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

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

    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define FILE_IO freopen("input.txt","r",stdin)
#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define bp __builtin_popcount
#define debug(x) cerr << #x << " = " << x << endl;

const int MOD = 1e9 + 7;
const int INF = 1e18;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>void print(T t){for(auto &it : t)cout<<it<<" ";}
inline int powerexp(int a, int b, int m = MOD){ int res = 1;while(b){if(b&1)res = res * a % m;a = a * a % m,b >>= 1;}return res % m;}
inline int modinv(int a){ return powerexp(a,MOD-2,MOD);}
inline int lcm(int a, int b){ int g = __gcd(a,b);return a/g*b;}
inline int add(int x, int y){ x += y; if (x >= MOD) x -=  MOD; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % MOD;}
inline int sub(int x, int y){ x -= y; if (x<0) x += MOD; return x ;}

//-------------------< start here >-------------------------// 

void solve(){
   int n, cnt = 1;
   while( cin >> n  && n > 0){
	  cout << "Case " << cnt <<": " << n << endl;
	  cnt++;   
	}
}

//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr << "time elapsed " << (double)clock()/CLOCKS_PER_SEC << endl;
   #endif
}



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

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

  if(k%2==0){
    cout << -1 << endl;
    return 0;
  }

  // long long tmp=0;
  // long long hoge=1;
  // long cnt=0;
  // while(true){
  //   tmp += hoge * 7;
  //   hoge *= 10;
  //   cnt++;
  //   cout << tmp%k << endl;
  //   if(tmp%k==0){
  //     break;
  //   }
    
  // }

  int cnt = 1;
  long long tmp = 7%k;
  if(tmp==0){
    cout << cnt << endl;
    return 0;
  }
  for(int i=0;i<k;i++){
    tmp = 10*tmp + 7;
    tmp = tmp%k;
    cnt++;
    if(tmp==0){
      cout << cnt << endl;
      return 0;
    }
  }

  cout << -1 << endl;
  return 0;
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << endl; exit(0); }
inline void no() { cout << "No" << endl; exit(0); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { x = max(x, y); }
template <typename T> inline void amin(T &x, T y) { x = min(x, y); }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  int x;
  cin >> x;
  int now = 0;
  for (int i = 1; ; i++) {
    now += i;
    if (now >= x) {
      cout << i << endl;
      return;
    }
  }
}

Measured memory_bytes: 256
'use strict';

var fs = require('fs');
var contents = fs.readFileSync('/dev/stdin', 'utf-8');

var findDivisors = function(contents) {
    var line = contents.trim().split(" ");
    var a = parseInt(line[0]);
    var b = parseInt(line[1]);
    var c = parseInt(line[2]);

    var n = 0;
    for (var i = a; i <= b; i++) {
        if (c % i === 0) {
            n++;
        }
    }
    return n;
}

console.log(findDivisors(contents));

Measured memory_bytes: 15576
//#pragma GCC optimize("trapv")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
//#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#include<bits/extc++.h>
using namespace __gnu_pbds;
//using namespace __gnu_cxx;
#define pb push_back
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using vi = vector<int>;
using pi = pair<ll, ll>;
using vpi = vector<pi>;
const int maxn = 3e5 + 33, mlg = 18, mod = 1e9 + 7;
ll cnt[60];
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;
	memset(cnt, 0, sizeof cnt);
	for(ll t, i = 0; i < n; i++) {
		cin >> t;
		for(int j = 0; j < 60; j++)
			if((t>>j)&1) cnt[j]++;
	}
	ll ans = 0, k = 1;
	for(int i = 0; i < 60; i++) {
		ll t = (cnt[i]*1ll*(n-cnt[i]))%mod;
//		cout << t << " " << cnt[i] << "\n";
		t = (t*k)%mod;
		ans = (ans + t)%mod;
		k = (k<<1)%mod;
	}
	cout << ans;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void){

  int n;
  while( cin >> n , n ){
    
    int x,y,h;
    int w,W = 0;
    int s;
    int total = 0;
    for( int i = 0 ; i < n ; i++ ){
      cin >> x >> y >> h >> w;
      s = x + y + h;
      
      if( s <= 60 && w <= 2 ){
	total += 600;
      }
      else if( s <= 80 && w <= 5 ){
	total += 800;
      }
      else if( s <= 100 && w <= 10 ){
	total += 1000;
      }
      else if( s <= 120 && w <= 15 ){
	total += 1200;
      }
      else if( s <= 140 && w <= 20 ){
	total += 1400;
      }
      else if( s <= 160 && w <= 25 ){
	total += 1600;
      }
      else total = total;
      
    }
    cout << total << endl; 
  }
  return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include <string>
#include<vector>
#include<algorithm>
#include <cstdlib>
using namespace std;
int main(){
    int a;
    cin >> a;
    int b= a%111;
    if(b == 0){
        cout << a << endl;
    }
    else{
        int c = 111-b;
        cout << a+c << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<map>
#include<stack>
#include<set>
#include<vector>
#include<functional>
using namespace std;
typedef long long LL;
inline LL read()
{
	LL kk=0,f=1;
	char cc=getchar();
	while(cc<'0'||cc>'9'){if(cc=='-')f=-1;cc=getchar();}
	while(cc>='0'&&cc<='9'){kk=(kk<<1)+(kk<<3)+cc-'0';cc=getchar();}
	return kk*f;
}
LL n,mod,len,asd=0;
char ss[400022];
LL cou[200022];
int main()
{
	n=read();mod=read();
	scanf("%s",ss);len=strlen(ss);
	if(mod==2)
	{
		for(int i=0;i<len;++i)
		{
			if(!((ss[i]-'0')&1))asd+=i+1;
		}
		printf("%lld\n",asd);
		return 0;
	}
	if(mod==5)
	{
		for(int i=0;i<len;++i)
		{
			if(((ss[i]-'0')==0)||((ss[i]-'0')==5))asd+=i+1;
		}
		printf("%lld\n",asd);
		return 0;
	}
	reverse(ss,ss+len);
	LL bas=1;
	LL kk=0;
	for(int i=0;i<len;++i)
	{
		kk=(kk+(ss[i]-'0')*bas)%mod;
		asd+=cou[kk]++;
		if(kk==0)asd++;
		bas=(bas*10)%mod;
	}
	printf("%lld\n",asd);
}

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

int main()
{
  int A,B,C ;
  cin>>A>>B>>C ;
  
  if(A<=C&&C<=B) cout<<"Yes"<<endl ;
  else if(B<=C&&C<=A) cout<<"Yes"<<endl ;
  else cout<<"No"<<endl ;
 
  return 0 ;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define mp make_pair
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }
template<typename T> inline T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }



vector<pair<char, int> > runlength(string str) {
    vector<pair<char, int> > ret;
    int cnt = 1;
    int n = sz(str);
    rep3(i, 1, n) {
        if (str[i] == str[i - 1]) {
            cnt++;
        } else {
            ret.eb(make_pair(str[i - 1], cnt));
            cnt = 1;
        }
    }
    ret.eb(make_pair(str[n - 1], cnt));
    return ret;
}





int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    
    int n;
    cin >> n;
    /*
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    */
    string s;
    cin >> s;
    auto v = runlength(s);
    cout << sz(v) << endl;
}


Measured memory_bytes: 1608
#include <bits/stdc++.h>  // clang-format off
using namespace std;
using Int = long long;
#define REP_(i, a_, b_, a, b, ...) for (int i = (a), lim_i = (b); i < lim_i; i++)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
struct SetupIO { SetupIO() { cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(13); } } setup_io;
#ifndef _MY_DEBUG
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Sun Mar 22 21:12:24 JST 2020
 **/

template <class T, class S> vector<T> make_vec(size_t n, S x) { return vector<T>(n, x); }
template <class T, class... Ts> auto make_vec(size_t n, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(n, make_vec<T>(ts...));
}
template <class T> inline bool chmin(T& a, const T& b) {
    if (a <= b) return false;
    a = b;
    return true;
}
template <class T> inline bool chmax(T& a, const T& b) {
    if (a >= b) return false;
    a = b;
    return true;
}

signed main() {
    Int H, W, K;
    cin >> H >> W >> K;
    vector<string> t(H);
    REP(i, H) cin >> t[i];
    Int mi = 1e18;
    REP(S, 1 << (H - 1)) {
        vector<vector<Int>> tbl(W);
        REP(j, W) {
            REP(i, H) {
                if (i == 0 || S >> (i - 1) & 1) {
                    tbl[j].push_back(t[i][j] - '0');
                } else {
                    tbl[j].back() += t[i][j] - '0';
                }
            }
        }
        Int X = tbl[0].size();
        vector<Int> cur(X);
        Int cnt = __builtin_popcount(S);
        REP(j, W) {
            bool ok = true;
            REP(i, X) {
                cur[i] += tbl[j][i];
                if (cur[i] > K) ok = false;
            }
            if (!ok) {
                cnt++;
                REP(i, X) {
                    cur[i] = tbl[j][i];
                    if (cur[i] > K) cnt = 1e18;
                }
            }
        }
        chmin(mi, cnt);
    }
    cout << mi << endl;
}


Measured memory_bytes: 496
def gcd(x,y):
  if x>y:
    x,y=y,x
  while y%x!=0:
    y,x=x,y%x
  return x

def main():
  K=int(input())
  T=[[0]*-~K for _ in range(K+1)]

  for x in range(1,K+1):
    for y in range(1,K+1):
      T[x][y]=gcd(x,y)

  t=0
  for a in range(1,K+1):
    for b in range(1,K+1):
      for c in range(1,K+1):
        t+=T[a][T[b][c]]

  print(t)

main()


Measured memory_bytes: 9336
#include <stdio.h>
int main(void){
    // Here your code !
    int n;
    int a[100];
    int i;
    
    scanf("%d", &n);
    for( i = 0; i < n; ++i){
        scanf("%d", &a[i]);
    }
    
    for( i = n-1; i > 0; --i){
        printf("%d ", a[i]);
    }
    printf("%d\n", a[0]);
    return 0;
}

Measured memory_bytes: 596
fun main(args : Array<String>) {
    val n = readLine()!!.toInt()
    val stations = mutableListOf<Station>()

    repeat(n-1) {
        val (c, s, f) = readLine()!!.split(" ").map { it.toInt() }
        stations.add(Station(c, s, f))
    }

    for (i in 0 until n-1) {
        val station = stations[i]
        var time = station.s + station.c

        for (j in i+1 until n-1) {
            val nextStation = stations[j]
            time = Math.max(time, nextStation.s)

            if (time % nextStation.f == 0) {
                time += nextStation.c
            } else {
                time += (nextStation.f - (time % nextStation.f)) + nextStation.c
            }
        }

        println(time)
    }

    println(0)
}

data class Station(val c: Int, val s: Int, val f: Int)

Measured memory_bytes: 38680
import sys

if __name__ == "__main__":
    # lines = """5
    # -1 2 3 1 -1
    # 2 -1 -1 4 -1
    # 3 -1 -1 1 1
    # 1 4 1 -1 3
    # -1 -1 1 3 -1
    # """.split("\n")
    lines = sys.stdin.readlines()
    matrix = [[int(x) for x in line.strip().split(" ")] for line in lines[1:] if line.strip() != ""]

    connections = set([0])  # ??\?¶????????????????
    dimension = int(lines[0])
    cost = 0

    while len(connections) < dimension:
        minimum = sys.maxsize
        candidate = None

        for i in connections:
            for index, value in enumerate(matrix[i]):
                if value != -1 and value < minimum and index not in connections:
                    minimum = matrix[i][index]  # minimum = value
                    candidate = index

        connections.add(candidate)
        cost += minimum

    # print(connections, cost)
    print(cost)

Measured memory_bytes: 7844