akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_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(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    
    int N;
    cin >> N;
    vector<string> S(N);
    rep(i, N) cin >> S[i];
    
    vector<vector<int>> A(N, vector<int>(26, 0));
    rep(i, N){
        rep(j, S[i].size()){
            A[i][S[i][j] - 'a']++;
        }
    }
    
    string ans = "";
    
    rep(i, 26){
        int m = inf;
        rep(j, N){
            m = min(m, A[j][i]);
        }
        rep(j, m){
            ans += 'a' + i;
        }
    }
    
    output(ans);
    
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,a[200004];
ll A=0;
int main(){
	cin>>n;for(int i=0;i<n;i++)cin>>a[i];
	sort(a,a+n);
	A+=a[n-1];
	int now=n-2,t=0,X=n-2;
	while(X--){
		if(t==0){
			A+=a[now];
			t++;
		}else{
			A+=a[now];
			now--,t=0;
		}
	}
	cout<<A;
}

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

int main() {
    int x;
    cin >> x;
    string day[7] = {
        "sat",
        "sun",
        "mon",
        "tue",
        "wed",
        "thu",
        "fri"};
    int sa = (x - 9) % 7;
    if(sa < 0)
        cout << day[7 + sa] << endl;
    else
        cout << day[sa] << endl;
}


Measured memory_bytes: 3200
// Example program
#include <iostream>
#include <string>
using namespace std;
string s;
int a,b,c;
bool ch;
int main()
{
 cin.tie();
 cout.tie();
 ios::sync_with_stdio(false);
for(size_t i=0;i<3;i++)
{
    a=cin.get();
    a-=48;
    if(a==7)
    ch=true;
}
if(ch)
cout<<"Yes";
else
cout<<"No";
}


Measured memory_bytes: 3656
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

K = int(input())
from math import gcd
ans = 0
for i in range(1, K+1):
    for j in range(1, K+1):
        for k in range(1, K+1):
            ans += gcd(i, gcd(j, k))
print(ans)

Measured memory_bytes: 68824
// Created by sz
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int k,n;
    cin >> k >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++){
        cin >> a[i];
    }
    
    int ans = a[n-1] - a[0];
    
    for (int i = 0; i < n-1; i++){
        ans = min(ans, a[i] + (k - a[i+1]));
    }
    cout << ans << "\n";
    
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define max1 305
#define siz 100000
#define mod 1000000007
#define inf 1e18+5
#define ll long long int
#define debug(x) cout<<#x<<" "<<x<<endl
#define jam(x) cout<<"Case #"<<x<<": "
typedef pair<ll,ll> pr;
double p[max1][max1][max1];
double ev[max1][max1][max1];
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  /*#ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif*/
  ll n;
  cin>>n;
  vector<ll> cnt(4,0);
  for(ll i=0;i<n;i++)
  {
    ll x;
    cin>>x;
    cnt[x]++;
  }
  p[cnt[1]][cnt[2]][cnt[3]]=1;
  for(ll c=n;c>=0;c--)
  {
    for(ll b=n;b>=0;b--)
    {
      for(ll a=n;a>=0;a--)
      {
        if(a==0&&b==0&&c==0)
        {
          continue;
        }
        if((a+b+c)>n)
        {
          continue;
        }
        double p_w,e_w;
        p_w=(double)(n-(a+b+c))/double(n);
        e_w=(double)p_w/double(1.0-p_w);
        ev[a][b][c]=ev[a][b][c]+e_w*p[a][b][c];
        //cout<<a<<" "<<b<<" "<<c<<" "<<ev[a][b][c]<<endl;
        if(a>0)
        {
          double p_go;
          p_go=double(a)/double(a+b+c);
          p[a-1][b][c]+=p[a][b][c]*p_go;
          ev[a-1][b][c]+=ev[a][b][c]*p_go;
        }
        if(b>0)
        {
          double p_go;
          p_go=(double)b/double(a+b+c);
          p[a+1][b-1][c]+=p[a][b][c]*p_go;
          ev[a+1][b-1][c]+=ev[a][b][c]*p_go;
        }
        if(c>0)
        {
          double p_go;
          p_go=(double)c/double(a+b+c);
          p[a][b+1][c-1]+=p[a][b][c]*p_go;
          ev[a][b+1][c-1]+=ev[a][b][c]*p_go;
        }
      }
    }
  }
  double ans;
  ans=ev[0][0][0]+cnt[1]+cnt[2]*2+cnt[3]*3;
  printf("%.10lf\n",ans);
}

Measured memory_bytes: 438528
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	int n, x, s[1000], p = 0, min = 10000;
	cin >> n >> x;
	for (int i = 0;i < n;i++) {
		cin >> s[i];
		p = p + s[i];
		if (min > s[i]) {
			min = s[i];
		}
	}
	int y = x-p;
	int d = y / min;
	cout << d+n;
}

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

void Constraints(int a,int b,int c)
{
  if(1<=a&&a<=10000&&1<=b&&b<=10000&&1<=c&&c<=10000&&a<=b){}
  else
  {
    printf("条件を満たす入力をしてください。\n");
    exit(0);
  }
}


int main(void)
{
  int a,b,c,cnt,i;
  scanf("%d %d %d",&a,&b,&c);
  Constraints(a,b,c);
  for(i=a,cnt=0;i<=b;cnt+=!(c%i++));
  printf("%d\n",cnt);
  return 0;
}



Measured memory_bytes: 2104
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		String a = scan.next();
		String b  = scan.next();
		String c =scan.next();
		System.out.print(a.charAt(0));
		System.out.print(b.charAt(1));
		System.out.println(c.charAt(2));
	}

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#ifdef _DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9 + 7;
const ll LINF = 1LL << 60;
template<class T, class U> inline bool chmax(T &a, const U &b) { if(a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if(a > b) { a = b; return true; } return false; }

int n, W, v[110], w[110], dp[110][100010];

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  cin >> n >> W;
  rep(i,n) cin >> v[i] >> w[i];
  rep(i,n) {
    rep(j,W+1) {
      chmax(dp[i+1][j], dp[i][j]);
      if(j+w[i] <= W) chmax(dp[i+1][j+w[i]], dp[i][j]+v[i]);
    }
  }
  int ans = dp[n][W];
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 7476
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.StringTokenizer;
import static java.lang.Long.bitCount;

public class Main {

	public static void main(String[] args) {
		FastScanner in = new FastScanner();
		int tt; tt=in.nextInt();
		int ac=0, wa=0, tle=0, re=0;
		while(tt-->0) {
			String s=in.next();
			if(s.equals("AC")) ++ac;
			if(s.equals("TLE")) ++tle;
			if(s.equals("WA")) ++wa;
			if(s.equals("RE")) ++re;
		}
		System.out.println("AC x "+ac);
		System.out.println("WA x "+wa);
		System.out.println("TLE x "+tle);
		System.out.println("RE x "+re);
	}

	static void sort(int[] a) {
		ArrayList<Integer> l = new ArrayList<>();
		for (int i : a)
			l.add(i);
		Collections.sort(l);
		for (int i = 0; i < a.length; i++)
			a[i] = l.get(i);
	}

	static class FastScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");

		String next() {
			while (!st.hasMoreTokens())
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}

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

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

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

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


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

long long gcd(long long a, long long b){
 
    long long A = max(a,b);
    long long B = min(a,b);
 
    if(A%B == 0) return B;
    else return gcd(B,A%B);
}

long long gcd3(long long a, long long b, long long c){
    return gcd(gcd(a,b),c);
}

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

  long long Ans = 0;

  for(int i = 1; i < N+1; i++){
      for(int j = 1; j < N+1; j++){
          for(int k = 1; k < N+1; k++){
              Ans += gcd3(i,j,k);
          }
      }
  }

  cout << Ans << endl;

}

Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>


using namespace std;

typedef long long ll;

int main()
{
    ll a,b,c=0;cin>>a>>b;
    while(a<=b)
    {
        c++;
        a*=2;
    }
    cout<<c<<endl;
}


Measured memory_bytes: 256
#import sys
MOD = 10 ** 9 + 7
INFI = 10**10
#input = sys.stdin.readline
import math
from collections import deque
import itertools
import heapq
#import bisect

import copy
from functools import lru_cache

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)]

def ret(a):
    c=[None]*(len(a)-1)
    if len(a)==1:
        return a[0]
    elif len(a)==0:
        return 0
    for i in range(1,len(a)):
        c[i-1]=abs(a[i]-a[i-1])
    return ret(c)


def main():
    n,m=map(int,input().split())
    a=[[] for _ in range(n+1)]
    for i in range(m):
        x,y=map(int,input().split())
        a[x].append(y)
        a[y].append(x)
#    print(a)
    moto=[-1 for _ in range(n+1)]
    def bfs(a, visited, s):
        queue = deque([])
        visited[s] = 0
        for i in a[1]:
            queue.append(i)
            visited[i] = visited[1] + 1
            moto[i] = 1
        while queue:
            if len(queue) <= 0:
                return
            now = queue.popleft()

            for i in a[now]:
                if visited[i]<0:
                    visited[i]=visited[now]+1
                    queue.append(i)
                    moto[i]=now
    visited=[-1 for _ in range(n+1)]
    bfs(a,visited,1)
#    print(visited)
    if min(moto[2:])>=0:
        print("Yes")
        for i in range(2,n+1):
            print(moto[i])
    else:
        print("No")


if __name__ == "__main__":

    main()

Measured memory_bytes: 35748
#pragma GCC optimize("Ofast")
#include <cstdio>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include <map>
#include <set>
#include <tuple>
using namespace std;
#define INF 1LL << 61
#define MAX 1LL << 30
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,ll> P;
//typedef pair<pair<int,int>,int> p;
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)
struct edge{ll to,cost,val;};
template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}
//__builtin_popcount(S);
//C.erase(unique(C.begin(),C.end()),C.end());
//#define int ll
int dx[]={1,-1,0,0},dy[]={0,0,-1,1};
template<class T>
struct BIT{
    vector<T> data;
    int size;
    BIT(int sz){
        init(sz);
    }
    void init(int sz){
        size=sz;
        data.assign(++size,0);
    }
    T sum(int k){
        T ans=0;
        while(k>0){
            ans+=data[k];
            k-=k&(-k);
        }
        return ans;
    }
    // data[r:l]の合計
    T sum(int r,int l){
        if(r>l) swap(r,l);
        return sum(l)-sum(r-1);
    }
    void add(int k,T x){
        while(k<=size){
            data[k]+=x;
            k+=k&(-k);
        }
    }
};


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

    int N;
    ll K;
    cin>>N>>K;
    vector<ll> a(N+1,0);
    for(int i=1;i<=N;i++) cin>>a[i],a[i]-=K;
    for(int i=2;i<=N;i++){
        a[i]+=a[i-1];
    }
    vector<ll> A=a;
    sort(A.begin(),A.end());
    BIT<ll> b(N+1);
    ll ans=0;
    for(int i=0;i<=N;i++){
        ll x=a[i];
        int num=(int)(lower_bound(A.begin(),A.end(),x)-A.begin())+1;
        ans+=b.sum(num);
        b.add(num,1);
        //cout<<num<<endl;
    }
    cout<<ans<<endl;
}

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

int main(){
    int N, tmp;
    int count = 0;
    cin >> N;
    tmp = N;
    for(int i=0;i<5;i++){
        tmp /= 10;
        if(tmp < 1){
            break;
        }
        count++;
    }
    int ans;
    if(count %2 == 0){
        ans = N - pow(10,count) + 1;
    }else ans = 0;
    for(int i=count;i>0;i--){
        if(i% 2 != 0){
            ans += (pow(10,i) - pow(10,i-1));
        }
    }
    cout << ans  << "\n";
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<math.h>
#include<set>
#include<queue>
#include<map>
#pragma comment(linker, "/STACK:66777216")

using namespace std;

#define ll long long
#define ld long double


int main() {
	ios_base::sync_with_stdio(false);
#ifndef ONLINE_JUDGE
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#endif
	ll a, b;
	cin >> a;
	string s;
	cin >> s >> b;
	for (ll i = 0; i < s.length(); i++) {
		if (s[i] != s[b-1])s[i] = '*';
	}
	cout << s;
	





}

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

using namespace std;

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

  int counter;

  for( int i = 0; i < 3; i++ ) {
    if( s[i] == '1' )
      counter++;
  }
  cout << counter << endl;
  return 0;
}

Measured memory_bytes: 256
from fractions import gcd
N=int(input())
a_list = list(map(int, input().split()))
gcd_l = [0] * (N+1) 
gcd_r = [0] * (N+1) 
for i, a in enumerate(a_list):
    gcd_l[i+1] = gcd(gcd_l[i], a)
for i in range(N, 0, -1):
    a = a_list[i-1]
    gcd_r[i-1] = gcd(gcd_r[i], a)
ans = 1
# print(gcd_l, gcd_r)
for i in range(N):
    tmp = gcd(gcd_l[i], gcd_r[i+1])
    if (ans < tmp):
        ans = tmp
print(ans)


Measured memory_bytes: 89580
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;
typedef string::const_iterator State;
class ParseError {};

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

const ll INF = 1e16;
const ll INM = 114514;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-12;

template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}
ll powm(ll a, ll b, ll c) {
	if (b == 0)
		return 1;
	else if (b % 2 == 0) {
		ll d = powm(a, b / 2, c);
		return (d * d) % c;
	} else
		return (a * powm(a, b - 1, c)) % c;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll dx[4] = {1, 0, -1, 0};
ll dy[4] = {0, 1, 0, -1};

int main() {
	IOS();
	ll n;
	cin >> n;
	vector<ll> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	ll ans = 0;
	set<P, greater<P>> s;
	for (int i = 0; i < n; i++) {
		auto it = s.lower_bound(P(a[i] - 1, INF));
		if (it == s.end()) {
			ans++;
			if (s.lower_bound(P(a[i], -1)) != s.lower_bound(P(a[i], INF))) {
				ll xx, yy;
				auto unko   = s.lower_bound(P(a[i], INF));
				tie(xx, yy) = *unko;
				s.erase(unko);
				s.insert(P(xx, yy + 1));
			} else {
				s.insert(P(a[i], 1));
			}
		} else {
			ll x, y;
			tie(x, y) = *it;
			s.erase(it);
			if (y > 1) {
				s.insert(P(x, y - 1));
			}
			if (s.lower_bound(P(a[i], -1)) == s.lower_bound(P(a[i], INF))) {
				s.insert(P(a[i], 1));
			} else {
				ll xx, yy;
				auto unko   = s.lower_bound(P(a[i], INF));
				tie(xx, yy) = *unko;
				s.erase(unko);
				s.insert(P(xx, yy + 1));
			}
		}
	}
	dump(ans);
}


Measured memory_bytes: 7168
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

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

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60


int main() {
    int N;
    cin >> N;
    vector<ll> A(N+1);
    REP(i, N) {
        cin >> A[i+1];
    }

    // dp[i][j]][k]: i番目までj個選び、k=0の場合iを使わない, k=1の場合iを使う
    vector< vector<vector<ll> > > dp(3, vector<vector<ll> >(N/2+5, vector<ll>(2, -1e18)));

    dp[0][0][0] = 0;
    dp[0][0][1] = 0;
    dp[1][0][0] = 0;
    dp[1][1][1] = A[1];

    FOR(i, 2, N) {
        FOR(j, (i-1)/2, (i+1)/2) {
            dp[i%2][j][0] = max(dp[(i-1)%2][j][0], dp[(i-1)%2][j][1]);
            if(j>=1)
                dp[i%2][j][1] = dp[(i-1)%2][j-1][0] + A[i];
        }
    }

    cout << max(dp[N%2][N/2][0], dp[N%2][N/2][1]) << endl;
    
    return 0;
}

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

int main() {
  ll n, m;
  cin >> n >> m;
  cout << (n == m ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 3620
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#pragma GCC optimize("Ofast")
//*********************************************DO IT NOW****************************************************************
#include<bits/stdc++.h> 
#include<random>
#define int long long   
#define pp pair<int,int> 
#define ss second 
#define ff first 
#define pb push_back
#define mod 1000000007
#define pi 3.14159265359
#define mk(arr,n,type)  type *arr=new type[n];
#define sl s1.length();
#define yes cout<< "YES"<<endl
#define no  cout<< "NO"<<endl
#define all(v) (v).begin(),(v).end()
#define s(v)   sort(v,v+n)
#define  mt mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define read(a,n) for(int i=0;i<n;i++)cin>>a[i]
#define print(a,n) for(int i=0;i<n;i++)cout<<a[i]<<" "
#define for1(i,a,n)  for(int i=0;i<n;i++)
#define rep(i, c) for(int i = 0; i < (int)c; i++)
#define set(x) cout<<fixed<<setprecision(x);
using namespace std;
//**********************************************DO IT NO****************************************************************
void fastio()
{  
  #ifndef ONLINE_JUDGE
  freopen("INPUT.txt","r",stdin);
  freopen("OUTPUT.txt","w",stdout); 
  #endif
  ios_base :: sync_with_stdio(false); 
  cin.tie(NULL) ; 
  cout.tie(NULL);
}
int dp[101][1001],ans1=1e9,dp1[1000001];
int num[10];
int a[1000000];
signed main()
{   
    fastio();
    int t=1;
   // cin>>t;
    while(t--)
    {  
       int l,r,d;
       cin>>l>>r>>d;
       int c=0;
       for(int i=l;i<=r;i++)
       {
           if(i%d==0)
           c++;
       }
       cout<<c;
    }
}
// 🍪 🍪 🍪


Measured memory_bytes: 3656
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=3.14159265359;

bool DP[50]; // DP[2のhoge乗] = フラグを立てた方がいい数

int main() {
    ll N, K;
    cin>>N>>K;
    ll A[N];
    for(int i=0;i<N;++i){
        cin>>A[i];
    }
    ll two = 1;
    int index = 0;
    int flag;
    while(two <= K){
        flag = 0;
        for(int i=0;i<N;++i){
            if((A[i]&two)==0) flag++;
        }
        if(flag > N/2) DP[index] = true;
        index++;
        two *= 2;
    }
    index--;
    two /= 2;
    ll tmpans = 0;
    for(int i=index;i>=0;--i){
        if((DP[i]==true) & (K>=two)){
            tmpans += two;
            K -= two;
        }
        two /= 2;
    }
    ll ans = 0;
    for(int i=0;i<N;++i){
        ans += tmpans ^ A[i];
    }
    cout<<ans<<endl;
}



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

int h, w;
char map[501][501];
int data[502][502];

int main(){
	while (std::cin >> h >> w, h || w){
		for (int i = 0; i < h; i++){
			for (int j = 0; j < w; j++){
				std::cin >> map[i][j];
			}
		}

		for (int i = 0; i < h; i++){
			data[i][w] = 0;
			for (int j = w - 1; j >= 0; j--){
				data[i][j] = data[i][j + 1] + 1;
				if (map[i][j] == '*')data[i][j] = 0;
			}
		}

		int max = 0;

		for (int i = 0; i < h; i++){
			for (int j = 0; j < w; j++){
				int width = data[i][j];
				for (int k = 1; k <= h - i; k++){
					max = std::max(max, k * width);
					width = std::min(width, data[i + k][j]);
				}
			}
		}

		std::cout << max << std::endl;
	}

	return 0;
}

Measured memory_bytes: 2388
#include <iostream>
#include<string>
#include<math.h>
#include<vector>
#include<algorithm>
#include<array>
#include<functional>
#include<iomanip>
#include<ios>
using namespace std;
#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)

typedef int value_type; /* ソートするキーの型 */

value_type med3(value_type x, value_type y, value_type z)
/* x, y, z の中間値を返す */
{
    if (x < y)
        if (y < z) return y; else if (z < x) return x; else return z; else
        if (z < y) return y; else if (x < z) return x; else return z;
}

void quicksort(value_type a[], int left, int right,value_type index[])
/* クイックソート
 * a     : ソートする配列 
 * left  : ソートするデータの開始位置
 * right : ソートするデータの終了位置
 * index: index配列
 */
{
    if (left < right) {
        int i = left, j = right;
        value_type tmp, pivot = med3(a[i], a[i + (j - i) / 2], a[j]); /* (i+j)/2ではオーバーフローしてしまう */
        while (1) { /* a[] を pivot 以上と以下の集まりに分割する */
            while (a[i] < pivot) i++; /* a[i] >= pivot となる位置を検索 */
            while (pivot < a[j]) j--; /* a[j] <= pivot となる位置を検索 */
            if (i >= j) break;
            tmp = a[i]; a[i] = a[j]; a[j] = tmp; /* a[i],a[j] を交換 */
            tmp = index[i]; index[i] = index[j]; index[j] = tmp;
            i++; j--;
        }
        quicksort(a, left, i - 1,index);  /* 分割した左を再帰的にソート */
        quicksort(a, j + 1, right,index); /* 分割した右を再帰的にソート */
    }
}


int dfs(int n,int N){
    if (n>N){
        return 0;
    }
    

    int ret;
    
    return ret;
}
int f(int n){

    if(n%2==0){
        return n/2;
    }else{
        return n*3 +1;
    }
}

int main(){
    int s;
    int Nmax=1000000;
    cin >> s;

    int m[Nmax];
    
    FOR(i,Nmax){
        m[i]= 2;
    }
    //cout << "aa";
    bool x=true;
    int tmp=s;
    int counter=1;
    m[tmp]--;
    while(x){
        
        //cout << tmp <<endl;
        tmp=f(tmp);
        m[tmp]--;
        counter++;
        if(m[tmp]==0){
            break;
        }
        
    }
    
    cout << counter << endl;
    return 0;

    


}

Measured memory_bytes: 4096
#include<iostream>
using namespace std;
#define MAX 100
static const int dx[4] = {1, 0, -1, 0};
static const int dy[4] = {0, -1, 0, 1};

int w, h, sx, sy, gx, gy, G[MAX+2][MAX+2];
 
bool dfs( int x, int y, int color ){
    if ( color == 0 || G[x][y] != color ) return false;
    if ( x == gx && y == gy ) return true;
    G[x][y] = 0;
    for ( int r = 0; r < 4; r++ ){
	if ( dfs(x + dx[r], y + dy[r], color) ) return true;
    }
    return false;
}

main(){
    int n, c, d, px, py, ww, hh;
    while( cin >> w >> h && w ){
	cin >> sx >> sy >> gx >> gy >> n;
	for ( int y = 0; y < h+2; y++ )
	    for ( int x = 0; x < w+2; x++ ) G[x][y] = 0;
	for ( int i = 1; i <=n; i++ ){
	    cin >> c >> d >> px >> py;
	    if ( d == 0 ) { ww = 4; hh = 2; }
	    else { ww = 2; hh = 4; }
	    for ( int y = 0; y <= hh-1; y++ ){
		for ( int x = 0; x <= ww-1; x++ ) {
		    G[px+x][py+y] = c;
		}
	    }
	}
	if ( dfs(sx, sy, G[sx][sy]) ) cout << "OK" << endl;
	else cout << "NG" << endl;
    }
}

Measured memory_bytes: 0
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		new Main().run();
	}

	private void run() {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int n = scanner.nextInt();
			if (n == 0)
				break;
			LinkedList<Integer> list = new LinkedList<Integer>();
			for (int i = 0; i <= n; i++)
				list.add(scanner.nextInt());
			for(ListIterator<Integer>it = list.listIterator();it.hasNext();){
				int a = it.next();
				it.remove();
				if(slove(list)){
					System.out.println(a);
					break;
				}
				it.add(a);
			}
		}
	}

	private boolean slove(List<Integer> tmp) {
		int ans = tmp.get(1) - tmp.get(0);
		for (int i = 2; i < tmp.size(); i++)
			if (tmp.get(i) - tmp.get(i - 1) != ans)
				return false;
		return true;
	}
}

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

// macros
#define ll long long int
#define pb emplace_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define FI first
#define SE second
using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1e9 + 7;

// solve
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(a > b){a = b; return 1;} return 0;}
template <typename T> istream &operator>>(istream &is, vector<T> &vec){for(auto &v: vec)is >> v; return is;}

template<typename T>
T extgcd(T a, T b, T &x, T &y){
  T d = a;
  if(b != 0){
    d = extgcd(b, a % b, y, x);
    y -= (a / b) * x;
  }else{
    x = 1, y = 0;
  }
  return d;
}

int main(int argc, char const* argv[])
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  ll a, b;
  cin >> a >> b;
  ll x, y;
  extgcd(a, b, x, y);
  cout << x << " " << y << endl;
	return 0;
}



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

const int N = 1000005;
string a;
int ans, n, dp[N][2];
 
int f(int i, int carry) {
    int digit = ((a[i] - '0')) + carry;
    if (i == 0) return digit;
    if (dp[i][carry]) return dp[i][carry];
    return dp[i][carry] = (min(f(i-1, 1) + (10-digit), f(i-1, 0) + digit));
}
 
int main() {
    cin >> a;
    n = a.length();
    a = '0' + a;
    cout << f(n, 0) << '\n';
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main(int argc, char *argv[]) {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    int A, B; cin >> A >> B;
    cout << max(A+B, max(A-B, A*B)) << endl;
    return 0;
}

Measured memory_bytes: 256
n = gets.chomp.to_i
arr = gets.chomp.split.map(&:to_i)
count = 0

loop{
    flg = 0
    for i in 1..n-1
        if arr[i] < arr[i-1]
            arr[i],arr[i-1] = arr[i-1],arr[i]
            count += 1
            flg += 1
        end
    end
    flg == 0 && break
}

puts arr.join(" ")
puts count

Measured memory_bytes: 8716
#include<cstdio>
#include<cstring>
#include<algorithm>
#define maxn 100005
using namespace std;
int n,a[3][maxn],f[2],g[2],bit[maxn],pos[maxn];
bool check(int x,int y,int z) { return x+1==y&&y+1==z&&z%3==0; }
int lowbit(int x) { return x&(-x); }
void Modify(int x,int d)
{
	for(;x<=n;x+=lowbit(x)) bit[x]+=d;
}
int Query(int x)
{
	int res=0;
	for(;x;x-=lowbit(x)) res+=bit[x];
	return res;
}
int main()
{
	scanf("%d",&n);
	for(int i=0;i<3;i++)
		for(int j=1;j<=n;j++) scanf("%d",&a[i][j]);
	for(int i=1;i<=n;i++)
	{
		if(!check(a[0][i],a[1][i],a[2][i])&&!check(a[2][i],a[1][i],a[0][i]))
			{ printf("No\n"); return 0; }
		int t=a[2][i]>a[0][i]?a[2][i]/3:a[0][i]/3;
		if((i-t)%2) { printf("No\n"); return 0; }
		pos[t]=i;
		if(a[0][i]>a[2][i]) f[i%2]^=1;
	}
	for(int i=1;i<=n;i+=2)
	{
		int now=pos[i]+(i/2+Query(pos[i]))*2;
		Modify(pos[i],1);
		if((abs(i-now)/2)&1) g[i%2]^=1;
	}
	memset(bit,0,sizeof(bit));
	for(int i=2;i<=n;i+=2)
	{
		int now=pos[i]+(i/2-1+Query(pos[i]))*2;
		Modify(pos[i],1);
		if((abs(i-now)/2)&1) g[i%2]^=1;
	}
	if(f[0]==g[1]&&f[1]==g[0]) printf("Yes\n");
	else printf("No\n");
}

Measured memory_bytes: 2176
function main(lines) {
    const input = lines.split(' ').map(Number)
    const A = input[0]
    const B = input[1]
    const C = input[2]
    const K = input[3]

    var variableNumber = K
    var sum = 0
    
    if(K-A>0){
        variableNumber -= A
        sum += A
    } else if(K-A<=0){
        variableNumber = 0
        sum += K
    }

    if(variableNumber - B>0){
        variableNumber -= B
    } else if(variableNumber - B<=0){
        variableNumber = 0
    }

    if(variableNumber - C <= 0){
        sum -= variableNumber
        console.log(sum)
    }
        
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));



Measured memory_bytes: 29880
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>

using namespace std;

typedef long long LL;
typedef vector<LL> VL;
#define REPD(i,a,b) for (LL i=(a);i<(b);i++)
#define REP(i,n) REPD(i,0,n)

LL inputValue(){
  LL a;
  cin >> a;
  return a;
};

string inputString(){
  string a;
  cin >> a;
  return a;
};

vector<LL> inputVector(LL a){
  vector<LL> rv;
  REP(i, a){
    LL input;
    cin >> input;
    rv.push_back(input);
  }
  return rv;
}

vector<string> inputVectorString(LL a){
  vector<string> rv;
  REP(i, a){
    string input;
    cin >> input;
    rv.push_back(input);
  }
  return rv;
}
vector<vector<LL>> inputVector2D(LL a, LL b){
  vector<vector<LL>> rv;
  REP(i, a){
    rv.push_back(vector<LL>());
    REP(j, b) {
      LL input;
      cin >> input;
      rv.at(i).push_back(input);
    }
  }
  return rv;
}

#if 0
#define debug(d) debug1(__LINE__,#d, d)
void debug1(LL line, const char* name, vector<LL>& v) {
  cout << line << ":" << name << ":vector<LL>(" << v.size() << ") ";
  REP(i, (LL)v.size()) {
    cout << v.at(i) << " ";
  }
  cout << endl;
}
void debug1(LL line, const char* name, LL i) {
  cout << line << ":" << name << ":LL " << i << endl;;
}
void debug1(LL line, const char* name, const char* v) {
  cout << line << ":" << name << ":char* " << v << endl;
}
void debug1(LL line, const char* name, vector<string>& v) {
  cout << line << ":" << name << ":vector<string>(" << v.size() << ") ";
  REP(i, (LL)v.size()) {
    cout << v.at(i) << " ";
  }
  cout << endl;
}
void debug1(LL line, const char* name, vector<vector<LL>>& v) {
  cout << line << ":" << name << ":vector<vector<LL>>(" << v.size() << ") ";
  REP(i, (LL)v.size()) {
    REP(j, (LL)v.at(i).size()) {
      cout << v.at(i).at(j) << " ";
    }
    cout << ", ";
  }
  cout << endl;
}
#else
#define debug(n)
#endif

int main(int argc, const char * argv[]) {
	cout.precision(16);
  // source code

  auto n = inputValue();
  auto hs = inputVector(n);

  LL r = 0;
  LL c = 0;
  LL last = -1;
  REP(i, n) {
    debug("----");
    debug(i);
    debug(r);
    debug(c);
    debug(last);
    debug(hs.at(i));
    if (last == -1) {
      c = 0;
      last = hs.at(i);
      continue;
    }
    if (last >= hs.at(i)) {
      c++;
    }else{
      if (r < c) r = c;
      c = 0;
    }
    last = hs.at(i);
    debug("====");
    debug(i);
    debug(r);
    debug(c);
    debug(last);
    debug(hs.at(i));
  }
  if (r < c) r = c;
  cout << r << endl;

  return 0;
}


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

int main(){
    
    int t;
    //cin >> t;
    t = 1;
    while(t--){
        long long x, k, d;
        cin >> x >> k >> d;
        if(x < 0){
            x *= -1;
        }
        if(x >= 0){
            long long q = x/d;
            long long final_location = x%d;
            
            if(k >= q){
                long long steps_left = k - q;
                if(steps_left%2 == 0){
                    cout << final_location << endl;
                }else{
                    cout << abs(final_location - d) << endl;
                }
                
            }else{
                final_location = x - k*1LL*d;
                cout << abs(final_location) << endl;
            }
            
            
        }
        
    }
    
}


Measured memory_bytes: 3632
import java.math.BigInteger;
import java.util.*;

public class Main{

    public  static void main(String args[])
    {
		Scanner in = new Scanner(System.in);
		int a = in.nextInt();
		int b = in.nextInt();
		if(a % b == 0)
		{
			System.out.println("-1");
		}else
		{
			System.out.printf("%d\n",a);
		}
    }
}

Measured memory_bytes: 21844
import java.util.*;
    public class Main {
     
    	public static void main(String[] args) {
    			
    		Scanner scan =new Scanner(System.in);
    		
    		int a=Integer.parseInt(scan.next());
    		int b=Integer.parseInt(scan.next());
    		
    		System.out.print(a*b%2==0?"Even":"Odd");
     
    }
    }
// end 

Measured memory_bytes: 21844
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<string.h>
#include<complex>
#include<math.h>
using namespace std;
typedef long long int llint;
#define rep(i,n) for(int i=0;i<n;i++)

bool check(int a, int b) {
	return a > b;
}

int main() {
	int h, w;
	cin >> h >> w;
	char s[10][10];
	rep(i, h) {
		cin >> s[i];
	}
	int cnt = 0;
	rep(i, h) {
		rep(j, w) {
			if (s[i][j] == '#') {
				cnt++;
			}
		}
	}
	if (cnt == h + w - 1) {
		cout << "Possible" << endl;
	}
	else {
		cout << "Impossible" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
# 偶数-> E869120 君,奇数-> square1001 君と決め打ち
# -> 各々8切れより多くは取れない
wantToEat = [int(i) for i in input().split(" ")]
if wantToEat[0] > 8 or wantToEat[1] > 8:
    print(":(")
else:
    print("Yay!")


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

typedef long long ll;
const ll M = 1e9 + 7;
const int MAX_K = 50;
const int MAX_N = 100100;
const int LOG_N = 20;

int N, Q;
vector<int> P;
ll table[MAX_K][MAX_N];
ll cumlt[MAX_N];
ll imos[MAX_N + 1];
ll stable[LOG_N][MAX_N];

ll lcm(ll a, ll b){
    return a / __gcd(a, b) * b;
}

ll extgcd(ll a, ll b, ll &x, ll &y) {
    ll g = a; x = 1; y = 0;
    if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
    return g;
}
ll inv(ll a) {
    ll x, y;
    if (extgcd(a, M, x, y) == 1) return (x + M) % M;
    else                         return 0; // unsolvable
}

ll query(int l, int r){
    int n = r - l;
    int i = sizeof(n)*8 - __builtin_clz(n) - 1;
    return lcm(stable[i][l], stable[i][r-(1<<i)]);
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    cin >> N >> Q;
    P.resize(N);
    for(int i=0; i<N; i++){
        int v; cin >> v, v--;
        P[v] = i;
    }
    
    for(int i=0; i<N; i++)
        table[0][i] = i+1;
    for(int i=1; i<MAX_K; i++)
        for(int j=0; j<N; j++)
            table[i][P[j]] = table[i-1][j];
    
    vector<ll> cycle(N);
    for(int i=0; i<N; i++){
        for(int j=1; j<MAX_K; j++){
            cumlt[i] = (table[j][i] + cumlt[i]) % M;
            if(table[j][i] == i+1){
                cycle[i] = j;
                break;
            }
        }
    }
    
    for(int i=0; i<N; i++)
        stable[0][i] = cycle[i];
    for(int i=1; i<LOG_N; i++){
        for(int j=0; j<N; j++){
            if(N <= j+(1<<(i-1)) || stable[i-1][j+(1<<(i-1))] == 0)
                break;
            stable[i][j] = lcm(stable[i-1][j], stable[i-1][j+(1<<(i-1))]);
        }
    }
    
    for(int i=0; i<N; i++)
        imos[i+1] = (imos[i] + (cumlt[i] * inv(cycle[i]))%M) % M;
    
    while(Q--){
        int L, R;
        cin >> L >> R, L--;
        
        ll x = query(L, R) % M;
        ll ans = ((imos[R] - imos[L] + M)%M * x)%M;
        
        cout << ans << endl;
    }
    
    return 0;
}

Measured memory_bytes: 56932
#include <iostream>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <deque>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <iomanip>
#include <map>
#include <stack>
#include <queue>
#include <functional>
#include <climits>
#include <numeric>
#include <bitset>
#include <random>
#include <tuple>
#include <initializer_list>
#include <fstream>
#include <cctype>
#include <string>
#include <cfloat>
#include <array>

int gcd(int a, int b) {
	return b == 0 ? a : gcd(b, a % b);
}
int main() {
	int k; std::cin >> k;
	long long int result{ 0 };
	for (auto a = 1; a <= k; ++a) {
		for (auto b = 1; b <= k; ++b) {
			const auto g = gcd(a, b);
			for (auto c = 1; c <= k; ++c) {
				result += gcd(g, c);
			}
		}
	}
	std::cout << result << std::endl;
}

Measured memory_bytes: 3228
a = raw_input()
a = a.split()
if(int(a[0]) < (int(a[2]) + int(a[4])) or int(a[2]) < 0):
    print 'No'
elif(int(a[1]) < (int(a[3])+int(a[4])) or int(a[3]) < 0):
    print 'No'
else:
    print 'Yes'


Measured memory_bytes: 4644
n = int(input())
s = input()
M = 0
for i in range(1, n):
    cnt = 0
    s1 = s[:i]
    s2 = s[i:]
    t = {}
    for x in s1:
        if x not in t: t[x]=1
    for k in s2:
        if k not in t: t[k]=0
        if t[k] == 1: t[k]+=1
    for x, y in t.items():
        if y==2: cnt+=1
    M = max(cnt, M)
print(M)

Measured memory_bytes: 9056
#include <bits/stdc++.h>
using namespace std;
 
//long long
using ll = long long;
 
// pair<int, int>
using PII = pair<int, int>;
 
//最大値、mod
const int MOD = 1000000007;
const int INF = 1000000000;
const long long LINF = 1e18;
const int MAX = 510000;
 
//出力系
#define print(x) cout << x << endl
#define prints(x) cout << fixed << setprecision(10) << x << endl
#define printc(x) cout << setw(2) << setfill('0') << x << endl;
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()
 
//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
 
//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
 
// 最小公倍数
unsigned lcm(unsigned a, unsigned b){
    return a / gcd(a, b) * b; 
}
 
// a = max(a, b), a = min(a, b)
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; }
 
// 累乗(MODをとる)
ll pow_mod(ll num, ll pow, ll mod) {
    ll prod = 1;
    num %= mod;
    while (pow > 0) {
        if (pow & 1) prod = prod * num % mod;
        num = num * num % mod;
        pow >>= 1;
    }
    return prod;
}
 
 
 
// 二項係数(MODとる、1 ≦ k ≦ n ≦ 10^7 程度)
// COMinit()
// COM(x, y)
// とコンビで使う
 
// テーブルを作る前処理
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
//int dx[4] = {1, 0, 0, -1}, dy[4] = {0, 1, -1 ,0};
 
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;
    }
};


bool f(string s){
    string t = s;
    reverse(all(t));
    return s == t;
}

int main(){
string S;
cin >> S;
int N = S.length();

f(S) && f(S.substr(0, N / 2)) ? yes : no;
return 0;

}


Measured memory_bytes: 256
#include<cstdio>
int H,W,c[26];
char a[110][110];
int dfs(int i,int j){
	int s=1;
	c[a[i][j]-'a']++;a[i][j]=0;
	if(a[i][W-j-1])s+=dfs(i,W-j-1);
	if(a[H-i-1][j])s+=dfs(H-i-1,j);
	return s;
}
int main(){
	scanf("%d%d",&H,&W);
	for(int i=0;i<H;i++)scanf("%s",a[i]);
	int t[5]={0};
	for(int i=0;i<H;i++)
		for(int j=0;j<W;j++)if(a[i][j])t[dfs(i,j)]++;
	for(int j=4;j;j/=2){
		for(int i=0;i<26;i++)t[j]-=c[i]/j,c[i]%=j;
		if(t[j]>0)return puts("No"),0;
		t[j/2]+=t[j]*2;
	}
	puts("Yes");
}

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

#define EPS (1e-7)
#define INF (1e9)
#define LLINF (1e18)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

vector<ll> divisor(ll n)
{
    vector<ll> ret;
    for (ll i = 1; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            ret.push_back(i);
            if (i * i != n)
                ret.push_back(n / i);
        }
    }
    sort(begin(ret), end(ret));
    return (ret);
}

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    vector<bool> ans(n, false); // ボールを入れるならtrue
    // 半分より上で余りが1なら絶対入れる必要あり
    map<ll, int> cnt;
    for (int i = n / 2; i < n; i++)
    {
        if (a[i])
        {
            ans[i] = true;
            auto yakusu = divisor(i + 1);
            for (auto a : yakusu)
            {
                cnt[a]++;
            }
        }
    }
    for (int i = n / 2 - 1; i >= 0; i--)
    {
        if (a[i] != cnt[i + 1] % 2)
        {
            ans[i] = true;
            auto yakusu = divisor(i + 1);
            for (auto a : yakusu)
            {
                cnt[a]++;
            }
        }
    }
    cout << count(ALL(ans), true) << endl;
    for (int i = 0; i < n; i++)
    {
        if (ans[i])
        {
            cout << i + 1 << endl;
        }
    }
}

Measured memory_bytes: 13696
#include<iostream>

using namespace std;

int main(void){

    int H, W, i, j;

    while(true){

        cin >> H >> W;

        if(H == 0 && W == 0)break;

        for(i = 0;i < H;i++){
                
                for(j = 0;j < W;j++){

                    if(j == 0 || j == W - 1)cout << "#";//??????????????????

                    else{

                        if(i == 0 || i == H - 1)cout << "#";//????????????????????¨????????????
                        
                        else{cout << ".";//????????????.???

                        }
                
                    }

                 }//?¨???????????????????

                 cout << endl;

        }

        cout << endl;

    }

return 0;

}

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

int main(){
    ll n;
    double t, a;
    cin >> n >> t >> a;
    double ans = 0, mn = 1e18;
    rep(i, 0, n){
        double h; cin >> h;
        if(mn > abs(a - (t - 0.006 * h))) {
            mn = abs(a - (t - 0.006 * h));
            ans = i+1;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int n,Count=0,res=0,a[15],x[15];

void Check()
{
    if(Count==n)
        return;
    int sum=1;
    for(int i=1;i<=n;i++)
        if(a[i]!=x[i])
            sum*=2;
    res+=sum;
}

void Try(int i)
{
    for(int j=0;j<=1;j++)
    {
        x[i]=j;
        Count+=j;
        if(i==n)
            Check();
        else
            Try(i+1);
        Count-=j;
    }
}

int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        a[i]%=2;
    }
    Try(1);
    cout<<res;
}


Measured memory_bytes: 256
def f():
 global d
 p=[]
 for i in range(len(d)-1):
  a,b=d[i],d[i+1]
  r=(b-a)/3;u,t=r+a+r*(1+3**.5*1j)/2,b-r
  p+=[a,r+a,u,t]
 d=p+[d[-1]]
d=[0j,100+0j]
for _ in[0]*int(input()):f()
for e in d:print(e.real,e.imag)


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

int main() {
  string s;
  cin >> s;
  int snum=0,tnum=0;
  for(int i=0;i<s.size();i++) {
    if(s[i]=='S') {
      snum++;
    }
    else {
      if(snum>0) {
        snum--;
      }
      else {
        tnum++;
      }
    }
  }
  cout << snum+tnum << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <cmath>

using namespace std;

int main(void){

  double x[4];
  double y[4];
  char ten;

  while( cin >> x[0] >> ten >> y[0] ){

    cin >> ten >> x[1] >> ten >> y[1] >> ten >> x[2] >> ten >> y[2] >> ten >> x[3] >> ten >> y[3]; 

    double Area = 0;
    int I;
    for( int i = 0 ; i < 4 ; i++ ){//座標から多角形の面積を求める公式
      if( i == 3 ){
	I = 0;
      }
      else{
	I = i + 1;
      }
      Area += ( x[i] * y[I] ) - ( x[I] * y[i] );
    }

    Area = abs(Area) / 2;

    double area[4];
    area[0] = x[0]*y[1] - x[1]*y[0] + x[1]*y[2] - x[2]*y[1] + x[2]*y[0] - x[0]*y[2];
    area[1] = x[1]*y[2] - x[2]*y[1] + x[2]*y[3] - x[3]*y[2] + x[3]*y[1] - x[1]*y[3];
    area[2] = x[2]*y[3] - x[3]*y[2] + x[3]*y[0] - x[0]*y[3] + x[0]*y[2] - x[2]*y[0];
    area[3] = x[3]*y[0] - x[0]*y[3] + x[0]*y[1] - x[1]*y[0] + x[1]*y[3] - x[3]*y[1];

    for( int i = 0 ; i < 4 ; i++ ){
      area[i] = abs(area[i]) / 2; 
    }
   
   
    double AREA = area[0] + area[1] + area[2] + area[3];
    //cout << area[0] << "---" << area[1] << "---" << area[2] << "---" << area[3]<< endl;
    //cout << Area << endl;
    //cout << AREA << endl;
    if( AREA == 2*Area ) cout << "YES" << endl;
    else cout << "NO" << endl;

  }
  return 0;
}

Measured memory_bytes: 1216