akhauriyash/Code-Regression huggingface dataset:
import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}
import scala.collection.mutable.{Map, Stack, Queue, PriorityQueue, Set}
import scala.util.Random
import java.util.Date

object Main extends App {
  val startTime = new Date().getTime // to milli seconds

  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val D = in.next().toInt
  val c = new Array[Long](26+1)
  val s = Array.ofDim[Long](D+1, 26+1)

  for (i <- 1 to 26) {
    c(i) = in.next().toInt
  }
  for (d <- 1 to D) {
    for (i <- 1 to 26) {
      s(d)(i) = in.next().toInt
    }
  }


  /** functions **/
  def calcScore(t: Array[Int]): Long = {
    val last = new Array[Int](26+1)
    var res = 0L

    for (d <- 1 to D) {
      val ty = t(d)

      res += s(d)(ty)
      last(ty) = d

      for (i <- 1 to 26) {
        res -= c(i) * (d - last(i))
      }
    }

    res
  }


  /** solve **/
  val t = new Array[Int](D+1)
  for (d <- 1 to D) {
    val (_, ty) = s(d).zipWithIndex.max
    t(d) = ty
  }

  val endTime = 1200
  var currentScore = calcScore(t)
  var bestAns = t.clone
  var bestScore =  currentScore

  val annStartTime = new Date().getTime
  var currentTime = annStartTime
  val T = endTime - annStartTime // 焼きなましにかける時間
  val R = 10000

  while ((new Date().getTime - startTime) < endTime) {
    for (_ <- 1 to 1000) {
      val time = currentTime - annStartTime // 焼きなまし法開始からの時間

      // 遷移を実施
      val d = Random.nextInt(D) + 1
      val ty = Random.nextInt(26) + 1

      val tmp = t(d)
      t(d) = ty

      val nextScore = calcScore(t) // 遷移後のスコアを計算

      // スコアが悪くなったときでも、次の状態に移動する遷移する場合はtrue。
      val ForceNext = T * Random.nextInt(R) < (T-time) * R // １次関数
      
      if (nextScore > currentScore || ForceNext) {
        // 遷移を適用
        currentScore = nextScore
      }
      else {
        // 遷移を破棄
        t(d) = tmp
      }

      // ベストスコアを保存
      if (currentScore > bestScore) {
        bestScore = currentScore
        bestAns = t.clone // 現在の盤面を渡す
      }
    }
  }


  for (d <- 1 to D) {
    pw.println(t(d))
  }
  pw.flush()
}

object Sub {
  def print2DimArray[A](mat: Array[Array[A]]): Unit = {
    mat.foreach(lin => println(lin.toList))
  }
}

class InputReader(stream: InputStream) {
  private[this] val reader = new BufferedReader(new InputStreamReader(stream))
  private[this] var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}


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

int main(){

  int n, m;
  cin >> n >> m;

  vector<pair<int, int>> xy(m);
  int x, y;
  for(int i = 0; i < m; i++){
    cin >> x >> y;

    xy[i] = make_pair(x, y - 1);
  }

  sort(xy.begin(), xy.end());

  vector<int> sumLane(n, 1);
  vector<int> sumShare(n - 1, 0);

  for(int i = 0; i < m; i++){
    int temp = xy[i].second;

    int upper = sumLane[temp];
    int lower = sumLane[temp + 1];

    int share = sumShare[temp];

    int newSum = share + (upper - share) + (lower - share);

    sumLane[temp] = newSum;
    sumLane[temp + 1] = newSum;
    sumShare[temp] = newSum;
  }

  for(int i = 0; i < n; i++){
    cout << sumLane[i];
    if(i == n - 1){
      cout << endl;
    }
    else{
      cout << " ";
    }
  }
  
  return 0;
}



Measured memory_bytes: 5188
#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstdlib>
using namespace std;
int arr[100000]={0};
int main() {
    unsigned long long x,y=0, a=0,d=0;
    cin>>x;

    for(int i=1;i<=130;i++){
        for(int w=1;w<=130;w++){
            for(int y=1;y<=130;y++){
                if(((i*i)+(w*w)+(y*y)+(i*w)+(i*y)+(y*w))<=x){
                    arr[((i*i)+(w*w)+(y*y)+(i*w)+(i*y)+(y*w))]++;

                }

            }

        }
    }
    for(int i=1;i<=x;i++){
        cout<<arr[i]<<"\n";
    }

}


Measured memory_bytes: 3524
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#define PI 3.141592653589793
#define MOD 1000000007


int main(){
	char s[101];
	scanf("%s", s);
	int len = strlen(s);
	for(int i=0; i<len; i++){
		s[i] = 'x';
	}
	printf("%s\n", s);
	
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>

int main() {
  uint32_t N = 0;
  std::cin >> N;
  std::vector<std::string> B(N), S(N);
  for (auto &&elem : B) std::cin >> elem;
  std::copy(B.begin(), B.end(), S.begin());

  // Bubble Sort
  for (size_t i = 0; i < N - 1; i++) {
    bool flag = true;
    for (size_t j = 0; j < N - 1 - i; j++) {
      uint32_t v = B[N - 1 - j][1] - '0', w = B[N - 2 - j][1] - '0';
      if (v < w) {
        auto temp = B[N - 1 - j];
        B[N - 1 - j] = B[N - 2 - j];
        B[N - 2 - j] = temp;
        flag = false;
      }
    }
    if (flag) break;
  }

  // Selection Sort
  for (size_t i = 0; i < N - 1; i++) {
    uint32_t min_index = i;
    for (size_t j = i + 1; j < N; j++) {
      uint32_t v = S[min_index][1] - '0', w = S[j][1] - '0';
      if (v > w) min_index = j;
    }
    if (min_index != i) {
      auto temp = S[i];
      S[i] = S[min_index];
      S[min_index] = temp;
    }
  }

  for (uint32_t i = 0; i < N - 1; i++) std::cout << B[i] << " ";
  std::cout << B[N - 1] << std::endl;
  std::cout << "Stable" << std::endl;

  for (uint32_t i = 0; i < N - 1; i++) std::cout << S[i] << " ";
  std::cout << S[N - 1] << std::endl;
  std::cout << (B == S ? "Stable" : "Not stable") << std::endl;

  return 0;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,sum=0;
  cin >> N;
  vector<int> vec(N);
  for (int i=0; i<N; i++){
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  reverse(vec.begin(),vec.end());
  
    for (int j=0; j<N-1; j++){
      if (vec.at(j) == vec.at(j+1)){
        sum ++;                     
      }
      else{
        sum = sum;
      }
    }
  cout << vec.size()-sum << endl;
}
    

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int x;
	cin>>x;
	int a[100005]={0};
	int i;
	for(i=1;i<100005;i++)
	{
		a[i]=a[i-1]+i;
		if(a[i]>=x)break;
	}
	cout<<i;
	
	
}

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

using namespace std;

int main(void){
  int N, M;
  cin >> N >> M;
  vector<int> like(M, 0);
  for(int i = 0; i < N; i++){
    int K;
    cin >> K;
   	for(int j = 0; j < K; j++){
      int A;
      cin >> A;
      like[A - 1]++;
    }
  }
  int ans = 0;
  for(int i = 0; i < M; i++) ans += (like[i] == N);
  cout << ans << endl;
  return 0;
}
  

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define ll long long
#define all(a) a.begin(),a.end()
#define endl '\n'
#define int ll

using namespace std;

const int N = 3e5 + 3;
const int inf = 1e9 + 3;
const int md = 1e9 + 7;

int n, ans;
int cnt[N], a[N];

int f(int n) {
    return n * (n - 1) / 2;
}

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

    cin >> n;
    for(int i = 1; i <= n; ++i) {
        cin >> a[i];
        cnt[a[i]]++;
    }
    for(int i = 1; i <= n; ++i) {
        ans += f(cnt[i]);
    }
    for(int i = 1; i <= n; ++i) {
        ans -= f(cnt[a[i]]);
        cnt[a[i]]--;
        ans += f(cnt[a[i]]);
        cout << ans << endl;
        ans -= f(cnt[a[i]]);
        cnt[a[i]]++;
        ans += f(cnt[a[i]]);
    }
}


Measured memory_bytes: 6272
#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() {
  int k, x;
  cin >> k >> x;
  int left = x-k+1;
  int right = x+k-1;
  for (int i = left; i <= right; i++) {
    cout << i << ' ';
  }
  return 0;
}

Measured memory_bytes: 3576
#include <iostream>

int main()
{
	int N = 0, ans = 0;
	std::cin >> N;

	int C[10][10] = { 0 };
	for (int i = 0; i < N; i++)
	{
		int A = 10;
		while ((i + 1) / A != 0)
		{
			A *= 10;
		}
		int first = (i + 1) / (A / 10);
		int end = (int)((i + 1) % 10);
		C[first][end]++;
	}

	for (int i = 0; i < 10; i++)
	{
		for (int j = 0; j < 10; j++)
		{
			ans += C[i][j] * C[j][i];
		}
	}

	std::cout << ans << std::endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cstdio>
#include<ctype.h>
#include<stdio.h>
#include<set>
#include<vector>
#include<map>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<numeric>
#include<string>
typedef long long ll;
using namespace std;

ll gcd(ll a, ll b){
if(a<b){return gcd(b,a);}
else if(a%b){return gcd(b,a%b);}
else{return b;}
}
int main(){
  ll N,A,B;
  cin>>N>>A>>B;
  ll X=B-A;
  if(X%2==0)
  cout<<"Alice"<<endl;
  if(X%2==1)
  cout<<"Borys"<<endl;
  
}


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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0LL)
#define mapmax(v) v.rbegin()->first
#define mapmin(v) v.begin()->first
#define pb push_back
#define pf push_front
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n

typedef long long ll;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;

typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);
const int mod=1000000007;
const int mod2=998244353;

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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

void YES(bool b) {cout << (b?"YES\n":"NO\n");}
void Yes(bool b) {cout << (b?"Yes\n":"No\n");}
void yes(bool b) {cout << (b?"yes\n":"no\n");}
void Yay(bool b) {cout << (b?"Yay!\n":":(\n");}

long long powmod(long long a,long long b){
    long long c=1;
    while(b>0){
        if(b&1) c=a*c%mod;
        a=a*a%mod;
        b>>=1;
    }
    return c;
}

ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	ll n,a,b,cnt=0,f=1;
	string s;
	cin >> n >> a >> b >> s;
	rep(i,SIZE(s)){
		if(s[i]=='a' && cnt<a+b){
			cout << "Yes\n";
			cnt++;
		}
		else if(s[i]=='b' && cnt<a+b && f<=b){
			cout << "Yes\n";
			cnt++;
			f++;
		}
		else cout << "No\n";
	}
	return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <iomanip>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>
#include <cstdint>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

constexpr ll inf = INT64_MAX / 4;

ull pow2(ull n) {
    if (n == 0)return 1;
    return pow2(n - 1) * 2;
}

ull xs(ull n) {
    ull r = n % 4 == 3 || n % 4 == 2 ? 1 : 0;
    for (ull i = 1; i < 60; i++) {
        ull c = n % pow2(i + 1);
        if (c > pow2(i) && c % 2) r |= ((ull)1 << i);
    }
    return r;
}

int main() {
    ull a, b;
    cin >> a >> b;
    cout << (xs(a) ^ xs(b+1)) << endl;
}

Measured memory_bytes: 256
import sys

input = sys.stdin.readline


def main():
    tour = [(i * (i + 1)) // 2 for i in range(1, 1000)]
    a, b = map(int, input().split())
    v = 0
    for i, j in zip(tour[:-1], tour[1:]):
        if i < a or j < b:
            continue
        if i - a == j - b:
            v = i - a
            break
    print(v)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3188
#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)
using namespace std;
typedef long long ll;
const ll MOD=998244353;
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;}

void add(ll &a,ll b){
  a=(a+b)%MOD;
}

void mul(ll &a,ll b){
  a%=MOD;b%=MOD;
  a=a*b%MOD;
}

ll dp[303][303][303];

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

  string S;
  cin>>S;
  int N=S.size();
  int K;
  cin>>K;

  int zero=0;
  rep(i,N) if(S[i]=='0') zero++;
  vector<int> B;
  for(int i=N-1;i>=0;i--){
      if(S[i]=='0') continue;
      int num=0;
      for(int j=i;j<N;j++) if(S[j]=='0') num++;
      B.push_back(num);
  }

  int M=B.size();
  vector<int> dw(zero+1,0);
  for(int i=0;i<=zero;i++) dw[i]=lower_bound(B.begin(),B.end(),i)-B.begin();
  vector<int> same(zero+1,0);
  for(int i=0;i<M;i++) same[B[i]]++;

  K=min(K,M);
  dp[0][0][0]=1;
  for(int i=0;i<M;i++) for(int j=0;j<=zero;j++) for(int k=0;k<=K;k++){
      if(dp[i][j][k]==0) continue;
      add(dp[i][j+1][k],dp[i][j][k]);

      for(int p=1;p<=same[j];p++) add(dp[i+p][j+1][k],dp[i][j][k]);

      for(int p=1;p<=dw[j]-i;p++) add(dp[i+same[j]+p][j+1][k+p],dp[i][j][k]);
  }

  ll ans=0;
  for(int j=0;j<=zero+1;j++) for(int k=0;k<=K;k++) add(ans,dp[M][j][k]);
  cout<<ans<<endl;

  return 0;
}


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

int main(){
    string s1, s2, s3;
    char a, b, c;
    cin >> s1 >> s2 >> s3;
    a = s1.at(0) - 32;
    b = s2.at(0) - 32;
    c = s3.at(0) - 32;
    cout << a << b << c << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n, cnt = 0;
	cin >> n;
	bool flag = true;
	vector<int> a(n);
	for (int i = 0; i < n; ++i) {
		cin >> a.at(i);
	}
	while (flag) {
		flag = false;
		for (int i = n - 1; i > 0; --i) {
			if (a.at(i) < a.at(i - 1)) {
				swap(a.at(i), a.at(i - 1));
				++cnt;
				flag = true;
			}
		}
	}
	for (int i = 0; i < n; ++i) {
		cout << a.at(i);
		if (i == n - 1) {
			cout << endl;
		} else {
			cout << " ";
		}
	}
	cout << cnt << endl;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
using ll = long long;
using ld = long double;
#define vpl vector<pair<long long,long long>>
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
using pll = pair<long long,long long>;
#define cY cout<<"Yes"<<endl
#define cN cout<<"No"<<endl
const long long INF = 1LL << 60;
long long MOD = 1000000007;
const long double pi = 3.1415926535897932;
#define pb push_back
#define mp make_pair
#define mt make_tuple
using Grid = vector<vector<char>>;
#define vc vector<char>
//(mod m)でのaの逆元を計算する
//a/b(mod m)=a(mod m)*modinv(b,m)
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

//最大最小の入れ替え
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;
}

//約数列挙
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}
//コンビネーション
ll nCr(ll n, ll r) {
    ll ans = 1;
    for (ll i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (ll i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}
//素因数分解
map< ll, ll > prime_factor(ll n) {
  map< ll, ll > ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

//切り上げの割り算は(a + b - 1) / bでできる

//ここから
int main(){
    ll H,W,K;
    cin>>H>>W>>K;
    Grid G(W,vc(H));
    ll sx,sy;
    rep(i,H){
        rep(j,W){
            cin>>G[j][i];
            if(G[j][i]=='S'){
                sx=j;
                sy=i;
            }
        }
    }
    ll dist=INF;
    queue<pll> q;
    pll w=mp(sx,sy);
    q.push(w);
    ll dx[4]={1,0,-1,0};
    ll dy[4]={0,1,0,-1};
    vvl D(W,vl(H,-1));
    D[sx][sy]=0;
    while (!q.empty())
    {
        pll P=q.front();
        q.pop();
        ll x=P.first;
        ll y=P.second;
        dist=min({dist,x,W-x-1,y,H-y-1});
        if(D[x][y]==K) continue;
        rep(i,4){
            ll nx=x+dx[i];
            ll ny=y+dy[i];
            if(nx<0||ny<0||ny>H-1||nx>W-1||D[nx][ny]!=-1)continue;
            if(G[nx][ny]=='.'){
            if(nx==0||nx==W-1||ny==H-1||ny==0){
                cout<<1<<endl;
                return 0;
            }else{
                pll p=mp(nx,ny);
                q.push(p);
                D[nx][ny]=D[x][y]+1;
            }
            }
        }
    }
    cout<<1+(dist+K-1)/K<<endl;
}

Measured memory_bytes: 5888
import sys
a=list(map(int,input().split()))
s=0
f=0

for i in range(3):
  s+=a[i]
  
if s!=17:
  print('NO')
  sys.exit()
  
else:
  for t in range(3):
    if a[t]==5:
      f+=1
      
if f==2:
  print('YES')
  

else:
  print('NO')
  

Measured memory_bytes: 8984
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#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 sz(a) (int)a.size()
#define de(a) cout << #a << " = " << a << endl
#define dd(a) cout << #a << " = " << a << " "
#define all(a) a.begin(), a.end()
#define pw(x) (1ll<<(x))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	int n;
	cin >> n;
	ll sum=0;
	rep(i,1,n+1){
		rep(j,1,n+1){
			rep(k,1,n+1){
				sum+=__gcd(__gcd(i,j),k);
			}
		}
	}
	cout<<sum<<endl;
	return 0;
}



Measured memory_bytes: 3652
use proconio::fastout;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

#[fastout]
fn main() {
    input! {
        n: usize,
    }
    println!("{}", if n % 1000 == 0 { 0 } else { 1000 - n % 1000 });
}


Measured memory_bytes: 2168
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;

namespace AtCoder
{
	public class Program
	{
		static void Main()
		{
			var ab = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

			int a = ab[0];
			int b = ab[1];

			if (b % a == 0) {
				Console.WriteLine(a + b);
			} else {
				Console.WriteLine(b - a);
			}
		}
	}
}

Measured memory_bytes: 13268
#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
using ll=long long;
template<class T,class U> inline bool chmin(T&x,U y){if(x>y){x=y;return true;}return false;}
template<class T,class U> inline bool chmax(T&x,U y){if(x<y){x=y;return true;}return false;}
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

void solve(){
    ll n,m,a,b;
    cin>>n>>m>>a>>b;
    cout<<floor_sum(n,m,a,b)<<'\n';
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int t;
    cin>>t;
    fr(i,t) solve();
}

Measured memory_bytes: 3696
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define int ll
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#ifdef int
const ll INF = (1LL<<60);
#else
const int INF = (1LL<<30);
#endif
const double PI = 3.14159265359;
const double EPS = 1e-12;
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

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

int dp[100];
signed main(void)
{
  int n;
  cin >> n;
  dp[0] = 2;
  dp[1] = 1;
  FOR(i, 2, n+1) {
    dp[i] = dp[i-1] + dp[i-2];
  }

  cout << dp[n] << endl;

  return 0;
}


Measured memory_bytes: 256
import java.math.BigDecimal;
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);

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

    void run() {


        int x = sc.nextInt();

        long sum = (long)x;

        long cnt = 1;

        while (true) {
            sum += x;
            cnt++;
            if (sum%360==0) break;
        }

        System.out.println(cnt);

    }
}


Measured memory_bytes: 35732
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <cctype>
#include <sstream>

/*

bool isOK(int index, int key) {
	if (a[index] >= key) return true;
	else return false;
}
int binary_search(int key) {
	int ng = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int ok = (int)a.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

	while (abs(ok - ng) > 1) {
		int mid = (ok + ng) / 2;

		if (isOK(mid, key)) ok = mid;
		else ng = mid;
	}
	return ok;
}
*/

//vector<vector<ll> > data(3, vector<ll>(4));
//vector<ll> data(N);
//v.erase(remove(v.begin(), v.end(), value_to_remove), v.end());
//str s = to_string(i);
//int i = c - '0'
//sort(data.begin(), data.end());
//reverse(data.begin(), data.end());
//data.erase(unique(data.begin(), data.end()), data.end()); //重複なし
//str.substr(n)//n番以降スライス
//str.substr(n,m)//n番以降m文字スライス
//str.erase(n)//n番以降削除
//str.erase(n,m)//n番以降m文字削除
//str.find(str_to_find)//位置 or string::npos
//cout << fixed << setprecision(15) << n;
//while (cin >> c){if (c == EOF) break;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=ll(a);i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
#define PB push_back
#define SIZE(x) ll(x.size())
#define ALL(x) x.begin(),x.end()
#define INF 1000000000000
#define MOD 1000000007
#define PI 3.14159265358979323846

using namespace std;
typedef pair<ll, ll> P;

int main() {
	ll N, Y;
	cin >> N >> Y;
	ll x = -1;
	ll y = -1;
	ll z = -1;
	bool b = false;


	REP(i, N+1) {
		REP(j, N+1 - i) {
			if (10000 * i + 5000 * j + 1000 * (N - i - j) == Y) {
				x = i;
				y = j;
				z = N - i - j;
				b = true;
				break;
			}
		}
		if (b)break;
	}

	cout << x << " " << y << " " << z;
}



Measured memory_bytes: 3644
#define _USE_MATH_DEFINES
#include<cmath>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>
#include<iomanip>
#include<random>

#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(int i = 0;i < n;i++)
#define FOR(i,a,b) for(int i = a;i < b;i++)
#define MEM(a,b) memset(a,b,sizeof(a))
#define ALL(x) (x).begin(),(x).end()
#define LMAX 9223372036854775807
#define LMIN -9223372036854775808

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) {}
	void unionSet(int x, int y) {
		x = root(x), y = root(y);
		if (x != y) {
			if (data[y] < data[x])swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	int k = a % b;
	if (k == 1)return 1;
	if (k == 0)return b;
	int ans = gcd(b, k);
	return ans;
}
ll digitsum(ll a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}
int getdigit(ll a) {
	return to_string(a).size();
}
int countpow(ll a, ll b) {
	int ans = 0;
	if (b == 0)return -1;
	while (1) {
		if (a % b == 0) {
			a /= b;
			ans++;
		}
		else break;
	}
	return ans;
}
int to_num(char c) {
	if (c >= '0' && c <= '9')return (c - '0');
	else return -1;
}

int main() {
	IOS;
	int n;
	cin >> n;
	vector<string> s(n);
	REP(i, n)cin >> s[i];
	int a[26] = {};
	int tmp[26] = {};
	REP(i, n) {
		REP(j, 26)tmp[j] = 0;
		REP(j, s[i].size()) {
			if (i == 0) {
				a[s[i][j] - 'a']++;
			}
			else {
				tmp[s[i][j] - 'a']++;
			}
		}
		if (i) {
			REP(j, 26)a[j] = min(a[j], tmp[j]);
		}
	}
	string ans = "";
	REP(i, 26) {
		char unko = 'a' + i;
		REP(j, a[i]) {
			ans = ans + unko;
		}
	}
	cout << ans << endl;
}



Measured memory_bytes: 256
import scala.annotation.tailrec
object Main extends App {

  import scala.io.StdIn._
  import scala.math._

  val Array(n, p) = readLine.trim.split(' ').map(_.toLong)
    // p == x^n = log(p) = n log(x) log(p) / n == log(x)
  if (n == 1){
    println(p)
  }else {
    val maxPrime = math.exp(math.log(p) / n)
    var res = 1L
    var current = p
    val primes = prime(maxPrime.toInt)
    for (primeFactor ← primes) {
      while (current % exponent(primeFactor, n) == 0) {
        res *= primeFactor
        current /= exponent(primeFactor, n)
      }
    }
    println(res)
  }
  def exponent(base: Long, exp: Long): Long = {
    exp match {
      case 0L ⇒ 1L
      case 1L ⇒ base
      case _ ⇒ exponent(base, exp / 2).let{it ⇒ it * it * exponent(base, exp % 2)}
    }
  }
  def prime(upper: Int): List[Int] = {
    val isPrime = Array.tabulate(upper + 1){_ ⇒ true}
    var res: List[Int] = Nil
    for (i ← 2 to math.sqrt(upper).ceil.toInt){
      if (isPrime(i)){
        for (j ← i * 2 to upper by i) {
          isPrime(j) = false
        }
      }
    }
    for (i ← 2 until isPrime.length){
      if (isPrime(i))
        res ::= i
    }
    res
  }
  implicit class Extension[T](val value :T){
    def also(func: T ⇒ Unit): T = {
      func(value)
      value
    }
    def let[R](func: T ⇒ R): R = func(value)
  }
}

Measured memory_bytes: 37876
//Zory-2020
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
// typedef __int128 ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define FR first
#define SE second
#define MP make_pair
#define PB push_back
#define vc vector
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define bin(x) (1ll<<(x))
#define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
#define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
#define mem(x,val) memset(x,val,sizeof x)
#define Swap(a,b,n) for(int I=0;I<=n;I++) swap(a[I],b[I])
#define PC __builtin_popcountll
#ifdef DEBUG
#define DD 1
#else
#define DD 0
#endif
#define Debug if(DD) printf("line %d\n",__LINE__)
#define deb(x) if(DD) cerr<<#x<<'='<<x<<endl
#define debug if(DD) printf
namespace mine
{
	ll qread()
	{
		ll ans=0,f=1;char c=getchar();
		while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
		while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
		return ans*f;
	}
	void write(ll num){if(num<0) putchar('-'),num=-num;if(num>=10) write(num/10);putchar('0'+num%10);}
	void write1(ll num){write(num);putchar(' ');}
	void write2(ll num){write(num);putchar('\n');}
	template<typename T>inline bool chmax(T&a,const T&b){return a<b?a=b,1:0;}
	template<typename T>inline bool chmin(T&a,const T&b){return a>b?a=b,1:0;}
	ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
	bool IN(ll x,ll l,ll r){return l<=x and x<=r;}
	void gg1(){write2(-1);exit(0);}
	void gg2(){puts("NO");exit(0);}
	
	const double eps=1e-8;
	const int INF=0x3f3f3f3f;
	const int MOD=1e9+7;
	int mm(const int x){return x>=MOD?x-MOD:x;}
	template<typename T> void add(T &x,const int &y){x=(x+y>=MOD?x+y-MOD:x+y);}
	ll qpower(ll x,ll e,int mod=MOD){ll ans=1;while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
	ll invm(ll x){return qpower(x,MOD-2);}
	const int N=2e5+10;
	
	int a[N];
	void main()
	{
		int n=qread(),k=qread();fo(i,1,n) a[i]=qread();sort(a+1,a+n+1);
		ll ans=0;fo(i,1,n) if(n-i+1<=k) ; else ans+=a[i];write(ans);
	}
};//变量重名！
signed main()
{
	#ifdef DEBUG
	//freopen("a.in","r",stdin);
	freopen("z.txt","r",stdin);
	#endif
	srand(time(0));
	mine::main();
	if(DD) cerr<<"Time: " <<1.0*clock()/CLOCKS_PER_SEC<<"s";
}

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

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		
		int n = in.nextInt();
		int maxCount = 0;
		int maxN = 1;
		
		for(int i = 1; i <= n; i++){
			int count = 0;
			int tmp = i;
			while(tmp%2 == 0){
				tmp /= 2;
				count++;
			}
			if(count > maxCount){
				maxCount = count;
				maxN = i;
			}
		}
		
		System.out.println(maxN);

	}

}


Measured memory_bytes: 21844
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef long long ll;
typedef pair<ll ,ll > P;

int N;
ll sec[1003];
char type[1003];
string id[1003];

ll cross(P p1,P p2) {
    int m1=max(p1.fr,p2.fr);
    int m2=min(p1.sc,p2.sc);

    return max(0,m2-m1);
}

void solve() {
    map<string,vector<P>> seg;
    set<string> visitors;
    rep(i,N) {
        if(id[i]!="000") visitors.insert(id[i]);
        if(type[i]=='I') {
            seg[id[i]].pb(P(sec[i],1e18));
        }
        else {
            auto it=seg[id[i]].end();
            it--;
            it->second=sec[i];
        }
    }

    map<string,ll> times;
    for(auto visitor : visitors) {
        for(const auto &e1 : seg["000"]) for(const auto &e2 : seg[visitor]) {
            //printf("[%s] %lld %lld -> %lld %lld : %lld\n",visitor.c_str(), e1.fr,e1.sc,e2.fr,e2.sc,cross(e1,e2));
            times[visitor]+=cross(e1,e2);
        }
    }

    ll ans=0;
    for(auto visitor : visitors) ans=max(ans,times[visitor]);
    cout<<ans/60<<endl;


}

int main() {
    while(cin>>N) {
        if(N==0) break;
        rep(i,N) {
            int M,D,h,m;
            scanf("%d/%d %d:%d",&M,&D,&h,&m);
            sec[i]=2678400*M+86400*D+3600*h+60*m;
            cin>>type[i];
            cin>>id[i];
        }
        solve();
    }
    return 0;
}

Measured memory_bytes: 1440
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<string>

using namespace std;

int main()
{
	int n,m,sum1;
	float sum;
	while(~scanf("%d %d",&n,&m))
	{
		sum = 1.0*(n + m)/2;
		sum1 = (int)sum;
		if(sum-sum1>=0.5)
			printf("%d\n",sum1 + 1);
		else
			printf("%d\n",sum1);
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int n,p[51],i,c=0;

	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%d",&p[i]);
	for(i=0;i<n;i++)
		if(p[i]!=i+1)
			c++;
	if(c>2)
		printf("NO\n");
	else
		printf("YES\n");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define local
//if you find any bug in my code, please tell me.

int main()
{
#ifdef local
    freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
#endif
    ll n,ans,t;
    cin>>n;
    ans=n/11*2;
    t=n%11;
    if(t>6) ans+=2;
    else if(t>0&&t<=6) ans++;
    cout<<ans<<endl;
    return 0;
}


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

int main() {
	int A, B, C;
	cin >> A >> B >> C;
	if (A - B > C) {
		cout << 0 << endl;
	}
	else {
		cout << C - (A - B) << endl;
	}

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

    ll p=1;
    REP(i, A){
        p*=(i+1);
        p =p%(1000000000+7);
    }

    cout << p << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#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 FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef long double ld;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int inf = 2e9;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

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

  rep(i, n) {
    if (a[i] % 2 == 0) {
      if (a[i] % 3 != 0 && a[i] % 5 != 0) {
        cout << "DENIED" << endl;
        return 0;
      }
    }
  }
  cout << "APPROVED" << endl;


  
  return 0;
}

Measured memory_bytes: 256
from collections import deque

icase=0
if icase==0:
    n=int(input())
    u=[0]*n
#    g = [deque([]) for _ in range(n)]
    g = [[] for _ in range(n)]
    for i in range(n):
        ukv=list(map(int,input().split()))
        u[i]=ukv[0]-1
        ki=ukv[1]
        v=ukv[2:]
        for vi in v:
            g[u[i]].append(vi-1)
#            g[vi-1].append(u[i])
elif icase==1:
    n=4
    g = [[] for _ in range(n)]
    g[0]=[1,3]
    g[1]=[0,3]
    g[2]=[3]
    g[3]=[0,1,2]
#ans:0 1 2 1

q=deque([0])

stack=[0]
parent=[-1]*n
parent[0]=0
dist=[-1]*n
dist[0]=0
while q:
    state = q.popleft()
#    print("--- q:",q,"state:",state,"g:",g[state],"p:",parent)
    for v in g[state]:
#        print("  state:",state,"v:",v,"q:",q)
#        if parent[state] == v:
        if parent[v] !=-1:
            continue
        else:
#            print("parent:",parent,"xx:",xx,"stack",stack)
            parent[v]=state
            dist[v]=dist[state]+1
            q.append(v)
#            print(" state:",state,"v:",v,"parent:",parent,"stack",stack,"dist[v]",dist[v])

for i in range(n):
    print(i+1,dist[i])
    


Measured memory_bytes: 6044
#include <bits/stdc++.h>
using namespace std;
#define REP(name, stop) for (ll(name) = 0; (name) < (stop); (name)++)
using ll = long long;
using vi = vector<ll>;

int main(void) {
    ll R;
    cin >> R;
    cout << fixed << R * 2 * M_PI << endl;

    return 0;
}


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

#define INF 1000000

int main(void){
  int N,w[105],sum[105],s1,s2,ans,i,t,min;
  char str[1000],*p;
  
  fgets(str,sizeof(str),stdin);
  N=atoi(str);
  
  fgets(str,sizeof(str),stdin);
  p=strtok(str," \n");
  w[0]=atoi(p);
  sum[0]=0;
  sum[1]=w[0];
  
  for(i=1;i<N;i++){
    p=strtok(NULL," \n");
    w[i]=atoi(p);
    sum[i+1]=sum[i]+w[i];
  }
  
  min=INF;
  
  for(t=0;t<N;t++){
    s1=sum[N]-sum[t+1];
    s2=sum[t+1];
    ans=abs(s1-s2);
    if(ans<min){
      min=ans;
    }
  }
  
  printf("%d\n",min);
  
  return 0;
}

Measured memory_bytes: 128
//{{{
#include<algorithm>
#include<cmath>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printw) FUNC(printwe) FUNC(printb) FUNC(printbe) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ return in >> p.first >> p.second; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<int> nums(m);
    for(int i = 0; i < n; i++){
        int k; cin >> k;
        for(int i = 0; i < k; i++){
            int a; cin >> a;
            a--;
            nums[a]++;
        }
    }
    int ans = 0;
    for(auto& num : nums){
        ans += num == n;
    }
    cout << ans << '\n';
}


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

using namespace std;

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

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

    int n, m;
    cin >> n >> m;
    string ans = "No";
    if(n%2 == 1 && m%2 == 1){
      ans = "Yes";
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
while 1:
	n=input()
	if n==0:break
	for i in range(n):
		m,e,j=map(int, raw_input().split())
		a=m+e+j
		if 100 in [m,e,j] or m+e>179 or a>239:print"A"
		elif a>209 or (a>149 and max(m,e)>79):print"B"
		else:print"C"

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

using namespace std;

typedef long long LL;

const int N = 1010;

int a, b;
string s;

int main()
{
    cin >> a >> b >> s;

    bool flag = true;
    if(s[a] != '-') flag = false;

    for(int i = 0; i < a; i++)
        if(s[i] < '0' || s[i] > '9')
            flag = false;

    for(int i = a + 1; i < a + b + 1; i++)
        if(s[i] < '0' || s[i] > '9')
            flag = false;

    if(flag) puts("Yes");
    else puts("No");
    return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var N int
	var W int
	sc.Scan()
	ss := strings.Split(sc.Text(), " ")
	N, _ = strconv.Atoi(ss[0])
	W, _ = strconv.Atoi(ss[1])

	var w []int
	var v []int
	for sc.Scan() {
		ss := strings.Split(sc.Text(), " ")
		s1, _ := strconv.Atoi(ss[0])
		s2, _ := strconv.Atoi(ss[1])
		w = append(w, s1)
		v = append(v, s2)
	}

	var dp [101][1000000]int

	for i := 0; i < N; i++ {
		for j := 0; j <= W; j++ {
			if j >= w[i] {
				num1 := dp[i][j-w[i]] + v[i]
				num2 := dp[i][j]
				if num1 > num2 {
					dp[i+1][j] = num1
				} else {
					dp[i+1][j]=dp[i][j]
				}
			} else {
				dp[i+1][j]=dp[i][j]
			}
		}
	}

	fmt.Println(dp[N][W])
}


Measured memory_bytes: 105848
#include<iostream>
#include<cstdio>

using namespace std;

const int N=2e5+10;
char s[N];
int n; 
int main(){
	scanf("%d",&n);
	scanf("%s",s+1);
	int num1=0,num2=0;
	for(int i=1;i<=n;i++){
		if(s[i]=='W') num1++;
		else num2++;
	} 
	int ans=0;
//	cout<<num1<<endl;
	for(int i=1;i<=num2;i++) if(s[i]=='W') ans++;
	printf("%d\n",ans);
}

Measured memory_bytes: 4004
import sys
input=sys.stdin.readline
from collections import Counter
n=int(input())
A=tuple(input().split())
C=Counter(A)
c1,c2,c3=[C[s] for s in ('1','2','3')]
DP=[[[0.0]*(n+1) for _ in range(n+1)] for _ in range(n+1)]
for i in range(c3+1):
    for j in range(c3+c2-i+1):
        for k in range(n-i-j+1):
            if i==j==k==0:
                continue
            tmp=n
            if i>0:
                tmp+=DP[k][j+1][i-1]*i
            if j>0:
                tmp+=DP[k+1][j-1][i]*j
            if k>0:
                tmp+=DP[k-1][j][i]*k
            DP[k][j][i]=tmp/(i+j+k)
print(DP[c1][c2][c3])

Measured memory_bytes: 254216
#include <bits/stdc++.h>
using namespace std;
// nichijou
#define REP(i,a,b) for (int i(a), _B(b); i < _B; ++i)
#define RP(i,n) REP(i,0,n)
#define PER(i,a,b) for(int i((a)-1), _B(b); i >= _B; --i)
#define PR(i,n) PER(i,n,0)
#define REP1(i,a,b) REP(i,a,(b)+1)
#define RP1(i,n) REP1(i,1,n)
#define PER1(i,a,b) PER(i,(a)+1,b)
#define PR1(i,n) PER1(i,n,1)
#define DO(n) REP(__i,0,n)
template<typename T>
void cmax(T & a, T b) {a = max(a, b);}
template<typename T>
void cmin(T & a, T b) {a = min(a, b);}

// data type
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define F first
#define S second

// STL container
typedef vector<int> vi;
typedef vector<ll> vll;
#define SZ(a) ((int)a.size())
#define ALL(a) a.begin(), a.end()
#define CLR(a) a.clear()
#define BK(a) (a.back())
#define FT(a) (a.front())
#define DB(a) a.pop_back()
#define DF(a) a.pop_front()
#define PB push_back
#define EB emplace_back

/* I gave you my heart and then you turned around. */
void _BG(const char * s) {}
template<typename T, typename ... TT>
void _BG(const char * s,T a, TT...b)
{
	for (int c = 0; *s && (c || *s != ','); ++s) {
		cerr<<*s;
		switch (*s) {
		case '(':
		case '[':
		case '{':
			++c;
			break;
		case ')':
		case ']':
		case '}':
			--c;
			break;
		}
	}
	cerr<<" = "<<a;
	if (*s) {
		cerr<<", ";
		_BG(++s,b...);
	} else
		cerr<<endl;
}
#define BG(...) do { \
	cerr << __PRETTY_FUNCTION__ << ':' << __LINE__ << ": "; \
	_BG(#__VA_ARGS__,__VA_ARGS__); \
} while(0)

/* Reading input is now 20% cooler! */
bool RD(void) {return true;}
bool RD(char & a) {return scanf(" %c", &a) == 1;}
bool RD(char * a) {return scanf("%s", a) == 1;}
bool RD(double & a) {return scanf("%lf", &a) == 1;}
bool RD(int & a) {return scanf("%d", &a) == 1;}
bool RD(ll & a) {return scanf("%lld", &a) == 1;}

template<typename T, typename ... TT>
bool RD(T & a, TT & ...  b) {return RD(a) && RD(b...);}

/* Do princesses dream of magic sheep? */
#define RI(a) int a; RD(a)
#define RII(a,b) RI(a); RI(b)
#define RIII(a,b,c) RI(a); RII(b,c)
#define RIIII(a,b,c,d) RI(a); RIII(b,c,d)

/* For it's time for you to fulfill your output. */
void PT(const char a) {putchar(a);}
void PT(const char * a) {fputs(a, stdout);}
void PT(char * a) {fputs(a, stdout);}
void PT(const double a) {printf("%.16f", a);}
void PT(const int a) {printf("%d", a);}
void PT(const ll a) {printf("%lld", a);}

/* The line will last forever! */
template<char sep = ' ',char end = '\n'>
void PL(void) {if (end) PT(end);}
template<char sep = ' ',char end = '\n',typename T, typename ... TT>
void PL(const T a, const TT ...  b) {PT(a); if (sizeof...(b) && sep) PT(sep); PL<sep,end>(b...);}

/* Good Luck && Have Fun ! */
int c[9];
int main()
{
	RI(n);
	DO(n) {
		RI(a);
		++c[min(a,3200)/400];
	}
	int ans = 0;
	RP(i,8)
		ans += c[i] ? 1 : 0;
	PL(ans + (!ans && c[8]), ans + c[8]);
}


Measured memory_bytes: 256
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function moveup(x::Array{Int,1},n)
	k = length(x)
	for i in 1:k-1
		if x[k-i+1] > n-1
			x[k-i] += div(x[k-i+1],n)
			x[k-i+1] = x[k-i+1]%n
		end
	end
	if x[1] > n-1
		0
	else
		x
	end
end

function main()
	h,w,k = readline() |> split |> parseMap
	a = zeros(Int,h,w)
	bit = zeros(Int,h-1)
	for i in 1:h
		s = readline() |> chomp
		for j in 1:w
			if s[j]=='1'
				a[i,j] = 1
			end
		end
	end
	b = zeros(Int,h+1,w+1)
	for i in 1:h
		for j in 1:w
			b[i+1,j+1] = b[i,j+1]+a[i,j]
		end
	end
	for j in 1:w
		for i in 1:h
			b[i+1,j+1] += b[i+1,j]
		end
	end
	ans = 10^18
	while bit!=0
		l = 1
		lk = 0
		chk = Int[1]
		for i in 1:h-1
			if bit[i]==1
				push!(chk,i+1)
			end
		end
		push!(chk,h+1)
		for j in 1:w
			f = 0
			for i in 2:length(chk)
				if b[chk[i],j+1]-b[chk[i],l]-b[chk[i-1],j+1]+b[chk[i-1],l]>k
					f = 1
					break
				end
			end
			if f==1
				lk += 1
				l = j
			end
		end
		v = 0
		for i in 2:length(chk)
			if b[chk[i],w+1]-b[chk[i],w]-b[chk[i-1],w+1]+b[chk[i-1],w]>k
				v = 1
			end
		end
		if v==0
			ans = min(ans,lk+sum(bit))
		end
		bit[h-1] += 1
		bit = moveup(bit,2)
	end
	println(ans)
end

main()

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



int main() {

	long long a , b , c , d , n;
	cin >> a >> b >> c >> d >> n;
	b = min(b , a<<1);
	c = min(c , b<<1);
	d = min(d , c<<1);

	cout << (n/2) * d + (n%2) * c << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i ,n) for(int i = 0 ; i < (n) ; i ++ )
#define all(x) (x).begin(),(x).end()
using ll = long long;
using namespace std;
//全探索
int main() {
 int n,m;//スイッチ、電球の数
   cin>>n>>m;
  vector<int> k(m);//i番目の電球に繋がるスイッチの数
  vector<vector<int>> s(m);//電球I番目の繋がっているスイッチ
  rep(i,m){
   
    cin>>k[i];
    rep(j,k[i]){
      int c;
      cin>>c;
      s[i].push_back(c);
    }
  }
  int ans=0;
vector<int> p(m);//2で割ったあまり。
  rep(i,m) cin>>p[i];
  //////////////
  
    for (int bit = 0; bit < (1 << n); ++bit) { //スイッチn個
      vector<int> sw(n,0); //スイッチ0クリア
      rep(i,n){         
         if (bit & (1 << i))  {//みぎからI番目がon (0~)
           sw[i]=1;          
         }        
      }
      bool lit=true;
      rep(i,m){//i番目の電球について
        if(!lit) break;
        int on=0;
        rep(j,s[i].size()){
          if(sw[s[i][j]-1]==1) on++;
        }
        if(on%2!=p[i]) lit=false;
      }
      if(lit) ans++;
      
      
      
    }
    
    cout<<ans<<endl;
    
    
    
   
}

Measured memory_bytes: 256
n = int(input())
ac = wa = tle = re = 0
temp = ""
for i in range(n):
    temp = input()
    if temp == "AC":
        ac += 1
    elif temp == "WA":
        wa += 1
    elif temp == "TLE":
        tle += 1
    elif temp == "RE":
        re += 1

print("AC x " + str(ac))
print("WA x " + str(wa))
print("TLE x " + str(tle))
print("RE x " + str(re))

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N, K;
    cin >> N >> K;
    vector<double> P(N), acc(N + 1, 0);
    rep(i, N) cin >> P[i];
    rep(i, N) {
        acc[i + 1] += acc[i] + (1 + P[i]) / 2.0;
    }
    double ans = 0;
    rep2(i, K, N + 1) {
        ans = max(ans, acc[i] - acc[i - K]);
    }
    cout << ans << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3328
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<map>
using namespace std;
#define N 200001
int n,k;
long long ans;
int main(){
    while (scanf("%d %d",&n,&k)!=EOF){
        ans = 1ll*(n/k)*(n/k)*(n/k);
        if (k%2==0){
            int cnt = -1;
            do{
                cnt++;
            }while(cnt*k+k/2<=n);
            ans=ans+1ll*cnt*cnt*cnt;
        }
        printf("%lld\n",ans);
    }
    return 0;
}



Measured memory_bytes: 256