akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long

int main(){
  int a,b;
  cin>>a>>b;
  
  if(a<=b){
    cout<<0<<endl;
  }else {
    if(a>=2*b){
      cout<<a-2*b<<endl;
    }else{
      cout<<0<<endl;
    }
  }
}

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

int building1[3][10] = {
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
};

int building2[3][10] = {
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
};

int building3[3][10] = {
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
};

int building4[3][10] = {
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
};

void enter(int building[3][10], int f, int r, int v) {
    building[f-1][r-1] += v;
}

void mark(int building[3][10]) {
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 10; j++) {
            cout << " " << building[i][j];
            if (j == 9) {
                cout << endl;
            }
        }
    }
}

int main() {
    int n, b, f, r, v;
    cin >> n;

    for (int i = 0; i < n; i++) {
        cin >> b >> f >> r >> v;
        if (b == 1) {
            enter(building1, f, r, v);
        } else if (b == 2) {
            enter(building2, f, r, v);
        } else if (b == 3) {
            enter(building3, f, r, v);
        } else {
            enter(building4, f, r, v);
        }
    }

    mark(building1);
    cout << "####################" << endl;
    mark(building2);
    cout << "####################" << endl;
    mark(building3);
    cout << "####################" << endl;
    mark(building4);

    return 0;
}


Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
#define ll long long
void max_self(ll&a , ll b){a=max(a,b);}
signed main(){
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
ll n ; cin >> n ;
vector<ll> arr (n) ,bit(n+1) ; 
for(ll i = 0 ; i<n ; i++)cin>> arr[i] ;
ll ans = 0  ;
for(ll i = 0;  i< n ; i++){
	ll k ; cin >> k ;
	ll res = 0 ;
	ll x = arr[i] - 1 ; 
	while(x>0){
		max_self(res , bit[x]) ; 
		x-=(x&-x);
	}
	max_self(ans , res + k );
	x = arr[i] ; 
	while(x < bit.size()){
		max_self(bit[x] , res +  k);
		x+=(x&-x);
	}	
}
cout << ans << endl;	
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >> s;
  int sum = 0;
  for(int i = 0;i<s.size();i++){
    sum += s.at(i) - '0';
  }
  if( stoi(s)%sum == 0){
    cout << "Yes";
  }
  else{
    cout << "No";
  }
}

Measured memory_bytes: 256
import java.util.*;
  public class Main {
    public static void main(String[] args) {
     
        //sec--1 (definition)
        Scanner sc = new Scanner(System.in);
        //int A = sc.nextInt();
        long A = sc.nextLong();
        //実数から小数点以下の値だけを取り出す
        long B = (long)(sc.nextDouble()*100.0+0.5);
        System.out.println((A*B)/100);
        
    }
  }

Measured memory_bytes: 37208
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>
#include <iomanip>

using namespace std;
int main(){
	int n, m;
  cin>>n>>m;
  if(n==m){
  	cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
    string s;
    cin >> s;
    int len = s.length();
    string a = s;
    reverse(s.begin(), s.end());
    for(int i = 0; i < len; i++) {
        if(a[i]=='b') {
            a[i]='d';
        } else if(a[i]=='d') {
            a[i]='b';
        } else if(a[i]=='p') {
            a[i]='q';
        } else if(a[i]=='q') {
            a[i]='p';
        }
    }
    if(a == s) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 512
#include <stdio.h>

int main(void) {
    // n = 読み込む数値、f = フラグ、i = ケーキの個数、j = ドーナツの個数
	int n;
	int f = 0, i = 0, j = 0;
	
    // 数値読み込み
	scanf("%d", &n);
    // 4で割り切れるならフラグ1
	if(n % 4 == 0) f = 1;
    // 7で割り切れるならフラグ1
	if(n % 7 == 0) f = 1;
    // 4 * i + 7 * j で割り切れるならフラグ1 にするループ文
	for(i = 4; i < 101; i += 4) {
		if(f == 1) break;
		for(j = 7; j < 101; j += 7) {
			if(n % (i + j) == 0) f = 1;
		}
	}
    // 出力
	printf( f ? "Yes\n" : "No\n");
	return 0;
}

Measured memory_bytes: 128
n = int(input())
a = list(map(int,input().split()))
flag = True
c = 0
while flag:
    flag = False
    for j in range(n-1,0,-1):
        if(a[j] < a[j-1]):
            a[j],a[j-1] = a[j-1],a[j]
            flag = True
            c += 1
print(*a)
print(c)


Measured memory_bytes: 5608
import java.util.Scanner;

public class Main {

	static Scanner scanner;

	public static void main(String[] args) {
	    scanner = new Scanner(System.in);

	    int a=gi();
	    int p=gi();
int pp=3*a+p;


	   
	    System.out.print(Math.floorDiv(pp, 2));

//        if (a>12) {
//        	System.out.print(b);
//        }else if(a>5){
//        	System.out.print(b/2);
//        } else {
//        	System.out.print(0);
//        }


	}
	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35684
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();

        int[] D = new int[K];
        int[] A = new int[N + 1];
        Arrays.fill(A, 0);

        int count = 0;
        for (int j = 0; j < K; j++) {
            D[j] = sc.nextInt();
            for (int i = 0; i < D[j]; i++) {
                int sunuke = sc.nextInt();
                if (A[sunuke] == 0) {
                    A[sunuke]++;
                    count++;
                }
            }
        }
        sc.close();

        System.out.println(N - count);

    }
}

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

#引き出せる金額の列挙
Withdr = [1] + [6**i for i in range(1, 7)] + [9**i for i in range(1,6)]
INF = 100010
dp = [INF]*159050
dp[0] = 0

#全てを順に計算
for j in range(n + 1):
    #あるnに対し複数の計算方法があるため、それらの中で一番少ないものをdpに格納する
    for WithdrOrder in Withdr:
        #dp[j + WithdrOrder]は今までに計算した最小値とdp[j]から1回で引き出せる金額を足したものとの比較で算出
        dp[j + WithdrOrder] = min(dp[j + WithdrOrder], dp[j] + 1)
print(dp[n])

Measured memory_bytes: 4212
#include<iostream>
#include<vector>
#include<algorithm>
#include<climits>
using namespace std;

const int V_MAX=100000;

struct edge{
	int from;
	int to;
	bool operator<( const edge& right ) const {
        return from == right.from ? to < right.to : from < right.from;
    }
};

vector<int> G[V_MAX];
vector<bool> check(V_MAX,false);
vector<int> pre(V_MAX);
vector<int> low(V_MAX,INT_MAX);
vector<edge> result;
int order;

void dfs(int s,int p){
	if(check[s]==true){return;}
	check[s]=true;
	pre[s]=order;
	low[s]=order;
	order++;
	for (int i=0;i<G[s].size();i++){
		if(G[s][i]!=p && low[G[s][i]]<low[s]){
			low[s]=pre[G[s][i]];
		}
		if(check[G[s][i]]==false){
			dfs(G[s][i],s);
		}
	}
	
	if(!(s==0&&p==0) && pre[s]==low[s]){
		edge e;
		e.from=min(s,p);
		e.to=max(s,p);
		result.push_back(e);
		//cout << p << " " << s << endl;
	}
	
	
	
	if(low[p]>low[s]){
		low[p]=low[s];
	}
}

int main(){
	int V,E,s,t;
	cin>> V >> E;
	for (int i=0;i<E;i++){
		cin >> s >> t;
		G[s].push_back(t);
		G[t].push_back(s);
	}
	
	order=0;
	dfs(0,0);
	
	sort(result.begin(),result.end());
	for(int i=0;i<result.size();i++){
		cout << result[i].from << " " << result[i].to << endl;
	}
	
	return 0;
}

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

using namespace std;

static int func (long long A, long long B){
    int a = 0, b = 0;
    while ( A > 0 ) {
        A /= 10;
        a++;
    }
    while ( B > 0 ) {
        B /= 10;
        b++;
    }
    return max(a, b);
}

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

    long long A = 1, B = N;
    for ( long long i = 2; i*i <= N; i++ ) {
        if ( N % i == 0 ) {
            A = i;
            B = N / i;
        }
    }

    cout << func(A, B) << endl;
    return 0;
}


Measured memory_bytes: 3620
import sys
# input = sys.stdin.readline
sys.setrecursionlimit(10 ** 9)
MOD = 10 ** 9 + 7

S, T = map(str, input().split())
A, B = map(int, input().split())

U = str(input())

if S == U:
    print (A - 1, B)
else:
    print (A, B - 1)

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

using namespace std;

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

  for (int i = 0; i < N; i++){
    cin >> s;
    if(s == 'Y'){
      cout << "Four" << endl;
      return 0;
    }
  }
  cout << "Three" << endl;
}

Measured memory_bytes: 256
import scala.io.StdIn._
import scala.collection.mutable

object Main {
  def main(args: Array[String]) {
    val Array(vertical, horizontal) = readLine().split(" ").map(_.toInt)
    var spreadsheet: mutable.Seq[Array[Int]] = mutable.Seq()

    for(i <- 0 until vertical) {
      val inputSpreadsheet = readLine().split(" ").map(_.toInt)
      spreadsheet = spreadsheet :+ (inputSpreadsheet :+ inputSpreadsheet.sum)
    }

    var verticalSum: Array[Int] = Array()
    for(i <- 0 to horizontal) {
      var j = 0
      spreadsheet.foreach(k => j += k(i))
      verticalSum = verticalSum :+ j
    }
    
    spreadsheet = spreadsheet :+ verticalSum

    spreadsheet.foreach(i => println(i.mkString(" ")))
  }
}

Measured memory_bytes: 48608
#include <bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define eps 1e-9
 
typedef long long ll;
 
using namespace std;
 
const ll inf = 1e18;
const ll mod = 1e9+7;
const int N = 1e5+5;
//int a[N];
 
int main()
 
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
 
    int n, k, ans = 0;
    string s;
 
    cin >> n >> k >> s;
 
    for (int i = 0; i < n; i++) {
 
        if (s[i] == 'L' && i && s[i-1] == 'L') ans++;
        if (s[i] == 'R' && i < n-1 && s[i+1] == 'R') ans++;
    }
 
    cout << min(n-1, ans+2*k);
 
    return 0;
}

Measured memory_bytes: 512
fun main(a:Array<String>){
    var n = readLine()!!.toInt()
    var s = readLine()!!
    var b = true

    for (i in 0 until n/2){
        if (s[i] != s[n/2+i]) b = false
    }
    if (n % 2 == 1) b = false
    println(if (b) "Yes" else "No")
}

Measured memory_bytes: 31996
#include <stdio.h>

int main(void)
{
	int i, j;

	int a[100][100];
	int b[100];
	int c[100];

	//c????????????.
	for (i = 0; i < 100; i++)
		c[i] = 0;

	int n, m;

	scanf("%d %d", &n, &m);

	for(i = 0; i < n; i++)
		for (j = 0; j < m; j++)
			scanf("%d", &a[i][j]);

	for (i = 0; i < m; i++)
		scanf("%d", &b[i]);

	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++) {
			c[i] += a[i][j] * b[j];
		}
		printf("%d\n", c[i]);
	}

	return 0;
}

Measured memory_bytes: 640
n, m = map(int, input().split())
h = list(map(int, input().split()))
ok = [1] * n
for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    if h[a] <= h[b]: ok[a] = 0
    if h[b] <= h[a]: ok[b] = 0

print(sum(ok))


Measured memory_bytes: 20044
#include <iostream>
#include <fstream>
#include <algorithm>
#include <string>
#include <cstring>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <vector>
#include <functional>
#include <cassert>
#include <cmath>
#include <map>
#include <set>

using namespace std;

int Cases;

int N, D;

int main() {
	ios_base::sync_with_stdio(false);

	cin >> N >> D;
	vector<vector<int>> V(N, vector<int>(D));
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < D; j++) {
			cin >> V[i][j];
		}
	}

	int ans = 0;
	for (int i = 0; i < N; i++) {
		for (int j = i + 1; j < N; j++) {
			int sum = 0;
			for (int k = 0; k < D; k++) {
				sum += (V[i][k] - V[j][k]) * (V[i][k] - V[j][k]);
			}
			if (int(sqrt(sum)) * int(sqrt(sum)) == sum) ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

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

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long
#define TBMod 1000000007

int main(int argc, char const *argv[])
{
	int n;
	scanf("%d",&n);
	printf("%d\n",(800 * n - 200 * (n / 15)));
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <cmath>
#include <string>

using namespace std;

int main(void){
    string a,b;
    cin >> a >> b;
    if(a[0]==b[2] && a[1] == b[1] && a[2] == b[0]){
        cout << "YES" << endl;
        return 0;
    }
    cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); ++i)
 
using namespace std;
 
typedef unsigned long long ll;
 
int main()
{
    ll N;
    cin >> N;
    ll ans = UINT64_MAX;
    
    for(ll i = 1; i*i <= N; i++){
        if(N % i != 0)continue;
        ll j = N / i;
        ans = min(ans, i+j-2);
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    int m1,d1,m2,d2;
    cin >> m1 >> d1 >> m2 >> d2;
    if(m1 != m2) cout << 1 << endl;
    else cout << 0 << endl;
    return 0;
}


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

int main()
{
  int H, W;

  while(true){
      cin >> H >> W;
      if(H==0&W==0) break;
      else {
        for(int i=0; i<H; i++){
          for(int j=0; j<W; j++){
            if((i+j)%2==0) cout << "#";
            else cout << ".";
          }
          cout << endl;
        }
        cout << endl;
      }
  }
}



Measured memory_bytes: 3104
/**
 *    author:  FromDihPout
 *    created: 2020-06-24
**/

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


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    long long w, t;
    cin >> n >> w >> t;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    
    long long ans = 0;
    for (int i = 1; i < n; i++) {
        if ((a[i] - a[i - 1]) * w < t) {
            ans += (a[i] - a[i - 1]) * w;
        }
        else {
            ans += t;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3704
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <iostream>
#include <numeric>
#define rep(i,n) for (int i = 0;i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
int INF = 1e9;


int main(){
	int w,h,n;cin >> w >> h >> n;
	int u=h,d=0,l=0,r=w;
	rep(i,n){
		int a,y,x;cin >> x >> y >> a;
		if(a == 1) l = max(l,x);
		else if(a == 2) r = min(r,x);
		else if(a == 3) d = max(d,y);
		else u = min(u,y);
	}
	if(r-l > 0 && u-d > 0) cout << (r-l)*(u-d) << endl;
	else cout << 0 << endl;
	//printf("%d %d\n",r-l,u-d);
} 


Measured memory_bytes: 3496
// https://atcoder.jp/contests/code-festival-2017-quala/tasks/code_festival_2017_quala_c
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    vector<int> v(26, 0);
    REP(i, h) {
        cin >> s[i];
        for (auto &x : s[i])
            v[x - 'a']++;
    }

    bool flag = true;
    vector<int> mo(4, 0);
    REP(i, 26) mo[v[i] % 4]++;
    // 縦横が全て偶数なら、文字の個数は4で割り切れる
    if (h % 2 == 0 && w % 2 == 0) {
        if (mo[1] > 0 || mo[2] > 0 || mo[3] > 0)
            flag = false;
    }
    // 縦横が奇数なら、中心の文字の1個は任意
    // (h - 1) + (w - 1)は2で割り切れる
    // 他は4で割り切れる
    else if (h % 2 == 1 && w % 2 == 1) {
        if (mo[1] != 1 || mo[3] > 0 || mo[2] > (h - 1) / 2 + (w - 1) / 2) {
            flag = false;
        }
    }
    // 縦が奇数、横が偶数
    else if (h % 2 == 1) {
        if (mo[1] > 0 || mo[2] > w / 2) {
            flag = false;
        }
    }
    // 縦が偶数、横が奇数
    else {
        if (mo[1] > 0 || mo[2] > h / 2) {
            flag = false;
        }
    }
    if (flag) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }

    return 0;
}


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

int main() {
   int n; 
   cin>>n;
   vector<vector<int>> data(n, vector<int>(2));
   for(int i=0;i<n;i++){
       for(int j=0;j<2;j++){
           cin>>data.at(i).at(j);
       }
   }
    bool ans=false;
   for(int i=0;i<n-2;i++){
       if(data.at(i).at(1)==data.at(i).at(0)){
           if(data.at(i+1).at(0)==data.at(i+1).at(1)){
               if(data.at(i+2).at(0)==data.at(i+2).at(1)){
                   ans=true;
               }
           }
       }
    }
   if(ans) cout<<"Yes"<<endl;
   else cout<<"No"<<endl;
}


Measured memory_bytes: 3636
/* monkukui 競技プログラミング用のテンプレート  (ここから) */
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
using ll = long long int;
using lnt = long long int;
using Graph = vector<vector<int>>;
using Wgraph = vector<vector<pair<int, long long int>>>;
constexpr long long int INF = 1001001001001001LL;
constexpr long long int MOD = 1000000007LL;
constexpr double PI = 3.1415926535897932;
constexpr long long int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
constexpr long long int dj[] = {0, 1, 0, -1, 1, 1, -1, -1};

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
inline void yes(){ cout << "yes" << endl; }
inline void Yes(){ cout << "Yes" << endl; }
inline void YES(){ cout << "YES" << endl; }
inline void no(){ cout << "no" << endl; }
inline void No(){ cout << "No" << endl; }
inline void NO(){ cout << "NO" << endl; }
inline void possible(){ cout << "possible" << endl; }
inline void Possible(){ cout << "Possible" << endl; }
inline void POSSIBLE(){ cout << "POSSIBLE" << endl; }
inline void impossible(){ cout << "impossible" << endl; }
inline void Impossible(){ cout << "Impossible" << endl; }
inline void IMPOSSIBLE(){ cout << "IMPOSSIBLE" << endl; }

#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = 1; i <= (n); i++)
#define DREP(i,n) for(int i = (n)-1; i >= 0; i--)
#define SREP(i,s,t) for(int i = s; i < t; i++)
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define PB push_back

/* monkukui 競技プログラミング用のテンプレート (ここまで)*/

int main(){
  
  lint n; cin >> n;
  if(n == 0) {
    cout << 0 << endl;
    return 0;
  }
  string s = "";
  while(n) {
    if(n % 2) {
      s += "1";
      n--;
    }
    else s += "0";
    n /= -2;
  }
  
  reverse(ALL(s));
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 256
/* kadai6_1
   reo012 */

#include <stdio.h>
#include <string.h>

#define SIZE 101

int main(void){
    char word[SIZE];    //単語入る配列word用意
    int length;    //単語の文字数length用意
    scanf("%s", word);    //単語入力
    length = (int)strlen(word);    //単語の文字数取得
    printf("%c%d%c\n", word[0], length-2, word[length-1]);    //最初の文字、間の文字数、最後の文字出力
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
const int Maxn=1e3+10,MOD=1e9+7;
int N,M;
char A[Maxn][Maxn];
int Dp[Maxn][Maxn];
int main()
{
	cin>>N>>M;
	for(int i=1;i<=N;i++)
	{
		for(int j=1;j<=M;j++)
		{
			cin>>A[i][j];
		}
	}
	Dp[1][1]=1;
	for(int i=2;i<=N;i++)
	{
		if(A[i][1]=='#')
		{
			Dp[i][1]=0;
		}
		else
		{
			Dp[i][1]=Dp[i-1][1];
		}
	}
	for(int j=2;j<=M;j++)
	{
		if(A[1][j]=='#')
		{
			Dp[1][j]=0;
		}
		else
		{
			Dp[1][j]=Dp[1][j-1];
		}
	}
	for(int i=2;i<=N;i++)
	{
		for(int j=2;j<=M;j++)
		{
			if(A[i][j]=='#')
			{
				Dp[i][j]=0;
			}
			else
			{
				Dp[i][j]=(Dp[i-1][j]+Dp[i][j-1])%MOD;
			}
		}
	}
	cout<<Dp[N][M]<<endl;
	return 0;
}

Measured memory_bytes: 5248
/*
*/
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>

int main()
{
    int a, b;
    std::cin >> a >> b;

    if(a <=5){
        std::cout << 0 << std::endl;   
    }else if(a <= 12){
        std::cout << b/2 << std::endl;   
    }else{
        std::cout << b << std::endl;
    }


    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

void print_rect(int h, int w){
    int i, j;
    for(j = 0; j < h; j++){
        for(i = 0; i < w; i++){
            printf("#");
        }
        printf("\n");
    }
    printf("\n");
}

int main(void){
    int h, w;

    scanf("%d %d", &h, &w);
    while(h != 0 && w != 0){
        print_rect(h, w);
        scanf("%d %d", &h, &w);
    }

    return 0;
}



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

long long part(vector<int> &C,vector<vector<int>> &S,vector<int> L,int i,int j){
  long long partsum=0;
  L.at(j)=i+1;
  partsum+=S.at(i).at(j);
  for(int k=0;k<26;k++){
    partsum-=C.at(k)*(i+1-L.at(k));
  }
  return partsum;
}
  
int main(){
  int D;
  cin >> D;
  vector<int> C(26);
  for(int i=0;i<26;i++){
    cin >> C.at(i);
  }
  long long sum=0;
  vector<vector<int>> S(D,vector<int>(26));
  for(int i=0;i<D;i++){
    for(int j=0;j<26;j++){
      cin >> S.at(i).at(j);
    }
  }
  vector<int> L(26);
  /*スコア関数
  for(int i=0;i<D;i++){
    int T;
    cin >> T;
    L.at(T-1)=i+1;
    sum+=S.at(i).at(T-1);
    for(int j=0;j<26;j++){
      sum-=C.at(j)*(i+1-L.at(j));
    }
    cout << sum << endl;
  }*/
  for(int i=0;i<D;i++){
    int tem=0;
    long long temsum=0;
    for(int j=0;j<26;j++){
      long long partsum=part(C,S,L,i,j);
      if(partsum>temsum){
        temsum=partsum;
        tem=j;
      }
    }
    L.at(tem)=i+1;
    cout << tem+1 << endl;
  }
}


Measured memory_bytes: 3676
import sys
input=sys.stdin.readline


class UnionFind(object):
    def __init__(self, n):
        self.parent={i:i for i in range(1,n+1)}
        self.size={i:1 for i in range(1,n+1)}
    def find(self, a):
        if self.parent[a]!=a:
            self.parent[a]=self.find(self.parent[a])
        return self.parent[a]
    def getsize(self, a):
        return self.size[self.find(a)]
    def unite(self, a, b):
        a=self.find(a)
        b=self.find(b)
        if a==b:return
        if self.size[a]>self.size[b]:
            self.size[a]+=self.size[b]
            self.parent[b]=a
        else:
            self.size[b]+=self.size[a]
            self.parent[a]=b
    def isunited(self, a, b):
        return self.find(a)==self.find(b)


def solve():
    N, M, K = map(int, input().split())
    uft = UnionFind(N)
    d = {i:set() for i in range(1, N+1)}
    e = {i:0 for i in range(1, N+1)}
    f = {i:0 for i in range(1, N+1)}

    for _ in range(M):
        A, B = map(int, input().split())
        d[A].add(B)
        d[B].add(A)
        f[A] += 1
        f[B] += 1
        uft.unite(A, B)

    for _ in range(K):
        C, D = map(int, input().split())
        if uft.isunited(C, D):
            if not D in d[C]:
                e[C] += 1
            if not C in d[D]:
                e[D] += 1

    print(*(uft.getsize(i)-e[i]-f[i]-1 for i in range(1, N+1)))


if __name__ == "__main__":
    solve()


Measured memory_bytes: 88900
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	long long n, k, a, b, sum = 0; cin >> n >> k;
	vector<vector<long long>>aa(n, vector<long long>(2));
	for (int h = 0; h < n; h++) {
		cin >> aa[h][0] >> aa[h][1];
	}
	sort(aa.begin(), aa.end());
	for (int h = 0; h < n; h++) {
		if (k > aa[h][1]) {
			k = k - aa[h][1];
			sum += aa[h][0] * aa[h][1];
		}
		else if (k <= aa[h][1]) {
			sum += aa[h][0] * k;
			cout << sum << endl; return 0;
		}
	}
	cin >> n;
}

Measured memory_bytes: 5760
#include <iostream>

using namespace std;

int main(void){
  int n;
  int p[20];
  int i, j, f = 0;
  cin >> n;
  for(i = 0; i < n; i++){
    cin >> p[i];
  }
  for(i = 1; i < n - 1; i++){
    if(p[i - 1] < p[i] && p[i] < p[i + 1]){
      f++;
    }
    else if(p[i - 1]> p[i] && p[i] > p[i + 1]){
      f++;
    }

  }

  cout << f;

  return 0;
}


Measured memory_bytes: 256
import numpy as np
n,W=map(int,input().split())
w,v=[],[]
for i in range(n):
    x,y=map(int,input().split())
    w.append(x)
    v.append(y)
dp = np.zeros((n+1,W+1),dtype=np.int64)
for i in range(n):
    tmp=np.zeros(W+1,dtype=np.int64)
    tmp[w[i]:]=dp[i][:-w[i]]+v[i]
    dp[i+1]=np.maximum(dp[i],tmp)
print(dp[n][W])

Measured memory_bytes: 92260
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <cstring>
using namespace std;
const long long MOD = 998244353;
const int MAX = 3000;
long long fac[MAX];
long long finv[MAX];
long long inv[MAX];
 
long long power(long long m, long long n){
    long long res = 1;
    while(n > 0){
        if(n & 1) {
            res = (res * m) % MOD;
        }
        m = (m * m) % MOD;
        n >>= 1;
    }
    return res;
}

long long inverse(long long a){
    return power(a, MOD - 2);
}
void comb_init() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
long long comb(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

long long dp[3001][3001];
int main(){
  int A;
  int B;
  int C;
  int D;
  cin >> A >> B >> C >> D;

  dp[0][0] = 1;
  for(int i = 1; i <= D - B; i++){
    dp[0][i] = (dp[0][i - 1] * (long long) A) % MOD;
  }
  
  for(int i = 1; i <= C - A; i++){
    dp[i][0] = (dp[i - 1][0] * (long long) B) % MOD;
    for(int j = 1; j <= D - B; j++){
      dp[i][j] = (dp[i - 1][j] * (long long) (B + j) % MOD + dp[i][j - 1] * (long long) (A + i) % MOD) % MOD;
      dp[i][j] = (dp[i][j] - dp[i - 1][j - 1] * (A + i - 1) * (B + j - 1) % MOD + MOD) % MOD;
    }
  }
  cout << dp[C - A][D - B ] << endl;
  /*
  for(int i = 0; i <= C - A; i++){
    for(int j = 0; j <= D - B; j++){
      cout << dp[i][j] << " ";
    }
    cout << endl;
  }
  */
  return 0;
}


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

int main(){
    int a,b;
    cin >> a >> b;
    string ans="Zero";

    if(a>0) ans="Positive";
    else if(b>0) ans="Zero";
    else if(b<0){
        if((a-b)%2) ans="Positive";
        else ans="Negative";
    }
    cout << ans << endl;
}

Measured memory_bytes: 3644
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	vi v(n + 1);
	REP(i, m) {
		int a; cin >> a;
		v[a] = 1;
	}
	vl dp(n + 1, 0);
	dp[0] = 1;
	REP(i, n) {
		if (v[i + 1])continue;
		dp[i + 1] += dp[i];
		if (i > 0)dp[i + 1] += dp[i - 1];
		dp[i + 1] %= MOD;
	}
	cout << dp[n] << endl;
}

Measured memory_bytes: 1408
N = int(input())
n = N
fs = {}
f = 2
while n > 1:
  if f*f > n:
    if n not in fs:
      fs[n] = 0
    fs[n] += 1
    n = 1
  elif n%f == 0:
    if f not in fs:
      fs[f] = 0
    fs[f] += 1
    n = n//f
  else:
    f += 1
#print(fs)
rs = []
for f in fs:
  n = fs[f]
  for r in range(1, 256):
    if (r+1)*(r+2)//2 > n:
      rs.append(r)
      break
r = sum(rs)
print(r)


Measured memory_bytes: 9172
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<stdio.h>
using namespace std;
int a,b;
int main()
{
	scanf("%d%d",&a,&b);
	for(int i=1;i<=3;i++)
		if(a*b*i%2==1) 
		{
			printf("Yes\n");
			return 0;
		}
	printf("No\n");
}


Measured memory_bytes: 256
#include <iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<tuple>
#include<algorithm>
#include<cmath>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); ++i) 

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];

	int pre = -999;
	rep(i, n) {//直前の要素をできるだけ小さくする
		if (pre <= a[i] - 1) {
			pre = a[i] - 1;
		}
		else if (pre <= a[i]) {
			pre = a[i];
		}
		else {
			cout << "No" << endl;

			return 0;
		}
	}
	cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <vector>
using namespace std;
using ll = long long;

int main() {
	int N;
	scanf("%d", &N);
	vector<ll> A(100000 + 1, 0);
	ll S = 0;
	for (int i = 0; i < N; i++) {
		int a;
	 	scanf("%d", &a);
		A.at(a)++;
		S += a;
	}

	int Q;
	scanf("%d", &Q);
	for (int i = 0; i < Q; i++) {
		int B, C;
		scanf("%d%d", &B, &C);
		S += (C - B) * A.at(B);
		A.at(C) += A.at(B);
		A.at(B) = 0;
		printf("%lld\n", S);
	}
	return 0;
}


Measured memory_bytes: 3556
/**
*    author:  Dooloper
*    created: 05.07.2020 23:35:09
**/

#include <bits/stdc++.h>

#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
using P = pair<int,int>;
using ll = long long;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int h, w, k;
  int ans = 0;
  cin >> h >> w >> k;
  vector<string> s(h);
  rep(i,h) cin >> s[i];
  rep(is,1<<h){
    rep(js,1<<w){
      int cnt = 0;
      rep(i,h)rep(j,w){
        if(is>>i&1) continue;
        if(js>>j&1) continue;
        if(s[i][j] == '#') cnt++;
      }
      if(cnt == k) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3652
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int compare_string(const void *a, const void *b)
{
    return strcmp(*((char **)a), *((char **)b));
}

int main()
{
    char s[5000+1];
    char **table;
    int K;
    int num;
    int i;
    int j;
    int count;
    int count2;
    char *current;

    scanf("%s%*c", s);
    scanf("%d", &K);

    num = ((strlen(s) + 1) * strlen(s)) / 2;
    table = (char **)malloc(sizeof(char *) * num);

    count = 0;
    for(i = 0; i < strlen(s); i++) {
        count2 = 0;
        for(j = 1; j <= strlen(s)-i; j++) {
            table[count] = (char *)malloc(sizeof(char) * (j + 1));
            strncpy(table[count], &(s[i]), j);
            count += 1;
            count2 += 1;
            if(count2 >= K) {
                break;
            }
        }
    }

    //qsort(table, num, sizeof(char *), compare_string);
    qsort(table, count, sizeof(char *), compare_string);

    j = 1;
    current = table[0];
    for(i = 1; i < num; i++) {
        if(j == K) {
            break;
        }
        if(strcmp(current, table[i]) != 0) {
            current = table[i];
            j += 1;
        }
    }

    printf("%s\n", current);

    return 0;
}

Measured memory_bytes: 3324
from collections import deque

H, W = map(int, input().split())
que = deque()
A = [[0 for i in range(W)] for j in range(H)]
white_num = 0
for i in range(H):
    S = input()
    for j in range(W):
        if S[j] == '.':
            A[i][j] = -1
            white_num += 1
        elif S[j] == '#':
            A[i][j] = 0
            que.append([j, i])

ans = 0
while len(que) > 0:
    x, y = que.popleft()
    for k in range(4):
        nx = x + [1, 0, -1, 0][k]
        ny = y + [0, 1, 0, -1][k]
        if nx < 0 or ny < 0 or nx >= W or ny >= H:
            continue
        if A[ny][nx] == -1:
            que.append([nx, ny])
            A[ny][nx] = A[y][x] + 1
            ans = max(ans, A[ny][nx])
print(ans)

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

int main() {
    #ifdef TooLazy
        freopen("A.txt", "r", stdin);
    #endif /// TooLazy

    string a, b, c;
    cin >> a >> b >> c;

    int x = a.size(), y = b.size();

    if(a[x-1]==b[0] && b[y-1]==c[0])
        puts("YES");

    else
        puts("NO");

    return 0;

}


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

using namespace std;

int main(){

  string S;
  string res = "No";
  int a=0, cnt=0;

  cin >> S;

  for(int i=0; i<3; ++i){
    if (S[0] == S[i+1]){
      ++cnt;
      if(cnt == 1){
        a=i+1;
      }
    }
  }

  if(cnt != 1){
    res = "No";
  }else{
    if(a == 1){
      if(S[2] == S[3])
        res = "Yes";
    }
    if(a == 2){
      if(S[1] == S[3])
        res = "Yes";
    }
    if(a == 3){
      if(S[1] == S[2])
        res = "Yes";
    }
  }

  cout << res << endl;
  return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>

using namespace std;
//#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
const int inf=1000000007;
const int MOD=1000000007;
int n,m;
int s[10],c[10];
bool judge(int k){
  bool flag=false;
  int keta=0;int buf=k;
  while(buf>0){
    buf/=10;
    keta++;
  }
  
  if(k==0)keta=1;
  if(keta!=n)return false;
  vector<int> num(n);
  rep(i,n){
    num[n-1-i]=k%10;
    k/=10;
  }
  //rep(i,n)cout<<num[i];
  //cout<<endl;
  flag=true;
  rep(i,m){
    if(num[s[i]-1]!=c[i])flag=false;
  }
  return flag;
}
signed main(){
  cin>>n>>m;
  rep(i,m)cin>>s[i]>>c[i];
  int res=-1;
  for(int i=0;i<1000;i++){
    if(judge(i)){
      res=i;
      break;
    }
  }
  cout<<res<<endl;
  return 0;
}


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

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

    vector<int> vec(N-1);
    vector<int> vec2(N);
    for (int i = 0; i < N; i++){
        vec2.at(i)= 0;
    }
        for (int i = 0; i < N - 1; i++)
        {
            cin >> vec.at(i);
        }

    for (int i = 0; i < N-1 ; i++){
        vec2.at(vec.at(i)-1) = vec2.at(vec.at(i)-1) + 1;
    }

    for (int i = 0; i < N; i++){
        cout << vec2.at(i) << endl;
    }
}

Measured memory_bytes: 4812
import sys

if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

N = INT()
A = MAP()

B = [abs(a) for a in A]
negatives = sum([1 for a in A if a<0])

#print(B, negatives)

if negatives % 2:
	min_B = min(B)
	ans = sum(B) - (2*min_B)
else:
	ans = sum(B)

print(ans)

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



int main(){

	char buf[10];
	int stack[200];
	int counter = 0;

	while(cin >> buf){

		switch(buf[0]){
			case '+':
				counter--;
				stack[counter] = stack[counter] + stack[counter + 1];			  
			break;

			case '-':
				counter--;
				stack[counter] = stack[counter] - stack[counter + 1];			  
			break;

			case '*':
				counter--;
				//cout << "result mul:" << stack[counter] << "*" << stack[counter + 1] << endl;
				stack[counter] = stack[counter] * stack[counter + 1];			  
			break;

			default:
				stack[++counter] = atoi(buf);						
					
		}
	}

	cout << stack[counter] << endl;
	

	return 0;
}

Measured memory_bytes: 1148
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[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()
        })*
    };
}

fn main() {
    let n = read::<usize>();
    let mut a = vec![];
    for _ in 0..n {
        a.push(read::<i64>());
    }
    a.sort();
    let mut ans = 0;
    if n % 2 == 1 {
        let mut lower = vec![];
        let mut upper = vec![];
        for i in 0..(n - n / 2) {
            lower.push(a[i]);
        }
        for i in (n - n / 2)..n {
            upper.push(a[i]);
        }
        let mut ans1 = upper.iter().sum::<i64>() * 2;
        ans1 -= lower.iter().sum::<i64>() * 2;
        ans1 += lower[lower.len() - 1];
        ans1 += lower[lower.len() - 2];

        let mut lower = vec![];
        let mut upper = vec![];
        for i in 0..(n / 2) {
            lower.push(a[i]);
        }
        for i in (n / 2)..n {
            upper.push(a[i]);
        }
        let mut ans2 = upper.iter().sum::<i64>() * 2;
        ans2 -= lower.iter().sum::<i64>() * 2;
        ans2 -= upper[0];
        ans2 -= upper[1];
        ans = max(ans1, ans2);
    } else {
        let mut lower = vec![];
        let mut upper = vec![];
        for i in 0..(n / 2) {
            lower.push(a[i]);
        }
        for i in (n / 2)..n {
            upper.push(a[i]);
        }
        ans = upper.iter().sum::<i64>() * 2;
        ans -= upper[0];
        ans -= lower.iter().sum::<i64>() * 2;
        ans += lower[lower.len() - 1];
    }

    println!("{}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


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

#define TYPE(c)   remove_reference_t<decltype(c)>
#define REP(i, n) for(TYPE(n) i = 0; i < n; i++)
#define FOR(v, c) for(TYPE(c.begin()) v = c.begin(); v != c.end(); v++)
#define ALL(c)    c.begin(), c.end()
#define SORT(c)   sort(ALL(c))
#define RSORT(c)  sort(ALL(c), greater<TYPE(c)::value_type>())
#define UNIQUE(c) c.erase(unique(ALL(c)), c.end())

using namespace std;
using ll = long long;

constexpr int MOD  = (int)1e9 + 7;
constexpr int INF  = (int)1e9 + 1;
constexpr ll  LINF = (ll)1e18 + 1;
template<typename T> constexpr bool chmax(T& a, const T& b)
{ if(a < b) { a = b; return true; } else { return false; } }
template<typename T> constexpr bool chmin(T& a, const T& b)
{ if(b < a) { a = b; return true; } else { return false; } }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T>& p)
{ return os << "(" << p.first << "," << p.second << ")"; }
template<typename T> auto operator<<(ostream& os, const T& t)
    -> typename conditional<true, ostream&, decltype(*t.begin())>::type
{ os << "["; FOR(v, t) { if(v != t.begin()) os << ","; os << *v; } os << "]"; return os; }
ostream& operator<<(ostream &os, const string& s)
{ FOR(v, s) os << *v; return os; }

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

    int A, B;
    std::cin >> A >> B;
    std::cout << ((A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0) ? "Possible" : "Impossible") << std::endl;

    return 0;
}


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

using namespace std;

int main() {
    int n, counter = 0, value;
    vector<int> a;
    cin>> n;
    while (n){
        cin>> value;
        a.push_back(value);
        n--;
    }
    for(int i = 0; i < a.size(); i+=2)
        if(a[i]%2 != 0)
            counter++;
    cout<< counter;
    return 0;
}


Measured memory_bytes: 3604
package main

import (
	"fmt"
	"strconv"
)

func main() {

	var n, count int
	var s string

	for fmt.Scan(&n); n > 0; n-- {

		s = strconv.Itoa(n)
		if len([]rune(s))%2 != 0 {
			count++
		}
	}
	fmt.Println(count)
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define max(p,q)((p)>(q)?(p):(q))

ll cumsum[1010][1010];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		int xx1,xx2,yy1,yy2;
		scanf("%d%d%d%d",&xx1,&yy1,&xx2,&yy2);
		cumsum[xx1][yy1]++;
		cumsum[xx1][yy2]--;
		cumsum[xx2][yy1]--;
		cumsum[xx2][yy2]++;
	}
	for(int i=0;i<1005;i++)for(int j=0;j<1005;j++)cumsum[i][j+1]+=cumsum[i][j];
	for(int j=0;j<1005;j++)for(int i=0;i<1005;i++)cumsum[i+1][j]+=cumsum[i][j];
	int ans=0;
	for(int i=0;i<1005;i++)for(int j=0;j<1005;j++)ans=max(ans,cumsum[i][j]);
	printf("%d\n",ans);
}


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

signed main()
{
   int N; cin>>N;
   vector<int> a(N);
   for(int i=0;i<N;i++){
      cin>>a[i];
   }
   sort(a.begin(),a.end());

   if(N%2==0){
      int ans=0;
      for(int i=0;i<N;i++){
         if(i<N/2-1){
            ans-=a[i]*2;
         }else if(i==N/2-1){
            ans-=a[i];
         }else if(i==N/2){
            ans+=a[i];
         }else{
            ans+=a[i]*2;
         }
      }
      cout<<ans<<endl;
   }else{
      int ans1=0;
      for(int i=0;i<N;i++){
         if(i<N/2){
            ans1-=a[i]*2;
         }else if(i==N/2 or i==N/2+1){
            ans1+=a[i];
         }else{
            ans1+=a[i]*2;
         }
      }
      int ans2=0;
      for(int i=0;i<N;i++){
         if(i<N/2-1){
            ans2-=a[i]*2;
         }else if(i==N/2-1 or i==N/2){
            ans2-=a[i];
         }else{
            ans2+=a[i]*2;
         }
      }
      cout<<max(ans1,ans2)<<endl;
   }
}


Measured memory_bytes: 1152
# -*- coding: utf-8 -*-

def answer(A, B):
  if (A == 1 and B == 2):
    return 3
  if (A == 1 and B == 3):
    return 2
  if (A == 2 and B == 1):
    return 3
  if (A == 2 and B == 3):
    return 1
  if (A == 3 and B == 1):
    return 2
  if (A == 3 and B == 2):
    return 1

A = int(input())
B = int(input())
X = answer(A, B)
print(X)


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

int main(void){
  int age, fee;
  cin >> age >> fee;
  
  int ret;
  if(age >= 13) { ret = fee; }
  else if(age >= 6) { ret = fee/2; }
  else { ret = 0; }
  cout << ret << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdio>
#include <algorithm>

using namespace std;

int B[105][105];
int h, w, n, A[10050];

int main()
{
    scanf("%d%d", &h, &w);
    scanf("%d", &n);
    for(int i = 0;i < n;++i)
        scanf("%d", A + i);

    int idx = 1;
    for(int i = 0;i < h;++i)
    {
        if(i & 1)
        {
            for(int j = w - 1;j > -1;--j)
            {
                if(A[idx - 1] == 0)
                    ++idx;

                --A[idx - 1];
                B[i][j] = idx;
            }
        }
        else
        {
            for(int j = 0;j < w;++j)
            {
                if(A[idx - 1] == 0)
                    ++idx;

                --A[idx - 1];
                B[i][j] = idx;
            }
        }
    }

    for(int i = 0;i < h;++i)
    {
        for(int j = 0;j < w;++j)
        {
            printf("%d ", B[i][j]);
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include<algorithm>
#include<string>
#include<vector>
#include <math.h>
#include <iomanip>

using namespace std;

int main()
{
	string s;
	long num = 0;
	cin >> s;
	for (int i = 0; i < s.length(); i++) if (s[i] == '/') {s.replace(i, 1, "0"); }
	num = stoi(s);
	//cout << num << endl;
	cout << (num <= 2019004030 ? "Heisei" : "TBD") << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
const int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, int b, int _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& vec) { for (auto &vi: vec) os << vi << " "; return os; }
template<class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<typename T >inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T> inline void add(T &a, int b) { a += b; if (a >= mod) a -= mod; }



void solve();

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

    int T;
    // cin >> T;
    T = 1;

    while (T--) {
        solve();
    }
}

void solve() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  cout << *max_element(all(a)) - *min_element(all(a)) << endl;
}


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

int main()
{
    int a,b, c=0, ec = 0;
    string s;
    cin >> a >> b >> s;
    for(int i=0; i<=(a+b); i++)
    {
        if(s[a] == '-') ec = 1;
        if(s[i] == '-') c++;

    }
    if((c == 1) && (ec == 1)) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3544
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define req(i,n) for(int i = 1;i <=n;i++)
#define pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
using Graph = vector<vector<int>>;
vector<vector<int>> field;
vector<bool> seen;

const int MOD = 1000000007;
typedef pair<int,int> P;

//最大公約数
int gcd(int a,int b){
	if (a%b == 0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}

}

//最小公倍数
int lcm(int a,int b){
	return a /gcd(a,b) * b;
}

//素数判定
bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}



  








int main() {
  int a, b;
  cin >> a >> b;
  int c = 0;
  for (int i = a; i <= b; i++) {
    if(i / 10000 == i % 10 && (i % 10000) / 1000 == (i % 100) / 10){
      c++;
    }   
  }
  cout << c << endl;
}

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

using namespace std;

vector<long long>ans;

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

    string str;
    long long i=0;
    cin>>str;
    while(true){
        long long now = 0;
        while(i<str.size() && str[i] == '<'){
            ans.push_back(now);
            now++;i++;
        }
        if(i == str.size()){
            ans.push_back(now);
            break;
        }
        long long idx = i;long long val = now;
        while(i<str.size() && str[i] == '>'){
            i++;
        }
        now = 1;long long temp = i;i--;
        while(i>idx){
            ans.push_back(now);
            i--;now++;
        }
        ans.push_back(max(val,now));
        if(temp == str.size())break;
        i = temp;
    }
    long long res = 0;
    for(i=0;i<ans.size();i++)res+=ans[i];
    cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 7188