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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define _abs(x)((x) < 0 ? (x) * -1 : (x))
#define _max(x, y)(max(0, max((x), (y))))
#define _min(x, y)(max(0, min((x), (y))))
template<typename T> inline bool __max__(T &x, const T &y) { return x < y ? x = y, 1 : 0; }
template<typename T> inline bool __min__(T &x, const T &y) { return x > y ? x = y, 1 : 0; }

#define pb push_back
#define mp make_pair

static const ll MOD = 1e9 + 7;

int main()
{
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    //freopen("debug.txt", "w", stderr);

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

    string s0, s1;

    cin >> s0;
    cin >> s1;

    if (s0[0] == s1[2] && s0[1] == s1[1] && s0[2] == s1[0]) cout << "YES" << '\n';
    else cout << "NO" << '\n';

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main() {
	int a, b;
	scanf("%d%d", &a, &b);
	if (b < 10) a = a * 10 + b;
	else if (b < 100) a = a * 100 + b;
	else a = a * 1000 + b;
	int i = 317;
	while (i--)
	{
		if (a==i*i)
		{
			printf("Yes");
			return 0;
		}
	}
	printf("No");
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
ll n,ans=0;
void dfs(ll x,ll a,ll b,ll c){
  if(x>n){return;}
  if(a&&b&&c)ans++;
  dfs(10*x+3,1,b,c);
  dfs(10*x+5,a,1,c);
  dfs(10*x+7,a,b,1);
}
int main(){
  cin>>n;
  dfs(0,0,0,0);
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef long int li;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
typedef pair<ll, ll>P;
#define PI 3.14159265359
#define MOD 998244353
const int MAX = 510000;

int main() {
 int N,M;
 cin>>N>>M;
 ll P=N*100ll+M*1800ll; 
 ll ans=1;
 rep(i,M){ans*=2ll;}
 cout<<ans*P; 
}

Measured memory_bytes: 256
#include <iostream>
#include <iosfwd>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <cassert>
#include <cctype>
#include <climits>
#include <vector>
#include <bitset>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <deque>
#include <string>
#include <list>
#include <iterator>
#include <sstream>
#include <complex>
#include <fstream>
#include <functional>
#include <numeric>
#include <utility>
#include <algorithm>
#include <assert.h>
#include <unordered_map>

using namespace std;

#define csl ios_base::sync_with_stdio(false); cin.tie(NULL)

long long t, n, m, u, v, q, k, s;
const int N = 2e5 + 500;
const long long mod = 1e9 + 7;
const long long INF = 1LL << 57;

long long arr[N];
string str, ss;

int main() {
   csl;
   cin >> str;
   int best = str.size() - 1;
   for (int i = 0; i < 26; ++i) {
      ss = str;
      string tss;
      int cnt = 0;
      char tar = 'a' + i;
      for (auto x : ss) if (x == tar) cnt++;
      if (cnt == 0) continue;
      int turn = 0;
      while (cnt != ss.size()) {
         ++turn;
         cnt = 0;
         tss = "";
         for (int i = 0; i < (int)ss.size() - 1; ++i) {
            if (ss[i] == tar) tss.push_back(ss[i]);
            else tss.push_back(ss[i + 1]);
            if (tss.back() == tar) cnt++;
         }
         ss = tss;
      }
      best = min(best, turn);
   }
   cout << best << endl;
   return 0;
}




























Measured memory_bytes: 256
// package main

// import "fmt"

// func main() {
// var h, w, k, black, ans int
// fmt.Scan(&h, &w, &k)
// var c [6][6]bool

// for i := 0; i < h; i++ {
// 	var s string
// 	fmt.Scan(&s)
// 	for j := 0; j < w; j++ {
// 		if s[j] == '#' {
// 			c[i][j] = true
// 		}
// 	}
// }
// ans = 0

// for maskR := 0; maskR < (1 << h); maskR++ {
// 	for maskC := 0; maskC < (1 << w); maskC++ {
// 		for i := 0; i < h; i++ {
// 			if (maskR>>i)&1 == 1 {
// 				continue
// 			}
// 			for j := 0; j < w; j++ {
// 				if c[i][j] && (maskC>>j)&1 == 0 {
// 					black++
// 				}
// 			}
// 		}
// 		if black == k {
// 			ans = ans + 1
// 		}
// 	}
// }
// fmt.Println(ans)
// 	package main

// import "fmt"

// func main() {
// 	var h, w, k int
// 	fmt.Scan(&h, &w, &k)
// 	var c [6][6]bool

// 	for i := 0; i < h; i++ {
// 		var s string
// 		fmt.Scan(&s)
// 		for j := 0; j < w; j++ {
// 			if s[j] == '#' {
// 				c[i][j] = true
// 			}
// 		}
// 	}

// 	ans := 0
// 	for i := 0; i < (1 << h); i++ {
// 		for j := 0; j < (1 << w); j++ {
// 			cnt := 0
// 			for x := 0; x < h; x++ {
// 				if (i>>x)&1 == 1 {
// 					continue
// 				}
// 				for y := 0; y < w; y++ {
// 					if c[x][y] && (j>>y)&1 == 0 {
// 						cnt++
// 					}
// 				}
// 			}
// 			if cnt == k {
// 				ans++
// 			}
// 		}
// 	}
// 	fmt.Println(ans)
// }
package main

import "fmt"

func main() {
	var h, w, k int
	fmt.Scan(&h, &w, &k)
	var c [6][6]bool

	for i := 0; i < h; i++ {
		var s string
		fmt.Scan(&s)
		for j := 0; j < w; j++ {
			if s[j] == '#' {
				c[i][j] = true
			}
		}
	}

	ans := 0
	for i := 0; i < (1 << h); i++ {
		for j := 0; j < (1 << w); j++ {
			cnt := 0
			for x := 0; x < h; x++ {
				if (i>>x)&1 == 1 {
					continue
				}
				for y := 0; y < w; y++ {
					if c[x][y] && (j>>y)&1 == 0 {
						cnt++
					}
				}
			}
			if cnt == k {
				ans++
			}
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1772
/*やったぜ。　投稿者：変態糞土方 (8月16日（水）07時14分22秒)

昨日の8月15日にいつもの浮浪者のおっさん（60歳）と先日メールくれた汚れ好きの土方のにいちゃん

（45歳）とわし（53歳）の3人で県北にある川の土手の下で盛りあったぜ。

今日は明日が休みなんでコンビニで酒とつまみを買ってから滅多に人が来ない所なんで、

そこでしこたま酒を飲んでからやりはじめたんや。

3人でちんぽ舐めあいながら地下足袋だけになり持って来たいちぢく浣腸を3本ずつ入れあった。

しばらくしたら、けつの穴がひくひくして来るし、糞が出口を求めて腹の中でぐるぐるしている。

浮浪者のおっさんにけつの穴をなめさせながら、兄ちゃんのけつの穴を舐めてたら、

先に兄ちゃんがわしの口に糞をドバーっと出して来た。

それと同時におっさんもわしも糞を出したんや。もう顔中、糞まみれや、

3人で出した糞を手で掬いながらお互いの体にぬりあったり、

糞まみれのちんぽを舐めあって小便で浣腸したりした。ああ～～たまらねえぜ。

しばらくやりまくってから又浣腸をしあうともう気が狂う程気持ちええんじゃ。

浮浪者のおっさんのけつの穴にわしのちんぽを突うずるっ込んでやると

けつの穴が糞と小便でずるずるして気持ちが良い。

にいちゃんもおっさんの口にちんぽ突っ込んで腰をつかって居る。

糞まみれのおっさんのちんぽを掻きながら、思い切り射精したんや。

それからは、もうめちゃくちゃにおっさんと兄ちゃんの糞ちんぽを舐めあい、

糞を塗りあい、二回も男汁を出した。もう一度やりたいぜ。

やはり大勢で糞まみれになると最高やで。こんな、変態親父と糞あそびしないか。

ああ～～早く糞まみれになろうぜ。

岡山の県北であえる奴なら最高や。わしは163*90*53,おっさんは165*75*60、や

糞まみれでやりたいやつ、至急、メールくれや。

土方姿のまま浣腸して、糞だらけでやろうや。*/
#include "bits/stdc++.h"
#include <numeric>
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define llMAX numeric_limits<long long>::max()
#define intMAX numeric_limits<int>::max()
#define llMIN numeric_limits<long long>::min()
#define intMIN numeric_limits<int>::min()
#define d_5 100000
#define d9_7 1000000007
#define vll vector<vector<long long>>
#define vl vector<long long>
#define vi vector<int>
#define vii vector<vector<int>>
#define pb push_back
#define pf push_front
#define ld long double
ll judge2(ll n){
  ll ans=1;
  while(!(n<ans && ans<=2*n)){
    ans*=2;
  }
  return ans-n;
}

int main(void){
  ll k;
  cin>>k;
  vl a(k);
  rep(i,k){
    cin>>a[i];
  }
  ll nowmax=2;
  ll nowmin=2;
  reverse(a.begin(),a.end());
  rep(i,k){
    ll tmp=(nowmin/a[i])*a[i];
    while(1){
      if(nowmax>=tmp && nowmin<=tmp)break;
      if(nowmax<tmp){
        cout<<-1<<endl;
        return 0;
      }
      tmp+=a[i];
    }
    if(a[i]>nowmax ){
      cout<<-1<<endl;
      return 0;
    }
    ll tmpnowmax=(nowmax/a[i])*a[i];
    nowmax=tmpnowmax+a[i]-1;
    if(a[i]>=nowmin){
      nowmin=a[i];
    }else{
      nowmin=a[i]*((nowmin+a[i]-1)/a[i]);
    }
    /*nowmin=max(a[i],((nowmin + a[i]-1)/a[i])*a[i] );
    nowmax=((nowmax+(a[i]-1))/a[i])*a[i] + -1;*/
  }
  cout<<nowmin<<" "<<nowmax<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define pb push_back
#define all(v) (v).begin() , (v).end()
#define popcnt(x) __builtin_popcount(x)
#define inf 0x3f3f3f3f
#define watch(x) cout << (#x) << " is " << (x) << endl
#define F first
#define S second

using namespace std;
using namespace __gnu_pbds;
typedef long long  ll;

template <typename T>
using ordered_set = tree<T, null_type, less<T> , rb_tree_tag, tree_order_statistics_node_update>;

const double EPS = 1e-9;
const double pi = acos(-1.0);

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


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

    vector<int> below , upon;
    for(int i = 0 ; i < n ; ++i){
        int num;
        cin >> num;
        if(num < 0)below.pb(num);
        else upon.pb(num);
    }

    sort(all(below) , greater<int>());
    sort(all(upon));

    for(int &x : below){
        x = abs(x);
    }

    ll ans = LLONG_MAX / 2;
    for(int i = 0 ; i <= k ; ++i){
        int f = i , s = k - i;

        if(f <= below.size() && s <= upon.size()){
            ll costf = 0 , costs = 0;
            if(f)costf = below[f - 1];
            if(s)costs = upon[s - 1];

            ans = min(ans , min(costf , costs) * 2LL + max(costf , costs));
        }
    }

    cout << ans << '\n';
}


Measured memory_bytes: 1020
/**
 *   created: 28 April 2019  23:46:46
**/
#include<bits/stdc++.h>
using namespace std;

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

#define PB push_back
#define PPB pop_back
#define all(c) (c).begin,(c).end()
#define rep(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
// #define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define INFLL 2000000000000000007
#define INF 2000000007
#define MOD 1000000007


#define TRACE

#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif


void optimizeIO()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}

//                                        //AUTHOR: Kaushalesh Shukla

//=========================================================================================================
vector< vi > adj;
vl val;
vi vis;

ll dfs(int node,ll x){
	vis[node]=1;
	if(val[node]>=0)
		x = min(x,val[node]);
	for(int t : adj[node]){
		if(!vis[t])
			x = dfs(t,x);
	}
	return x;
}
int main()
{
	optimizeIO();
	int tt=1;
	// cin>>tt;
	while(tt--){
		int n,m;
		cin>>n>>m;
		vii v(m);
		rep(i,0,m){
			int a,b;
			cin>>a>>b;
			v[i] = {a,b};
		}
		sort(v.begin(), v.end());
		int mini = 1, mixi= n;
		rep(i,0,m){
			mini = max(mini, v[i].first);
			mixi = min(mixi, v[i].second);
		}
		if(mixi-mini+1<=0)
			cout<<0;
		else
			cout<<mixi-mini+1;
		// cout<<res;
	}
	return 0;
}





Measured memory_bytes: 1024
n = int(input())

list = []

for i in range(n):
	city,score = input().split()
	list.append({'id': i + 1, 'city': city, 'score': int(score)})

list = sorted(list, key=lambda x:x['score'], reverse=True)
list = sorted(list, key=lambda x:x['city'])

for dict in list:
	print(dict['id'])


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

int main(){ 
  int N; cin >> N;
  for(int X = 1; X <= 100100; X++){ 
    if( floor(X*1.08) == N){ cout << X << endl; return 0;}
    
  }
  
  cout << ":(" << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int Fibonacci (int);
int main()
{
int n,f;
scanf("%d",&n);
f=Fibonacci(n);
printf("%d\n",f);
return 0;

}
int Fibonacci(int n)
{
  int f,f1,f2,i;
  if(n<2) return n;
  else{
    f1=f2=1;
    for(i=2;i<=n;i++){
      f=f1+f2;
      f2=f1;
      f1=f;
    }
    return f;
  }
}

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



int main() {
	string s;cin >> s;
	for(int i = 1; i < 4;i++) {
		if(s[i] == s[i-1]) {cout << "Bad" << endl; return 0;}
	}
	cout << "Good" << endl;
}


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

Measured memory_bytes: 21716
#include <bits/stdc++.h>
typedef long long LL;
const int maxN = 1e4+3;
int cnt[maxN];
int main()
{
    for (int x = 1; x < 100; ++x)
        for (int y = 1; y < 100; ++y)
            for (int z = 1; z < 100; ++z)
    {
        int tmp = x*x + y*y + z*z + x*y + y*z + z*x;
        if (tmp <= 10000)
            ++cnt[tmp];
    }
    int N;
    std::scanf("%d", &N);
    for (int i = 1; i <= N; ++i)
        std::printf("%d\n", cnt[i]);
}


Measured memory_bytes: 3788
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
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; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  string s; 
  cin >> s;
  reverse(ALL(s));
  s += '0';

  int N = s.size();

  vector<vector<int>> dp(N+1, vector<int>(2, INF));
  dp[0][0] = 0;

  REP(i, N) REP(j, 2){
    int d = s[i]-'0'+j;

    REP(a, 10){
      chmin(dp[i+1][(a-d < 0)], dp[i][j]+2*a-d+(a-d<0? 10: 0));
    }
  }

  cout << dp[N][0] << "\n";

  return 0;
}

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

#define ll long long int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()
using namespace std;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	ll a,b,c,x,y;
	cin >> a >> b >> c >> x >> y;
	ll minus;
	ll ans=0;
	if(a>c*2 && b>c*2){
		ans += max(x,y) * c * 2;
	}else if(a>c*2){
		ans += x * c * 2;
		y -= x;
		if(y>0) ans += y * b;
	}else if(b>c*2){
		ans += y * c * 2;
		x -= y;
		if(x>0) ans += x * a;
	}else if(a+b > c*2){
		minus = min(x,y);
		ans += minus * c * 2;
		x -= minus;
		y -= minus;
		ans += a * x + b * y;
	}else ans += a*x+b*y;
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <cstdlib>

int main()
{
    int N, M;
    std::cin >> N >> M;
    std::vector<int> H(N);
    std::vector<bool> good(N, true);
    
    
    for(int i = 0; i < N; i++) {
        int h;
        std::cin >> h;
        H[i] = h;
    }
    
    for(int i = 0; i < M; i++) {
        int A, B;
        std::cin >> A >> B;
        if(H[A-1] > H[B-1]) {
            good[B-1] = false;
        }
        if(H[B-1] > H[A-1]) {
            good[A-1] = false;
        }
        if(H[B-1] == H[A-1]) {
            good[A-1] = false;
            good[B-1] = false;
        }
    }
    
    int count = 0;
    for(int i = 0; i < N; i++) {
        if(good[i]) {
            count++;
        }
    }
    
    std::cout << count << std::endl;
}


Measured memory_bytes: 3772
#include<cstdio>
int main(void) {
  int n,res=0;
  int p=-1;
  scanf("%d",&n);
  for(int i=0;i<n;i++) {
    int a;
    scanf("%d",&a);
    if(a==p) res++, p=-1;
    else p=a;
  }
  printf("%d\n", res);
}

Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
#define ll long long
using namespace std;
int cnt[30];
int main() {
	char s[5];
	scanf("%s", &s);
	for (int i = 0; i < 4; i++) {
		cnt[s[i] - 'A']++;
	}
	int res = 0;
	for (int i = 0; i < 30; i++) {
		if (cnt[i] != 0 && cnt[i] % 2 == 0) {
			cnt[i] -= 2;
			res++;
		}
	}
	if (res == 2) {
		printf("Yes\n");
	}
	else
		printf("No\n");
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=n;i<(int)N;i++)
#define RREP(i,n,N) for(int i=N-1;i>=0;i--)
#define p(s) cout<<(s)<<endl
#define CK(n,a,b) ((a)<=(n)&&(n)<(b))
#define F first
#define S second
typedef long long ll;
using namespace std;
const int inf=1e9;


int N,M,K;
string ans;
int main() {
	cin>>N>>M>>K;
	ans="No";
	REP(m,0,M+1){
		REP(n,0,N+1){

			if(n*M+m*(N-n)-n*m==K) {
				ans="Yes";
			}
		}
	}

	p(ans);
	return 0;
}


Measured memory_bytes: 256
/*
 *  Author : Jun_SH
 *  Solution for sumitrust2019 146 B
 */
#include<bits/stdc++.h>
#define int long long
using namespace std;
inline int read(){
    int f=1,x=0;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return f*x;
}
main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    double x;
    cin>>x;
    int tmp=(x/1.08);
    for(int i=-5;i<=5;++i){
        if((int)((tmp+i)*1.08)==(int)x){
            cout<<(tmp+i)<<endl;
            return 0;
        }
    }
    puts(":(");
}


Measured memory_bytes: 384
#include<stdio.h>
int Y[]={0,1,0,-1};
int X[]={1,0,-1,0};
int main(){
  int h,w,x[30][3],y[30][3],i,j,k,l,ny,nx,p=0,r[30]={0};
  char s[510][510]={0};
  scanf("%d %d",&h,&w);
  for(i=1;i<=h;i++){
    for(j=1;j<=w;j++){
      scanf(" %c",&s[i][j]);
      if(s[i][j]-'.'){
	p=s[i][j]-'A';
	y[p][r[p]  ]=i;
	x[p][r[p]++]=j;
      }
    }
  }
  p=0;
  FRONT:;
  for(i=0;i<26;i++){
    if(r[i]==0)continue;
    int d[510][510]={0};
    for(l=0;l<2;l++){
      for(j=0;j<4;j++){
	for(k=1;1;k++){
	  ny=Y[j]*k+y[i][l];
	  nx=X[j]*k+x[i][l];
	  if(s[ny][nx]-'.')break;
	  d[ny][nx]++;
	  if(d[ny][nx]==2){
	    s[y[i][0]][x[i][0]]=s[y[i][1]][x[i][1]]='.';
	    p+=2;
	    r[i]=0;
	    goto FRONT;
	  }
	}
      }
    }
  }
  printf("%d\n",p);
  return 0;
}

Measured memory_bytes: 1876
#include<stdio.h>
int main(void)
{
	int a,b,c;
	scanf("%d %d",&a,&b);
	if(a>b){
	c=a-b;
	}
	if(a<b){
	c=b-a;
	}
	printf("%d\n",c);
	return 0;
}


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

#define FI(i,a,b) for(int i=(a);i<=(b);i++)
#define FD(i,a,b) for(int i=(a);i>=(b);i--)

#define LL long long
#define Ldouble long double
#define PI 3.1415926535897932384626

#define PII pair<int,int>
#define PLL pair<LL,LL>
#define mp make_pair
#define fi first
#define se second

using namespace std;

int n, l, r;
char s[10005][25];

struct name{
	char t[25];
	int id;
	bool operator<(const name & k) const{
		if(!strcmp(t, k.t)) return id < k.id;
		else return strcmp(t, k.t) < 0;
	}
};

name u[10005];

int main(){
	scanf("%d", &n);
	FI(i, 1, n + 1) scanf(" %s", s[i]);
	//first
	FI(i, 1, n){
		int len = strlen(s[i]);
		FI(j, 0, len - 1){
			if(s[i][j] == '?') u[i].t[j] = 'z';
			else u[i].t[j] = s[i][j];
		}
		u[i].t[len] = 0;
		u[i].id = i;
	}
	strcpy(u[n + 1].t, s[n + 1]);
	u[n + 1].id = 0;
	sort(u + 1, u + n + 2);
	FI(i, 1, n + 1) if(u[i].id == 0){
		l = i;
		break;
	}
	//last
	FI(i, 1, n){
		int len = strlen(s[i]);
		FI(j, 0, len - 1){
			if(s[i][j] == '?') u[i].t[j] = 'a';
			else u[i].t[j] = s[i][j];
		}
		u[i].t[len] = 0;
		u[i].id = i;
	}
	strcpy(u[n + 1].t, s[n + 1]);
	u[n + 1].id = n + 1;
	sort(u + 1, u + n + 2);
	FI(i, 1, n + 1) if(u[i].id == n + 1){
		r = i;
		break;
	}
	FI(i, l, r) printf("%d%c", i, i == r ? '\n':' ');
	return 0;
}


Measured memory_bytes: 768
import java.util.*;
import java.awt.geom.*;

public class Main{

	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n == 0) break;
			int sum = 1;
			Dice d = new Dice(new int[]{0,1,2,3,4,5,6});
			while(n-- > 0){
				String s = sc.next();
				char c = s.charAt(0);
				if(c == 'N'){
					d.turn('n');
				}
				else if(c == 'E'){
					d.turn('e');
				}
				else if(c == 'W'){
					d.turn('w');
				}
				else if(c == 'S'){
					d.turn('s');
				}
				else if(c == 'L'){
					d.slide();
					d.slide();
					d.slide();
				}
				else if(c == 'R'){
					d.slide();
				}
				sum += d.dice[1];
			}
			System.out.println(sum);
		}
	}

	class Dice{
		int [] dice;
		public Dice(int[] dice) {
			this.dice = dice;
		}
		private void slide() {
			swap(2,4,5,3);
		}
		private void turn(char c) {
			switch(c){
			case 'n': swap(1,5,6,2); break;
			case 's': swap(1,2,6,5); break;
			case 'w': swap(1,4,6,3); break;
			case 'e': swap(1,3,6,4); break;
			}
		}
		private void swap(int i, int j, int k, int l) {
			int temp = dice[l];
			dice[l] = dice[k];
			dice[k] = dice[j];
			dice[j] = dice[i];
			dice[i] = temp;
		}
	}
	
	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

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

Measured memory_bytes: 23376
//Kagami Mochi

#include<bits/stdc++.h>
using namespace std;

int main (){
    int N,a;
    cin >> N;
    vector<int> d(N);
    for(int i=0;i<N;i++)cin >> d[i];
    
    set<int> values;
    for(int i=0;i<N;i++)values.insert(d[i]);
    cout << values.size() << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
signed main()
{
    int n;
    cin >> n;
    vector<int> w(n);
    rep(i, n) cin >> w[i];

    int best = 1e8;    
    rep(i, n) {
        int sum0 = 0, sum1 = 0;
        rep(j, i) {
            sum0 += w[j];
        }
        rep (j, n - i) {
            sum1 += w[n - j - 1];
        }
        if (abs(best) > abs(sum1 - sum0)) {
            best = abs(sum1 - sum0);
        }
    }

    cout << best << endl;

    return 0;
}

Measured memory_bytes: 3556
use proconio::{
    fastout, input,
    marker::{Bytes, Chars, Isize1, Usize1},
};

#[fastout]
fn main() {
    input! {s:usize,w:usize}
    if w >= s {
        println!("unsafe");
    } else {
        println!("safe");
    }
}


Measured memory_bytes: 2128
import sys
X ,N = map(int,input().split())
p = list(map(int,input().split()))
min_dif = 10000
output = 10000
for i in range(10000):
  if (5000 - i in p) == False:
    if abs(X-(5000-i)) <= min_dif:
      min_dif = abs(X-(5000 - i))
      output =  5000 - i
print(output)
      
  

Measured memory_bytes: 9188
/*
  ------------------------- Hachiikung ---------------------------------
  ---------------------- Worrachate Bosri ------------------------------
  ------ Faculty of Computer Engineering Chulalongkorn University ------
*/
#include <bits/stdc++.h>
using namespace std;
#define REP(i,FN) for(int i=0;i<FN;i++)
#define FOR(i,ST,FN) for(int i=ST;i<=FN;i++)
#define FORD(i,FN,ST) for(int i=FN;i>=ST;i--)
#define FORX(i,c) for(typeof(c.begin())i=c.begin();i!=c.end();i++)
#define pause system("pause")
#define S scanf
#define P printf
#define X first
#define Y second
#define pb push_back
#define PII pair<int,int>
#define mp make_pair
#define sz size()
#define eps 1e-8

const int MOD(1000000007);
const int INF((1<<30)-1);
const int MAXN();

int main(){

    int a,b,c;
    S("%d%d%d",&a,&b,&c);

    if(b-a == c-b) P("YES\n");

    else P("NO\n");

}


Measured memory_bytes: 768
#include <stdio.h>

int main(void){

  long long n, m, l, i, ii, iii;
  long long c = 0;
  long long a[100][100] = {{0},{0}};
  long long b[100][100] = {{0},{0}};

  scanf("%lld%lld%lld", &n, &m, &l);

  for(i = 0; i < n; i++){
    for(ii = 0; ii < m; ii++){
      scanf("%lld", &a[i][ii]);
    }
  }

  for(i = 0; i < m; i++){
    for(ii = 0; ii < l; ii++){
      scanf("%lld", &b[i][ii]);
    }
  }

  for(i = 0; i < n; i++){
    if(i != 0) printf("\n");
    for(ii = 0; ii < l; ii++){
      for(iii = 0; iii < m; iii++){
	c = a[i][iii] * b[iii][ii] + c;
      }
      printf("%lld", c);
      if(ii != l-1) printf(" ");
      c = 0;
    }
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <queue>
#include <numeric>
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)

using namespace std;
using ll = long long;

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

	rep(i, s.size()) {
		if (s[i] == 'B') {
			if (ans.size() > 0) {
				ans.pop_back();
			}
		}
		else {
			ans.push_back(s[i]);
		}
	}
	
	cout << ans;

	return 0;
}

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

#define pb push_back
#define mp make_pair
#define fs first
#define se second
#define pi 2*acos(0)
#define PI 3.14159265358979323846264338

typedef long long ll;
typedef unsigned long long ull;
typedef pair < int , int > pii;
typedef pair < ll , ll > pll;

const int N = 100010;
const int MX = 123456;
const int mod = (int)1e9 + 7;
const int base = 1023456789;
const ull BS1 = 10000019ULL;
const int INF = (1 << 29);

template < class T > inline void fastScan(T &x){
    register char c = getchar();
    int neg = 0; x = 0;
    for(   ; (c < 48 || c > 57) && (c != '-'); c = getchar());
    if(c == '-') { neg = 1; c = getchar(); }
    for(   ; c > 47 && c < 58; c = getchar()){
        x = (x << 1) + (x << 3) + c - 48;
    }
    if(neg) x = -x;
}

int n, m;
int inp[505][505];

struct info {
    int x1, y1, x2, y2;
    info(){}
    info(int _x1, int _y1, int _x2, int _y2){
        x1 = _x1; y1 = _y1;
        x2 = _x2; y2 = _y2;
    }
};

vector < info > ans;

int main(){
    fastScan(n);
    fastScan(m);
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            fastScan(inp[i][j]);
        }
        for(int j = 1; j < m; j++){
            while(inp[i][j] & 1){
                ans.pb(info(i, j, i, j + 1));
                inp[i][j]--;
                inp[i][j + 1]++;
            }
        }
    }
    for(int i = 1; i < n; i++){
        int j = m;
        while(inp[i][j] & 1){
            ans.pb(info(i, j, i + 1, j));
            inp[i][j]--;
            inp[i + 1][j]++;
        }
    }
    cout << (int) ans.size() << '\n';
    for(int i = 0; i < ans.size(); i++){
        cout << ans[i].x1 << " " << ans[i].y1 << " " << ans[i].x2 << " " << ans[i].y2 << '\n';
    }
    return 0;
}


Measured memory_bytes: 5232
#include<stdio.h>
void swap(int *x, int *y){
  int temp;
  temp = *x;
  *x = *y;
  *y = temp;
}
 
int main(void){
  int a, b, c;
  scanf("%d %d %d", &a, &b, &c);
  swap(&a,&b);
  swap(&a,&c);
  printf("%d %d %d", a, b, c);
  return 0;
}


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

#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << " = " << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define SP << " " <<

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<int> vec;
typedef vector<P> pvec;
typedef vector<vector<int>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<int> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<int,vector<int>,greater<int>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;

const vector<int> DX = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> DY = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const ll INF = (1LL << 60); // 1152921504606846976
const double PI = (3.141592653589794);
const double EPS = (0.0000000001); // 10^(-10)

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> inline T ceil(T a, T b) {return T((a + b - 1) / b);}
template<class T> inline T round(T a, T b) {return T(a / b);}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }
template <class T> inline void out(T &a) { bool flag=true; for(auto&x:a){if(flag) {flag=false;} else{ cout << ' '; } cout<<x; } cout << endl; }



//----------------------------------------------------------------
int nmax=200000; // 2*(10^5)
vvec G(nmax);





void solve4ts()
{
    
    int k;
    string s;
    cin>>k>>s;
    rep(i,s.size()){
        if(i<k) cout<<s[i];
        else{
            cout<<"...";
            break;
        }
    }
    cout<<endl;
    
}
//-----------------------------------------------------------------

signed main(){ ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(15);
    int repeat = 1;
    // cin >> repeat;
    while(repeat--) solve4ts();
}

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

int main(){
  int n;
  cin >> n;
  int ans;
  if(n<10) ans = n;
  else if(10<=n && n<100) ans = 9;
  else if(100<=n && n<1000) ans = 9 + (n-99);
  else if(1000<=n && n<10000) ans = 909;
  else if(10000<=n && n<100000) ans = 909 + (n-9999);
  else ans = 90909;
  cout << ans << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define F first
#define S second
#define PB push_back
#define REP(i,a,b) for (int i = a ; i <= b ; i++)
#define REPI(i,a,b) for (int i = a ; i >= b ; i--)
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

const int OO = 1e9+7;
const int MOD = 1e9+7;
const int N = 1e5+7;

ll dp[N];
int n;
ll h[N];

int main()
{
    //ios::sync_with_stdio(0);
    //cin.tie(0);cout.tie(0);
    //freopen("teleport.in","r",stdin);
    //freopen("teleport.out","w",stdout);

    scanf("%d",&n);
    REP(i,0,n-1) scanf("%lld",&h[i]);

    REP(i,0,n-1)
    {
        if (i >= 1) dp[i] = dp[i-1]+abs(h[i]-h[i-1]);
        if (i >= 2) dp[i] = min(dp[i],dp[i-2]+abs(h[i]-h[i-2]));
    }
    printf("%lld\n",dp[n-1]);

    return 0;
}


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

int main(){
    long int a,b,c,k,tmp;
    cin >> a >> b >> c >> k;
    tmp = k;
    int pattern = 0;

    for(int i=0; i<3; i++){
        switch(pattern){
            case 0:
            tmp -= a;
            if(tmp > 0){
                pattern++;
            }
            else if(tmp < 0){
                cout << k << endl;
                return 0;
            }
            else{
                cout << a << endl;
                return 0;
            }
            break;

            case 1:
            tmp -= b;
            if(tmp > 0){
                pattern++;
            }
            else{
                cout << a << endl;
                return 0;
            }
            break;

            case 2:
                cout << a-tmp << endl;
                return 0;
            break;
        }
        
    }
    
    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <queue>
#include <tuple>
#include <stack>
#include <climits>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#define INF INT_MAX>>1 //要climits#includ

typedef long long ll;

using namespace std;

int main(void){
	int N;
	cin >> N;
	cout << 180*(N-2) << endl;
	return 0;
}

Measured memory_bytes: 256
if __name__ == "__main__":
    k, n = map(int, input().split())
    a = list(map(int, input().split()))
    import numpy as np
    a = np.array(a)

    sa_kouho = a[0] + (k - a[-1])

    sa = a[1:] - a[0: -1]

    sa_kouho1 = max(sa)

    print(k - max(sa_kouho, sa_kouho1))



Measured memory_bytes: 30632
#include"iomanip"
#include"iostream"
#include"limits"
#include"cmath"
#include"vector"
#include"algorithm"
#include"list"
#include"queue"
#include"stack"
#include"set"
#include"unordered_set"
#include"map"
#include"unordered_map"
#include"string"
#include"cstring"
#include"assert.h"
using namespace std;
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define mp make_pair
#define pb push_back
#define mset(a,b) memset(a,b,sizeof(a))
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	string x;
	cin>>x;
	if(x.find("AC")!=string::npos)
	{
		cout<<"Yes\n";
	}
	else cout<<"No\n";
}

Measured memory_bytes: 256
#include<iostream>
#include<complex>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
using namespace std;
typedef long long int llint;
#define rep(i,n) for(int i=0;i<n;i++)
int main() {
	int a, b;
	cin >> a >> b;
	string str;
	int x, y;
	rep(i, a) {
		rep(j, b) {
			cin >> str;
			if (str == "snuke") {
				x = i;
				y = j;
			}
		}
	}
	cout << (char)('A' + y) << x + 1 << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {


  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[][] h = new int[3][N];
    for (int i = 0; i < N; i++) {
      h[0][i] = sc.nextInt();
      h[1][i] = sc.nextInt();
      h[2][i] = sc.nextInt();
    }
    int[][] dp = new int[3][N];
    dp[0][0] = h[0][0];
    dp[1][0] = h[1][0];
    dp[2][0] = h[2][0];

    for (int i = 0; i < N-1 ; i++) {
      //
      dp[1][i+1] = Math.max( (dp[0][i]+ h[1][i+1]),(dp[2][i]+ h[1][i+1]));
      dp[2][i+1] = Math.max( (dp[0][i]+ h[2][i+1]),(dp[1][i]+ h[2][i+1]));
      dp[0][i+1] = Math.max( (dp[2][i]+ h[0][i+1]),(dp[1][i]+ h[0][i+1]));

    }

    System.out.println(Math.max(Math.max(dp[0][N-1],dp[1][N-1]),dp[2][N-1]));
  }


}


Measured memory_bytes: 92072
#include <stdio.h>
 
int main(){
    char o[51], e[51], ans[101] = "";
    scanf("%s %s", o, e);
 
    for(int i = 0; o[i] != '\0'; i++){
        sprintf(ans, "%s%c%c", ans, o[i], e[i]);
    }
    printf("%s\n", ans);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

int N, M;
bool graph[50][50];
bool visited[50];

void dfs(int v) {
    visited[v] = true;
    rep(i, N) {
        if (graph[v][i] == false) continue;
        if (visited[i] == true) continue;
        dfs(i);   
    }
}

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> M;
    int a[M], b[M];
    rep(i, M) {
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
        graph[a[i]][b[i]] = true;
        graph[b[i]][a[i]] = true;
    }
    int ans = 0;
    rep(i, M) {
        rep(j, N) visited[j] = false;
        bool bridge = false;

        graph[a[i]][b[i]] = false;
        graph[b[i]][a[i]] = false;        

        dfs(0);
        rep(j, N) if(visited[j] == false) bridge = true;
        if (bridge) ans++;

        graph[a[i]][b[i]] = true;
        graph[b[i]][a[i]] = true;
    } 
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::io::Write;

#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

#[allow(non_snake_case)]
fn main() {
    input![A: [i32; 6]];

    println!("{}", if A[4] - A[0] <= A[5] { "Yay!" } else { ":(" });
}


Measured memory_bytes: 2112
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rec register char
#define rel register ll
#define gc getchar
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
template <typename mitsuha>
inline bool read(mitsuha &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';
  if (!~c) return 0;
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return x=f?x:-x,1;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return 0&pc(48);
  if (x<0) x=-x,pc('-');
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  return 0;
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;

int main(){
ll x,y,i,ans=0;read(x),read(y);
for (i=x;i<=(y>>1);i*=2) ++ans;
write(ans+1); 
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;

int getC(string s){
	int c = 0;
	for (int i = 2; i < s.length(); i++){
		if (s[i] == 'C'){
			if (c != 0) return -1;
			c = i;
		}
	}
	return c;
}

bool is_small(char c){
	if (c >= 'a' && c <= 'z') return true;
	return false;
}


int main(){
	string s;
	cin >> s;
	if (s[0] == 'A'){
		if (getC(s) >= 2 && getC(s) < s.length()-1){
			int temp = getC(s);
			for (int i = 1; i < s.length(); i++){
				if (i == temp) continue;
				if (!is_small(s[i])){
					cout << "WA" << endl;
					return 0;
				}
			}
			cout << "AC" << endl;
			return 0;
		}
	}
	cout << "WA" << endl;
	return 0;
}


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


Measured memory_bytes: 2108
n = int(input())
a = list(map(int, input().split()))
ans = 0
x = [0] * (10**5 + 2)
for i in a:
    x[i+1] += 1
for i in range(1, 10**5):
    ans = max(ans, x[i-1] + x[i+1] + x[i])
print(ans)

Measured memory_bytes: 84068
from bisect import bisect

n=int(input())
a=sorted(list(map(int,input().split())))

x=a[-1]

if n%2==0:
  mid=x//2
else:
  mid=x//2+1

if mid in a:
  print(x,mid)
else:
  inx=bisect(a,mid)
  if a[inx]-mid>=mid-a[inx-1]:
    print(x,a[inx-1])
  else:
    print(x,a[inx])

Measured memory_bytes: 14428
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

// 約数のvectorを返す
vector<int> divisor(int n) {
    vector<int> ret;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i != n / i) ret.push_back(n / i);
        }
    }
    return ret;
}

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

    int n;
    cin >> n;

    vector <int> a(n+1, 0);
    for (int i = 1; i <= n; i++) cin >> a[i];

    vector <int> ans;
    for (int i = n; i > 0; i--) {
        if (a[i] % 2 == 1) {
            ans.push_back(i);
            vector <int> div = divisor(i);
            for (int d : div) a[d]++;
        }
    }

    cout << ans.size() << "\n";
    for (int ret : ans) cout << ret << " ";

    return 0;
}

Measured memory_bytes: 2424
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    long long int n;
    long long int sum = 0, res = 0;
    
    cin >> n;
    
    while(n--) {
        long long int temp;
        cin >> temp;
        res = (res + sum * temp) % 1000000007LL;
        sum = (sum + temp) % 1000000007LL;
    }
    
    cout << res;
    
    return 0;
}


Measured memory_bytes: 3612
#include <iostream>
using namespace std;
 
int main() {
    long long n, m, k;
    cin >> n >> m >> k;
    for(int i=0; i<=n; i++){
        for(int l=0; l<=m; l++){
            if(m*i+n*l-2*i*l == k){
                cout << "Yes" << endl; 
                return 0;
            }
        }
    }
    cout << "No" << endl; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,K;
  cin >> N >> K;
  vector<int> x(N);
  int time;
  int mi = 1000000000;
  for(int i=0; i<N; i++){
    cin >> x.at(i);
  }
  for(int i=0; i<N-K+1; i++){
    if(x.at(i) > 0){
      time = x.at(i+K-1);
    }
    if(x.at(i+K-1) < 0){
      time = -x.at(i);
    }
    if(x.at(i) <= 0 && 0 <= x.at(i+K-1)){
      time = x.at(i+K-1)-x.at(i)+min(-x.at(i),x.at(i+K-1));
    }
    mi = min(mi,time);
  }
  cout << mi << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
const int MOD=(int)1e9+7;
using namespace std;
int main(){
    int s,n,a;
    string ans;
    cin>>n;
    a=n;
    while(n){
        int dig = n % 10;
        s = s + dig;
        n = n / 10;
    }
    if(a%s==0)ans="Yes";
    else ans="No";
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.io.*;

class Main
{
 public static void main(String[] args) throws IOException
 {
  BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

  String str = br.readLine();

  int x=Integer.parseInt(str);
     
  int h=x/3600;
  x%=3600;
  
  int m=x/60;
  x%=60;
     
  int s=x;

  System.out.println(h+":"+m+":"+s);
 }
}

Measured memory_bytes: 24436
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include<iostream>
#include<cmath>
#include<math.h>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=1e9+7;
const double PI=M_PI;
signed main(){
    ll n;cin>>n;
    vector<ll>a(n);
    rep(i,n){
        cin>>a[i];
    }
    sort(all(a));
    ll mi=0;
    ll now=0;
    rep(i,n-1){
        now+=a[i];
        if(now*2>=a[i+1])continue;
        else mi=i+1;
    }
    cout<<n-mi<<endl;
}

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

public class Main{
	final static int MOD = 1000000007;
	final static int INF = 1000000000;

	public static void main(String[] args) throws IOException{
		//final double PI = 3.14159265;
		NScanner sc = new NScanner(System.in);
		int n = sc.nextInt();
		long sum = 0;
		int minv = INF, maxv = -INF;
		for(int i = 0; i < n; ++i){
			int a = sc.nextInt();
			sum += a;
			minv = Math.min(minv, a);
			maxv = Math.max(maxv, a);
		}
		System.out.printf("%d %d %d\n", minv, maxv, sum);
	}

}

class NScanner{

	private BufferedReader br;
	private StringTokenizer tok;

	public NScanner(InputStream is) throws IOException{
		br = new BufferedReader(new InputStreamReader(is));
		getLine();
	}

	private void getLine() throws IOException{
		while(tok == null || !hasNext()){
			tok = new StringTokenizer(br.readLine());
		}
	}

	private boolean hasNext(){
		return tok.hasMoreTokens();
	}

	public String next() throws IOException{
		if(hasNext()){
			return tok.nextToken();
		}else{
			getLine();
			return tok.nextToken();
		}
	}

	public int nextInt() throws IOException{
		if(hasNext()){
			return Integer.parseInt(tok.nextToken());
		}else{
			getLine();
			return Integer.parseInt(tok.nextToken());
		}
	}

	public long nextLong() throws IOException{
		if(hasNext()){
			return Long.parseLong(tok.nextToken());
		}else{
			getLine();
			return Long.parseLong(tok.nextToken());
		}
	}

	public double nextDouble() throws IOException{
		if(hasNext()){
			return Double.parseDouble(tok.nextToken());
		}else{
			getLine();
			return Double.parseDouble(tok.nextToken());
		}
	}
}


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

int main() {
string s;
cin >> s;
if(s[0]=='a' || s[0]=='i' ||s[0]=='u' ||s[0]=='e' ||s[0]=='o'){
  cout << "vowel"; return 0;
}
cout << "consonant";
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MAX (ll)(5e3 + 4)
#define MOD (ll)(1e9 + 7)
#define PI (double)(3.14159265)
#define IO ios_base :: sync_with_stdio (false), cin.tie (nullptr);

using namespace std;
using ll = long long;
using ld = long double;

vector<pair<int, int>> ar[MAX];

int main () {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int x;
		cin  >> x;
		for (int j = 0; j < x; j++) {
			int a, b;
			cin >> a >> b;
			ar[i].push_back (make_pair (a, b));
		}
	}
	int ma = 0;
	for (int i = 1; i < (1 << n); i++)  {
		bool fl = 1;
		int cn[n + 1] = {}, co = 0;
		for (int j = 0; j < n; j++) {
			if ((i >> j) & 1) {
				cn[j + 1] = 2;
			}
			else {
				cn[j + 1] = 1;
			}
		}
		for (int j = 0; j < n && fl; j++) {
			if ((i >> j) & 1) {
				co++;
				for (pair<int, int> x : ar[j]) {
					if (cn[x.first] && cn[x.first] != x.second + 1) {
						fl = 0;
						break;
					}
					cn[x.first] = x.second + 1;
				}
			}
		}
		if (fl)  {
			ma = max (co, ma);
		}
	}
	cout << ma << "\n";
}
					
				
			


Measured memory_bytes: 384