akhauriyash/Code-Regression huggingface dataset:
/*
 * @Author: Kaizyn
 * @Date: 2020-05-30 19:56:59
 * @LastEditTime: 2020-05-30 20:03:58
 */ 
#include <bits/stdc++.h>

// #define DEBUG

using namespace std;

const double eps = 1e-7;
const double PI = acos(-1);
typedef pair<int, int> pii;
const int MOD = 998244353;
const int INF = 0x3f3f3f3f;

string s;

inline void solve() {
  cin >> s;
  for (int i = 0; i < (int)s.size(); ++i) {
    if (s[i] != '?') continue;
    /*
    if (i > 0 && s[i-1] == 'P') s[i] = 'D';
    else s[i] = 'P';
    */
    s[i] = 'D';
  }
  cout << s << endl;
}

signed main() {
  ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  int T = 1;
  // cin >> T;
  for (int t = 1; t <= T; ++t) {
    solve();
  }
  return 0;
}

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

  int p[100001];
  int sz[100001];

int root(int x)
{
  if (p[x]!=x) p[x] = root(p[x]);
  return p[x];
}

bool same(int x, int y)
{
  return root(x) == root(y);
}

void unite(int x, int y)
{
  x=root(x);y=root(y);
  if(x==y) return;
  if (sz[x] > sz[y]) swap(x,y);
  p[x] = y;
  sz[y] += sz[x];
  
  return;
}



int main()
{
  int N, M, K;
  scanf("%d %d %d", &N, &M, &K);  
    
  int minus[N+1];
  
  for(int i=0;i<N+1;i++)
  {
    p[i]=i;
    sz[i]=1;
    minus[i]=0;
  }

  for(int i=0;i<M;i++)
  {
    int k,j;
    scanf("%d %d", &k, &j);  
    unite(k,j);
    minus[k]++;
    minus[j]++;
  }

  for(int i=0;i<K;i++)
  {
    int k,j;
    scanf("%d %d", &k, &j); 
    
    if (same(k,j))
    {
      minus[k]++;
      minus[j]++;
    }
  }

  for(int i=1;i<N+1;i++)
  {
    if(i!=1) cout << " ";
    //printf("i: %d, root: %d, sz: %d, minus: %d\n",i,root(i),sz[root(i)],minus[i]);
    cout << sz[root(i)] - minus[i] - 1;
  }
  
  cout << endl;
  
    return 0;
}




Measured memory_bytes: 2048
import sys
sys.setrecursionlimit(500000)
K = int(input())

ans_list = []
def dfs(A):
    if len(A)!=0 and int("".join(A))<=10**10:
        ans_list.append(int("".join(A)))
    elif len(A)!=0 and int("".join(A))>10**10:
        return
    if len(A)==0:
        for i in range(1, 10, 1):
            A.append(str(i))
            dfs(A)
            A.pop()
        return

    for i in range(0, 10, 1):
        if abs(int(A[-1])-i)<=1:
            A.append(str(i))
            dfs(A)
            A.pop()
    return
dfs([])
ans_list.sort()
print(ans_list[K-1])

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

using namespace std;

int p[65500], j[65500];

int main(void)
{
	int n;
	while (cin >> n, n){
		long long sum = 0, ret;
		for (int i = 0; i < n; i++){
			cin >> p[i];
			sum += p[i];
		}
		for (int i = 0; i < n-1; i++){
			cin >> j[i];
			sum += j[i];
		}
		ret = sum;
		sort(j, j + n-1);
		for (int i = 0; i < n-1; i++){
			sum -= j[i];
			ret = max(ret, sum * (i + 2));
		}
		cout << ret << endl;
	}
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  int sum = 0;
  for (char c : s) {
    sum += c - '0';
    sum %= 9;
  }   
  if (sum == 0)
    cout << "Yes\n";
  else
    cout << "No\n";
  return 0;
}

Measured memory_bytes: 3708
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <climits>

#define X first
#define Y second
#define vsort(v) sort((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())


//INT_MAX
//INT_MIN
//LLONG_MAX
//LLONG_MIN
//DBL_MIN
//DBL_MAX
//LDBL_MIN
//LDBL_MAX

using namespace std;
using ll = long long;

int main(int argc, const char * argv[]) {
    int k;
    cin >> k;
    int x = 0, y = 0;
    for (int i = 1; i <= k; i++) {
        if (i % 2 == 0) {
            x++;
        }else{
            y++;
        }
    }
    cout << x * y << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
/*                        */    //#undef int
#define INF 1000000009
#define INFL 1000000000000000018
#define mod 1000000007
#define pb push_back
typedef pair<int, pair<int, pair<int, int> > > PA;
typedef priority_queue<int> PQ;
typedef priority_queue<PA, vector<PA>, greater<PA> >PQG;
#define fi first
#define sf second.first
#define ssf second.second.first
#define sss second.second.second
#define MP make_pair

int n, m, a[100005], interval[100005], sum;

signed main()
{
    cin >> n >> m;
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    for(int i = 0; i < n - 1; i++){
        interval[i] = a[i + 1] - a[i] - 1;
    }
    sort(interval, interval + n - 1, greater<int>() );
    for(int i = 0; i < m - 1; i++){
        sum += interval[i];
    }
    cout << a[n - 1] - sum - a[0] + 1 << endl;

    return 0;
}



Measured memory_bytes: 4732
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		sc.close();
		
		if(b - a == c - b)
			System.out.println("YES");
		else
			System.out.println("NO");
	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    string S; cin >> S;
    ll ans = 0;
    ll R = 0, G = 0, B = 0;
    rep(i, N) {
        if(S[i] == 'R') R++;
        if(S[i] == 'G') G++;
        if(S[i] == 'B') B++;
    }
    rep(i, N) {
        rep(k, N) {
            
            int j2 = (k + i);
            if(j2 % 2 == 1) continue;
            int j = j2 / 2;
            if(i == j || i == k || j == k || i > j || j > k) continue;
            if(0 <= j && j < N && S[i] != S[j] && S[j] != S[k] && S[k] != S[i]) ans++;
        }
    }
    cout << R * G * B - ans << endl;

    return 0;
}
// j - i = k - j
// 2j = k + i


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while ('0'>ch||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do {(t*=10)+=ch-'0';ch=getchar();} while ('0'<=ch&&ch<='9'); t*=f;
}
const int maxn=(4e5)+10;
int n,m,cnt,idx;
vector<int> g[maxn];
char s[maxn];
int dfn[maxn],low[maxn],fa[maxn];
bool inStack[maxn];
stack<int> st;
void tarjan(int u) {
	dfn[u]=low[u]=++idx;
	inStack[u]=1;
	st.push(u);
	for (int i=0;i<g[u].size();i++) {
		int v=g[u][i];
		if (dfn[v]==-1) {
			fa[v]=u;
			tarjan(v);
			low[u]=min(low[u],low[v]);
		}
		else if (inStack[v])
			low[u]=min(low[u],dfn[v]);
	}
	if (dfn[u]==low[u]) {
		cnt++;
		while (1) {
			int v=st.top();
			st.pop(); inStack[v]=0;
			if (v==u) break;
		}
	}
}
int main() {
	//freopen("1.txt","r",stdin);
	read(n); read(m);
	scanf("%s",s+1);
	for (int i=1;i<=m;i++) {
		int x,y; read(x); read(y);
		if (s[x]==s[y]) g[x].push_back(y+n),g[y].push_back(x+n);
		else g[x+n].push_back(y),g[y+n].push_back(x);
	}
	n*=2;
	memset(dfn,-1,sizeof(dfn));
	for (int i=1;i<=n;i++)
		if (dfn[i]==-1) tarjan(i);
	if (cnt==n) printf("No\n");
	else printf("Yes\n");
	return 0;
}

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



class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int d = sc.nextInt();

    //c<<b<<d
    if(c <= b && b <= d){
      System.out.println( Math.min(Math.abs(a-b), Math.abs(c-b)) );
    }
    //c<<a<<d
    else if(c <= a && a <= d){
      System.out.println( Math.min(Math.abs(a-b), Math.abs(a-d)) );
    }
    //a<<c<<d<<b
    else if(a < c && d < b){
      System.out.println( Math.abs(d-c) );
    }else{
      System.out.println(0);
    }
  }
}


Measured memory_bytes: 20948
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <math.h>
#include <iostream>
#include <string>
#include<algorithm>
#include <vector>
#include <cassert>
using namespace std;
int main() {
	int N;
	int p[100];
	int i, j;
	int mini = 0;
	int sw = 0;

	cin >> N;

	for (i = 0; i < N; ++i) {
		cin >> p[i];
	}

	for (i = 0; i < N; ++i) {
		mini = i;
		for (j = i; j < N; ++j) {
			if (p[mini] > p[j]) {
				mini = j;
			}
		}
		swap(p[i], p[mini]);
		if (mini != i) {
			++sw;
		}
	}




	if (sw == 0||sw==1) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

}


Measured memory_bytes: 256
import java.util.*;
import java.lang.Math;
import java.math.BigInteger; 
public class Main{

	static int check(int x){
		String xx = String.valueOf(x);
		char k[] = xx.toCharArray();
		int flag = 1;
		for(int i = 1;i < xx.length();i ++){
			if(k[i] < k[i-1] || k[i] - k[i-1] != 1){flag = 0;break;}
		}
		if(flag == 0){return 0;}
		else {return 1;}
	}
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int n = sc.nextInt();
			int m[] = new int[n];
			for(int i = 0;i < n;i ++){
				m[i] = sc.nextInt();
			}
			int max = -1;
			for(int i = 0;i < n-1;i ++){
				for(int j = i+1;j < n;j ++){
					int t = m[i] * m[j];
					if(check(t) == 1 && t > max){max = t;}
				}
			}
			System.out.println(max);
		}
	}
}

Measured memory_bytes: 62828
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = LLONG_MAX;

int main()
{
    string s;
    cin >> s;
    int y, m;
    y = m = 0;
    y = (s[0] - '0') * 10 + s[1] - '0';
    m = (s[2] - '0') * 10 + s[3] - '0';
    if (y == 0)
    {
        if (m == 0)
            cout << "NA" << endl;
        if (1 <= m && m <= 12)
            cout << "YYMM" << endl;
        if (13 <= m)
            cout << "NA" << endl;
    }
    else if (1 <= y && y <= 12)
    {
        if (m == 0)
            cout << "MMYY" << endl;
        if (1 <= m && m <= 12)
            cout << "AMBIGUOUS" << endl;
        if (13 <= m)
            cout << "MMYY" << endl;
    }
    else if (13 <= y)
    {
        if (m == 0)
            cout << "NA" << endl;
        if (1 <= m && m <= 12)
            cout << "YYMM" << endl;
        if (13 <= m)
            cout << "NA" << endl;
    }
}


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

#define rep(i,n) for(ll i = 0; i < n; i++)
#define per(i,n) for(ll i = n-1; i >= 0; i--)
#define REP(i,n) for(ll i = 1; i < n; i++)
#define PER(i,n) for(ll i = n; i >= 1; i--)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
using vP = vector<P>;
using vPP = vector<vP>;
using vPl = vector<Pl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
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; }



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

  int n, m;
  cin >> n >> m;
  int ans = 0;
  for(int i = 1; i*i <= m; i++) {
    if(m % i != 0) continue;
    if(i >= n) chmax(ans, m/i);
    if(m/i >= n) chmax(ans, i);
  }
  cout << ans << endl;
}

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

struct Node {
  int ParIdx, ParDepth, Deep; // Deep: HeavyEdge?????§?????±???
  int Size;
};
typedef vector< vector< int > > Graph;

int N, Q;
Graph graph;
int treesz[100000], sz;
Node nodes[100000];
vector< int > Nodes[100000];
int nowtreeIdx[100000], nowtreeDepth[100000]; 

int sizeDFS(int idx, int prev) {
  treesz[idx] = 1;
  for(int i = 0; i < graph[idx].size(); i++) {
    if(graph[idx][i] != prev) treesz[idx] += sizeDFS(graph[idx][i], idx);
  }
  return(treesz[idx]);
}
void makeDFS(int idx, int prev, int treeIdx, int treeDepth, int ParDepth) {
  nodes[treeIdx].Size++;
  Nodes[treeIdx].push_back(idx);
  nowtreeIdx[idx] = treeIdx;
  nowtreeDepth[idx] = treeDepth;
  int ret = 0;
  for(int i = 0; i < graph[idx].size(); i++) {
    if(graph[idx][i] != prev) ret = max(ret, treesz[graph[idx][i]]);
  }
  bool done = false;
  for(int i = 0; i < graph[idx].size(); i++) {
    if(graph[idx][i] != prev) {
      if(!done && treesz[graph[idx][i]] == ret && !done++) {
        makeDFS(graph[idx][i], idx, treeIdx, treeDepth + 1, ParDepth);
      } else {
        nodes[sz++] = (Node){ treeIdx, treeDepth, ParDepth + 1, 0};
        makeDFS(graph[idx][i], idx, sz - 1, 0, ParDepth + 1);
      }
    }
  }
}
void HL() { // ??????????§£
  sizeDFS(0, -1);
  sz = 0;
  nodes[sz++] = (Node){ -1, -1, 0, 0};
  makeDFS(0, -1, 0, 0, 0);
}
int main() {
  int N, Q;
  scanf("%d", &N);
  graph.resize(N);
  for(int i = 0; i < N; i++) {
    int k;
    scanf("%d", &k);
    for(int j = 0; j < k; j++) {
      int c;
      scanf("%d", &c);
      graph[i].push_back(c);
    }
  }
  HL();
  scanf("%d", &Q);
  for(int i = 0; i < Q; i++) {
    int u, v;
    scanf("%d %d", &u, &v);

    int TreeIdxA = nowtreeIdx[u], TreeDepthA = nowtreeDepth[u];
    int TreeIdxB = nowtreeIdx[v], TreeDepthB = nowtreeDepth[v];
    while(TreeIdxA != TreeIdxB) {
      if(nodes[TreeIdxA].Deep > nodes[TreeIdxB].Deep) {
        TreeDepthA = nodes[TreeIdxA].ParDepth;
        TreeIdxA   = nodes[TreeIdxA].ParIdx;
      } else {
        TreeDepthB = nodes[TreeIdxB].ParDepth;
        TreeIdxB   = nodes[TreeIdxB].ParIdx;
      }
    }
    if(TreeDepthA > TreeDepthB) swap(TreeDepthA, TreeDepthB);
    printf("%d\n", Nodes[TreeIdxA][TreeDepthA]);
  }
}

Measured memory_bytes: 19316
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <numeric>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define ll long long
#define debug(x) cout << "debug: " << x << endl
#define MOD 1e9 + 7
#define INF 1e9

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;}

int main(){
    int n, w; cin >> n >> w;
    vector<vector<int>> v(n, vector<int>(2));
    rep(i, n) rep(j, 2) cin >> v[i][j];
    vector<vector<ll>> dp(110, vector<ll>(100100, 0));
    rep(i, n){
        rep(j, w + 1){
            if (j - v[i][0] >= 0)
                chmax(dp[i + 1][j], dp[i][j - v[i][0]] + v[i][1]);
            chmax(dp[i + 1][j], dp[i][j]);
        }
    }
    cout << dp[n][w] << endl;
}

Measured memory_bytes: 87296
using namespace std;
#include <bits/stdc++.h>
#define rep(i, s) for (int i = 0; i < s; ++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 all(v) (v.begin(), v.end())
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define EPS (1e-7)
#define INF (1e10)
#define PI (acos(-1))
const ll mod = 1000000007;
bool f(string s){
  bool ans=true;
  rep(i,s.size()/2){
    if(s[i]!=s[s.size()/2+i]){
      ans=false;
      break;
    }
  }
  return ans;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string N;
  cin>>N;
  if(N=="Sunny")
    cout<<"Cloudy"<<endl;
  else if(N=="Cloudy")
    cout<<"Rainy"<<endl;
  else
    cout<<"Sunny"<<endl;


}


Measured memory_bytes: 256
n, k = gets.to_s.split.map{|t|t.to_i}
s = gets.to_s.chomp

a = []
s.scan(/(1*)(0*)/){ a << $1.size << $2.size }
a.flatten!

ans = t = a[0, 2*k+1].reduce(0){|s,t| s+t }

i = 2
while i+2*k < a.length
  t = t - a[i-1] - a[i-2] + a[i+2*k-1] + a[i+2*k]
  ans = t if ans < t
  i += 2
end
 
puts ans

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

int main()
{
    int n, m;
    cin >> n >> m;
    int a[105];
    if(m == 1){
        if(n == 1){
            cout << 1 << endl;
            cout << 1 << endl;
            cout << 1 << endl;
        }
        else{
            cout << n << endl;
            cout << 2 << endl;
            cout << 1 << " " << n - 1 << endl;
        }
        return 0;
    }
    int c = 0;
    for(int i = 0; i < m; i++){
        cin >> a[i];
        c += a[i] % 2;
    }
    if(c > 2){
        cout << "Impossible" << endl;
        return 0;
    }
    for(int i = 0; i < m; i++){
        if(a[i] % 2){
            swap(a[i], a[0]);
            break;
        }
    }
    for(int i = m - 1; i >= 0; i--){
        if(a[i] % 2){
            swap(a[i], a[m - 1]);
            break;
        }
    }
    for(int i = 0; i < m; i++) cout << a[i] << " ";
    cout << endl;
    if(a[0] == 1){
        cout << m - 1 << endl;
    }
    else{
        cout << m << endl;
        cout << a[0] - 1 << " ";
    }
    for(int i = 1; i < m - 1; i++) cout << a[i] << " ";
    cout << a[m - 1] + 1 << endl;
}


Measured memory_bytes: 256
import collections


M = 10 ** 5 + 10


def solve(n, xs):
    ctr = collections.Counter(xs)
    freqs = [ctr[i] for i in range(0, M)]
    res = max(sum(freqs[i: i + 3]) for i in range(M - 3))
    return res


def main():
    n = int(input())
    xs = [int(x) for x in input().split()]
    print(solve(n, xs))


if __name__ == '__main__':
    main()


Measured memory_bytes: 14556
#include<bits/stdc++.h>
using namespace std;
#define max(a,b) (a<b?b:a)
#define abs(x) (x<0?(-x):x)
#define F(i,L,R) for (int i = L; i < R; i++)
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define RF(i,L,R) for (int i = L; i > R; i--)
#define RFE(i,L,R) for (int i = L; i >= R; i--)
#define getI(a) scanf("%d", &a)
#define getII(a,b) scanf("%d%d", &a, &b)
#define getIII(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define VgetI(n) int (n); scanf("%d",&(n))
#define VgetII(n,m) int (n),(m); scanf("%d %d",&(n),&(m))
#define VgetIII(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k))
#define ll long long
#define INF 1000000000000000005
#define nINF -2000000000
#define MOD 1e9+7
#define PI 3.1415926535897932384626
int main(){
	int n;
	while(~getI(n)){
		int arr[n],ans=0;
		F(i,0,n) getI(arr[i]);
		F(i,0,n){
			ans++;
			F(j,0,i) if(arr[j]>arr[i]){
				ans--;
				break;
			}
		}
		printf("%d\n",ans);
	}
}


Measured memory_bytes: 256
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
S = input()
cnt = 0
pre = ""
now = ""
for i in range(len(S)):
    now += S[i]
    if pre != now:
        cnt += 1
        pre = now
        now = ""
print(cnt)


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

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

    vector<int> A(N);
    int ans = 1e18;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        if (i) {
            ans = __gcd(ans, A[i]);
        }
        else {
            ans = A[i];
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
(defun solve (n m tests)
  (let* ((accepted (make-array n :initial-element nil))
         (rejected (make-array n :initial-element 0))
         (ac 0)
         (pen 0))
    (dotimes (i m)
      (let ((test (aref tests i)))
        (cond
          ((equal (rest test) "WA") (incf (aref rejected (first test))))
          ((null (aref accepted (first test)))
           (progn
             (incf ac)
             (incf pen (aref rejected (first test)))
             (setf (aref accepted (first test)) 1))))))
    (format nil "~a ~a~%" ac pen)))

(defun main ()
  (let* ((n (read))
         (m (read))
         (tests (make-array m)))
    (dotimes (i m)
      (setf (aref tests i) (cons (1- (read)) (read-line))))
    (princ (solve n m tests))
    (fresh-line)))

(main)


Measured memory_bytes: 79824
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<tuple>
#include<utility>
#include<cctype>
using namespace std;

#define REP(i,n) for(int i=0;i<n;++i)
#define enter "\n"

typedef long long ll;


int abc102_b(){
    //入力
    int n;
    cin >> n;
    int a[n];
    int maxa=0;
    int mina=1e9;
    REP(i,n){
        cin >> a[i];
        maxa = max(maxa,a[i]);
        mina = min(mina,a[i]);
    }
    
    //処理
    
    //出力
    cout << maxa-mina <<enter;
    return 0;
}

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


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

using namespace std;

#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 REP(i, n) for(int i = 0; i < (n); ++i)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"

typedef long long ll;
typedef unsigned long long ul;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef priority_queue<int> PQ;
typedef priority_queue<int, V, greater<int>> PQG;

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

ll x, y;

ll sign(ll A) { return (A > 0) - (A < 0); }

int main() {
    cin >> x >> y;
    ll ans = abs(abs(x) - abs(y));
    if(x > y || (signbit(x) && abs(x) < abs(y))) {
        ans++;
        if(signbit(x) == signbit(y)) ans++;
    } else if(signbit(x) != signbit(y)) {
        ans++;
    }
    if(x < 0 && y == 0) ans--;
    if(x > 0 && x > y && y == 0) ans--;
    cout << ans << "\n";
}


Measured memory_bytes: 256
import math
import copy
from copy import deepcopy
import sys
import fractions
# import numpy as np
from functools import reduce
# import statistics
import decimal
import heapq
import collections
import itertools
from operator import mul

sys.setrecursionlimit(100001)


# input = sys.stdin.readline
# sys.setrecursionlimit(10**6)

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum


def getInputListInt():
    outputData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===

n = int(input())

ans = sys.maxsize
for i in range(1, int(math.sqrt(n))+1, 1):
    if n % i == 0:
        b = n//i
        tmp_ans = max(len(str(i)), len(str(b)))
        ans = min(ans, tmp_ans)

print(ans)



Measured memory_bytes: 5164
#include <bits/stdc++.h>
#include <vector>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTG(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) (bit>>i) & 1
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL((a))), (a).end());} while(0)
#define ENDL cout << endl;
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using VPII = vector<PII>;
using VI = vector<int>;
using VVI = vector<VI>;
using Vll = vector<ll>;
using VVll = vector<Vll>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
const int INF = 1e9;


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int H, W;
  cin >> H >> W;
  VS S(H);
  REP(i, H) cin >> S.at(i);
  VVI left(H, VI(W)), right(H, VI(W)), up(H, VI(W)), down(H, VI(W));
  REP(i, H)
  {
    REP(j, W)
    {
      if (S.at(i).at(j) == '#')
      {
        left.at(i).at(j) = -1;
        continue;
      }
      if (j == 0)
      {
        left.at(i).at(j) = 0;
        continue;
      }
      left.at(i).at(j) = left.at(i).at(j-1) + 1;
    }
    REPR(j, W)
    {
      if (S.at(i).at(j) == '#')
      {
        right.at(i).at(j) = -1;
        continue;
      }
      if (j == W-1)
      {
        right.at(i).at(j) = 0;
        continue;
      }
      right.at(i).at(j) = right.at(i).at(j+1) + 1;
    }
  }

  REP(i, W)
  {
    REP(j, H)
    {
      if (S.at(j).at(i) == '#')
      {
        down.at(j).at(i) = -1;
        continue;
      }
      if (j == 0)
      {
        down.at(j).at(i) = 0;
        continue;
      }
      down.at(j).at(i) = down.at(j-1).at(i) + 1;
    }
    REPR(j, H)
    {
      if (S.at(j).at(i) == '#')
      {
        up.at(j).at(i) = -1;
        continue;
      }
      if (j == H-1)
      {
        up.at(j).at(i) = 0;
        continue;
      }
      up.at(j).at(i) = up.at(j+1).at(i) + 1;
    }
  }
  int ans = 0;
  REP(i, H) REP(j, W) ans = max(ans, left.at(i).at(j) + right.at(i).at(j) + up.at(i).at(j) + down.at(i).at(j) + 1);
  cout << ans << endl;

  return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

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

int N,M,Q;
vint G[111111];

int V[111111],D[111111],C[111111];

int ma[111111][11];

signed main(){
    scanf("%lld%lld",&N,&M);
    rep(i,M){
        int a,b;
        scanf("%lld%lld",&a,&b);
        a--;b--;
        G[a].pb(b);G[b].pb(a);
    }

    scanf("%lld",&Q);
    rep(i,Q)scanf("%lld%lld%lld",&V[i],&D[i],&C[i]),V[i]--;

    memset(ma,-1,sizeof(ma));
    priority_queue<tuple<int,int,int>>que;
    rep(i,Q){
        ma[V[i]][D[i]]=i;
        que.push(make_tuple(i,V[i],D[i]));
    }

    while(que.size()){
        int c,v,d;
        tie(c,v,d)=que.top();
        que.pop();
        if(ma[v][d]>c)continue;

        if(d==0)continue;
        for(auto u:G[v]){
            if(ma[u][d-1]>=c)continue;
            ma[u][d-1]=c;
            que.push(make_tuple(c,u,d-1));
        }
    }

    rep(i,N){
        int val=*max_element(ma[i],ma[i]+11);
        if(val==-1)puts("0");
        else printf("%lld\n",C[val]);
    }
    return 0;
}


Measured memory_bytes: 34024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=50+5;
int a[maxn],A,B;
int n,p;
ll c[maxn][maxn];
void yanghui()
{
    c[0][0]=1;
    c[1][0]=c[1][1]=1;
    for(int i=2;i<maxn;i++)
    {
        c[i][0]=c[i][i]=1;
        for(int j=1;j<i;j++) c[i][j]=c[i-1][j-1]+c[i-1][j];
    }
/*    for(int i=1;i<maxn;i++)
    {
        for(int j=0;j<=i;j++){
            printf("%8lld ",c[i][j]);
        }puts("");
    }*/
}
ll C(int i,int j) {return c[i][j];}
int main()
{
//    freopen("1.out","w",stdout);
    scanf("%d%d",&n,&p);
    yanghui();
    for(int i=1;i<=n;i++) {scanf("%d",&a[i]);A+=(a[i]%2==1),B+=(a[i]%2==0);}
    if(p==1){
        ll ans=0;
        int lim=A%2==1?A:A-1;
        for(int i=1;i<=lim;i+=2)
                for(int j=0;j<=B;j++)
                    ans+=C(B,j)*C(A,i);
        printf("%lld\n",ans);
    }else{
        ll ans=0;
        int lim=A%2==0?A:A-1;
        for(int i=0;i<=lim;i+=2)
            for(int j=0;j<=B;j++)
                ans+=C(B,j)*C(A,i);
        printf("%lld\n",ans);
    }
    return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
using namespace std;
int a[200005];
int main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)a[i]-=i;
	sort(a+1,a+n+1);
	int m=n/2+n%2;
	long long ans=0;
	for(int i=1;i<=n;i++)
		ans+=abs(a[i]-a[m]);
	cout<<ans<<endl;
}

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

int main() {
    ll l,r;
    cin>>l>>r;
    if(r-l>2019){
        cout<<0<<endl;
    }else{
        ll ml=(l+2019)%2019;
        ll mr=(r+2019)%2019;
        if(ml>mr){
            mr=ml+(2019-(mr-ml));
        }
        ll mini=1e9;
        for(ll i=ml;i<mr;i++){
            for(ll j=i+1;j<=mr;j++){
                mini=min(mini,(i*j+2019)%2019);
            }
        }
        cout<<mini<<endl;
    }
}


Measured memory_bytes: 256
N,M = map(int,input().split())
H = list(map(int,input().split()))

d = []
for i in range(M):
    A,B = map(int,input().split())
    d.append((A-1,B-1))

cnt = 0
flag = {}
for i in range(N):
    flag[i] = True

for i in d:
    A = i[0]
    B = i[1]
    if not(H[A] > H[B] and flag[A] == True):
        flag[A] = False
    if not(H[B] > H[A] and flag[B] == True):
        flag[B] = False
print(list(flag.values()).count(True))

Measured memory_bytes: 38024
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
// please, read the question correctly (do you need set or multiset)???
const int N=500010; //check the limits, dummy


// Variable to represent block size. This is made global 
// so compare() of sort can use it. 
int block; 

// Structure to represent a query range 
struct Query 
{ 
	int L, R, idx;
}; 

// Function used to sort all queries so that all queries 
// of the same block are arranged together and within a block, 
// queries are sorted in increasing order of R values. 
bool compare(Query x, Query y) 
{ 
	// Different blocks, sort by block. 
	if (x.L/block != y.L/block) 
		return x.L/block < y.L/block; 

	// Same block, sort by R value 
	return x.R < y.R; 
} 

// Prints sum of all query ranges. m is number of queries 
// n is size of array a[]. 
int cnt[N], res[N];
void queryResults(int a[], int n, Query q[], int m) 
{ 
	// Find block size 
	block = (int)sqrt(n); 

	// Sort all queries so that queries of same blocks 
	// are arranged together. 
	sort(q, q + m, compare); 

	// Initialize current L, current R and current sum 
	int currL = 0, currR = 0; 
	int ans=0;

	// Traverse through all queries 
	for (int i=0; i<m; i++) 
	{
		// L and R values of current range 
		int L = q[i].L, R = q[i].R; 

		// Remove extra elements of previous range. For 
		// example if previous range is [0, 3] and current 
		// range is [2, 5], then a[0] and a[1] are subtracted 
		while (currL < L) 
		{
			--cnt[a[currL]];
			if(cnt[a[currL]]==0)--ans;
			currL++; 
		} 

		// Add Elements of current Range 
		while (currL > L) 
		{
			++cnt[a[currL-1]];
			if(cnt[a[currL-1]]==1)++ans;
			// currSum += a[currL];
			currL--; 
		} 
		while (currR <= R) 
		{

			++cnt[a[currR]];
			if(cnt[a[currR]]==1)++ans;
			// currSum += a[currR]; 
			currR++; 
		} 

		// Remove elements of previous range. For example 
		// when previous range is [0, 10] and current range 
		// is [3, 8], then a[9] and a[10] are subtracted 
		while (currR > R+1) 
		{ 
			--cnt[a[currR-1]];
			if(cnt[a[currR-1]]==0)--ans;
			// currSum -= a[currR-1]; 
			currR--; 
		} 
		res[q[i].idx]=ans;
		// Print sum of current range 
		// cout << "Sum of [" << L << ", " << R 
		// 	<< "] is " << ans << endl; 
	}
} 

// Driver program 
	Query q[N];
	int a[N];
int n, m;
int main() 
{ 
int x, y;
	scanf("%d%d",&n,&m);
	for(int i=0; i<n; ++i){
		scanf("%d",&a[i]);
	}
	for(int i=0; i<m; ++i){
		scanf("%d%d",&x,&y);--x;--y;
		q[i].L=x;
		q[i].R=y;
		q[i].idx=i;
	} 
	queryResults(a, n, q, m);
	for(int i=0; i<m; ++i){
		printf("%d\n",res[i]);
	} 
	return 0; 
} 


Measured memory_bytes: 15440
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In,' '));
        }

        public void Solve(ConsoleInput cin)
        {     
            //ABC 162 B
            var N = cin.ReadInt;
            long sum = 0;
            for (int i = 1; i <= N; i++)
            {
                if (i % 3 != 0 && i % 5 != 0) sum += i;
            }
            Console.WriteLine(sum);
        }
    }


    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream,char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }

        public string Read
        {
            get
            {
                if(inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for(int i = 0;i < tmp.Length;i++)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }

        
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }

}

Measured memory_bytes: 27904
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define rep(i, n) for(ll i=0; i<(ll)(n); i++)
#define repd(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=b-1; (ll)(a)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
string YES[2] = {"NO", "YES"};
string yes[2] = {"No", "Yes"};

int main(){
    
    ll a, b, c, d;  cin >> a >> b >> c >> d;
    ll res = max(a*c, max(a*d, max(b*c, b*d)));
    cout << res << endl;
}


Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
                int m = sc.nextInt();
                int matrix_A[][] = new int[n][m];
                int matrix_B[] = new int[m]; 
                int AB = 0;
                for(int i = 0; i < n; i++){
                    for(int j = 0; j < m; j++){
                     int num = sc.nextInt();
                     matrix_A[i][j] = num;
                    }
                }
                for(int j = 0; j < m; j++){
                    int num = sc.nextInt();
                   matrix_B[j] =  num;
                }
                for(int i = 0; i < n; i++){
                    for(int j = 0; j < m; j++){
                AB += matrix_A[i][j]*matrix_B[j];
                    }
                    System.out.println(AB);
                    AB = 0;
                }
    }
}

Measured memory_bytes: 40320
#include <stdio.h>

int main(void)
{
	int N;
	scanf("%d", &N);
	int H[N];
	int ans = 0;
	int count = 0;

	for (int i = 0; i < N; i++)
	{
		scanf("%d", &H[i]);
		if (i > 0)
		{
			if (H[i-1] >= H[i])
			{
				count++;
			}

			else
			{
				if (ans < count)
				{
					ans = count;
				}
				count = 0;
			}
		}
	}

	if (ans < count)
		ans = count;
	
	printf("%d\n", ans);



	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
const ll INF = 1001001001;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
//printf("%.10f\n", N);
/*
ll memo[100000];
ll fibo(ll n){
    if(memo[n] != 0)return memo[n];
    if(n <= 1)return n;
    else return memo[n] = fibo(n - 1)+ fibo(n - 2);
}*/
int main() {
    ll W,A,B;
    cin >> W >> A >> B;
    if(A + W < B)cout << B - A - W << endl;
    else if(B + W < A)cout << A - B - W << endl;
    else cout << 0 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
void Input(); void Prepare(); void Setup(); void Solve(); void Clean();

#ifdef DEBUG6500
LL N = 10000000019;
int main(){ Prepare(); Solve(); return 0; }
#else
LL N;
int main(){ Input(); Prepare(); Solve(); Clean(); return 0; }
#endif

void Solve()
{
	LL sqrtN = LL(sqrt(N));
	LL div;
	for (div = sqrtN; div >= 1; --div){
		if (N % div == 0) break;
	}

	LL ans = div + N / div - 2;
	cout << ans << endl;
}

void Prepare()
{
}

#ifndef DEBUG6500
void Clean()
{
}

void Input()
{
	cin >> N;
}
#endif


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

#define rep(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define mt make_tuple
template<class T1, class T2> bool chmin(T1 &a, T2 b) { return b < a && (a = b, true); }
template<class T1, class T2> bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

using ll = long long; using ld = long double; using vll = vector<ll>; using vvll = vector<vll>; using vld = vector<ld>; 
using vi = vector<int>; using vvi = vector<vi>;
using P = pair<ll, ll>;

template <typename T, typename U> ostream &operator<<(ostream &o, const pair<T, U> &v) {  o << "(" << v.first << ", " << v.second << ")"; return o; }
template<size_t...> struct seq{}; template<size_t N, size_t... Is> struct gen_seq : gen_seq<N-1, N-1, Is...>{}; template<size_t... Is> struct gen_seq<0, Is...> : seq<Is...>{};
template<class Ch, class Tr, class Tuple, size_t... Is>
void print_tuple(basic_ostream<Ch,Tr>& os, Tuple const& t, seq<Is...>){ using s = int[]; (void)s{0, (void(os << (Is == 0? "" : ", ") << get<Is>(t)), 0)...}; }
template<class Ch, class Tr, class... Args> 
auto operator<<(basic_ostream<Ch, Tr>& os, tuple<Args...> const& t) -> basic_ostream<Ch, Tr>& { os << "("; print_tuple(os, t, gen_seq<sizeof...(Args)>()); return os << ")"; }
ostream &operator<<(ostream &o, const vvll &v) { rep(i, v.size()) { rep(j, v[i].size()) o << v[i][j] << " "; cout << endl; } return o; }
template <typename T> ostream &operator<<(ostream &o, const vector<T> &v) { o << '['; rep(i, v.size()) o << v[i] << (i != v.size()-1 ? ", " : ""); o << "]";  return o; }
template <typename T>  ostream &operator<<(ostream &o, const set<T> &m) { o << '['; for (auto it = m.begin(); it != m.end(); it++) o << *it << (next(it) != m.end() ? ", " : ""); o << "]";  return o; }
template <typename T, typename U>  ostream &operator<<(ostream &o, const map<T, U> &m) { o << '['; for (auto it = m.begin(); it != m.end(); it++) o << *it << (next(it) != m.end() ? ", " : ""); o << "]";  return o; }
template <typename T, typename U>  ostream &operator<<(ostream &o, const unordered_map<T, U> &m) { o << '['; for (auto it = m.begin(); it != m.end(); it++) o << *it; o << "]";  return o; }
#define VN(v) # v
#define print(a) cout << a << "#" << VN(a) << endl;

static const double EPS = 1e-14;
static const long long INF = 1e18;
static const long long mo = 1e9+7;

int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    ll a, b, c;
    while (cin >> a >> b >> c && a > 0) {
        ll m = 0;
        rep(i, c) rep(j, c) { 
            if (!i || !j)
                continue;
            if (i * (100 + a) / 100 + j * (100 + a) / 100 != c) 
                continue;
            chmax(m, i * (100 + b) / 100 + j * (100 + b) / 100);
        }
        cout << m << endl;
    }
    return 0;
}

Measured memory_bytes: 3092
import heapq
N, M = map(int, input().split())
A = list(map(lambda x:int(x)*(-1), input().split()))
heapq.heapify(A)
for i in range(0,M):
    a=heapq.heappop(A)
    heapq.heappush(A,(-1)*(-a//2))
print(-sum(A))

#　優先度付きキューが難しい

Measured memory_bytes: 20476
#include<bits/stdc++.h>
using namespace std;
int main()
{  int n,t=1,min=1001,a[2];
   cin>>n;
   for(int i=1;i<=32;i++)
   {
     for(int j=2;j<=10;j++)
	 {
	   int flag=0;
	   for(int k=1;k<=j;k++)
	   {
	     t=t*i;
	     if(t>n)
	     {
	       flag=1;
		   break;	
		 }
	   }
	   if(flag==0 && n-t<min)
	   {
	     min=n-t;
	     a[0]=i;
	     a[1]=j;
	   }
	   t=1;
	 }	 
   }
   for(int i=1;i<=a[1];i++)  t=t*a[0];
   cout<<t; 
   return 0;
}

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

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << ((abs(a - b) > d || abs(b - c) > d ) && abs(c - a) > d ? "No" : "Yes") << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
namespace TestApp
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                 
                var st = Console.ReadLine()
                    .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
                    .Select(x => int.Parse(x))
                    .ToArray();
                int n = st[0];
                int m = st[1];
                if (n + m == 0)
                    break;
                var ls = new List<KeyValuePair<int, int>>();
                for (int i = 0; i < n; i++)
                {
                    var x = Console.ReadLine().Split(' ');
                    var d = int.Parse(x[0]);
                    var p = int.Parse(x[1]);
 
                    var unko = ls.FirstOrDefault(y => y.Value == p);
                    if (unko.Key != 0 && unko.Value != 0)
                    {
                        var a = ls.FindIndex(z => { return z.Key == unko.Key && z.Value == unko.Value; });
                        unko = new KeyValuePair<int, int>(unko.Key + d, p);
 
                        if (a < 0)
                            continue;
                        ls[a]
                            = unko;
                    }
                    else
                    {
                        ls.Add(new KeyValuePair<int, int>(d, p));
                    }
                }
                 
                ls = ls.OrderByDescending(x => x.Value).ToList();
                var oldls = ls.ToList();
                foreach (var item in oldls)
                {
                    if (m == 0)
                        break;
                    var ind = oldls.FindIndex(x => { return x.Value == item.Value && x.Key == item.Key; });
                    var l = ls[ind];
 
                    if (m-item.Key <= 0)
                    {
                        ls[ind] = new KeyValuePair<int, int>(l.Key - m,l.Value);
                        m = 0;
                    }
                    else
                    {
                        m = m - ls[ind].Key;
                        ls[ind] = new KeyValuePair<int, int>(0, l.Value);
                    }
                }
                var ans = 0;
                foreach (var item in ls)
                {
                    ans += item.Key * item.Value;
                }
                Console.WriteLine(ans);
            }
        }
         
    }
 
}


Measured memory_bytes: 10392
K = int(input())

R = ["1","2","3","4","5","6","7","8","9"]

len_R_p,len_R_n,digit = 0,9,0
while len_R_n < K:
    for i in range(len_R_p,len_R_n):
        if R[i][digit] == "0":
            R.append(R[i]+"0")
            R.append(R[i]+"1")
        elif R[i][digit] == "9":
            R.append(R[i]+"8")
            R.append(R[i]+"9")
        else:
            R.append(R[i]+str(int(R[i][digit])-1))
            R.append(R[i]+str(int(R[i][digit])))
            R.append(R[i]+str(int(R[i][digit])+1))
    len_R_p = len_R_n
    len_R_n = len(R)
    digit += 1

print(R[K-1])


Measured memory_bytes: 17300