akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

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

    for (int i = 0; i < s.size(); i++) {
        if (s.substr(i) + s.substr(0, i) == t) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())

S = input()
s = list(S)
l = len(s)



B = []

for i in range(l):
  c = ord(s[i])
  e = c+N
  if e>ord('Z'):
    e = e - 26
  d = chr(e)
  B.append(d)
    
b = ''.join(B)

print(b)


Measured memory_bytes: 9304
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;
 
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }
 

int main()
{
  cin.tie( 0 );
  ios::sync_with_stdio( false );
  
  int x;cin>>x;
  if(x<=3){
    cout(1);
    return 0;
  }
  int ans=1;
  irep(i,2,x){
    int tmp=i;
    while(true){
      tmp*=i;
      if(tmp>x)break;
      if(tmp>ans)ans=tmp;
      if(ans==x){
        cout(ans);return 0;
      }
    }
  }
  cout(ans);
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<cmath>
#include<queue>
#include<limits>
#include<cassert>
#include<set>
#include<tuple>
#include<map>
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
typedef long long ll;
using namespace std;

int main() {
	int N; cin >> N;
	if (N == 1) {
		cout << 1 << endl;
		return 0;
	}
	for (int i = 2;; ++i) {
		if (i*i > N) {
			cout << (i - 1) * (i - 1) << endl;
			return 0;
		}
	}
}


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

#define INF 1e18

int main() {

  long long a, b, c;
  long long x, y, z;
  long long k;

  cin >> a >> b >> c >> k;

  if(k%2==0) {
    cout << a-b << endl;
  }else {
    cout << b-a << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define maxn 100005
using namespace std;
int arr[maxn];
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,T;
	cin >> n >> T;
	for(int i=1;i<=n;i++)
		cin >> arr[i];
	int max_val = arr[n] , max_dif = 0;
	int ans = 0;
	for(int i=n-1;i>=1;i--) {
		if(max_val - arr[i] > max_dif) {
			ans = 1;
			max_dif = max_val - arr[i];
		}
		else if(max_val - arr[i] == max_dif) {
			ans++;
		}
		max_val = max(max_val,arr[i]);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 640
from itertools import accumulate
n, m = map(int, input().split())
a = [0]+list(accumulate(map(int, input().split())))
di = {}
for i in a:
    i %= m
    if i not in di:
        di[i] = 0
    di[i] += 1
ans = 0
for i in di.values():
    ans += i*(i-1)//2
print(ans)

Measured memory_bytes: 22308
#include<iostream>
using namespace std;
int main(){
int P,Q,R;
cin>>P>>Q>>R;
if(P<=R&&Q<=R){
    cout<<P+Q;
}
else if (Q<=P&&R<=P){
    cout<<Q+R;
}

else if (P<=Q&&R<=Q){
    cout<<P+R;
}
return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
using namespace std;

int main() {
	
	int A;
	int B;
	int C;
	cin >> A;
	cin >> B;
	cin >> C;

	int D = A - B;

	if (D > C) {
		cout << 0 << endl;
	}
	else {
		cout << C - D << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>
#include <locale>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define repsg(i,s,g) for(int i = s; i <g; i++)
#define name(x) #x
using namespace std;


const int INF = 10000000;
const long long INFL = (1LL<<40);
const int MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}

template< typename T >
struct edge{
    int src, to;T cost;
    edge(int to,T cost) :src(-1),to(to),cost(cost){}
    edge(int src, int to, T cost) :src(src),to(to),cost(cost){}edge
    &operator=(const int &x){
        to =x;
        return *this;
    }
    operator int() const{ return to;}
};

double dist (double a, double b,  double c, double d){
    
    return sqrt((a-c)*(a-c) + (b-d)*(b-d));
    
}

int main() {
    int k, s; cin>>k>>s;
    int ans =0;
    for(auto i = 0; i<=k;i++){
        for(auto j = 0;j<=k;j++){
            auto x = s-i-j;
            if(x < 0 || x > k) continue;
            ans++;
        }
    }
    
    cout << ans << endl;
    return 0;
}







Measured memory_bytes: 256
a1, b1 = map(int, input().split())
a2, b2 = map(int, input().split())
a3, b3 = map(int, input().split())

cnt = {1: 0, 2: 0, 3: 0, 4: 0}
for i in range(4):
    if not i+1 in [a1, a2, a3, b1, b2, b3]:
        print('NO')
        exit()

lis = [a1, a2, a3, b1, b2, b3]

c = 0
for l in range(4):
    cnt = lis.count(l+1)
    if cnt > 1:
        c += 1

if c < 2:
    print('NO')
    exit()

print('YES')


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

int main() {
  int A, x, y, z;
  cin >> A;
  x = A % 2;
  y = (A - x) % 20;
  z = (A - x - y) % 200;
  cout << x + y/10 + z/100 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<unordered_set>
#include<vector>
#include<math.h>

using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    string s;
    cin >> s;
    int n = s.length();
    string fsub = s.substr(0, (n-1)/2);
    string ssub = s.substr((n+1)/2, (n-1)/2);
    if (s == string(s.rbegin(), s.rend()) && fsub == string(fsub.rbegin(), fsub.rend())
    && ssub == string(ssub.rbegin(), ssub.rend())){
        cout << "Yes";
    }
    else cout << "No";
}

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

using ll = long long;

#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 ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vs = vector<string>;
using vvs = vector<vs>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "{";
    rep(i, (int)v.size()) {
        if (i)
            os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
    for (auto val : array)
        std::cout << val << ", ";
    std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

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

    int a, b, c; std::cin >> a >> b >> c;
    int k; std::cin >> k;

    while (k && a >= b) {
        b *= 2;
        k--;
    }
    while (k && b >= c) {
        c *= 2;
        k--;
    }
    std::cout << ((a < b && b < c) ? "Yes" : "No") << "\n";
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef long double llf;
typedef pair<int, int> pi;

bool win(string a, string b){
	for(auto &i : a) if(i == '?') i = 'a';
	for(auto &i : b) if(i == '?') i = 'z';
	return a <= b;
}

int n;
string a, b[10005];

int main(){
	cin >> n;
	for(int i=0; i<n; i++) cin >> b[i];
	cin >> a;
	int l = 0, h = 0;
	for(int i=0; i<n; i++){
		if(win(a, b[i]) && win(b[i], a)) h++;
		else if(win(b[i], a)) l++, h++;
	}
	for(int i=l+1; i<=h+1; i++){
cout << i;
if(i <= h) cout << " ";
else cout << endl;
}

}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int cnt[35];
int n,m;
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int a;
      cin >> a;
      cnt[a]++;
    }
  }
  int ans = 0;
  for (int i = 1; i <= m; i++) {
    if (cnt[i] == n) {
      ans++;
    }
  }
  cout <<ans << endl;
}

/*　【提出前に確認すること】
・コンパイルできるか
・テストケース試したか
・オーバーフローあるか
*/


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) {Main instance = new Main();sc = instance.new Scanner();instance.solve();}
    private class Scanner {String[] s = new String[0];String regex = " ";int i = 0;BufferedReader br = new BufferedReader(new InputStreamReader(System.in));public String next() {try {if (i < s.length) { return s[i++];}String st = br.readLine();while ("".equals(st)) { st = br.readLine(); }s = st.split(regex, 0);i = 0;return s[i++];} catch (IOException e) { return null; }}public int nextInt(){return Integer.parseInt(next());}}        
    private static Scanner sc;

    private void solve() {
        System.out.println(sc.nextInt()%2+sc.nextInt()%2 == 2 ? "Odd" : "Even");
    }
}


Measured memory_bytes: 21204
class Array
  # k <= self[i]である最小のiを求める
  # 存在しない場合はi=n
  # (lo, hi]
  def lower_bound(k)
    lo = -1
    hi = size
    while hi - lo > 1
      mid = (lo + hi) / 2
      k <= at(mid) ? hi = mid : lo = mid
    end
    return hi
  end

  # k < self[i]である最小のiを求める
  # 存在しない場合はi=n
  # (lo, hi]
  def upper_bound(k)
    lo = -1
    hi = size
    while hi - lo > 1
      mid = (lo + hi) / 2
      k < at(mid) ? hi = mid : lo = mid
    end
    return hi
  end
end

n = gets.to_i
a = gets.split.map &:to_i
m = gets.to_i
b = gets.split.map &:to_i

ans = 0
b.each do |b|
  i = a.lower_bound(b)
  ans += 1 if i < n && a[i] == b
end
puts ans



Measured memory_bytes: 15348
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	private StringTokenizer st;
	private BufferedReader bf;
	private int w;
	
	Main() {
		readData();
		

	}
	

	private void readData() {
		try {
			bf = new BufferedReader(new InputStreamReader(System.in));
			st = new StringTokenizer(bf.readLine());
			
			while (true) {
				int m = nextInt();
				if (m==0)
					break;
				boolean[] r = new boolean[256];
				char[] table = new char[256];
				for (int i=0;i<256;i++)
					table[i] = (char)i;
				
				for (int i=0;i<m;i++) {
					char a = next().charAt(0);
					char b = next().charAt(0);
					table[a] = b;
					r[a] = true;
				}
				
				int n = nextInt();
				String tmp;
				StringBuilder result = new StringBuilder();
				for (int i=0;i<n;i++) {
					tmp = next();
					char c = tmp.charAt(0);
					if (r[c]) {
						result.append(table[c]);
//						r[c] = false;
//						table[c] = c;
					} else {
						result.append(c);
					}
				}
				System.out.println(result.toString());
//				System.out.println("a");
			}
			
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	private int nextInt() throws IOException {
		return Integer.parseInt(next());
	}
	
	
	private String next() throws IOException {
		if (st == null || !st.hasMoreTokens())
			st = new StringTokenizer(bf.readLine());
		return st.nextToken();
	}
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Main m = new Main();
	}

}

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

long long a[200005];
long long s[200005]={0};

int main(){
  int i,j,next=2,k;
  long long now=0,co=0,n,nn;
  cin >> n;
  for(i=1;i<=n;i++){
    cin >> a[i];
    s[i]=s[i-1]+a[i];
  }
  for(i=1;i<=n;i++){
    now=a[i];
    for(j=max(next,i+1);j<=n;j++){
      if(j==max(next,i+1)&&j!=i+1)now = nn^a[i-1];
      else now ^=a[j];
      if(now==s[j]-s[i-1])co+=j-i;
      else {
	//cout << i << " " << j <<" "<< co<< endl;
	next = j;
	nn = now;
	break;
      }
      if(j==n)i=n;
    }
  }
  

  cout <<co+n<< endl;

  return 0;
}


Measured memory_bytes: 3328
import math
n = int(input())
dv = []
dved = []
for i in range(1,int(math.sqrt(n)+1)):
    if n%i==0 and not(i in dved):
        dv.append(i)
        dved.append(n//i) 
    if i in dved:
        break
print(len(str(dved[-1]))if len(dv)>0 else 1)


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

typedef long long ll;
const int N = 500054, mod = 998244353;

int n, K;
int inv[N];

int main() {
	int i, cur = 1; ll ans = 0;
	scanf("%d%d", &n, &K), n = K-- - n, inv[1] = 1;
	for (i = 2; i <= n; ++i) inv[i] = ll(mod - mod / i) * inv[mod % i] % mod;
	for (i = 0; i <= n; ++i)
		ans += cur, cur = cur * ll(K - i) % mod * inv[i + 1] % mod;
	printf("%d\n", int(ans % mod));
	return 0;
}

Measured memory_bytes: 2176
#include<stdio.h>
#include<algorithm>
using namespace std;
int a[100000],sum[100000],sbm[100000],mm[100000];

int main()
{
    int n;
    scanf("%d",&n);
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        ans+=a[i];
    }

    sum[0]=0;
    for(int i=1;i<=n-1;i++)
    {
        sum[i]=sum[i-1]+a[i];
        sbm[i]=ans-sum[i];
    }

    int mmin=105;
    for(int i=1;i<=n-1;i++)
    {
        mm[i]=abs(sum[i]-sbm[i]);
        mmin=min(mm[i],mmin);
    }

    printf("%d\n",mmin);

    return 0;
}


Measured memory_bytes: 128
using System;
using System.Collections.Generic;

namespace Aizu
{
    class OnlineJudge
    {
        public static void Main()
        {
            for(int i; (i = int.Parse(Console.ReadLine())) != 0;) {
                var list = new SortedList<int, string>();
                for(;i > 0; --i) {
                    var input = Console.ReadLine().Split();
                    var time = 0;
                    for(int m = 1; m <= 8; ++m) {
                        time += int.Parse(input[m]) * ((m & 1) == 1 ? 60 : 1);
                    }
                    list.Add(time, input[0]);
                }
                Console.WriteLine(list.Values[0]);
                Console.WriteLine(list.Values[1]);
                Console.WriteLine(list.Values[list.Count - 2]);
            }
        }
    }
}

Measured memory_bytes: 6704
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<cmath>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define FOR(i, j, limit) for(int i=j; i< limit; ++i)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ECHO(x) cout<<x<<endl;
#define LL long long
int INF = 2147483647;
LL LINF = 9223372036854775807;
LL MOD = 1000000007;
typedef pair<int, int>P;
typedef pair<LL, LL>PL;
typedef vector<int> vi;
typedef vector<LL> vl;

LL h[51];
LL patty[51];

int main(){
  int n;
  LL x;
  cin>>n>>x;

  h[0]=1;
  patty[0]=1;
  REP(i, 50){
    h[i+1]=3+2*h[i];
    patty[i+1]=1+2*patty[i];
    //cout<<i<<" "<<h[i]<<" "<<patty[i]<<endl;
  }
  LL ans=0;
  while(n>=0 && x>0){
    if(n==0&&x==1) {
      ++ans;
      break;
    }
    else if(x<h[n-1]+1){
      --x;
      --n;
    }
    else if(x==h[n-1]+1){
      ans += patty[n-1];
      break;
    }
    else if(x==h[n-1]+2){
      ans += patty[n-1]+1;
      break;
    }
    else{
      ans += patty[n-1]+1;
      x -= h[n-1]+2;
      --n;
    }
    //cout<<n<<" "<<x<<" "<<ans<<endl;
  }
  //cout<<n<<" "<<x<<" "<<ans<<endl;
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<functional>
#include<fstream>
#include<utility>
#include<bitset>
#include<map>
#include<deque>
#include<cmath>
#include<random>
#include<string.h>
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define makei(N) int N; cin >> N;
#define makel(N) ll N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007
#define re return 0

using namespace std;
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using msi = map<string, int>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

void yn(bool b) {
	if (b)say("Yes");
	else say("No");
}

int main() {
	makei(X);
	makei(A);
	makei(B);
	if (A >= B)say("delicious");
	else if (A + X >= B)say("safe");
	else say("dangerous");
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (n); i++)
using namespace std;

int main(){
  int x, y;
  cin >> x >> y;
  bool flag = false;
  rep(i, x+1){
    int n = 2 * i + 4 * (x-i);
    if (n == y) flag = true;
  }
  if (flag) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 3624
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {
    public static void main(String[] args) throws NumberFormatException, IOException {
        BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(stdin.readLine());
        
        Map<Integer, Map<Integer, Integer>> weights 
            = IntStream.range(0, n)
                       .boxed()
                       .collect(Collectors.toMap(Function.identity(), unused -> new HashMap<>()));
        for (int i = 0; i < n - 1; i++) {
            String[] line = stdin.readLine().split(" ");
            int u = Integer.parseInt(line[0]) - 1;
            int v = Integer.parseInt(line[1]) - 1;
            int w = Integer.parseInt(line[2]);
            weights.get(u).put(v, w);
            weights.get(v).put(u, w);
        }
        
        
        int[] colors = new int[n];
        Arrays.fill(colors, -1);
        colors[0] = 0;
        
        Deque<Integer> stack = new ArrayDeque<>();
        stack.push(0);
        
        while (!stack.isEmpty()) {
            int current = stack.pop();
            for (Entry<Integer, Integer> e : weights.get(current).entrySet()) {
                int next = e.getKey();
                if (colors[next] != -1) {
                    continue;
                }
                
                if (e.getValue() % 2 == 0) {
                    colors[next] = colors[current];
                } else {
                    colors[next] = 1 - colors[current];
                }
                stack.push(next);
            }
        }
        
        Arrays.stream(colors).forEach(System.out::println);
    }
}


Measured memory_bytes: 107604
# coding: utf-8
import sys


def main(argv=sys.argv):

    number_of_500 = int(input())
    number_of_100 = int(input())
    number_of_50 = int(input())
    total_amount = int(input())

    number_of_cases = 0
    for counter_of_500 in range(number_of_500 + 1):
        for counter_of_100 in range(number_of_100 + 1):
            for counter_of_50 in range(number_of_50 + 1):
                if counter_of_500 * 500 + counter_of_100 * 100 + counter_of_50 * 50 \
                        == total_amount:
                    number_of_cases += 1

    print(number_of_cases)

    return 0


if __name__ == '__main__':
    sys.exit(main())


Measured memory_bytes: 3060
n = int(input())
A = 0
B = 0
AB = 0
ans = 0
S = [ input() for i in range(n)]
Bs = []
As = []
ABs = []
#print()
for i in range(n):
    s = S[i]
    for i in range(len(s)-1):
        if s[i] == "A" and s[i+1] == "B":
            ans += 1
            #print(s)
    if s[0] == "B" and s[-1] == "A":
        AB += 1
        ABs.append(s)
    elif s[0] == "B":
        B += 1
        Bs.append(s)
    elif s[-1] == "A":
        A += 1
        As.append(s)
#print(ABs)
#print(As)
#print(Bs)
#print(ans)
#ans += AB
#print(ans)
if AB > 0:
    if A + B > 0:
        ans += AB + min(A,B)
    elif A + B == 0:
        ans += AB - 1
else:
    ans += min(A,B)
print(ans)

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

int main()
{
  int top = 0,sub;
  char s[100];
  int t[100];
  t[0] = 0;
  top++;
  while(scanf("%s",s)!= EOF)
    {
      if(s[0] == '\n')
	{
	  break;
	}
      if(s[0] == '+')
	{
	  sub = t[top -2] + t[top -1];
	 if(top == 0)
	    {
	      break;
	    }
	 top--;
	 if(top == 0)
	    {
	      break;
	    }
	 top--;
	  if(top >= 100)
	    {
	      break;
	    }
	  t[top] = sub;
	}
      else if(s[0] == '-')
	{
	  sub = t[top -2] - t[top -1];
	  if(top == 0)
	    {
	      break;
	    }
	  top--;
	  if(top == 0)
	    {
	      break;
	    }
	  top--;
	  //printf(" aa %d aa",top);
	  if(top >= 100)
	    {
	      break;
	    }
	  t[top] = sub;
	}
      else if(s[0] == '*')
	{
	  
	  sub = t[top -2] * t[top -1];
	  if(top == 0)
	    {
	      break;
	    }
	  top--;
	  if(top == 0)
	    {
	      break;
	    }
	  top--;
	  if(top >= 100)
	    {
	      break;
	    }
	  t[top] = sub;
	}
      else
	{
	  t[top] = atoi(s);
	}
      //printf(" %d test  %d ",top,t[top]);
      top++;
    }
  printf("%d\n",t[top - 1]);
  
  
  return 0;
}




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

using namespace std;

#define REPI(x) for(int i=0;i<x;i++)
#define REPJ(x) for(int j=0;j<x;j++)
#define SCANFD(x) scanf("%d",&x)

int main(){
    string s1,s2;
    bool flag = true;

    cin >> s1;
    cin >> s2;
    
    REPI(3){
        if(s1[i]!=s2[2-i])
            flag=false;
    }
    if(flag)
        printf("YES\n");
    else
        printf("NO\n");
    
    return 0;
}


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

#define ll long long
#define pii pair<int, int>
using namespace std;
const ll mod = 1e9 + 9;

bool check(int state, vector<vector<pii>> &gr) {
    int n = gr.size();
    for (int i = 0; i < n; i++) {
        if (state & (1 << (n - i - 1))) {
            for (int k = 0; k < gr[i].size(); k++) {
                if (gr[i][k].second == ((state & (1 << (n - gr[i][k].first - 1)))!=0))
                    continue;
                else return false;
            }
        }
    }
    return true;
}

int main() {
    int n;
    cin >> n;
    vector<vector<pii>> gr(n, vector<pii >());
    for (int i = 0; i < n; i++) {
        int k;
        cin >> k;
        for (int j = 0; j < k; j++) {
            int a, b;
            cin >> a >> b;
            gr[i].push_back({--a, b});
        }
    }
    int ans = 0;
    for (int state = 0; state < (1 << n); state++) {
        if (check(state, gr))ans = max(ans, __builtin_popcount(state));
    }
    cout << ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <utility>
#include <string>
#include <math.h>
#include <algorithm>
#include <cstring>
#include <cctype>

using namespace std;

int main() {
 
   int N;
   string S;

   cin >> N;
   cin >> S;
   int cnt=0;
   for(int i=0;i<N;i++){
      if(i<N-2 && S[i]=='A' && S[i+1]=='B' && S[i+2]=='C'){
         cnt +=1;
      }
   }   
   cout << cnt << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>

using namespace std;

int main(){
  long long a, b;
  cin >> a >> b;
  for(long long i = 1; i <= b; i++){
    if((i*a) % b == 0){
      cout << i*a << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string.h>
using namespace std;
int main(){
    int a, b, s, k=0, i=0;
    while(scanf("%d%d", &a, &b)!=EOF){
        s=a+b;
        k=1;
        while(i>=0){
            s=s/10;
            k++;
            if(s/10<1)  break;
        }
        printf("%d\n", k);
    }
    
    return 0;
}

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

int mod = 1000000007;

int main()
{
    int A, B, C;
    cin >> A >> B >> C;
    if (A == B || B == C || C == A)
    {
        if (A == B && B == C && C == A)
            cout << "No";
        else
            cout << "Yes";
    }
    else
        cout << "No";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using intpair=pair<int,int>;
using llpair=pair<ll,ll>;
using llvec=vector<ll>;
using llmat=vector<vector<ll>>;
#define PI 3.141592653589793
#define llmattp(name,a,b,num) name(a,vector<ll>(b,num))
#define INTINF 1<<30
#define LLINF 1LL<<60
#define ABS(x) ( (x)>0 ? (x) : -(x) )
#define gsort(vbeg,vend) sort(vbeg,vend,greater<>())

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

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

ll gcd(ll a, ll b) { //最大公約数
	if(a==0||b==0) return 0;
	if(a<b) swap(a,b);
	ll tmp = a%b;
	while(tmp!=0) {
		a = b;
		b = tmp;
		tmp = a%b;
	}
	return b;
}

ll factorial(ll x) { //階乗
	ll f=1;
	for(ll i=2; i<x; i++) {
		f*=i;
	}
	return f;
}

ll nPr(ll n, ll r) {
	ll result=1;
	for(ll i=r+1; i<=n; i++) result*=i;
	return result;
}

ll nCr(ll n, ll r) {
	if (n == r) { return 1; }
	if (r > n) { return 0; }

	if (r > n / 2) { r = n - r; }

	if (n == 0) { return 0; }
	if (r == 0) { return 1; }
	if (r == 1) { return n; }

	double result = 1;
	for (double i = 1; i <= r; i++) {
		result *= (n - i + 1) / i;
	}

	return (ll)result;
}

ll GreaterBinarySearch(ll *array, ll key, ll max, ll min) { //にぶたんgreater
	if(array[max]<array[min]) {
		return NULL;
	} else {
		ll mid = max + (min-max)/2;
		if(array[mid]<key) {
			return GreaterBinarySearch(array,key,max,mid-1);
		} if(array[mid]>key) {
			return GreaterBinarySearch(array,key,mid+1,min);
		} else {
			return mid;
		}
	}
}

int DigitNum(ll n) { //桁数
	int digit=0;
	ll wari=1LL;
	while(n/wari) {
		digit++;
		wari*=10;
	}
	return digit;
}

bool IsPrime(ll num) { //素数判定
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

	double sqrtNum = sqrt(num);
	for (ll i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			// 素数ではない
			return false;
		}
	}

	// 素数である
	return true;
}

vector<ll> Divisor(ll x) { // 約数列挙
	vector<ll> result;
	ll i=1LL;
	for( ; i*i<x; i++) {
		if(x%i) continue;
		result.push_back(i);
		result.push_back(x/i);
	}
	if(i*i==x&&x%i==0)
		result.push_back(i);
	
	sort(result.begin(),result.end());
	return result;
}

vector<llpair> PrimeFact(ll x) { // 素因数分解 {素因数,指数}
	vector<llpair> result;
	ll ex=0LL;
	if(x%2==0) {
		while(x%2==0) {
			x/=2;
			ex++;
		}
		result.push_back({2,ex});
	}

	for(ll i=3LL; i*i<=x; i+=2) {
		if(x%i) continue;

		ex=0LL;
		while(x%i==0) {
			x/=i;
			ex++;
		}
		result.push_back({i,ex});
	}

	if(x!=1) result.push_back({x,1});

	return result;
}

bool Palind(string s) { //回文判定
	return s == string(s.rbegin(), s.rend());
}


int main() {
	ll N,K; cin>>N>>K;

	if(N>=K) {
		N-=N/K*K;
	}

	if(N>K/2) {
		N=K-N;
	}

	cout<<N<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()




int main(){
    int n,k; cin>>n>>k;
    if(n%k==0) cout<<0<<endl;
    else cout<<1<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

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

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

void	solve()
{
	string s;
	cin >> s;

	reverse(all(s));
	int n = s.size();
	int ans = 0;
	rep(i, n - 1) {
		if (s[i] - '0' < 9) {
			ans += s[n - 1] - '0' - 1;
			ans += 9 * (n - 1);
			cout << ans << endl;
			return;
		}
	}
	ans += s[n - 1] - '0';
	ans += 9 * (n - 1);
	cout << ans << endl;

}

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

	solve();
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var a, v, b, w, t int
	fmt.Scan(&a, &v, &b, &w, &t)
	d := abs(a - b)
	x := v - w

	if x <= 0 {
		fmt.Println("NO")
		return
	}

	if (d+x-1)/x <= t {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}


Measured memory_bytes: 1816
#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 repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

double dp[301][301][301];
int flag[301][301][301];
ll n;

double f(int a,int b,int c){
	if(flag[a][b][c])return dp[a][b][c];
	flag[a][b][c]=1;
	double ans=0;
	if(a)ans+=f(a-1,b,c)*a/(a+b+c);
	if(b)ans+=f(a+1,b-1,c)*b/(a+b+c);
	if(c)ans+=f(a,b+1,c-1)*c/(a+b+c);
	ans+=(double)n/(a+b+c);
	return dp[a][b][c]=ans;
}

int main(){
	int a[3]={};
	scanf("%lld",&n);
	rep(i,0,n){
		ll t;
		scanf("%lld",&t);
		a[--t]++;
	}
	flag[0][0][0]=1;
	printf("%.15f\n",f(a[0],a[1],a[2]));
	return 0;
}

Measured memory_bytes: 319744
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    int n, q;
    cin >> n >> q;
    string s;
    cin >> s;
    vector<int> v;
    rep(i, n) {
        if (i==0) continue;
        if (s[i-1]=='A' && s[i]=='C') v.push_back(i);
    }
    
    rep(i, q) {
        int l, r;
        cin >> l >> r;
        l--; r--;
        auto it1 = lower_bound(whole(v), l+1);
        auto it2 = upper_bound(whole(v), r);
        it2--;
        int ans = it2 - it1 + 1;
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 1276
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long[][] dp= new long[11][1010];
		int n, s;
		dp[0][0]=1;
		for(int i=0; i<=100; i++) {
			for(int j=9; j>=0; j--) {
				for(int k=0; k<=1000-i; k++) {
					dp[j+1][k+i]+=dp[j][k];
				}
			}
		}
		while(sc.hasNext()) {
			n=sc.nextInt();
			s=sc.nextInt();
			if(n==0 && s==0)	break;
			System.out.println(dp[n][s]);
		}
        
	}
}


Measured memory_bytes: 27076
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long a,b,k;
  cin>>a>>b>>k;
  if(k<=a){
    a=a-k;
  }
  else if(k<=a+b){
    k=k-a;
    a=0;
    b=b-k;
  }
  else{
    a=0;
    b=0;
  }
  cout<<a<<" "<<b;
}

Measured memory_bytes: 256
// In the name of God

#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>

using namespace std;

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

int cnt[N];

int32_t main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n; cin >> n;
    for (int j = 1; j <= n; ++j) {
        int x = j;
        for (int a = 2; a <= x; ++a)
            while (x % a == 0)
                cnt[a]++, x /= a;
    }
    int res = 1;
    for (int j = 0; j < N; ++j) {
        res = res * 1ll * (cnt[j] + 1) % mod;
    }
    cout << res << endl;
}

Measured memory_bytes: 256
var
	a, b : Integer;
	ans : Integer;
	
begin
	read(a);
	readln(b);
	ans := 0;
	case a of
		0 :
			if b < 100 then
				ans := b
			else
				ans := b + 1;
		1 : 
			if b < 100 then
				ans := 100 * b
			else
				ans := 100 * (b + 1);
		2 :
			if b < 100 then
				ans := 10000 * b
			else
				ans := 10000 * (b + 1);
		end;
	writeln(ans);
end.

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int a = 0;
        int r=(int)'a';
        char taher = in.next().charAt(0);
        if ((int)taher>=r)
        System.out.print('a');
        else {
            System.out.print('A');
        }
    }
}

Measured memory_bytes: 35540
from enum import Enum
import sys
import math
 
BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001
 
class Info:
    def __init__(self,arg_start,arg_end,arg_S):
        self.start = arg_start
        self.end = arg_end
        self.S = arg_S
 
 
LOC = []
POOL = []
 
line = input()
loc = 0
sum_S = 0
 
for ch in line:
 
    if ch == '\\':
 
        LOC.append(loc)
 
    elif ch == '/':
 
        if len(LOC) == 0:
            continue
 
        tmp_start = int(LOC.pop())
        tmp_end = loc
        tmp_S = tmp_end-tmp_start;
        sum_S += tmp_S;
 
        #既に突っ込まれている池の断片が、今回の断片の部分区間になるなら統合する
        while len(POOL) > 0:
            if POOL[-1].start > tmp_start and POOL[-1].end < tmp_end:
                tmp_S += POOL[-1].S
                POOL.pop()
            else:
                break
 
        POOL.append(Info(tmp_start,tmp_end,tmp_S))
 
    else:
        pass
 
    loc += 1
 
print("%d"%(sum_S))
print("%d"%(len(POOL)),end = "")
 
while len(POOL) > 0:
    print(" %d"%(POOL[0].S),end = "") #先頭から
    POOL.pop(0)
 
print()


Measured memory_bytes: 7524
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))
X = 10 ** 5 + 1
ans = 0
for i in range(N):
    t = T - H[i] * 0.006
    if abs(t - A) <= X:
        ans = i + 1
        X = abs(t - A)
print(ans)



Measured memory_bytes: 9232
#include <fstream>
#include <iostream>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <functional>

using namespace std;
#define ALL(c) (c).begin(), (c).end()
#define REP(i,n) for(ll i=0; i < (n); ++i)
using ll = long long;
using vl = vector<ll>;

struct union_find{
	vl v;
	union_find(ll n) : v(n, -1){}
	ll find(ll x) { return (v[x] < 0) ? x : (v[x] = find(v[x])); }
	void unite(ll x, ll y){
		x = find(x); y = find(y);
		if (x == y) return;
		if (-v[x] < -v[y]) swap(x, y);
		v[x] += v[y];
		v[y] = x;
	}
	bool same(ll x, ll y){
		return find(x) == find(y);
	}
	ll size(ll x) { return -v[find(x)]; }
};

using vb = vector<bool>;
int main(){
#ifdef _WIN32
	ifstream cin("sample.in");
	ofstream cout("sample.out");
#endif
	cout << fixed << setprecision(8);
	ll n, u, v; cin >> n >> u >> v; u--, v--;
	vl a(n - 1), b(n - 1);
	REP(i, n - 1) cin >> a[i] >> b[i];
	REP(i, n - 1) a[i]--, b[i]--;
	if (n % 2 != 0){
		cout << "No" << endl;
		return 0;
	}

	vector<vl> paths(n); 
	REP(i, n - 1){
		paths[a[i]].push_back(b[i]);
		paths[b[i]].push_back(a[i]);
	}

	function<bool(ll, ll, ll)> dfs2 = [&](ll cur, ll prev , ll other){
		if (cur == other) return true;
		for (ll next : paths[cur]) if (next != prev){
			if(dfs2(next, cur, other)) return true;
		}
		return false;
	};

	vb visited(n, false);
	visited[u] = visited[v] = true;
	function<bool(ll, ll, ll)> dfs = [&](ll cur, ll d, ll other){
		visited[cur] = true;
		if (d == n / 2) return true;
		vl kouho = {};
		for (ll next : paths[cur]){
			if (visited[next]) continue;
			kouho.push_back(next);
		}
		if (kouho.size() == 2){
			return dfs(kouho[(dfs2(kouho[0], cur, other) ? 1 : 0)], d+1, other);
		}
		else if(kouho.size() == 1){
			return dfs(kouho[0], d+1, other);
		}
		return false;
	};

	if (dfs(u, 1, v)) if (dfs(v, 1, u)){
		cout << "Yes" << endl;
		return 0;
	}
	cout << "No" << endl;

}

Measured memory_bytes: 20816
#include<stdio.h>

void trace(int A[], int N) {
    int i;
    for(i = 0;i < N; i++) {
        if(i > 0) printf(" ");
        printf("%d", A[i]);
    }
    printf("\n");
}

void insertionSort(int A[], int N) {
    int j, i, v;
    for(i=1; i<N;i++) {
        v=A[i];
        j = i-1;
        while( j >= 0 && A[j] > v) {
            A[j + 1] = A[j];
            j--;
        }
        A[j + 1] = v;
        trace(A, N);
    }
}

int main() {
    int N, i, j;
    int A[100];
    
    scanf("%d", &N);
    for(i = 0; i < N; i++) scanf("%d", &A[i]);
    
    trace(A, N);
    insertionSort(A, N);
    
    return 0;
}


Measured memory_bytes: 2108
#include<cstdio>
int main(){
    int n;
    scanf("%d",&n);
    for(int ix=0;ix<n;ix++){
        char ar[8][10];
        for(int i=0;i<8;i++){
            scanf("%s\n",ar[i]);
        }
        int x,y;
        scanf("%d\n%d\n\n",&x,&y);
        x--;y--;
        ar[y][x]='m';
        for(;;){
            bool ism=false;
            for(int i=0;i<8;i++){
                for(int j=0;j<8;j++){
                    if(ar[i][j]=='m'){
                        ar[i][j]='0';
                        for(int k=1;k<=3&&i+k<8;k++)if(ar[i+k][j]=='1')ar[i+k][j]='m';
                        for(int k=-1;k>=-3&&j+k>=0;k--)if(ar[i+k][j]=='1')ar[i+k][j]='m';
                        for(int k=1;k<=3&&j+k<8;k++)if(ar[i][j+k]=='1')ar[i][j+k]='m';
                        for(int k=-1;k>=-3&&j+k>=0;k--)if(ar[i][j+k]=='1')ar[i][j+k]='m';
                        ism=true;
                    }
                }
            }
            if(!ism)break;
        }
        printf("Data %d:\n",ix+1);
        for(int i=0;i<8;i++){
            printf("%s\n",ar[i]);
        }
    }
}

Measured memory_bytes: 0
import numpy as np
n = int(input())
l = np.array(list(map(int,input().split()))).astype("i")

m = np.sum(l < 0)

if m % 2 == 0:
  print(np.sum(np.abs(l)))
else:
  print(np.sum(np.abs(l)) - 2 * np.min(np.abs(l)))

Measured memory_bytes: 23304
//
//  main.cpp
//  Study
//
//  Created by 佐々木勇星 on 2020/03/12.
//  Copyright © 2020 佐々木勇星. All rights reserved.
//

#include <iostream>
#include <vector>
#include <cmath>
#include <sstream>
#include <iomanip>

using namespace std;


int main(int argc, const char * argv[]) {
    
    int n, r, ans;
    
    cin >> n >> r;
    
    ans = r;
    
    if(n < 10)
    {
        ans = r + 100 * (10 - n);
    }
    
    cout << ans << endl;
    
    return 0;
}


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

int main(void){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  
  while(a > 0 && c > 0){
    c = c - b;
    if(c <= 0)
      break;
    a = a - d;
  }
  
  if(a > c)
    cout <<"Yes";
  else
    cout << "No";
  
  return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define all(v) v.begin(),v.end()
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

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

  int N;
  cin>>N;

  int ans=0;
  if(N%1000) ans=1000-N%1000;
  cout<<ans<<endl;

  return 0;
}


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

public class Main {
	
	public static void main(String[] args) {
		FastReader scan = new FastReader();
		PrintWriter out = new PrintWriter(System.out);
		Task solver = new Task();
		solver.solve(1, scan, out);
		out.close();
	}
	
	static class Task {
		static ArrayList<Integer>[] adj;
		static long[] counter;
		public void solve(int testNumber, FastReader scan, PrintWriter out) {
			int n = scan.nextInt(), q = scan.nextInt();
			adj = new ArrayList[n];
			counter = new long[n];
			for(int i = 0; i < n; i++) {
				adj[i] = new ArrayList<>();
			}
			for(int i = 0; i < n-1; i++) {
				int a = scan.nextInt()-1, b = scan.nextInt()-1;
				adj[a].add(b);
				adj[b].add(a);
			}
			for(int i = 0; i < q; i++) counter[scan.nextInt()-1] += scan.nextLong();
			go(0, -1, 0);
			for(long i : counter) out.print(i + " ");
		}
		static void go(int at, int p, long curr) {
			long temp = counter[at];
			counter[at] += curr;
			curr += temp;
			for(int i : adj[at]) {
				if(i != p) go(i, at, curr);
			}
		}
	}
	
	static void shuffle(int[] a) {
		Random get = new Random();
		for(int i = 0; i < a.length; i++) {
			int r = get.nextInt(a.length);
			int temp = a[i];
			a[i] = a[r];
			a[r] = temp;
		}
	}
	
	static void shuffle(long[] a) {
		Random get = new Random();
		for(int i = 0; i < a.length; i++) {
			int r = get.nextInt(a.length);
			long temp = a[i];
			a[i] = a[r];
			a[r] = temp;
		}
	}
	

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		public FastReader(String s) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(new File(s)));
		}

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

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

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

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

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}

}


Measured memory_bytes: 138436
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
typedef long long ll;
typedef vector<int> vi;
const ll M = 1e9 + 7;

template<typename T>
vi z_algorithm(T& s, ll n){
    vi res(n);
    res[0] = n;
    ll i1 = 1, i2 = 0;

    while(i1 < n){
        while (i1 + i2 < n && s[i2] == s[i1 + i2]) ++i2;
        res[i1] = i2; if (i2 == 0){++i1; continue;}
        ll i3 = 1;
        while (i1 + i3 < n && i3 + res[i3] < i2){res[i1 + i3] = res[i3]; ++i3;}
        i1 += i3, i2 -= i3;
    }
    return res;
}

int main(void){
  int n, ans = 0; string s;
  cin >> n >> s;
  rep(i, n){
    string ss = s.substr(i, n - i);
    vi res = z_algorithm(ss, n - i);
    rep(j, n - i) ans = max(ans, min(j, res[j]));
  }

  cout << ans << endl;

  return 0;
}


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

int main(){
  string a, b;
  cin >> a >> b;
  string c=a;
  for(int i=0; i<b.size(); i++){
    c+= b.at(i);
  }

  int num = std::stoi(c);

  int ans=0;
  for(int i=0; i<=317; i++){
    if(i*i==num) ans++; 
  }
  if(ans==0) cout << "No" << endl;
  else cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include<math.h>
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int main()
{
    int N, X, T;
    cin >> N >> X >> T;
    int c = N / X;
    if (N % X != 0) {
        c += 1;
    }

    cout << T * c << endl;
    return 0;
}

Measured memory_bytes: 3632
n,k=map(int,input().split())
ki=[[] for _ in range(n)]
for _ in range(n-1):
  a,b=map(int,input().split())
  a,b=a-1,b-1
  ki[a].append(b)
  ki[b].append(a)
mod=pow(10,9)+7
from collections import deque
seen=[-1]*n
seen[0]=k
todo=deque([0])
while todo:
  t=todo.popleft()
  s=max(k-2,seen[t]-1)
  for li in ki[t]:
    if seen[li]==-1:
      if s<=0:
        print(0)
        exit()
      seen[li]=s
      s-=1
      todo.append(li)
ans=1
for s in seen:
  ans*=s
  ans%=mod
print(ans)


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

int main(void){
	int MOD = 998244353;
	int N, S;
	cin >> N >> S;
	int A[N];
	for (int i = 0; i < N; i++) cin >> A[i];
	sort(A,A+N);
	if (A[0] > S) {
		cout << 0 << endl;
		return 0;
	}

	int dp[N+1][S+1];
	for (int i = 0; i <= N; i++) {
		for (int j = 0; j <= S; j++) {
			dp[i][j] = 0;
		}
	}
	
	dp[0][0] = 1;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j <= S; j++) {
			dp[i+1][j] += 2*dp[i][j];
			dp[i+1][j] %= MOD;
			if (A[i] <= j){ 
				dp[i+1][j] += dp[i][j-A[i]];
				dp[i+1][j] %= MOD;	
			}
		}
	}
		cout <<  dp[N][S] << endl;

return 0;
}


Measured memory_bytes: 38352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 5e2 + 5;

ll n, ans;
int main(){
    #ifdef Irene
    freopen("in.txt","r",stdin);
    #endif // Irene
    ios_base::sync_with_stdio(false);

    cin >> n;
    for(int i = 1; i <= n; i++)
    for(int j = 1; j <= n; j++)
    for(int k = 1; k <= n; k++)
        ans += __gcd(i, __gcd(j, k));
    cout << ans;
}


Measured memory_bytes: 3640
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<iomanip>
#define pi 3.14159265358979323846
#define ll long long
#define elif else if
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
int main(){
  int n;
  cin >> n;
  int ac = 0, wa = 0, tle = 0, re = 0;
  vector<string> v(n);
  rep(i, 0, n){
    cin >> v[i];
    if(v[i] == "AC"){
      ac++;
    }
    elif(v[i] == "WA"){
      wa++;
    }
    elif(v[i] == "TLE"){
      tle++;
    }
    elif(v[i] == "RE"){
      re++;
    }
  }
  cout << "AC x " << ac << "\n" << "WA x " << wa << "\n" << "TLE x " << tle << "\n" << "RE x " << re << "\n";
}


Measured memory_bytes: 6404