akhauriyash/Code-Regression huggingface dataset:
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
printV = lambda x: print(*x, sep="\n")
printH = lambda x: print(" ".join(map(str,x)))
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	n = II()
	ch = False
	for nn in str(n):
		if(nn=='7'):
			ch=True
	if ch:
		print("Yes")
	else:
		print("No")

if __name__ == '__main__':
	main()

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr double EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max()/2;
constexpr int MOD = 1e9+7;

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

    int n,m;cin>>n;
    map<string,int> mp;
    vector<string> s(n);
    for(int i=0;i<n;i++){
        cin>>s[i];
        mp[s[i]]++;
    }
    cin>>m;
    for(int i=0;i<m;i++){
        string t;cin>>t;
        mp[t]--;
    }
    int res=0;
    for(int i=0;i<n;i++){
        //cout<<mp[s[i]]<<endl;
        res=max(res,mp[s[i]]);
    }
    cout<<res<<endl;
}


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

#define   ll     long long int

ll mod = 1000000007;

int main( )
{
    ll n, m, i, ans = 0;
    cin >> n >> m;
    if (n == m) {
        ans = 1;
        for (i = 1; i <= n; i++) {
            ans = (ans * i) % mod;
        }
        ans = (ans * ans) % mod;
        ans = (2 * ans) % mod;
    }
    else if (abs(n - m) == 1) {
        if (n > m) swap(n, m);
        ans = 1;
        for (i = 1; i <= n; i++) {
            ans = (ans * i) % mod;
        }
        ans = (ans * ans) % mod;
        ans = (m * ans) % mod;
    }
    cout << ans << '\n';
    return 0;
}



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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    int N, V, P;  ll M; cin >> N >> M >> V >> P;
    ll A[N]; rep(i, N) cin >> A[i];
    sort(A, A+N);
    int ng = -1, ok = N;
    int m = (ng+ok)/2;
    while(abs(ng-ok) > 1){
        //問題mは採用される可能性があるか?
        //問題mがそもそも上からp番目以内ならok
        if(N-m <= P) ok = m;
        else if(A[m] + M < A[N-P]) ng = m; //P番目をジャッジが選ばなくてもm番目の問題が越せない場合は無理
        else{
            int rem = V - (P+m); //必ず選ぶものは上からP-1番目までと下からm番目まで
            if(rem <= 0) ok = m;
            else{
                //A[m]より大きいスコアの問題をrem問選ぶことをM回繰り返す
                //A[m+1], ..., A[N-P]のそれぞれに,A[m] + Mを超えないようになるべく多くスコアを分配した結果,
                //分配した数の合計がrem*M以上ならok 未満ならng
                //各問題に振れるスコアの上限値はM
                //というか、Mより大きい値を振ったら絶対A[m] + Mを超える(Aは昇順なので)
                ll acc = 0;
                for(int i = m+1; i <= N-P; i++){
                    acc += (A[m] + M) - A[i];
                }
                if(acc >= M*rem) ok = m;
                else ng = m;
            }
        }
        m = (ng+ok)/2;
    }
    cout << N-ok << endl;
    return 0;
}

Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;

class Pair{
    int position;
    int area;

    Pair(int pos, int area){
        this.position = pos;
        this.area = area;
    }
}

public class Main {

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

        int sum = 0;
        ArrayDeque<Integer> stack1 = new ArrayDeque<>();
        ArrayDeque<Pair> stack2 = new ArrayDeque<>();

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String string = br.readLine();
        char[] chars = string.toCharArray();
        for (int i=0; i<chars.length; i++){
            if (chars[i] == '\\'){
                stack1.push(i);
            }
            else if (chars[i] == '/' && !stack1.isEmpty()){
                int j = stack1.pop();
                int temp = i-j;
                sum += temp;
                while (!stack2.isEmpty() && stack2.peek().position>j){
                    temp += stack2.pop().area;
                }
                stack2.push(new Pair(j, temp));
            }
        }

        // ?°?stack2?????¬
        ArrayDeque<Integer> stack3 = new ArrayDeque<>();
        while (!stack2.isEmpty()){
            stack3.push(stack2.pop().area);
        }

        System.out.println(sum);
        System.out.print(stack3.size());

        while (!stack3.isEmpty()){
            System.out.print(" " + stack3.pop());
        }
        System.out.println();
    }
}

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

int main(){
    int n;
    cin>>n;
    vector<int>a(n);
    int ans=0;
    rep(i,n){
        cin>>a[i];
        ans=__gcd(ans,a[i]);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define dd(x) cout << #x << " = " << x << ", "
#define de(x) cout << #x << " = " << x << endl
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
int main()
{
	int n,m,t;
	vector<pii> u[10];
	scanf("%d%d",&n,&m);
	/*rep(i,0,10){
		rep(j,0,10){
			scanf("%d",&t);
			if(i != j){
				u[i].pb(mp(t,j));
			}
			sort(all(u[i]));
		}
	}
	int st[10];
	rep(i,0,10){
		
	}*/
	int G[10][10];
	rep(i,0,10){
		rep(j,0,10){
			scanf("%d",&G[i][j]);
		}
	}
	rep(k,0,10){
		rep(i,0,10){
			rep(j,0,10){
				G[i][j] = min(G[i][j],G[i][k] + G[k][j]);
			}
		}
	}
	int ans = 0;
	rep(i,0,n){
		rep(j,0,m){
			scanf("%d",&t);
			ans += G[t][1];
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
(defun splitat (c line)
  (labels ((rec (line acc)
				(let ((pos (position-if (lambda(cc) (char= c cc)) line)))
				  (if pos
					  (rec (subseq line (1+ pos)) (cons (subseq line 0 pos) acc))
					(nreverse (cons line acc))))))
	(rec line nil)))

(defun f(n a b)
  (let ((r (truncate n (+ a b)))
        (m (mod n (+ a b))))
    (if (< m a)
      (+ (* r a) m)
      (+ (* r a) a))))

(let* ((line (mapcar #'parse-integer (splitat #\space (read-line nil nil))))
       (n (car line))
       (a (cadr line))
       (b (caddr line)))
  (format t "~A~%" (f n a b)))


Measured memory_bytes: 16100
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<utility>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#define EPS 1e-9
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define LL long long
const int MOD = 1E9+7;
const int N = 1000000+5;
const int dx[] = {-1,1,0,0,-1,-1,1,1};
const int dy[] = {0,0,-1,1,-1,1,-1,1};
using namespace std;
 
LL n,A,B;
LL a[N];
bool judge(LL x){
    LL temp=x*B;
    LL sub=A-B;
    LL sum=0;
    for(LL i=n;i>=1;i--){
        if(a[i]>temp){
            if((a[i]-temp)%sub)
                sum+=(a[i]-temp)/sub+1;
            else
                sum+=(a[i]-temp)/sub;
        }
    }
    if(sum<=x)
        return true;
    return false;
}
int main() {
    scanf("%lld%lld%lld",&n,&A,&B);
 
    LL right=0;
    for(LL i=1;i<=n;i++){
        scanf("%lld",&a[i]);
        right+=a[i]/B+1;
    }
    sort(a+1,a+1+n);
 
    LL left=1;
    while(left<right){
        LL mid=(left+right)>>1;
        if(judge(mid))
            right=mid;
        else
            left=mid+1;
    }
    printf("%lld\n",left);
 
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cassert>
#include<stdexcept>
#include<utility>
#include<functional>
#include<numeric>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<array>
#include<stack>
#include<queue>
#include<deque>
#include<vector>
#include<complex>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<string>
#include<bitset>
#include<memory>
using namespace std;
using ll=long long;

using Graph=vector<vector<int>>;

Graph g;

void dfs0(int v,vector<int>& color){
    for(auto to:g[v]){
        if(color[to]==-1){
            color[to]=!color[v];
            dfs0(to,color);
        }
        else{
            if(color[to]==color[v]) throw "Excep";
        }
    }
}

int calc(int v){
    queue<int> que;
    que.push(v);
    int res=0;
    vector<int> used(g.size());
    used[v]=true;
    while(!que.empty()){
        res++;
        queue<int> tmp;
        while(!que.empty()){
            v=que.front(); que.pop();
            for(auto to:g[v]){
                if(!used[to]){
                    tmp.push(to);
                    used[to]=true;
                }
            }
        }
        que=tmp;
    }
    return res;
}

int main(){
    int n;
    cin>>n;
    g.resize(n);
    for(int i=0;i<n;i++){
        string s;
        cin>>s;
        for(int j=0;j<s.size();j++){
            if(s[j]=='1') g[i].push_back(j);
        }
    }    
    try{
        vector<int> color(n,-1);
        for(int i=0;i<n;i++){
            if(color[i]==-1){
                color[i]=0;
                dfs0(i,color);
            }
        }
        int res=0;
        for(int i=0;i<n;i++){
            res=max(res,calc(i));
        }
        cout<<res<<endl;
        return 0;
    }
    catch(...){
        cout<<-1<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 512
#include <vector>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <cstdlib>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i,n) for(int i=0;i<n;i++)
#define SORT(c) sort((c).begin(),(c).end())
#define ALL(a) (a).begin(),(a).end()

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

  string S;
  cin >> S;
  bool ans = true;

	int rec = S.length() - 1;
	while (true) {
		if (rec <= 0) { break; }
		if (S[rec - 4] == 'd'&&
			S[rec - 3] == 'r'&&
			S[rec - 2] == 'e'&&
			S[rec - 1] == 'a'&&
			S[rec] == 'm') {
			rec -= 5;
		} else if (S[rec - 6] == 'd'&&
			S[rec - 5] == 'r'&&
			S[rec - 4] == 'e'&&
			S[rec - 3] == 'a'&&
			S[rec - 2] == 'm'&&
			S[rec - 1] == 'e'&&
			S[rec] == 'r') {
			rec -= 7;
		} else if (S[rec - 4] == 'e'&&
			S[rec - 3] == 'r'&&
			S[rec - 2] == 'a'&&
			S[rec - 1] == 's'&&
			S[rec] == 'e') {
			rec -= 5;
		} else if (S[rec - 5] == 'e'&&
			S[rec - 4] == 'r'&&
			S[rec - 3] == 'a'&&
			S[rec - 2] == 's'&&
			S[rec - 1] == 'e'&&
			S[rec] == 'r') {
			rec -= 6;
		} else {
			ans = false;
			break;
		}
	}

	if (ans == true) {
    cout << "YES";
  } else {
    cout << "NO";
  }
	return 0;
}


Measured memory_bytes: 512
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
h, w = map(int, input().split())
n = h*w
fld = ''.join([input().rstrip()for _ in range(h)])
edges = [set() for _ in range(n)]


def to_v(i, j):
    return i*w+j


for i in range(h):
    for j in range(w):
        v = to_v(i, j)
        dirc = [(-1, 0), (0, 1), (1, 0), (0, -1)]
        for di, dj in dirc:
            x, y = i+di, j+dj
            if x < 0 or h <= x or y < 0 or w <= y:
                continue
            v2 = to_v(x, y)
            if fld[v] != fld[v2]:
                edges[v].add(v2)
                edges[v2].add(v)


def dfs(v, c=0):
    if visited[v]:
        return
    visited[v] = 1
    cnt[c] += 1
    for v2 in edges[v]:
        dfs(v2, c ^ 1)


visited = [0]*n
ans = 0
for v in range(n):
    if visited[v]:
        continue
    cnt = [0, 0]
    dfs(v)
    ans += cnt[0]*cnt[1]
print(ans)


Measured memory_bytes: 130808
#include<iostream>
using namespace std;
int main(){
    int n, x;
    while(1){
        cin>>n>>x;
        if(n == 0 && x == 0) break;
        int ans = 0;
        for(int a=1;a<=n;a++)
            for(int b=a + 1;b<=n;b++)
                for(int c=b + 1;c<=n;c++){
                    if(a + b + c != x) continue;
                    ans++;
                }
        cout<<ans<<endl;
    }
    return 0;
}



Measured memory_bytes: 3116
#include<iostream>
#include<vector>
#include<queue>
#include <string>
#include <sstream>
#include <queue>
#include <complex>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <set>
using namespace std;

#define ll int64_t
const long MOD = 1e9 + 7;






int main()
{


  long n, XX;
  cin >> n >> XX;

  vector<long> x(n);

  for (int i = 0; i < n; ++i) {
    cin >> x[i];
    x[i] -= XX;
    if (x[i] < 0)x[i] = -x[i];
  }

  long maxD = 0;
  sort(x.begin(), x.end()); //昇順ソート;

  long minx = x[0];

  long mindiv = 0;


  while (true) {
    bool isAllMod = true;
    for (int i = 0; i < n; ++i) {
      if (x[i] % minx != 0)isAllMod = false;
      if (!isAllMod)break;
    }
    if (isAllMod)break;

    while (true) {
      mindiv++;
      if (x[0] % mindiv == 0) {
        minx = x[0] / mindiv;
        break;
      }
    }

  }




  cout << minx << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <utility>
#include <set>
#include <queue>
using namespace std;

#define DEBUG(x) cerr << #x << " = " << x << endl

vector<string> splitAll(string s, string t) {
    vector<string> v;
    for(size_t p = 0; (p = s.find(t)) != string::npos; ) {
        v.push_back(s.substr(0, p));
        s = s.substr(p + t.size());
    }
    v.push_back(s);
    return v;
}

int main() {
    for(int N; cin >> N, N; ) {
        vector<pair<string, vector<string> > > vec(N);
        for(int i = 0; i < N; i++) {
            string s; cin >> s;
            s = s.substr(0, s.length() - 1);
            vec[i].first = s.substr(0, s.find(':'));
            s = s.substr(s.find(':') + 1);
            vec[i].second = splitAll(s, ",");
        }
        map<string, int> m;
        for(int i = 0; i < N; i++) {
            if(!m.count(vec[i].first)) {
                int id = m.size();
                m[vec[i].first] = id;
            }
            for(string s : vec[i].second) {
                if(!m.count(s)) {
                    int id = m.size();
                    m[s] = id;
                }
            }
        }
        vector<vector<int> > G(m.size());
        for(auto p : vec) {
            for(string s : p.second) {
                G[m[p.first]].push_back(m[s]);
            }
        }
        int ans = 0;
        queue<int> Q;
        Q.push(m[vec[0].first]);
        vector<char> vis(m.size(), false);
        while(!Q.empty()) {
            int x = Q.front(); Q.pop();
            if(vis[x]) continue;
            vis[x] = true;
            if(G[x].size() == 0) ans++;
            for(int y : G[x]) {
                Q.push(y);
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 1384
n = int(input())
dic = {}
num_list = []
for i in range(n):
    a = int(input())
    dic[a] = 0
    num_list.append(a)
for a in num_list:
    dic[a] += 1
ans = 0
for i in dic.values():
    if i % 2 != 0:
        ans += 1
print(ans)

Measured memory_bytes: 15628
#include <iostream>
#include <algorithm>
#include <string>
#define int long long
using namespace std;
const int A6[] = { 6,36,216,1296,7776,46656 };
const int L9[] = { 9,81,729,6561,59049 };
signed main() {
	int n, ans = 100000; cin >> n;
	for (int i6 = 0; i6 < 3; i6++) {
		for (int i5 = 0; i5 < 6; i5++) {
			for (int i4 = 0; i4 < 6; i4++) {
				for (int i3 = 0; i3 < 6; i3++) {
					for (int i2 = 0; i2 < 6; i2++) {
						for (int i1 = 0; i1 < 6; i1++) {
							int cnt = i1 + i2 + i3 + i4 + i5 + i6;
							int sum = i1 * A6[0] + i2 * A6[1] + i3 * A6[2] + i4 * A6[3] + i5 * A6[4] + i6 * A6[5];
							if (sum <= n) {
								int p;
								p = (n - sum) / L9[4]; cnt += p; sum += p * L9[4];
								p = (n - sum) / L9[3]; cnt += p; sum += p * L9[3];
								p = (n - sum) / L9[2]; cnt += p; sum += p * L9[2];
								p = (n - sum) / L9[1]; cnt += p; sum += p * L9[1];
								p = (n - sum) / L9[0]; cnt += p; sum += p * L9[0];
								cnt += n - sum;
								ans = min(ans, cnt);
							}
						}
					}
				}
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream> 
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
#include<set>
#include<queue>
#include<deque>
#include<iomanip>
#include<sstream>
#include<cmath>
#include<bitset>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define req(i,n) for(int i = 1;i <=  n; i++)
#define rrep(i,n) for(int i = n -1;i >= 0;i--)
#define ALL(obj) begin(obj), end(obj)
typedef long long int ll;
typedef long double ld;
const ll INF = (1 << 29);
ll k, m, n,h,w,v;
const ll MOD= 1000000007;
const ld PI = acos(-1);
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T & val) {
    std::fill((T*)array, (T*)(array + N), val);
}
int main() {
    cin >> n >> m; vector<pair<int, int>> a(m);
    rep(i, m) {
        cin >> h >> w;
        a[i] = make_pair(w, h);
    }
    int cnt = 1;
    sort(ALL(a)); k = a[0].first;
    req(i, m - 1) {
        if (k <= a[i].second) {
            cnt++; k = a[i].first;
        }
    }cout << cnt << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int main(void){
     string n,s;
     cin >> n >> s;
     int count = 0;
     
     for (int i=0; i < n.size(); i++){
           if (n[i] == s[i]) count++;
     }
    
    if(count==n.size()) cout << "Yes" << endl;
    else cout << "No" <<endl;
}


Measured memory_bytes: 3620
def resolve():
    N = int(input())
    A = []
    for _ in range(N):
        a = int(input())
        A.append(a)
    count = 0
    num = 1
    for i in range(N):
        num = A[num-1]
        count += 1
        if num == 2:
            print(count)
            exit()
    print("-1")
resolve()

Measured memory_bytes: 13060
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MAX 300003
#define MOD 998244353
#define INF 1000000000000000

int main(){
  int n,m,s,t;
  cin>>n>>m>>s>>t;
  s--,t--;
  vector<vector<pair<int,int>>> G(n);
  vector<ll> a(m),b(m);
  for(int i=0;i<m;i++){
    int u,v;
    cin>>u>>v>>a.at(i)>>b.at(i);
    u--;v--;
    G.at(u).push_back(make_pair(v,i));
    G.at(v).push_back(make_pair(u,i));
  }

  vector<ll> cost_y(n,INF);
  cost_y.at(s)=0;
  priority_queue<pair<ll,int>,vector<pair<ll,int>>,greater<pair<ll,int>>> pq;
  pq.push(make_pair(cost_y.at(s),s));
  while(!pq.empty()){
    int v=pq.top().second;
    pq.pop();
    for(auto p:G.at(v)){
      int nv=p.first;
      int i=p.second;
      if(cost_y.at(nv)>cost_y.at(v)+a.at(i)){
        cost_y.at(nv)=cost_y.at(v)+a.at(i);
        pq.push(make_pair(cost_y.at(nv),nv));
      }
    }
  }

  vector<ll> cost_s(n,INF);
  cost_s.at(t)=0;
  pq.push(make_pair(cost_s.at(t),t));
  while(!pq.empty()){
    int v=pq.top().second;
    pq.pop();
    for(auto p:G.at(v)){
      int nv=p.first;
      int i=p.second;
      if(cost_s.at(nv)>cost_s.at(v)+b.at(i)){
        cost_s.at(nv)=cost_s.at(v)+b.at(i);
        pq.push(make_pair(cost_s.at(nv),nv));
      }
    }
  }

  vector<ll> ans(n);
  ans.at(n-1)=cost_y.at(n-1)+cost_s.at(n-1);
  for(int i=n-2;i>=0;i--){
    ans.at(i)=min<ll>(ans.at(i+1),cost_y.at(i)+cost_s.at(i));
  }

  for(int i=0;i<n;i++){
    cout<<1000000000000000-ans.at(i)<<endl;
  }
}


Measured memory_bytes: 12276
n = int(input())
info = []
cnt = 0

###初期配置
ans1 = [[0] * 10 for i in range(3)]###棟
ans2 = [[0] * 10 for i in range(3)]
ans3 = [[0] * 10 for i in range(3)]
ans4 = [[0] * 10 for i in range(3)]

while True:
    b, f, r, v = map(int, input().split())
    info.append([b, f, r, v])
    cnt += 1
    if cnt == n:
        break

for i in range(len(info)):
    if info[i][0] == 1:
        ans1[info[i][1]-1][info[i][2]-1] += info[i][3]
    
    elif info [i][0] == 2:
        ans2[info[i][1]-1][info[i][2]-1] += info[i][3]

    elif info [i][0] == 3:
        ans3[info[i][1]-1][info[i][2]-1] += info[i][3]

    else:
        ans4[info[i][1]-1][info[i][2]-1] += info[i][3]

for i in range(3):
    print("", " ".join(map(str, ans1[i])))
print(20*'#')

for i in range(3):
    print("", " ".join(map(str, ans2[i])))
print(20*'#')

for i in range(3):
    print("", " ".join(map(str, ans3[i])))
print(20*'#')

for i in range(3):
    print("", " ".join(map(str, ans4[i])))


Measured memory_bytes: 5620
package main

import "fmt"

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	if a%3 == 0 || b%3 == 0 || (a+b)%3 == 0 {
		fmt.Println("Possible")
	} else {
		fmt.Println("Impossible")
	}
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<long long>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}



int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, p;
    cin >> n >> p;
    vi a(n);
    rep(i, n) cin >> a[i];
    rep(i, n) a[i] %= 2;


    vll cnt(2, 0);
    rep(i, n) cnt[a[i]]++;
    
    if (cnt[1] == 0 && p == 1) {
        cout << 0 << endl;
        return 0;
    } 
    ll ans = 1LL<<(cnt[0]+max(cnt[1]-1, 0LL));
    cout << ans << endl;

}

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

int main() {
  ll x;cin>>x;
  ll cnt = x / 11;
  int rest = x % 11;
  cnt *= 2;
  if (rest>6) cnt += 2;
  else if (rest>0) cnt += 1;
  cout << cnt;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		//sort(all(vi S)) sort(all(string S))
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

using P = pair<int, int>;		//P.first, P.second

typedef long long ll;

const int MOD = 1e9+7;
const int INF = 1e9;

using Graph = vector<vector<int>>;
int N,Q;
ll dp[200005];
ll query_matome[200005];
// 深さ優先探索
vector<bool> seen;
void dfs(const Graph &G, int v,int pre) {
    seen[v] = true; // v を訪問済にする
    if(pre>=0){
        dp[v] = query_matome[v] + dp[pre];
    }
    // v から行ける各頂点 next_v について
    for (auto next_v : G[v]) { 
        if (seen[next_v]) continue; // next_v が探索済だったらスルー
        dfs(G, next_v,v); // 再帰的に探索
    }
}

int main() {
	//頂点数, Query数

	cin>>N>>Q;
	//グラフ（隣接リスト表現）
	Graph G(N);
	rep(i,N-1){
		int a,b;
		cin>>a>>b;
		a--,b--;
		G[a].push_back(b);
		//無向グラフの場合は以下を追加
		G[b].push_back(a);
	}
    rep(i,Q){
        int p,x;
        cin>>p>>x;
        p--;
        query_matome[p] += x;
    }
    
	// 頂点 0 をスタートとした探索
    seen.assign(N, false); // 全頂点を「未訪問」に初期化
    dp[0] = query_matome[0];
    dfs(G, 0, -1);
    for(int i = 0; i < N; ++i){
        if(i == N){
            cout<<dp[i]<<endl;
        }
        else cout<<dp[i]<<" ";
    }
	return 0;
}


Measured memory_bytes: 25600
#include<algorithm>
#include <iostream>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<string>
using namespace std;
int main(){
    
    int d,n;
    cin>>d>>n;
    if(n!=100){
        
        cout<<n*pow(100,d)<<endl;
    }else if(n==100 && d==2){
        cout<<(n+1)*10000<<endl;
    }else{
        cout<<(n+1)*pow(100,d)<<endl;
    }
    
    return 0;
}








Measured memory_bytes: 256
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0].split(" ")[0]);
    const X = arg[1].split(" ").map(n=>parseInt(n));
    const sortedX = [...X].sort((a,b)=>a-b);
    
    const middleOne = sortedX[(N / 2) - 1];
    const middleTwo = sortedX[N / 2];

    let answer = [];
    
    for(let i in X) {
        if(X[i] < middleTwo) {
            answer.push(middleTwo);
        } else {
            answer.push(middleOne);
        }
    }
    
    console.log(answer.join("\n"));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 65020
#include<stdio.h>

void checkTri(int,int,int);

int main(){
	int a,b,c,n,i;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d %d %d",&a,&b,&c);
		checkTri(a,b,c);
	}
	return 0;
}

void checkTri(int a,int b,int c){
	a*=a;
	b*=b;
	c*=c;
	if(a==b+c)printf("YES\n");
	else if(b==a+c)printf("YES\n");
	else if(c==a+b)printf("YES\n");
	else printf("NO\n");
}

Measured memory_bytes: 580
#include <iostream>
#include <string>
#include <cstdint>

std::string& test_decode(std::string& decoded_text)
{
	for (char& c : decoded_text) {
		if (c == 'a') {
			c = 'z';
		}
		else if (c != '.' && c != ' ') {
			c -= 1;
		}
	}
	return decoded_text;
}

int main()
{
	std::string encrypted_text;

	while (std::getline(std::cin, encrypted_text)) {
		do {
			test_decode(encrypted_text);
		} while (encrypted_text.find("the")  == std::string::npos &&
				 encrypted_text.find("this") == std::string::npos &&
				 encrypted_text.find("that") == std::string::npos);
		std::cout << encrypted_text << std::endl;
	}

	return 0;
}

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

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

const int N = 2e5 + 5, mod = 1e9 + 7;

int n, c[N], dp[N][2], prt[N];
vector <int> vec[N];

int sum(int a, int b) {
	a += b;
	if(a >= mod)
		a -= mod;
	if(a < 0)
		a += mod;
	return a;
}

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> c[i];
		c[i]--;
	}
	n = unique(c, c + n) - c;
	dp[0][0] = 1;
	prt[c[0]] = 1;
	for (int i = 1; i < n; i++) {
		dp[i][0] = sum(dp[i - 1][0], dp[i - 1][1]);
		dp[i][1] = prt[c[i]];
		prt[c[i]] = sum(prt[c[i]], dp[i][0]);
	}
	cout << sum(dp[n - 1][0], dp[n - 1][1]) << "\n";
}


Measured memory_bytes: 8064
#include <bits/stdc++.h>
#define newl "\n"
using namespace std;
using lli = long long int;
using vvint = vector <vector <int>>;
const int mod = 1e9 + 7;

const int N = 2e5 + 1;

void dfs(int s,vector <bool> &vis,vector <int> &p,vector <int> &out){
	vis[s] = 1;
	out.push_back(s);
	if(!vis[p[s]]) dfs(p[s],vis,p,out);
	return;
}

void solve(){
	int n,k;
	cin >> n >> k;
	vector <int> p(n),c(n);
	for(int i = 0;i < n;++i){
		cin >> p[i];
		--p[i];
	}
	for(int i = 0;i < n;++i){
		cin >> c[i];
	}
	lli maxx = -2e18;
	vector <bool> vis(n,0);
	for(int i = 0;i < n;++i){
		if(!vis[i]){
			vector <int> out;
			dfs(i,vis,p,out);
			lli l = out.size();
			//for(int i : out) cout << i << " ";
			//cout << newl;
			for(int i = 0;i < l;++i){
				if(k >= l){
					lli k1 = k / l;
					lli summ = 0;
					for(int j = i + 1;j < l;++j){
						summ = summ + c[out[j]];
						maxx = max(maxx,summ);
					}
					for(int j = 0;j <= i;++j){
						summ = summ + c[out[j]];
						maxx = max(maxx,summ);
					}
					if(summ <= 0){
					}
					else{
						lli maxx3 = summ * k1;
						lli pp = summ * k1;
						lli k2 = k % l;
						for(int j = i + 1;j <= min(l - 1,i + k2);++j){
							pp = pp + c[out[j]];
							maxx3 = max(maxx3,pp);
						}
						for(int j = 0;j <= max(-1ll,k2 - (l - i));++j){
							pp = pp + c[out[j]];
							maxx3 = max(maxx3,pp);
						}
						lli maxx4 = summ * (k1 - 1);
						lli pp1 = summ * (k1 - 1);
						for(int j = i + 1;j <= l - 1;++j){
							pp1 = pp1 + c[out[j]];
							maxx4 = max(maxx4,pp1);
						}
						for(int j = 0;j <= i;++j){
							pp1 = pp1 + c[out[j]];
							maxx4 = max(maxx4,pp1);
						}
						maxx3 = max(maxx3,maxx4);
						maxx = max(maxx3,maxx);
					}
				}
				else{
					lli summ = 0;
					lli maxx2 = -2e18;
					for(int j = i + 1;j <= min(l - 1ll,(lli)(i + k));++j){
						summ = summ + c[out[j]];
						maxx2 = max(maxx2,summ);
					}
					for(int j = 0;j <= max(-1ll,k - (l - i));++j){
						summ = summ + c[out[j]];
						maxx2 = max(maxx2,summ);
					}
					maxx = max(maxx2,maxx);
				}
			}
		}
	}
	cout << maxx << newl;

	return;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(10);
	#ifdef EXECUTE_LOCALLY
		   freopen("in.txt","r",stdin);
	#endif
	int t = 1;
	//cin >> t;
	while(t--) solve();
	#ifdef EXECUTE_LOCALLY
    	cout << setprecision(3) << "program time: " << (double)clock() / CLOCKS_PER_SEC << newl;
	#endif
	return 0;
}


Measured memory_bytes: 3940
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//(a+b-1)/b

signed main(){
	int a,b; cin>>a>>b;
	if(a>b)swap(a,b);
	int ans=b;
	--b;
	ans+=max(a,b);
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 3596
import heapq
from collections import defaultdict
n, m = list(map(int, input().split()))

#list型のdistを初期化 works[key]:{list}になっている
works = defaultdict(list)
for i in range(n):
    a, b = list(map(int, input().split()))
    #a日後にお金が振り込まれる物のlistを作成
    works[a].append(b)
candidate = []
ans = 0
heapq.heapify(candidate)
for i in range(1,m+1):
    for j in works[i]:
        heapq.heappush(candidate, -j)
    if len(candidate) != 0:
        ans += heapq.heappop(candidate)

print(-ans)


Measured memory_bytes: 33028
#include <bits/stdc++.h>
#define ll long long
#define ls id << 1
#define rs id << 1 | 1
#define mem(array, value, size, type) memset(array, value, ((size) + 5) * sizeof(type))
#define memarray(array, value) memset(array, value, sizeof(array))
#define pb(x) push_back(x)
#define st(x) (1LL << (x))
#define pii pair<int, int>
#define mp(a, b) make_pair((a), (b))
#define Flush fflush(stdout)
using namespace std;
const int N = 500050;
const int inf = 0x3f3f3f3f;
const ll mod = 998244353LL;
clock_t TIME_START, TIME_END;
void program_end()
{
#ifdef ONLINE
    printf("\nTime used: %.6lf(s)\n", ((double)TIME_END - TIME_START) / CLOCKS_PER_SEC);
    system("pause");
#endif
}
ll n;
set<ll> s;
inline ll mi(ll a, ll b)
{
    ll ret = 1;
    while (b)
    {
        if (b & 1)
            ret *= a;
        a *= a;
        b >>= 1;
    }
    return ret;
}

void check(ll d)
{
    for (ll i = 1; i <= 60; ++i)
    {
        ll k = pow(d * 1.0, 1.0 / i);
        if (k == 1)
            continue;
        if (mi(k, i) == d)
        {
            if ((n / d - 1 + k) % k == 0)
                s.insert(k);
        }
        if (mi(k + 1, i) == d)
        {
            if ((n / d - 1 + k + 1) % (k + 1) == 0)
                s.insert(k + 1);
        }
        if (k > 1 && mi(k - 1, i) == d)
        {
            if ((n / d - 1 + k - 1) % (k - 1) == 0)
                s.insert(k - 1);
        }
    }
}

void solve()
{
    cin >> n;
    for (ll i = 1; i * i <= n - 1; ++i)
    {
        if ((n - 1) % i == 0)
        {
            s.insert(i);
            s.insert((n - 1) / i);
        }
    }
    for (ll i = 1; i * i <= n; ++i)
    {
        if (n % i == 0)
        {
            check(i);
            check(n / i);
        }
    }
    check(n);
    s.erase(1);
    cout << s.size() << '\n';
    // for (auto i : s)
    //     cout << i << ' ';
}

int main()
{
    TIME_START = clock();
    int Test = 1;
    // cin >> Test;
    while (Test--)
        solve();
    TIME_END = clock();
    program_end();
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1000000007;
const double PI = 3.141592653589793238463;
const int N=4e5+100;
int main()
{
    FASTINOUT;
    string s;
    cin>>s;
    int ls=s.length();
    cout<<s[0]<<ls-2<<s.back()<<endl;
    return 0;
}


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

using namespace std;

int main() {
  int a, b, i;
  vector<pair <int, int> > p;
  while(~scanf("%d,%d", &a, &b), a != 0 || b  != 0)  {
    p.push_back(pair<int, int>(b,a));
  }
  
  sort(p.begin(), p.end());
  reverse(p.begin(), p.end());
  
  while(cin >> a)  {
    i = 0;
    int bef = p[0].first;
    int rank = 1;
    
    while(1) {
      if(bef != p[i].first) {
	bef = p[i].first;
	rank++;
      }
      if(p[i++].second == a) break;
    }
      
    cout << rank << endl;
  }
  
  return 0;
}
  

Measured memory_bytes: 1244
# 中心座標と半径を求める
class SolvCircle

	LOOP_MAX = 100

	# 移動距離がこの値以下になったら処理を終了させる
	CONVRGV = 1.0e-10

	#
	#=== 円の中心座標と半径を求める
	#
	#_pt_x_ :: n個の点のx座標の配列
	#_pt_y_ :: n個の点のy座標の配列
	# 
	#返り値::配列を返す。[中心点のx座標, 中心点のy座標, 円の半径]
	#
	def solv_circle(pt_x, pt_y)
		mv_rate  = 0.5 # 移動係数
		max_dist = 0.0 # 中心点から最遠点までの距離
		xsv      = 0.0 # 中心点のx座標
		ysv      = 0.0 # 中心点のy座標
		cx       = 0.0 # 仮中心点のx座標
		cy       = 0.0 # 仮中心点のy座標
		k        = 0
		cvgflg   = false

		while (cvgflg == false)

			LOOP_MAX.times { |t|
				# 最遠点を求める
				max_dist = 0.0
				pt_x.length.times { |i|
					dist = distance(cx, cy, pt_x[i], pt_y[i])
					if (dist > max_dist)
						max_dist = dist
						k        = i
					end
				}

				# 仮の中心点を計算
				cx += (pt_x[k] - xsv) * mv_rate
				cy += (pt_y[k] - ysv) * mv_rate

				# 移動距離が境界値を下回っていればループを抜ける
				if (distance(cx, cy, xsv, ysv) <= CONVRGV)
					cx     = xsv
					cy     = ysv
					cvgflg = true
					break
				end

				xsv = cx
				ysv = cy
			}

			mv_rate /= 2.0

		end

		return [cx, cy, max_dist]
	end

	#
	#=== 二点の距離を求める
	#
	def distance(x1, y1, x2, y2)
		dx = x2 - x1
		dy = y2 - y1
		Math.sqrt(dx * dx + dy * dy)
	end
end

n = gets.chomp!.to_i
ptx = []
pty = []
n.times{
	a,b = gets.chomp!.split(/ /).map(&:to_i)
	ptx.push(a)
	pty.push(b)
}
hoge = SolvCircle.new()
x,y,r = hoge.solv_circle(ptx,pty)
puts r

Measured memory_bytes: 1788
n = int(input().rstrip())
a = map(int,input().rstrip().split())
b = list(sorted(a,reverse=True))

c = 0
ad = 0
for i in range(n):
 if c == 0:
  ad += b[i]
  c = 1
 else:
  ad -= b[i]
  c = 0

print(ad)
 


Measured memory_bytes: 3060
#pragma region include
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <cstdio>
#include <tuple>
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define MOD 1000000007
#define INF 1000000000
#define LLINF 4000000000000000000
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#pragma endregion

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    int N, M; cin >> N >> M;
    VI a(M);
    vector<ll> dp(N + 3, 0);
    REP(i, M) {
        cin >> a[i];
        a[i]--;
    }
    int k = 0;
    dp[0] = 1;
    dp[1] = 1;
    REP(i, N) {
        if (k < M && a[k] == i) {
            k++;
            dp[i] = 0;
        }
        else {
            if (i - 2 >= 0) dp[i] += dp[i - 2];
            if (i - 1 >= 0) dp[i] += dp[i - 1];
            dp[i] %= MOD;
        }
    }
    cout << dp[N-1] << endl;
    getchar(); getchar();
}

Measured memory_bytes: 1408
// header {{{
// #define NDEBUG
#include <bits/stdc++.h>
using namespace std;

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define ALPHABET    (26)
#define INF         INT_MAX
#define MOD         (1000000007LL)
#define EPS         (1e-10)
#define EQ(a, b)        (abs((a)-(b)) < EPS)
#define CILING(a, b)    (((a)+(b)-1LL)/(b))

template<class T>
using PIT = pair<int, T>;
template<class T>
using PTI = pair<T, int>;
using PII = pair<int, int>;
using PDI = pair<double, int>;
using LL  = long long;
using ULL = unsigned long long;
// }}}

int main() {
    int n;cin >> n;
    vector<int> a(n);
    vector<int> count(100005, 0);
    for(auto &aa : a) cin >> aa;
    for(int i=0;i<n;i++){
        count[a[i]]++;
    }
    int ans = 0;
    for(int i=0;i<=100000;i++){
        int sum = count[i]+count[i+1]+count[i+2];
        ans = max(ans, sum);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
A, B = [int(x) for x in input().split()]


def prime_decomposition(n):
    i = 2
    table = []
    while i * i <= n:
        while n % i == 0:
            n //= i
            table.append(i)
        i += 1
    if n > 1:
        table.append(n)
    return table

a = prime_decomposition(A)
b = prime_decomposition(B)

a = set(a)
b = set(b)
ab = a.intersection(b)
ab.add(1)

print(len(ab))

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

int main(){
  int A, B, C, K;
  cin >> A >> B >> C >> K;
  if (A >= K){
    cout << K << endl;
  }
  else if (A + B >= K){
    cout << A << endl;
  }
  else if (A + B + C >= K){
    cout << 2 *A + B - K << endl;
  }
}
    

Measured memory_bytes: 3592
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	n := getInt()
	W := getInt()

	ws := make([]int, n)
	vs := make([]int, n)
	for i := 0; i < n; i++ {
		ws[i] = getInt()
		vs[i] = getInt()
	}

	dp := make([][]int, n+1)
	for i := range dp {
		dp[i] = make([]int, W+1)
	}

	for i := 1; i < n+1; i++ {
		for j := range dp[i-1] {
			if tmpW := j + ws[i-1]; tmpW <= W {
				dp[i][tmpW] = max(dp[i][tmpW], dp[i-1][j]+vs[i-1])
			}
			dp[i][j] = max(dp[i][j], dp[i-1][j])
		}
	}

	fmt.Println(max(dp[n]...))
}

func max(ns ...int) int {
	max := ns[0]
	for i := 1; i < len(ns); i++ {
		if max < ns[i] {
			max = ns[i]
		}
	}
	return max
}

// -----------------------------------------

var scanner = wordScanner()

func wordScanner() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}

func getInt() int {
	scanner.Scan()
	i, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func getIntSlice(n int) []int {
	is := make([]int, n)
	for i := range is {
		is[i] = getInt()
	}
	return is
}

func getString() string {
	scanner.Scan()
	s := scanner.Text()
	return s
}


Measured memory_bytes: 81792
//              +-- -- --++-- +-In the name of ALLAH-+ --++-- -- --+              \\

#include <bits/stdc++.h>

#define F first
#define S second
#define _sz(x) (int)x.size()

using namespace std ;
using ll = long long ;
using ld = long double ;
using pii = pair <int , int> ;

int const N = 500 + 5 ;
int n , m , a[N][N] ;

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

	cin >> n >> m ;

	for (int i = 0 ; i < n ; i ++) {
		string s ;
		cin >> s ;

		for (int j = 0 ; j < m ; j ++) if (s[j] == '#') a[i][j] = 3 ;
	}

	for (int i = 0 ; i < n ; i ++) {
		a[i][0] |= 1 , a[i][m - 1] |= 2 ;

		for (int j = 1 ; j < m - 1 ; j ++) {
			if (i & 1) a[i][j] |= 1 ;
			else a[i][j] |= 2 ;
		}
	}
	
	for (int i = 0 ; i < n ; i ++) {
		for (int j = 0 ; j < m ; j ++)
			cout << (a[i][j] & 1 ? '#' : '.') ;
		cout << '\n' ;
	}
	cout << '\n' ;
	for (int i = 0 ; i < n ; i ++) {
		for (int j = 0 ; j < m ; j ++)
			cout << (a[i][j] & 2 ? '#' : '.') ;
		cout << '\n' ;
	}
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using st = string;
using P = pair<int, int>;
#define mrep(i, m, n) for(int i = m; i < n; i++)
#define rep(i, n) mrep(i, 0, n)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

int main() {
    int x;
    cin >> x;
    int rank;
    if(400 <= x && x <= 599) rank = 8;
    if(600 <= x && x <= 799) rank = 7;
    if(800 <= x && x <= 999) rank = 6;
    if(1000 <= x && x <= 1199) rank = 5;
    if(1200 <= x && x <= 1399) rank = 4;
    if(1400 <= x && x <= 1599) rank = 3;
    if(1600 <= x && x <= 1799) rank = 2;
    if(1800 <= x && x <= 1999) rank = 1;
    cout << rank << endl;
    return 0;
}

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

int main(){
	
	string s;
	int k;
	cin >> k >> s;
	if ((int)s.length() > k){
		for (int i = 0; i < k; i++){
			cout << s[i];
		}
		cout << "...";
	}
	else
		cout << s;
	return 0;
}


Measured memory_bytes: 3628
S = list(input())
ans = 'AC'
if not S[0] == 'A':
    ans = 'WA'
if not 'C' in (S[2:-1]):
    ans = 'WA'
if ans == 'AC':
    S.remove('A')
    S.remove('C')
    if not S == [s.lower() for s in S]:
        ans = ('WA')
print(ans)


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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll n;
    cin >> n;
    ll ans = 0;
    for(i = 1;i <= n;++i){
        ll b = (n-1)/i;
        ans += b;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3628
#define _USE_MATH_DEFINES
#include<iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main(){
	double r;
	cin >> r;
	cout << setprecision(6) << fixed << M_PI*r*r << " " << 2*M_PI*r <<endl;
	return 0;
}


Measured memory_bytes: 3244
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
var n=Arr.shift()-0;
for(var I=0;I<n;I++){
   var arr=(Arr.shift()).split(" ");
   var sum=0;
   arr.forEach(function(v){
      v=v.replace(/(\d?)([mcxi])/g,function(s,s1,s2){
         s1=(s1)?s1-0:1;
         if(s2=="m")s2=1000;
         if(s2=="c")s2=100;
         if(s2=="x")s2=10;
         if(s2=="i")s2=1;
         sum+=(s1*s2);
         return s;
      });
   });
   var str=("000"+sum).slice(-4);
   var S=str.split("").map(Number);
   var result="";
   S.forEach(function(v,i){
      if(v==1)v="";
      if(v!==0){
         if(i==0)result+=v+"m";
         if(i==1)result+=v+"c";
         if(i==2)result+=v+"x";
         if(i==3)result+=v+"i";
      }
   });
   console.log(result);
}

Measured memory_bytes: 12304
from itertools import zip_longest

abcd = input()

for i in range(0, 8):
	signs = bin(i)[2:].zfill(3).replace("1", "+").replace("0", "-")
	formula = "".join("".join(s) for s in zip_longest(abcd, signs, fillvalue=""))
	if eval(formula) == 7:
		print(formula+"=7")
		exit()


Measured memory_bytes: 3060
#include <stdio.h>
#include <string.h>

int main(void)
{
	char s[16], t[16];
	int a, b;
	char u[16];

	scanf("%s %s", s, t);
	scanf("%d %d", &a, &b);
	scanf("%s", u);

	if (!strcmp(s, u)) {
		printf("%d %d\n", a-1, b);
	}
	else {
		printf("%d %d\n", a, b-1);
	}
	return 0;
}


Measured memory_bytes: 128
#
import sys
import math
import numpy as np
import itertools

# ひとつ入力
n = int(input())

# 文字列を一文字ずつのリストに代入 test は['t', 'e', 's', 't']
m = list(input())
answer = n
for i in range(1,n):
    if m[i-1]==m[i]:
        answer -= 1
#print(m)
print(answer)


Measured memory_bytes: 13384
import sys
l, r = map(int, input().split())
mod = 2019

if l%mod == 0 or r%mod == 0 or l//mod != r//mod:
  print(0)
  sys.exit()

ans = mod
for i in range(l, r):
  for j in range(i+1, r+1):
    ans = min(ans, i*j%mod)
print(ans)

Measured memory_bytes: 65048
from sys import stdin
N, M = [int(_) for _ in stdin.readline().rstrip().split()]
PYs = [list(map(int, stdin.readline().rstrip().split()))+[i] for i in range(M)]
PYs.sort(key=lambda x:x[1])

num = [0]*N
ans = [""]*M

for p, y, i in PYs:
    num[p-1]+=1
    ans[i] = str(p).zfill(6) + str(num[p-1]).zfill(6)

for i in range(M):
    print(ans[i])

Measured memory_bytes: 32536
#[test]
fn test_solve() {
    assert_eq!(solve("4\n1 -3 1 0\n"), "4\n");
    assert_eq!(solve("5\n3 -6 4 -5 7\n"), "0\n");
    assert_eq!(solve("6\n-1 4 3 2 -5 4\n"), "8\n");
}

fn solve(src: &str) -> String {
    let mut sc = Scanner::from_str(src);

    let n: usize = sc.read();
    let a: Vec<isize> = (0..n).map(|_| sc.read()).collect();

    let ans: usize = [0, 1]
        .iter()
        .map(|&stt| {
            let mut sum = 0;
            let mut scr = 0;
            for i in 0..n {
                sum += a[i];
                let d = if i & 1 == stt && sum <= 0 {
                    1 - sum
                } else if i & 1 != stt && sum >= 0 {
                    -1 - sum
                } else {
                    0
                };
                sum += d;
                scr += d.abs() as usize;
            }
            scr
        })
        .min()
        .unwrap();

    format!("{}\n", ans)
}

fn main() {
    let mut buf = String::new();
    use std::io;
    use std::io::{Read, Write};
    io::stdin().read_to_string(&mut buf).unwrap();
    io::stdout().write_all(solve(&buf).as_bytes()).unwrap();
}

struct Scanner<'a>(std::str::SplitWhitespace<'a>);
impl<'a> Scanner<'a> {
    fn from_str(src: &str) -> Scanner {
        Scanner(src.split_whitespace())
    }
    fn get(&mut self) -> &str {
        self.0.next().unwrap()
    }
    fn read<T: std::str::FromStr>(&mut self) -> T {
        self.get().parse().ok().unwrap()
    }
}


Measured memory_bytes: 6396
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long long INF = 1000000007;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){
    int W,a,b; cin >> W >> a >> b;
    if(a+W < b || b+W < a) cout << min(abs(b-(a+W)), abs(a-(b+W))) << endl;
    else cout << 0 << endl;
    return 0;
}

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

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

int main() {
	 long long int a, b,g;
	while (cin >> a >> b) {
		if (a < b) {
			swap(a, b);
		}
		g = gcd(a, b);
		cout << g << " " << (a * b) / g << endl;
	}
	return 0;
}

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

int main()
{
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	
	int s1,s2,s3;
	s1=a+b;
	s2=b+c;
	s3=a+c;
	cout<<min(s1,min(s2,s3)) ;
 } 

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

main()
{
	int x[1000],y[1000];
	double p[4]={0};
	int n,cou,a;
	scanf("%d",&n);
	
	for(cou=0;cou<n;cou++){
		scanf("%d",&x[cou]);
	}
	
	for(cou=0;cou<n;cou++){
		scanf("%d",&y[cou]);
	}
	
	for(cou=0;cou<n;cou++){
		a=x[cou]-y[cou];
		if(a<0){a*=-1;}
		p[0]+=a;
	}
	
	for(cou=0;cou<n;cou++){
		a=x[cou]-y[cou];
		a*=a;
		p[1]+=a;
	}
	p[1]=sqrt(p[1]);
		
	for(cou=0;cou<n;cou++){
		a=x[cou]-y[cou];
		if(a<0){a*=-1;}
		a=a*a*a;
		p[2]+=a;
	}
	p[2]=pow(p[2],1.0/3.0);
	
	for(cou=0;cou<n;cou++){
		a=x[cou]-y[cou];
		if(a<0){a*=-1;}
		
		if(p[3]<a){p[3]=a;}
	}
	
	printf("%f\n%f\n%f\n%f\n",p[0],p[1],p[2],p[3]);
	
	return 0;
}


Measured memory_bytes: 2112