akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br =
				new BufferedReader(new InputStreamReader(System.in));
		String line = "";
		int cnt = 0;

		while ((line = br.readLine()) != null) {
			String rev = new StringBuffer(line).reverse().toString();
			if (line.equals(rev)) cnt++;
			line = null;
		}

		System.out.println(cnt);

	}

}

Measured memory_bytes: 16864
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define ALL(v) (v).begin(), (v).end()

int main()
{
  int N, M; cin >> N >> M;
  vector<bool> a(N, false), b(N, false);
  for (int i = 0; i < M; ++i) {
    int ai, bi; cin >> ai >> bi;
    ai--, bi--;
    if (ai == 0) a[bi] = true;
    if (bi == N-1) b[ai] = true;
  }

  for (int i = 0; i < N; ++i) {
    if (a[i] && a[i] == b[i]) {
      cout << "POSSIBLE" << endl;
      return 0;
    }
  }

  cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 256
#include <cstdio>

using namespace std;

long long get(long long x, long long y) {
    long long ans = 0;
    
    while (x > 0) {
        ans += x % y;
        x /= y;
    }
    
    return ans;
}

int main() {
    int i;
    long long n, s;
    
    scanf("%lld %lld", &n, &s);
    
    for (i = 2; i <= 1000000; i++) {
        if (get(n, i) == s) {
            printf("%d\n", i);
            
            return 0;
        }
    }
    
    for (i = n / 1000000; i > 0; i--) {
        long long x = n / (i + 1) + 1;
        long long y = n / i;
        
        if (x > y) continue;
        
        if (i + n % y <= s && i + n % x >= s) {
            long long l = x, r = y, m = (l + r) / 2;
            
            if (i + n % x == s) {
                printf("%lld\n", x);
                
                return 0;
            } else if (i + n % y == s) {
                printf("%lld\n", y);
                
                return 0;
            }
            
            while (r - l > 1) {
                if (i + n % m > s) {
                    l = m;
                    m = (l + r) / 2;
                } else {
                    r = m;
                    m = (l + r) / 2;
                }
            }
            
            if (i + n % r == s) {
                printf("%lld\n", r);
                
                return 0;
            }
        }
    }
    
    if (n == s) {
        printf("%lld\n", n + 1);
    } else {
        puts("-1");
    }
    
    return 0;
}


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

int main() {
    //input
    int a,b;
    cin >> a >> b;

    if(a == b){
        cout << "Draw" << endl;
    }else if(a == 1){
        cout << "Alice" << endl;
    }else if(b == 1){
        cout << "Bob" << endl;
    }else if(a > b){
        cout << "Alice" << endl;
    }else{
        cout << "Bob" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

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 * m) / gcd(n, m);//gl=xy
}
 
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;
}
 
using namespace std;

//ここから


void solve(){
  int n,a;
  cin>>n>>a;
  int x=n%500;
  bool ok=false;
  for(int i=0;i<=a;++i){
    if(x==i)ok=true;
  }
  if(ok)cout<<"Yes";
  else cout<<"No";
}

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


Measured memory_bytes: 256
#include <stdio.h>

int SelectionSort(int *array, int len);

int main()
{
    int i,j,len;
    char buf[10];
    fgets(buf,sizeof(buf),stdin);
    sscanf(buf,"%d",&len);
    int *array;
    array = malloc(len*sizeof(int));
    for (i=0;i<len;i++){
        scanf("%d",array+i);
    }
    int cnt;
    cnt = SelectionSort(array, len);
    for (i=0;i<len;i++){
        if (i==(len-1)) printf("%d\n",*(array+i));
        else printf("%d ",*(array+i));
    }
    printf("%d\n",cnt);
    return 0;
}

int SelectionSort(int *array, int len)
{
    int i,j,tmp,cnt,mini;
    cnt = 0;
    for (i=0;i<len;i++)
    {
        mini = i;
        for (j=i;j<len;j++)
        {
            if (array[j] < array[mini])
            {
                mini = j;
            }
        }
        tmp = array[i];
        array[i] = array[mini];
        array[mini] = tmp;
        if (i != mini) cnt += 1;
    }
    return cnt;
}



Measured memory_bytes: 2108
//Author rahuliitkgp

/*A thing of beauty is a joy forever,
Its loveliness increases,
it will never pass into nothingness.*/
//Men at Work :)

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;

#define setbits(x)      __builtin_popcountll(x)
#define mod             1000000007
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(x)            int x; cin>>x; while(x--)
#define INF (int)1e9 + (int)1e8
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());

double pi = 3.14159265358979323846264338327;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

void cpp(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

int main() {
    cpp();
    string s;
    cin>>s;
    ll sum = 0;
    for(int i=0; i<s.size(); i++){
        sum+=(s[i]-'0');
        sum%=9;
    }
    if(sum==0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}




Measured memory_bytes: 3724
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
	string S;
	cin >> S;

	int c0 = count(S.begin(), S.end(), '0');
	int c1 = count(S.begin(), S.end(), '1');
	int ans = 2 * min(c0, c1);
	cout << ans << endl;
}


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

int main() {
  int N; cin >> N;
  vector<int> A(N+1);
  for (int i = 0; i < N+1; i++) cin >> A.at(i);
  vector<long long> M(N+1), m(N+1);
  M.at(N) = m.at(N) = A.at(N);
  for (int i = N-1; i >= 0; i--) {
    M.at(i) = M.at(i+1) + A.at(i);
    m.at(i) = (m.at(i+1) + 1) / 2 + A.at(i); 
  }
  if (m.at(0) > 1) { cout << -1 << endl; return 0; }
  long long ans = 0, tmp = 1;
  for (int i = 0; i <= N; i++) {
    ans += tmp;
    tmp = (tmp - A.at(i)) * 2;
    if (i != N && tmp > M.at(i+1)) tmp = M.at(i+1);
  }
  cout << ans << endl;
}

Measured memory_bytes: 5080
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <limits>
typedef long long ll;
#define REP(i,n)   for(int i=0; i<(int)(n); ++i)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); ++i)

#define in cin
#define out cout
#define pb push_back
using namespace std;

int main(){
	int a, b = 0;
	REP(i, 4) {
		in >> a;
		b += a;
	}
	out << b / 60 << endl;;
	out << b % 60 << endl;
	return 0;

}

Measured memory_bytes: 3056
import java.util.*;

public class Main {
    static long mod = 1000000007;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long x = sc.nextLong();
        long y = sc.nextLong();
        if ((x+y)%3==0){
            long d = (x+y)/3;
            long m = x-d;
            long n = y-d;
            if (m>=0&&n>=0){
                long c = 1;
                for (long i=m+n;i>m;i--){
                    c = c*i%mod;
                }
                long e = 1;
                for (long i=1;i<=n;i++){
                    e=e*i%mod;
                }
                e = modinv(e,mod);
                c = c*e%mod;
                System.out.println(c);
            }else {
                System.out.println(0);
            }
        }else {
            System.out.println(0);
        }
    }

    static long modPow(long a, long n, long mod){
        long res = 1;
        while (n>0){
            if ((n&1)!=0)res = res*a%mod;
            a=a*a%mod;
            n >>= 1;
        }
        return res;
    }
    static long modinv(long a, long mod){return modPow(a,mod-2,mod);}
}


Measured memory_bytes: 35572
#include <iostream>

int main(void)
{
  int value;
 std::cin >> value;
  int check_target = value % 10;
  switch(check_target)
  {
    case 3:
      std::cout << "bon" << std::endl;
      break;
    case 0:
    case 1:
    case 6:
    case 8:
		std::cout << "pon" << std::endl;
      break;
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
      	std::cout << "hon" << std::endl;
      break;
    default:
      break;
  }
      
  
  return 0;
}

Measured memory_bytes: 3636
#include<stdio.h>
int main()
{
	int N,K,X,Y;
	scanf("%d %d %d %d",&N,&K,&X,&Y);
	if(N<=K)
	{
		printf("%d",X*N);
	}
	else  if (N>K)
	 {
		printf("%d", (K*X)+(N-K)*Y);
	}
	return 0;

}

Measured memory_bytes: 128
#include<iostream>
#include<cstring>
#include<vector>
#include <set>
#include<algorithm>
using namespace std;
int main()
{
	int a,b,c,k;
	cin >> a >> b >> c;
	cin >> k;
	if (a < b && b < c)
		cout << "Yes"<< endl;
	else
	{
		int num = 0;
		for (int i = 1; a >=b; i++)
		{
			b = b * 2;
			num++;
		}
		for (int i = 1; b >= c; i++)
		{
			c = c * 2;
			num++;
		}
		if (num <= k)
			cout << "Yes" << endl;
		else cout << "No" << endl;
	}
}


Measured memory_bytes: 3632
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <cmath>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

std::string S;

int main()
{
assert(false);
    using std::endl;
    in.sync_with_stdio(false);
    out.sync_with_stdio(false);
    in.tie(nullptr);
    out.tie(nullptr);

    in >> S;
    if (S[1] == 'R') {
        out << 1 + (S[0] == 'R' ? 1 : 0) + (S[2] == 'R' ? 1 : 0) << endl;
    }
    else {
        out << std::max(S[0] == 'R' ? 1 : 0, S[2] == 'R' ? 1 : 0) << endl;
    }


    return 0;
}
#endif


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

int main() {
  int D, N;
  cin >> D >> N;
  int d=1;
  for (int i=0; i<D; i++) {
    d*=100;
  }
  if (N==100) {N++;}
  cout << (int)N*d << endl;
}


Measured memory_bytes: 3616
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int i = 1;
        do {
            int x = i;
            if (x % 3 == 0) {
                System.out.print(" " + i);
                continue;
            }
            while (true) {
                if (x % 10 == 3) {
                    System.out.print(" " + i);
                    break;
                }
                x /= 10;
                if (x != 0) continue;
                else break;
            }
        } while ((++i) <= n);
            System.out.println();
        }
    }



Measured memory_bytes: 28860
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <cmath>
#include <sstream>
#include <set>
#include <queue>
#include <stdio.h>
#include <string.h>
#include <ctype.h>

using namespace std;

#define all(v)   v.begin(),v.end()
#define rall(v)  v.rbegin(),v.rend()
#define sz(v)    (int)v.size()

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

    int n;
    cin>>n;
    vector<int>v(n);

    for(int i=0 ; i<n ; i++)
        cin>>v[i];

    sort(rall(v));

    long long sum1=0, sum2=0;

    for(int i=0 ; i<n ; i++)
    {
        if(i%2==0)
            sum1+=v[i];
        else
            sum2+=v[i];
    }

    cout<<sum1-sum2<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
#include <math.h>
typedef long long ll;
using namespace std;

int main()
{
	int x, a, b;
	cin >> x >> a >> b;
	int y = b - a;
	if (y <= 0) cout << "delicious";
	else if (y <= x) cout << "safe";
	else cout << "dangerous";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define M 1000000007
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define gcd __gcd
#define in(a) scanf("%d",&a)
#define in2(a,b) scanf("%d%d",&a,&b)
#define in3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define read(v,n) for(h=0;h<n;h++)in(v[h]);
#define sc(ch) scanf("%c",&ch)
#define sstr(str) scanf("%s",str)
#define pr(n) printf("%d ",n)
#define out(n) printf("%d\n",n)
#define cf(n) printf("%I64d\n",n)
#define yes printf("YES\n")
#define no printf("NO\n")
#define lin printf("\n")
#define dbg(v,n) for(h=0;h<n;h++)pr(v[h]); lin
#define ck printf("continue\n")
#define ii pair<int,int>
#define vi vector<int>
#define vii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define viii vector<pair<pair<int,int>,int> >
#define vvii vector<vector<pair<int,int> > >
#define all(vec) vec.begin(),vec.end()
#define asc(vec) sort(vec.begin(),vec.end())
#define lp(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) for(i=0;i<n;i++)
#define lower(v,k) lower_bound(v.begin(),v.end(),k)-v.begin()
#define upper(v,k) upper_bound(v.begin(),v.end(),k)-v.begin()
#define N 1005
typedef long long int ll;
int main()
{
    int n,i,a,b,j,c,k;
    in2(n,k);
    string str;
    cin >> str;
    k--;
    n=str[k]-'A';
    str[k]=n+'a';
    cout << str << endl;
}


Measured memory_bytes: 256
require 'prime'

def divisors(num)
  num.prime_division.inject([1]) do |arr, (p, e)|
    (0..e).map { |e1| p**e1 }.product(arr).map { |a, b| a * b }
  end.sort
end

n = gets.to_i
d = divisors(n)
ans = (n - 1)
((d.length + 1) / 2).times do |i|
  xdiff = (d[i] - 1)
  ydiff = (d[-1 * (i + 1)] - 1)

  ans = xdiff + ydiff if xdiff + ydiff <= ans
end

puts ans


Measured memory_bytes: 4092
#include <stdio.h>
#include <iostream>
#include <vector>
#include<algorithm>
using namespace std;

int main()
{
	vector<int> a = { 0,1,3,1,2,1,2,1,1,2,1,2,1 };

	int x, y;
	cin >> x >> y;

	string com;
	a.at(x) == a.at(y) ? com = "Yes" : com = "No";
	cout << com << endl;	
}

Measured memory_bytes: 256
//ARC075-C(Bugged)
#include<iostream>
using namespace std;

//i問について一つ一つやっていると当然間に合わない
//dpを考える
//10の倍数については最後に考えればいける
int N;
int score[110];
bool dp[110][10010]={};
//dp[i][j]:i番目までの問題でj点が作れるか

int main(){
    
    cin>>N;
    for(int i=0; i<N; i++)cin>>score[i];
    
    //dp初期条件
    for(int i=0; i<=N; i++)dp[i][0]=1;
    
    for(int i=0; i<N; i++){
        for(int j=0; j<=10000; j++){
            //dp漸化式:dp[i+1][j]=dp[i][j-score[i]] | dp[i][j]
            if(j-score[i]>=0)dp[i+1][j]=dp[i][j-score[i]] | dp[i][j];
            else dp[i+1][j]=dp[i][j];
        }
    }
    
    int ans=10000;
    //10の倍数の時はノーカウントでmaxを考える
    for(int t=10000; t>=0; t--){
        if(dp[N][t] && t%10!=0){ans=t;break;}
        if(t==0)ans=t;
    }
    
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1280
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        long k = sc.nextLong();
      
        if(a>k){
          a-=k;
        }else if(a<=k){
          k-=a; a=0;
          if(b>k){
            b-=k;
          }else if(b<=k){
            b=0;
          }
        }
        System.out.println(a + " " + b);
    }
}


Measured memory_bytes: 22608
! 2019.12.22
!
      program answer
      implicit none
      integer :: N
      character(len=100) :: S,T
      character(len=200) :: ans
      integer :: i,cn
      intrinsic trim
!
      read(*,*) N
      read(*,*) S,T
!
      cn = 0
      do i=1,N
        cn = cn+1
        ans(cn:cn) = S(i:i)
        cn = cn+1
        ans(cn:cn) = T(i:i)
      end do
      write(*,*) ans(1:2*N)
      end program answer

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <string>
#include <cstring>
#include <functional>

using namespace std;

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
    long long n, a, b, c;
    cin >> n >> a >> b;

    c = a + b;
    long long ans = n / c * a + min(a, n % c);
    cout << ans << endl;
    
	return 0;
}

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

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

using namespace std;

int main(){
	int n; scanf("%d",&n);
	vector<int> a(n);
	rep(i,n) scanf("%d",&a[i]);

	int ans=0;
	for(int i=0;i<n;i+=2) if(a[i]%2==1) ans++;
	printf("%d\n",ans);

	return 0;
}


Measured memory_bytes: 3784
#include<bits/stdc++.h>
#define int long long
#define M 1000000009
#define H 65
#define W 75
#define N 30
using namespace std;
typedef pair<int,int> P;

int w, h, n, idx;
int dp[W][H][W], ans[2][W];

void init(){

  memset(dp,0,sizeof(dp));

  for(int i=0;i<w;i++)
    for(int j=0;j<w;j++)
      if(abs(i-j)<=1) dp[i][1][j]=1;
  
  for(int j=1;j<H-1;j++)
    
    for(int i=0;i<w;i++){
      
      for(int k=0;k<w;k++)

	for(int l=0;l<w;l++)
	  dp[i][j+1][l]=(dp[i][j+1][l]+dp[i][j][k]*dp[k][j][l]%M)%M;

  }
  
}

void update(int num){

  int bit=1;
  
  while(num){
    
    if(num%2){
      
      for(int i=0;i<w;i++) ans[!idx][i]=0;
      
      for(int i=0;i<w;i++)

	for(int j=0;j<w;j++)
	
	  ans[!idx][j]=(ans[!idx][j]+ans[idx][i]*dp[i][bit][j]%M)%M;
      
      idx=!idx;
      
    }

    num/=2;
    
    bit++;
    
  }
  
}

main(){
  
  int T=1;
  
  while(1){
  
    cin>>w>>h>>n;
    if(!w&&!h&&!n) break;

    init();
    
    vector<P> point;
    vector<int> Y;
    
    for(int i=0;i<n;i++){

      int x, y;
      cin>>x>>y;
      
      x--, y--;
      
      if(y==0) continue;
      
      point.push_back(P(y,x));
    }

    sort(point.begin(),point.end());
    
    int py=-1;
    
    for(int i=0;i<point.size();i++)
      if(py!=point[i].first){
	py=point[i].first;
	Y.push_back(py);
      }
    
    memset(ans,0,sizeof(ans));
    
    ans[0][0]=1;

    idx=0;
    
    py=0;
    
    for(int i=0;i<Y.size();i++){
      
      update(Y[i]-py);
      
      for(int j=0;j<point.size();j++){
	
	if(point[j].first!=Y[i]) continue;

	ans[idx][point[j].second]=0;
      }
      
      py=Y[i];
    }

    update(h-1-py);
    
    cout<<"Case "<<T++<<": ";
    
    cout<<ans[idx][w-1]<<endl;
  }
  
}

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

#define pb push_back


using namespace std;

int32_t main()
{
    string a,b;
    cin>>a>>b;

    int n=a.length();
    int m=b.length();
    vector<vector<int>>d(n+1,vector<int>(m+1));
    for(int i=0;i<=n;i++)
   {
       for(int j=0;j<=m;j++)
    {  d[i][j]=0;
    }
   }
    for(int i=0;i<=n;i++)
   {
       for(int j=0;j<=m;j++)
    {
         d[i][j]=0;
        if(i==0||j==0)
            d[i][j]=0;

        else if(a[i-1]==b[j-1])
        {
            d[i][j]+=d[i-1][j-1]+1;
        }
        else
        {   if(d[i-1][j]>=d[i][j-1])
            d[i][j]+=d[i-1][j];
            else
            d[i][j]+=d[i][j-1];
        }
    }
   }

   int i=n;
   int j=m;
   string ans;
   while(i>0&&j>0)
   {
       if(a[i-1]==b[j-1])
       {
           ans.push_back(a[i-1]);

           i--;j--;
       }
       else if(d[i-1][j]>d[i][j-1])
        i--;
       else
        j--;

   }

   reverse(ans.begin(),ans.end());
   cout<<ans;

}


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

#define int long long
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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


	int ans[10010] = {};
	for(int i = 1;i <= n;i++){
		for(int j = 1;j <= n;j++){
			bool f1 = false;
			for(int k = 1;k <= n;k++){
				int tmp = 0;
				if((tmp = i*i+j*j+k*k+i*j + j*k + k*i) > n) break;
				ans[tmp]++;
			}
		}
	}

	for(int i = 1;i <= n;i++){
		cout << ans[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <cstring>
using namespace std;
int n,a[26],ans,ans2;
char s[101];
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>s[i];
	}
	for(int i=1;i<n;i++){
		for(int j=0;j<i;j++){
			if(a[s[j]-'a']==0) a[s[j]-'a']=1;
		}
		for(int j=i;j<n;j++){
			if(a[s[j]-'a']==1){
			ans++;
			a[s[j]-'a']=0;	
			} 
		}
		if(ans>ans2) ans2=ans;
		ans=0;
		memset(a,0,sizeof(a));  
	} 
	cout<<ans2;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long int
// #include "../../Template.cpp"

struct item {
    int w, v;
};

void solve() {
    int n, w; cin >> n >> w;
    vector<item> arr(n);
    for(int i = 0; i < n; i ++) {
        cin >> arr[i].w >> arr[i].v;
    }
    vector<vector<int>> dp(n+1, vector<int>(1e5+5, 1e18));
    dp[0][0] = 0;
    for(int i = 1; i <= n; i ++) {
        for(int j = 0; j <= 1e5+5; j ++) {
            if(j >= arr[i-1].v)
                dp[i][j] = min(dp[i][j], dp[i-1][j - arr[i-1].v] + arr[i-1].w);
            dp[i][j] = min(dp[i][j], dp[i-1][j]);
        }
    }
    int ans = 0;
    for(int i = 0; i < 1e5+5; i ++) {
        if(dp[n][i] <= w) {
            ans = i;
        }
    }
    cout << ans << endl;
}

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    while (t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 80256
#include<bits/stdc++.h>
#define ll long long
#define all(a) a.begin(),a.end()
#define sz(a) a.size()
#define re return 
#define MP make_pair
#define pb push_back
#define pii pair<int,int>
#define se second
#define fi first
using namespace std;
int ans;
signed main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++) ans+=i;
	cout<<ans;
	re 0;
}

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

const int maxn=2005;
int n,mod;
int dp[maxn*3][maxn];
void Add(int &a,int b){
	a+=b;
	if(a>=mod)a-=mod;
}

int main(){
	scanf("%d%d",&n,&mod);
	dp[0][0]=1;
	for(int i=1;i<=3*n;i++)for(int j=0;j<=n;j++){
		Add(dp[i][j],dp[i-1][j]);
		if(i>=2&&j)Add(dp[i][j],1LL*dp[i-2][j-1]*(i-1)%mod);
		if(i>=3&&j)Add(dp[i][j],1LL*dp[i-3][j-1]*(i-1)%mod*(i-2)%mod);
	}
	int ans=0;
	for(int j=0;j<=n;j++)Add(ans,dp[3*n][j]);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 47360
#include <stdio.h>
#include <string.h>
int main(void){
	int length,i=0;
	scanf("%d",&length);
	char s[length+1],t[length+1],done[2*length+1];
	scanf("%s%s",s,t);
	while(i<=2*length-1){
		if(i%2==0){
			done[i]=s[i/2];
		}else{
			done[i]=t[(i-1)/2];
		}
		i++;
	}
	done[2*length]='\0';
	printf("%s",done);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define all(x) (x).begin(),(x).end()
#define pushb push_back()
#define popb pop_back()
#define makep make_pair
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv);
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v);
template<typename T> ll gcd(T a,T b);
template<typename T> ll lcm(T a,T b);
int main(){
    vector<ll> a(5);
    ll n;cin>>n;
    ll mina=-1;
    for(auto& x:a){
        cin>>x;
        if(mina==-1){
            mina=x;
        }
        mina=min(mina,x);
    }
    cout<<(n-1)/mina+1+4<<endl;

    return 0;
}

Measured memory_bytes: 256
S = input()
C = 0
if S[0] == S[1]:
	if S[2] == S[3]:
		C = 1
elif S[0] == S[2]:
	if S[1] == S[3]:
		C = 1
elif S[0] == S[3]:
	if S[1] == S[2]:
		C = 1
if (S[0] == S[1]) & (S[1] == S[2]) & (S[2] == S[3]):
	print('No')
elif C == 1:
	print('Yes')
else:
	print('No')


Measured memory_bytes: 3064
package main

import (
	"fmt"
	"strconv"
)

// Operation is struct
type Operation struct {
	val string
}

func (op *Operation) calc(num int, other int) int {
	if op.val == "+" {
		return num + other
	}
	return num - other
}

func main() {
	var input string

	fmt.Scan(&input)

	A, _ := strconv.Atoi(string(input[0]))
	B, _ := strconv.Atoi(string(input[1]))
	C, _ := strconv.Atoi(string(input[2]))
	D, _ := strconv.Atoi(string(input[3]))

	operations := []Operation{
		Operation{val: "+"},
		Operation{val: "-"},
	}

	for i := 0; i < 2; i++ {
		for j := 0; j < 2; j++ {
			for k := 0; k < 2; k++ {
				res := 0

				res = operations[i].calc(A, B)
				res = operations[j].calc(res, C)
				res = operations[k].calc(res, D)

				if res == 7 {
					fmt.Printf("%d%s%d%s%d%s%d%s\n", A, operations[i].val, B, operations[j].val, C, operations[k].val, D, "=7")
					return
				}
			}
		}
	}
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
#define itn int
#define all(c) c.begin(),c.end()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
#define ll long long
#define pll pair<ll, ll>
#define mp(x, y) make_pair(x, y)
using namespace std;

const ll N = 3e5 + 5, inf = 1e18, mod = 1e9 + 7;
const double PI = 3.1415926536;
int days[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

bool is_prime(ll n) {
    for (ll i = 2; i * i <= n; ++i) {
        if (n % i == 0) {
            return false;
        }
    }
    return true;
}

vector<pll> fact(ll n) {
    n = abs(n);
    ll t = 0;
    vector<pll> ans;
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            pll cur = {i, 0};
            while (n % i == 0) {
                cur.second++;
                n /= i;
            }
            ans.push_back(cur);
        }
    }
    if (n > 1) {
        ans.push_back({n, 1});
    }
    return ans;
}

inline ll getPow(ll a,ll b) {
    ll res = 1ll, tp = a;
    while (b){
       if (b&1ll) {
           res *= tp;
       }
       tp *= tp;
       //tp %= mod; res %= mod;
       b >>= 1ll;
    }
    return res;
}

ll vec_mult(const pll & t1, const pll & t2, const pll & t3) {
   const ll & x1 = t1.first, y1 = t1.second;
   const ll & x2 = t2.first, y2 = t2.second;
   const ll & x3 = t3.first, y3 = t3.second;
   return abs((x2 - x1) * (y3 - y1) - (y2 - y1) * (x3 - x1));
}

void ok() {
   cout << "YES" << endl;
   exit(0);
}

void no() {
   cout << "NO" << endl;
   exit(0);
}

inline ll nxt() {
    ll x;
    cin >> x;
    return x;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    int n = nxt();
    vector<ll> mas(n);
    for (int i = 0; i < n; i++) {
        mas[i] = nxt();
    }
    vector<ll> dp(n);
    dp[0] = 0;
    dp[1] = abs(mas[0] - mas[1]);
    for (int i = 2; i < n; i++) {
        dp[i] = min(abs(mas[i - 2] - mas[i]) + dp[i - 2], abs(mas[i - 1] - mas[i]) + dp[i - 1]);
    }
    cout << dp[n - 1];
    return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;

class Main {
	public static void main(String args[]){
		
		Scanner sc = new Scanner(System.in);
		
                //スキャナーでa(整数) op(文字) b(整数) の式を読み取る
		while(true){
		    String s1 = sc.next();
		    int a = Integer.parseInt(s1);
		    String sop = sc.next();
		    char op = sop.charAt(0);
		    String s2 = sc.next(); 
		    int b = Integer.parseInt(s2);
		    
                    //文字に？が入ったらプログラムが終了する
		    if(op == '?'){
		    	break;
		    }
		    if(0 <= a && a <= 20000){
		    	if(0 <= b && b <= 20000){
		    		
                                //文字により処理を変え、計算結果を表示する
		    		if(op == '+'){
		    			System.out.println(a + b);
		    		}
		    		else if(op == '-'){
		    			System.out.println(a - b);
		    		}
		    		else if(op == '*'){
		    			System.out.println(a * b);
		    		}
		    		else if(op == '/'){
		    			System.out.println(a / b);
		    		}
		    	}
		    }
		}
	}

}

Measured memory_bytes: 17156
<?php

while($line = fgets(STDIN)){
	$ret = array();
	$g = intval($line);
	$m = 1;
	while($g > 0){
		if(($g & 1) == 1){
			$ret[] = $m;
		}
		$g = $g >> 1;
		$m = $m << 1;
	}
	echo implode(" ", $ret) . PHP_EOL;
}

Measured memory_bytes: 15104
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)  
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define RVSORT(v) sort(v.rbegin(), v.rend());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

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

ll modpow(ll n,ll k){
  if(k == 1){
    return n;
  }else if(k == 0){
    return 1;
  }else if(k%2==0){
    ll memo = modpow(n,k/2)%MOD;
    return memo*memo%MOD;
  }else{
    return n * modpow(n,k-1)%MOD;
  }
}

int main(){

  string s;
  cin>>s;

  int n = s.size();

  int l[n];
  REP(i,n){
    if(s[i]=='1'){
      l[i] = 1;
    }else{
      l[i] = 0;
    }
  }

  ll ans = 0;
  ll counter = 0;

  REP(i,n){
    if(l[i] == 1){
      ans += modpow(2,counter) * modpow(3,n-1-i);
      ans %= MOD;
      counter++;
    }
  }
  ans += modpow(2,counter);
  ans %= MOD;

  cout<<ans<<endl;


 

  return 0;
}

Measured memory_bytes: 896
# AtCoder Regular Contest 093
# C - Traveling Plan
# https://atcoder.jp/contests/arc093/tasks/arc093_a
N = int(input())
*A, = map(int, input().split())

A = [0]+A+[0]
sun = 0
pre = 0
for i, a in enumerate(A):
    sun += abs(a-pre)
    pre = a

pre = 0
for i, a in enumerate(A[:-1]):
    if i == 0:
        continue
    print(sun - abs(pre - a) - abs(a - A[i+1]) + abs(pre - A[i+1]))
    pre = a


Measured memory_bytes: 13920
import java.util.*;

public class Main {
	Scanner sc;
	int N;
	String S;
	int l;
	
	public Main() {
		sc = new Scanner(System.in);
	}
	
	private void calc() {
		N = sc.nextInt();
		S = sc.next();
		l = S.length();
		
		int max = 0;
		for (int s = 1; s < l; s++) {
			int eq = match(s);
			if (eq > max) max = eq;
		}
		System.out.println(max);
	}
	
	private int match(int s) {
		int m = 0;
		int eq = 0;
		for (int i = s; i < l; i++) {
			if (S.charAt(i) == S.charAt(i-s)) {
				eq++;
				if (eq > m) {
					m = eq;
					if (m >= s) return s;
				}
			}
			else eq = 0;
		}
		return m;
	}
	
	public static void main(String[] args) {
		new Main().calc();
	}

}


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

#define rep(i, a, b) for(int i=(a); i<(b); i++)

int main(){
  int N,res=0;
  cin >> N;
  int a[10000];
  rep(i, 0, N){
    cin >> a[i];
    while(a[i]%2==0){
      res++;
      a[i]/=2;
    }
  }
  cout<<res<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>  // clang-format off
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() { std::cin.tie(nullptr), std::ios::sync_with_stdio(false), std::cout << std::fixed << std::setprecision(13); } } setup_io;
#ifndef dump
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Sun Apr 26 21:12:25 JST 2020
 **/

signed main() {
    Int a, b, c, d;
    std::cin >> a >> b >> c >> d;
    Int x = (c + b - 1) / b;
    Int y = (a + d - 1) / d;
    std::cout << (x <= y ? "Yes" : "No") << std::endl;
}


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

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


Measured memory_bytes: 3068
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};
int main() {
	int N, M, K;
	cin >> N >> M >> K;
	int AC, BD;
	UnionFind U(N);
	vector<vector<int>>community(N),fri(N);
	vector<int>ans(N);
	for (size_t i = 0; i < M; i++)
	{
		cin >> AC >> BD;
		AC--;
		BD--;
		fri.at(AC).push_back(BD);
		fri.at(BD).push_back(AC);
		U.unite(AC, BD);
	}
	for (size_t i = 0; i < N; i++)
	{
		community.at(U.root(i)).push_back(i);
	}
	for (size_t i = 0; i < N; i++)
	{
		ans.at(i) = community.at(U.root(i)).size()-1-fri.at(i).size();
	}
	for (size_t i = 0; i < K; i++)
	{
		cin >> AC >> BD;
		AC--;
		BD--;
		if (U.same(AC, BD)) {
			ans.at(AC)--;
			ans.at(BD)--;
		}
	}
	for (size_t i = 0; i < N; i++)
	{
		cout << ans.at(i)<<endl;
	}
	

    
}

Measured memory_bytes: 10744
#include <stdio.h>

int main(void)
{
	int H, W, x, y, i;
	
	for(i = 0; i < 300; i++){
		scanf("%d%d", &H, &W);
		if((H == 0) && (W == 0)) break;
		for(y = 0; y < H; y++){
			for(x = 0; x < W; x++){
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
	
	return(0);
}



Measured memory_bytes: 1728
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

const int KN = 1e5 + 5;

int n, m, a[KN];
ll b[KN << 2];

int main() {
	ios::sync_with_stdio(false);
	cin >> n >> m;
	for (int i = 1; i <= n; ++i)
		cin >> a[i];
	ll all = 0;
	for (int i = 1; i < n; ++i) {
		int l = a[i], r = a[i + 1];
		if (l > r)
			r += m;
		all += r - l;
		if (l < r) {
			b[l + 1] += 1;
			b[r] -= (r - l + 1) - 1;
			b[r + 1] += (r - l + 1) - 2;
		}
	}
	for (int i = 2; i <= 2 * m; ++i)
		b[i] = b[i - 1] + b[i];
	for (int i = 2; i <= 2 * m; ++i)
		b[i] = b[i - 1] + b[i];
	ll ans = 1LL << 62;
	for (int i = 1; i <= m; ++i)
		ans = min(ans, all - b[i] - b[i + m]);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2176
from collections import deque


def BFS():
    color=["white" for _ in range(n)]
    D=[0]*n
    M=[[] for _ in range(n)]

    for u,v,w in UVW:
        M[u-1].append([v-1,w])
        M[v-1].append([u-1,w])

    D[0]=1
    color[0]="gray"
    queue=deque([0])

    while len(queue)>0:
        u=queue.popleft()
        for i,j in M[u]:
            if color[i]=="white":
                if j%2==0:D[i]=D[u]
                elif j%2==1:D[i]=-D[u]
                color[i]="gray"
                queue.append(i)
        color[u]="black"

    return D


n=int(input())
UVW=[list(map(int,input().split())) for _ in range(n-1)]
for i in BFS():
    if i==-1:print(0)
    else:print(i)

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

typedef vector< vector<int> > vvi;
typedef vector< vector<bool> > vvb;
typedef vector< vector<char> > vvc;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef long long ll;

int main(){
    int N;
    cin >> N;
    map<string,int> mp;
    for(int i=0;i<N;i++){
        string s;
        cin >> s ;
        mp[s]++;
    }
    int ans=0;
    for(auto x:mp){
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 19160
#include <stdio.h>

int main(void){

   int a, b;
   long long int i=1;
   long long int s=1;

   scanf("%d %d", &a, &b);
       if( a==b ){
           while( i<=a ){
               s = s * i;
               if(s>1000000007) s = s%1000000007;
               i++;
           }
           s = s*s*2%1000000007;
           printf("%lld\n", s);
       }else if( a-b==1 || a-b==-1 ){
           while( i<=a ){
               s = s * i;
               if(s>1000000007) s = s%1000000007;
               i++;
           }
           i = 1;
           while( i<=b ){
               s = s * i;
               if(s>1000000007) s = s%1000000007;
               i++;
           }
           printf("%lld\n", s%1000000007);
       }else {
           printf("%d\n", 0%1000000007);
       }

}

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

using namespace std;

int euclid(int);

int main(void){
	string in,data;
	int i,j,y,line,size,a,b,c,flag=0;

	cin>>line;
	getline(cin,in);
	while(line>0){
		line--;
		getline(cin,in);
		size=in.size();

		data=in;
		for(b=0;b<26;b++){
			for(a=1;a<100;a++){
				c=euclid(a);
				if(c==1){
					for(i=0;i<size;i++){
						if(in[i]!=' '){
								for(j=0;j<26;j++){
									if('a'+j==in[i]){
										y=j;
										data[i]='a'+(a*y+b)%26;
									}
								}
						}
					}
					if(data.find("that")!=-1 || data.find("this")!=-1){
						goto end;
					}
				}
			}
		}
		end:;
		cout<<data<<endl;
		flag=0;
	}

	return 0;
}



int euclid(int x){
	int y=26,n;
	if(x>26){
		while(1){
			n=x%y;
			if(n==0)	return y;
			x=y;
			y=n;
		}
	}
	if(x<26){
		while(1){
			n=y%x;
			if(n==0)	return x;
			y=x;
			x=n;
		}
	}
	if(x==26)	return x;
}

Measured memory_bytes: 920
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;
	public const long DpInf = 99999999999999;

	public static void Main(string[] args)
	{
		var p = Console.ReadLine();
		var c = p[p.Length - 1];
		
		if(c == '3')
		{
			Console.WriteLine("bon");
		}
		else if( c == '0' || c == '1' || c == '6' || c == '8')
		{
		Console.WriteLine("pon");
		
		}
		else
		{
		Console.WriteLine("hon");
		}
	}
	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str, int offset = 0)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt() + offset;
		return r;
	}
}

Measured memory_bytes: 25896
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	int n,w;
	while(cin>>n>>w){
		if(n==0&&w==0) break;
		int a[n],m=0;
		for(int i=0;i<n;i++){
			cin>>a[i];
			m=max(m,a[i]);
		}
		int k=m/w+1;
		int b[k];
		for(int i=0;i<k;i++){
			b[i]=0;
		}
		for(int i=0;i<n;i++){
			int c=a[i]/w;
			b[c]++;
		}
		int h=0;
		for(int i=0;i<k;i++){
			h=max(h,b[i]);
		}
		double ink=0.01;
		for(int i=0;i<k;i++){
			double d1=b[i]*(k-1-i);
			double d2=h*(k-1);
			ink=ink+d1/d2;
		}
		cout<<ink<<endl;
	}
    return 0;
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i <= n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

using namespace std;

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

  rep(i, 0, N/7){
    if((N-7*i) % 4 == 0){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


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

bl, wl = 0, 0
br, wr = S.count('#'), S.count('.')
ret = min(br, wr)
for s in S :
  ret = min(ret, bl + wr)
  if s == '#' :
    bl += 1
    br -= 1
  else :
    wl += 1
    wr -= 1
    
print(ret)

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

int main() {
	int n, w, sum = 0, i = 0;
	double ws = 0;
	char t;
	while (cin >> n) {
		cin >> t >> w;

		i++;
		sum += n * w;
		ws += w;
	}

	cout << sum << endl;
	cout << round(ws / i) << endl;

	return 0;
}

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

int main () {
  int H, W, h, w;
  scanf("%d %d %d %d", &H, &W, &h, &w);

  if(H % h == 0 && W % w == 0) {
    printf("No\n");
    return 0;
  }

  printf("Yes\n");
  int x = - 10*(h*w - 1)*(H/h)*(W/w) - 1;
  int y = 10*(H/h)*(W/w);
  rep(i,H){
    rep(j,W) {
      if(j != 0) printf(" ");
      printf("%d", i % h == h - 1 && j % w == w - 1 ? x : y);
    }
    printf("\n");
  }

  return 0;
}


Measured memory_bytes: 2304
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <utility>
#include <set>
#include <map>
#include <tuple> 
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
using namespace  std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(long long (i)=0, i_bound = (long long)(n); (i)<i_bound; ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
const long long MOD = static_cast<long long>(1e9) + 7LL;
const long long INF = 1234567891234567890LL;
int main(){
    cin.tie(0);
    cout.sync_with_stdio(false);
    int N; cin>>N;
    ll l = floor(1.0*N/1.08); 
    ll r = ceil(1.0*(N+1)/1.08); 
    ll res = 0;
    for(ll i = l; i<=r; i++){
        ll y = floor(i*1.08);
        if(y==N){
            res = i;
            break;
        }
    }
    if(res) cout << res << endl;
    else cout << ":(" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
vector < vector<int> >ed;
bool f;
vector<int> t;
void dfs(int a,int tt) {
	t[a] = tt;
	for (int i = 0; i < ed[a].size(); i++) {
		if (t[ed[a][i]] == -1) {
			dfs(ed[a][i], 1 - tt);
		}
		else {
			if (t[ed[a][i]] + tt != 1) {
				f = false;
			}
		}
	}
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N ,M;
	cin >> N >> M;
	ed.resize(N);
	t.resize(N , -1);
	int res = 0;
	int a, b;
	for (int i = 0; i < M; i++) {
		cin >> a >> b;
		a--;
		b--;
		ed[a].push_back(b);
		ed[b].push_back(a);
	}
	f = true;
	dfs(0 , 0);
	int cnt = 0;
	if (!f) {
		cout << (N*(N - 1) / 2)-M << endl;
	}
	else {
		for (int i = 0; i < N; i++) {
			if (t[i] == 0)cnt++;
		}
		cout << (cnt*(N - cnt))-M << endl;
	}
	
}

Measured memory_bytes: 7680
N = int(input())
tmp = [[int(i) for i in input().split()] for i in range(N)]
tmp.insert(0, [0, 0, 0])
ans = 'Yes'

for i in range(N):
    t = tmp[i+1][0] - tmp[i][0]
    dx = abs(tmp[i+1][1] - tmp[i][1])
    dy = abs(tmp[i+1][2] - tmp[i][2])
    d = dx + dy
    if t < d \
    or t % 2 != d % 2:
        ans = 'No'
print(ans)

Measured memory_bytes: 21156
#include <bits/stdc++.h>
using namespace std;
int INF = 1000000007;

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

  int N, K;
  cin >> N >> K;
  string S;
  cin >> S;
  int A[1000000] = {};
  int a = 1;
  bool ans = true;
  for(int i=0;i<N;i++){
    if(ans){
      if(S[i] == '1'){
        continue;
      }
      else{
        A[a] = i-1;
        a++;
        ans = false;
      }
    }
    else{
      if(S[i] == '1'){
        A[a] = i;
        a++;
        ans = true;
      }
      else{
        continue;
      }
    }
  }
  if(S[N-1] == '1'){
    A[a] = N-1;
    a++;
  } 
  else{
    A[a] = N-1;
    A[a+1] = N-1;
    a += 2;
  }
  int ans1 = 0;
  for(int i=0;i<a;i+=2){
    if(A[i+1+2*K] == 0){
      if(A[i] == 0){
        ans1 = N-1;
        break;
      }
      else{
        break;
      }
    }
    int m = A[i+1+2*K] - A[i];
    ans1 = max(ans1, m);
  }
  cout << ans1 + 1 << endl;
}


Measured memory_bytes: 4432
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <list>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef long double ld;
using namespace std;

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

int main(){
	int n, k;
	cin >> n >> k;
	int d;
	cin >> d;
	int m = d;
	REP(i, n-1){
		int a;
		cin >> a;
		d = gcd(max(a, d), min(a, d));
		m = max(m, a);
	}
	if(m < k || k % d != 0) cout << "IMPOSSIBLE" << endl;
	else cout << "POSSIBLE" << endl;
	return 0;
}


Measured memory_bytes: 256
import math
N,K = map(int, input().split())

ans1 = abs(N - (K * math.floor(N / K)))# 余り
ans2 = abs(N - (K * (math.floor(N / K)+1)))# 余り

ans1 = N % K
ans2 = K - N % K 
print(min(ans1,ans2))


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define D(x) cout << #x << "=" << x <<endl; 
using namespace std; 

//int _; 

int n;
long long ans=1,a[100050];

int main()
{
	//for(scanf("%d",&_);_;_--)
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%lld",a+i);
		if(!a[i])
		{
			puts("0");
			return 0;
		}
	}
	for(int i=0;i<n;i++)
	{
		if(1000000000000000000/ans<a[i])
		{
			puts("-1");
			return 0;
		}
		ans *= a[i];
	}
	cout << ans << endl;	 
	return 0;
}

Measured memory_bytes: 4428
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int m,p;
	scanf("%lld %lld",&m,&p);
	if(abs(m-p)>=2)
		printf("0\n");
	else
	{
		long long int ans=1;
		int i;
		for(i=1;i<=m;i++)
			ans=(ans*i)%1000000007;
		for(i=1;i<=p;i++)
			ans=(ans*i)%1000000007;
		if(m==p)
			ans=(ans*2)%1000000007;
		printf("%lld\n",ans);
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

#define MAX 1000000000

int min(int a, int b) {
    if (a < b)
        return a;
    return b;
}

int abs(int a){
    if (a < 0)
        return -1*a;
    return a;
}

int main() {
    int n, k;
    int harr[1000000], dp[1000000];
    
    scanf("%d %d", &n, &k);
    k++;

    for (int i=0; i < n; i++){
        scanf("%d", &harr[i]);
        dp[i] = MAX;
    }
    dp[0] = 0;

    for (int i=1; i < n; i++)
        for (int j=1; j < k; j++){
            if (i-j < 0)
                break;
            dp[i] = min(dp[i], dp[i-j]+abs(harr[i]-harr[i-j]));
        }
    printf("%d\n", dp[n-1]);

    return 0;
}


Measured memory_bytes: 2508