akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<string>
#include<math.h>
#include<algorithm>
#include<numeric>

using namespace std;
typedef long long ll;
int mod = 1e9 + 7;

int main(void) {
	int n;
	cin >> n;
	ll pw = 1;
	for (int i = 2; i <= n; i++) {
      pw = pw * i % mod;
	}
	cout << pw << endl;
	return 0;
}


Measured memory_bytes: 256
k,a,b =  map(int,input().split())

c = b-a

if c >1:
    if k < a-1:
        print(1+k)
        exit(0)
    else:
        d=(k-a+1)
        if d %2==0:
            print(c*(d//2)+a)
        else:
            print(c*(d//2)+a+1)
        exit(0)
else:
    print(1+k)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define range(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, a) range(i, 0, a)
using namespace std;

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

    int mini = 1e9, num;
    rep (i, n - 1) {
        if (n % 2) {
            if (mini > abs(a[i] - (a.back() + 1) / 2)) {
                mini = abs(a[i] - (a.back() + 1) / 2);
                num = a[i];
            }
        }
        else {
            if (mini > abs(a[i] - a.back() / 2)) {
                mini = abs(a[i] - a.back() / 2);
                num = a[i];
            }
            if (mini > abs(a[i] - (a.back() / 2 + 1))) {
                mini = abs(a[i] - (a.back() / 2 + 1));
                num = a[i];
            }
        }
    }

    cout << a.back() << " " << num << endl;

    return 0;
}

Measured memory_bytes: 640
N=list(input())
Nsum=0
N2=0

for i in range(len(N)):
    N[i]=int(N[i])
    Nsum+=N[i]
    N2+=N[i]*( 10** (len(N)-(i+1)) )

if N2%Nsum==0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
import java.util.*;
	public class Main{
        public static void main(String[] args){
            Scanner sc = new Scanner(System.in);
            
            //出力
            System.out.println(Math.min(Integer.parseInt(sc.next()), Integer.parseInt(sc.next())) + Math.min(Integer.parseInt(sc.next()), Integer.parseInt(sc.next())));
            sc.close();
        }
    }
	

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

int main()
{
  int K,A,B;
  cin >> K >> A >> B;
  int a,b;
  a = A / K;
  b = B / K;
  if(A == B && K == B) K = 1;
  if((A % K) == 0) K = 1;
  if(K == 1) cout << "OK" << endl;
  else{
    if((b - a) >= 1) cout << "OK" << endl;
    else cout << "NG" << endl;
  }
  return 0;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s, t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());
    if ( s < t ) cout << "Yes" ;
    else cout << "No";
}


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

int main(){
	string S;
	cin >> S;
	int n = S.size();
	for(int i=(n-1)/2; i>0; i--){
		string Test, Check;
		for(int j=0; j<n-i; j++){
			for(int k=0; k<i; k++){
				Test += S[j+k];
			}
			for(int k=0; k<2*i; k++){
				Check += S[j+k];
			}
			if(Check==Test+Test){
				cout << 2*i<< endl;
				return 0;
			}
			Test.erase();
		}
	}
}

Measured memory_bytes: 384
#include <cstdio>
#include <queue>
#include <utility>
using namespace std;

typedef pair<int, int> Pair;

int n;
int field[100][100];
queue<Pair> q;

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

bool WithinRange(int y, int x) {
  if (y < 0) return false;
  if (x < 0) return false;
  if (y >= 8) return false;
  if (x >= 8) return false;
  return true;
}

void ProcessBomb(Pair p) {
  int y = p.first;
  int x = p.second;
  
  for (int i=0; i<4; i++) {
    for (int j=0; j<4; j++) {
      int newy = y + dy[i] * j;
      int newx = x + dx[i] * j;

      if (WithinRange(newy, newx) && field[newy][newx]) {
        q.push(Pair(newy, newx));
        field[newy][newx] = 0;
      }
    }
  }
}

int main() {
  scanf("%d", &n);

  for (int Case=1; Case<=n; Case++) {
    for (int i=0; i<8; i++) {
      for (int j=0; j<8; j++) {
        scanf("%1d", &field[i][j]);
      }
    }
  
    int x, y;
    scanf("%d", &x);
    scanf("%d", &y);
    --y;
    --x;
    q.push(Pair(y, x));
    while (!q.empty()) {
      Pair p = q.front(); q.pop();
      ProcessBomb(p);
    }

    printf("Data %d:\n", Case);
    for (int i=0; i<8; i++) {
      for (int j=0; j<8; j++) {
        printf("%d", field[i][j]);
      }
      puts("");
    }
  }
}

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

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

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

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int r, g, b;  cin >> r >> g >> b;
    if ((10 * g + b )% 4 == 0) {
      cout << "YES" << '\n';
    } else {
      cout << "NO" << '\n';
    }

    return 0;
}


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

int main()
{
    vector<string> nums = {"0", "10", "100"};
    vector<int> check(4, -1);
    int n, m;
    cin >> n >> m;
    string num = nums[n - 1];
    for (int i = 0; i < m; i++)
    {
        int s, c;
        cin >> s >> c;
        if (check[s] >= 0 && check[s] != c)
        {
            cout << "-1\n";
            return 0;
        }
        check[s] = c;

        if (n != 1 && (s == 1 && c == 0))
        {
            cout << "-1\n";
            return 0;
        }
        num[s - 1] = '0' + c;
    }
    int ans = stoi(num);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define mkp make_pair
#define pr(num) cout << num << "\n"
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define INF 1000000000000000000
#define MOD 1000000007LL
#define MAX 100010
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;

ll N, A, B;
ll a[44], b[44], c[44];
ll dp[44][444][444];

int main(void) {
    ll i, j, k;
    cin >> N >> A >> B;
    
    for(i=0; i<N; i++) {
        cin >> a[i] >> b[i] >> c[i];
    }
    
    for(i=0; i<=N; i++) {
        for(j=0; j<404; j++) {
            for(k=0; k<404; k++) {
                dp[i][j][k]=INF;
            }
        }
    }
    
    dp[0][0][0]=0;
    for(i=0; i<N; i++) {
        for(j=0; j<404; j++) {
            for(k=0; k<404; k++) {
                dp[i+1][j][k]=min(dp[i+1][j][k], dp[i][j][k]);
                dp[i+1][j+a[i]][k+b[i]]=min(dp[i][j+a[i]][k+b[i]], dp[i][j][k]+c[i]);
            }
        }
    }
    
    ll ans=INF;
    for(i=1; i*max(A, B)<404; i++) {
        ans=min(ans, dp[N][i*A][i*B]);
    }
    
    if(ans==INF) pr(-1);
    else pr(ans);
    
}


Measured memory_bytes: 63616
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
using namespace std;
//using ll = long long;
//using P = pair<int,int>;
//static const double PI = acos(-1);


//---------------------------//
//DFS 再帰関数を利用


static const int N     = 100;
static const int WHITE = 0;
static const int GRAY  = 1;
static const int BLACK = 2;

//隣接行列
int n, M[N][N];
int color[N], d[N], f[N], tt;

void dfs_visit(int u){
  //cout << "u: " << u << endl; //来訪地点のチェック
  color[u] = GRAY;
  d[u] = ++tt;  //最初に訪れたときの処理
  REP(v,n){
    if(M[u][v] == 0) continue;
    //cout << "v: " << v << endl; // 次に向かう点をチェック
    if(color[v] == WHITE) {
      dfs_visit(v); //再帰
    }
  }
  color[u] = BLACK;
  f[u] = ++tt;  //最後に訪れたときの処理

}


void dfs(){
  //int u;
  // 初期化
  REP(u,n) color[u] = WHITE;
  tt = 0;
  //
  REP(u,n) {
    if( color[u] == WHITE) dfs_visit(u); //再帰関数に
  }
  REP(u,n){
    cout << u+1 << " " << d[u] << " " << f[u] << endl;
    //cout << color[u] << endl;
  }


}


int main(){
  int u,k,v;
  cin >> n;
  //隣接行列の初期化
  REP(i,n) REP(j,n) M[i][j] = 0;


  //隣接行列の作製
  REP(i,n){
    cin >> u >> k;
    --u;
    REP(j,k){
      cin >> v;
      --v;
      M[u][v] = 1;
    }

  }
  //dfs
  dfs();


  //隣接行列のoutput(確認用)
  //REP(i,n) {REP(j,n) cout << M[i][j];cout << endl;}



  return 0;
}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,r;
	cin>>n;
	r=n%10;
	if(r==2||r==4||r==5||r==7||r==9)
	cout<<"hon";
	if(r==0||r==1||r==6||r==8)
	cout<<"pon";
	if(r==3)
	cout<<"bon";
	return 0;
}

Measured memory_bytes: 3636
N=gets.to_i
a=gets.chomp.split.map(&:to_i)
a.unshift(-1)
b=Array.new(N+1)
N.downto(1) do |i|
  j=i*2
  t=0
  while(j<=N) do
    t+=b[j]
    j += i
  end
  t %= 2
  b[i] = (t+a[i])%2
end
ans=[]
1.upto(N) do |i|
  ans << i if b[i] == 1
end
puts ans.size
puts ans.join(' ') if ans.size > 0

Measured memory_bytes: 23108
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

const int MAX_N = 100000+10;

bool visited[MAX_N];
int N;

vector<pair<int,int> > U[MAX_N];
int color[MAX_N];

int same(int s) {
    return s;
}

int diff(int s) {
    return s == 1 ? 0 : 1;
}

void dfs(int u, int d) {
    if(visited[u])
        return;
    visited[u] = true;
    color[u] = d;
    for(auto v:U[u]) {
        if(v.second % 2 == 0)
            dfs(v.first, same(d));
        else
            dfs(v.first, diff(d));
    }

    return;
}

int main(void) {
    cin>>N;

    for(int i = 0;i < N-1;i++) {
        int u,v,w;
        cin>>u>>v>>w;
        U[v].push_back(make_pair(u,w));
        U[u].push_back(make_pair(v,w));
    }

    dfs(1, 1);
    

    for(int i = 1;i <= N;i++) {
        cout<<color[i]<<endl;
    }

    return 0;
}


Measured memory_bytes: 7680
#include<stdio.h>
int main(void){
	int r, g, b, ans;
	scanf("%d %d %d", &r, &g, &b);
	ans = 100*r + 10*g + b;
	if(ans % 4) printf("NO\n");
	else printf("YES\n");
	
	return 0;
}

Measured memory_bytes: 128
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif

#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <cassert>
#include <string.h>
#include <unordered_set>
#include <unordered_map>

using namespace std;

typedef long long int64;
typedef unsigned long long uint64;
#define two(X) (1<<(X))
#define twoL(X) (((int64)(1))<<(X))
#define contain(S,X) (((S)&two(X))!=0)
#define containL(S,X) (((S)&twoL(X))!=0)
const double pi=acos(-1.0);
const double eps=1e-11;
template<class T> inline void ckmin(T &a,T b){if(b<a) a=b;}
template<class T> inline void ckmax(T &a,T b){if(b>a) a=b;}
template<class T> inline T sqr(T x){return x*x;}
typedef pair<int,int> ipair;
#define SIZE(A) ((int)A.size())
#define LENGTH(A) ((int)A.length())
#define MP(A,B) make_pair(A,B)
#define PB(X) push_back(X)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,a) for(int i=0;i<(a);++i)
#define ALL(A) A.begin(),A.end()

int n;

int gcd(int a,int b,int &x,int &y)
{
	if (b==0) { x=1; y=0; return a; }
	int d=gcd(b,a%b,x,y);
	int t=x;
	x=y;
	y=t-(a/b)*y;
	return d;
}
int gcd(int a,int b)
{
	return (b==0)?a:gcd(b,a%b);
}

bool dfs(int depth,int p,int s,int g)
{
	if (p+(n-depth)>30000) return false;
	if (depth==n)
	{
		if (g!=1) return false;
		if (s%2!=0) return false;
		if (s%3!=0) return false;
		if (s%5!=0) return false;
		return true;
	}
	if ((p%2==0 || p%3==0 || p%5==0) && dfs(depth+1,p+1,s+p,gcd(g,p)))
	{
		printf("%d ",p);
		return true;
	}
	return dfs(depth,p+1,s,g);
}
void solve()
{
	//printf("n = %d\n",n);
	/*
	if (n==3)
	{
		printf("2 6 63\n");
		return;
	}
	if (n==4)
	{
		printf("2 5 20 63\n");
		return;
	}
	*/
	if (!dfs(0,2,0,0))
	{
		printf("ERROR n = %d",n);
		exit(0);
	}
	printf("\n");
}

int main()
{
#ifdef _MSC_VER
	//freopen("input.txt","r",stdin);
#endif
	std::ios::sync_with_stdio(false);
	//for (n=3;n<=30000;n++) solve();
	cin>>n;
	solve();
	return 0;
}



Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int h, w, n;
  cin >> h >> w >> n;
  vector<int> a(n);
  rep(i, 0, n) cin >> a[i];

  int ans[h][w];
  int ch = 0, cw = 0, ca = 0;
  rep(i, 0, h) {
    if (i & 1) {
      cw = w - 1;
      repr(j, 0, w) {
        if (a[ca] == 0)
          ca++;
        ans[ch][cw] = ca + 1;
        a[ca]--;
        cw--;
      }

    } else {
      cw = 0;
      rep(j, 0, w) {
        if (a[ca] == 0)
          ca++;
        ans[ch][cw] = ca + 1;
        a[ca]--;
        cw++;
      }
    }
    ch++;
  }

  rep(i, 0, h) {
    rep(j, 0, w) {
      if (w > 0)
        cout << " ";
      cout << ans[i][j];
    }
    cout << endl;
  }
}


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

int a[1005], b[1005];
int main(){
	string str;
	int tmp;
	fill(a, a+1005, 0);
	fill(b, b+1005, 0);
	while(getline(cin, str)){
		if(str == "")break;
		tmp = atoi(str.substr(0, str.find(",")).c_str());
		a[tmp]++;
	}
	while(getline(cin, str)){
		if(str == "a")break;
		tmp = atoi(str.substr(0, str.find(",")).c_str());
		b[tmp]++;
	}
	for(int i = 0;i < 1005;i++){
		//if(a[i])cout << a[i] << endl;
		if(a[i] && b[i])cout << i << " " << a[i]+b[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 3008
n, m = map(int, input().split())

a, b = [0] * m, [0] * m
root_i = [False] * n
root_n = [False] * n
for i in range(m):
    a[i], b[i] = map(int, input().split())

for i in range(m):
    if a[i] == 1:
        root_i[b[i]] = True
    elif b[i] == n:
        root_n[a[i]] = True

for i in range(n):
    if root_i[i] == True and root_n[i] == True:
        print("POSSIBLE")
        exit()
    
print("IMPOSSIBLE")

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

using namespace std;

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


int main(){
 long m,d;
   cin >> m >> d;

  long res=0;
 rep(i,1,m){
  rep(j,1,d){
   if((j%10)<2||(j/10)<2) continue;
   if(i==(j/10)*(j%10)) res++;
  }
 }
  

   cout << res << endl;
}

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

using namespace std;
using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++)
    cin >> A[i];
  int now = 0;
  ll even_count = 0;
  for (int i = 0; i < N; i++) {
    now += A[i];
    if (i % 2 == 0 && now <= 0) {
      even_count += 1LL * (1 - now);
      now = 1;
    } else if (i % 2 == 1 && now >= 0) {
      even_count += 1LL * (now + 1);
      now = -1;
    }
  }
  now = 0;
  ll odd_count = 0;
  for (int i = 0; i < N; i++) {
    now += A[i];
    if (i % 2 == 1 && now <= 0) {
      odd_count += 1LL * (1 - now);
      now = 1;
    } else if (i % 2 == 0 && now >= 0) {
      odd_count += 1LL * (now + 1);
      now = -1;
    }
  }
  cout << min(even_count, odd_count) << '\n';
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>
#include <iomanip>
#include <cassert>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = INT_MAX;
const ll MOD = 1e9+7;


int H,W;
int di[4]={0,1,0,-1};
int dj[4]={1,0,-1,0};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>H>>W;
  vector<string> S(H);
  repeat(i,H){
    cin>>S[i];
  }
  vector<vector<bool> > used(H,vector<bool>(W,false));
  ll ans = 0;
  repeat(i,H){
    repeat(j,W){
      if(used[i][j])continue;
      ll oddeven[2]={0,0};
      queue<Pii> Q;
      Q.push({i,j});
      while(!Q.empty()){
        Pii e = Q.front();
        Q.pop();
        if(used[e.first][e.second])continue;
        //debug(e.first);
        //debug(e.second);
        used[e.first][e.second]=true;
        oddeven[S[e.first][e.second]=='#']++;
        repeat(d,4){
          int ni = e.first+di[d],nj = e.second+dj[d];
          //debug(ni);
          //debug(nj);
          if(0<=ni&&ni<H&&0<=nj&&nj<W){
            if(S[ni][nj]!=S[e.first][e.second]){
              Q.push({ni,nj});
            }
          }
        }
      }
      //debugArray(oddeven,2);
      ans += oddeven[0]*oddeven[1];
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<queue>
#include<stack>
#include<list>

using namespace std;
using ll = long long;

int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }

    int ans=0;
    bool ok = true;
    while(ok){
        for(int i=0;i<n;i++){
            if(a[i]%2 == 1){
                cout<<ans<<endl;
                return 0;
            }
            else{
                a[i] /= 2;
            }
        }
        ans++;
    }

    cout<<ans<<endl;
}

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

#define x first
#define y second

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;

const int mod=1000000000+7;

int addm(int& a,int b) {return (a+=b)<mod?a:a-=mod;}

template<class T,class U> bool smin(T& a,U b) {return a>b?(a=b,1):0;}
template<class T,class U> bool smax(T& a,U b) {return a<b?(a=b,1):0;}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	string s;
	cin >> s;
	int r=0;
	int sc=0;
	for (int i=0;i<s.size();i++) {
		if (s[i]=='S') sc++;
		else {
			if (sc) {
				sc--;
				r++;
			}
		}
	}
	cout << s.size()-2*r << endl;

}

Measured memory_bytes: 720
'''
.append(要素) リストに要素を追加
.extend(リスト) リストを連結する
.insert(場所,要素) 指定した場所に要素追加
del 配列名[場所]
-1で末尾で末尾から一つ前
sort()
sorted(reverse=true)
配列の初期化
配列名=[a]*n+[b]*m
Decimal()
'''

from sys import stdin
from itertools import accumulate, dropwhile, takewhile, groupby
import bisect
import copy
import math
from functools import reduce
from operator import mul
from collections import Counter
import itertools
import fractions
import sys
d = stdin.readline().rstrip().split()
H = int(d[0])
W = int(d[1])
K = int(d[2])

data = []
bCount = 0
result = 0
for el1 in range(H):
    tmp = stdin.readline().rstrip().split()
    d = []
    for el in tmp:
        for el3 in el:
            if el3 == '#':
                bCount += 1
            d.append(el3)
    data.append(d)
datas = copy.deepcopy(data)
counter = 0
for el in range(H+W):
    counter += 2**el
for el in range(counter+1):
    bin_str = ''.join(list(reversed(str(bin(el))[2:])))
    poss = []
    count = 0
    for el2 in bin_str:
        if el2 == '1':
            poss.append(count)
        count += 1
    res = 0
    for el2 in poss:
        if el2 >= H:
            el2 -= H
            for el3 in datas:
                el3[el2] = 'o'
        else:
            datas[el2] = ['o']*W
    for el2 in datas:
        res += el2.count('#')
    if res == K:
        result += 1
    datas = copy.deepcopy(data)
print(result)


Measured memory_bytes: 76176
<?php
fscanf(STDIN, "%d %d", $n, $k);
fscanf(STDIN, "%d %d %d", $r, $s, $p);
$ts=str_split(trim(fgets(STDIN)));
$res=0;
foreach ($ts as $i => &$t) {
  if ($i >= $k && $ts[$i-$k] == $t) {
    $t = 'x';
    continue;
  }
  if ($t=='r') {
    $res += $p;
  } elseif ($t=='s') {
    $res += $r;
  } else {
    $res += $s;
  }
}
echo $res;

Measured memory_bytes: 21132
#!/usr/bin/env python3
import sys
# import math
# import numpy as np
# from functools import lru_cache

args = sys.argv
if len(args) == 2:
  from IPython import embed
  em = True
else:
  em = False

# sys.setrecursionlimit(10000)

#### input
N = int(input())
# a, b = map(int, input().split())
vs = list(map(int, input().split()))
# vs = list(map(lambda x: int(x)*(2**(N - 1)), vs_orig))  # 各要素を-1倍

# n = int(input())
# t = [int(input()) for i in range(n)]
if em: sys.stdin = open('/dev/tty')
if em : embed()

#### function
# @lru_cache(maxsize=10000)

#### process
vs_sorted = sorted(vs)
vs_sum = vs_sorted[0]

for i in range(1, len(vs_sorted)):
  vs_sum = vs_sum + 2**(i-1) * vs_sorted[i]

print(vs_sum / 2**(N-1))
# if em: embed()

## heapsort, O(NlogN)
# import heapq
# # As = [0,1,2,3]
# heapq.heapify(vs)
# min1 = heapq.heappop(vs)
# min2 = heapq.heappop(vs)
# heapq.heappush(vs, )


Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int N;
    scanf("%d",&N);
    int a[N],b[N],c[N];
    for(int i=0;i<N;++i){
        cin>>a[i];
    }
    for(int i=0;i<N;++i){
        cin>>b[i];
    }
    for(int i=0;i<N-1;++i){
        cin>>c[i];
    }
    int pt=0;
    for(int i=0;i<N;++i){
        if(i!=0 && a[i-1]==a[i]-1){
            pt+=b[a[i]-1]+c[a[i]-2];
        }else{
            pt+=b[a[i]-1];
        }
    }
    printf("%d",pt);
}

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

#define pi 3.1415926536
#define mod 1000000007
#define lli long long int
#define rep(i, n) for(int i = 0 ; i < n ; i++)
#define repn(i, n) for(int i = n - 1 ; i >= 0 ; i--)
#define loop(i, a, b) for(int i = a ; i < b ; i++)
#define mod1 1000003
#define hello "hello"

using namespace std;

//fixed<<setprecision(9);

bool sortbysec(const pair<int, int> &a, const pair<int, int> &b)
{
	return (a.second < b.second);
}

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



int main()
{
	int  a, b, x, tmp = 180.00000000;

	cin>>a>>b>>x;

	
	if ((a*a*b)/2.0 < x)
	{
		cout<<fixed<<setprecision(9)<<(atan(((2.0*a*a*b) - (2.0*x))/(a*a*a))*tmp)/M_PI<<endl;
	}
	else
	{
		cout<<fixed<<setprecision(9)<<(atan((a*b*b)/(2.0*x))*tmp)/M_PI<<endl;
	}
}	

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define len(x) (int)(x.size())
#define all(vs) vs.begin(), vs.end()
using ii = pair<int, int>;
using ll = long long;

int mem[200];
int32_t main(){
	ios::sync_with_stdio(0);
	int x, n;
	cin >> x >> n;
	for(int i=0; i<n; ++i){
		int w; cin >> w;
		mem[w] = 1; 
	}
	int ans = 0;
	int res = 1e9;
	for(int i=0; i<150; ++i){
		if(mem[i]) continue;
		if(abs(x-i)<res){
			res = abs(x-i);
			ans = i;
		}
	}
	cout << ans << endl;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef pair<int,int> pii;
typedef pair<long long, int> pli;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

ll mod = 1000000007;

ll gcd(ll a, ll b){
  if (a%b == 0)return(b);
  else return(gcd(b, a%b));
}

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

  char c;
  cin >> c;
  if('A' <= c && c <= 'Z')cout << 'A' << endl;
  else cout << 'a' << endl;
}

Measured memory_bytes: 3648
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
//ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b%mod ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

int main(){
	ll n ; cin >> n ;
	vll a(n) ;
	for(auto &i:a) cin >> i ;
	ll ans = 0 ;
	ll q ; cin >> q ;
	for(int i=0;i<q;i++){
		ll b ; cin >> b ;
		ans += (b==*lower_bound(all(a),b)) ;
	}
	cout << ans << endl ;
}



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

#define REP(i,n) for(ll i=0; i<(ll)(n); i++)
#define FOR(i,n,m) for (ll i=n; i<(ll)(m); i++)
#define pb push_back
#define INF 1000000007LL
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)

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

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


#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

#define MAX_V 10000
vector<int> G[MAX_V];
vector<pair<int, int> > bridge;
vector<int> articulation;
int order[MAX_V], lowlink[MAX_V];
bool visited[MAX_V];

void dfs(int v, int pre, int &k)
{
    visited[v] = true;
    order[v] = k++;
    lowlink[v] = order[v];
    
    bool isArticulation = false;
    int ct = 0;
    
    for (int i = 0; i < G[v].size(); i++){
        if (!visited[G[v][i]]){
            ct++;
            dfs(G[v][i], v, k);
            lowlink[v] = min(lowlink[v], lowlink[G[v][i]]);
            if (pre != -1 && order[v] <= lowlink[G[v][i]]) isArticulation = true;
            if (order[v] < lowlink[G[v][i]]) bridge.pb(make_pair(min(v, G[v][i]), max(v, G[v][i])));
        }
        else if (G[v][i] != pre){
            lowlink[v] = min(lowlink[v], order[G[v][i]]);
        }
    }
    
    if (pre == -1 && ct > 1) isArticulation = true;
    if (isArticulation) articulation.pb(v);
}

int main(){
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    REP(i,m) {
        int x, y;
        cin >> x >> y;
        G[--x].push_back(--y);
        G[y].push_back(x);
    }
    
    
    int k = 0;
    for (int i = 0; i < n; i++){
        if (!visited[i]) dfs(i, -1, k);
    }
    
    sort(bridge.begin(), bridge.end());
    sort(articulation.begin(), articulation.end());
    
    cout << bridge.size() << endl;
    
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using longlong=long long;

void err() { std::cout << "WA" << std::endl; exit(0); }
#define suppose(exp) do { if (!(exp)) { err(); } } while(false)

int main(){
    std::cin.tie(nullptr);std::cin.sync_with_stdio(false);
    std::string s; std::cin >> s;
    suppose(s.front()=='A');
    int n=s.length();
    int pos=-1;
    for(int i=1;i<n;i++){
        if(std::isupper(s.at(i))){
            suppose(2<=i&&i<n-1&&pos==-1&&s.at(i)=='C');
            pos=i;
        }
    }
    std::cout << (pos==-1?"WA":"AC") << std::endl;
}

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

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;
using namespace std;

const ll M=1000000007;

signed main() {
  struct V {
    ll id;
    ll par, bros;
  };

  ll N,K;
  cin>>N>>K;
  stack<V> s;
  vector<vector<ll>> edges(N+1);
  vector<ll> pat(N+1, -1);
  rep(i,0,N-1){
    ll a,b;
    cin>>a>>b;
    edges[a].push_back(b);
    edges[b].push_back(a);
  }

  s.push(V{1,0,0});
  while (!s.empty()) {
    auto t = s.top();
    s.pop();
    if (pat[t.id]!=-1)
      continue;
    pat[t.id] = K-t.par-t.bros;
    // cout<<t.id<<" "<<t.par<<" "<<t.bros<<" "<<pat[t.id]<<endl;
    if (pat[t.id]<=0) {
      cout<<0<<endl;
      return 0;
    }
    ll x = 0;
    for (auto c: edges[t.id]) {
      if (pat[c]!=-1)
        continue;
      s.push(V{c, min((ll)2, t.par+1), x});
      x++;
    }
  }
  ll ans = 1;
  for (int i=1; i<=N; i++) {
    //cout<<pat[i]<<endl;
    ans *= pat[i];
    ans %= M;
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 9716
#include<bits/stdc++.h>
using namespace std;
vector<vector<int> > adjlist;
#define sfor(n) for(int i=0;i<n;i++)
#define mod 1000000007
#define pb push_back
#define in insert
#define mp make_pair
#define inf mod
#define bg begin()
#define ed end()
#define vi vector<int>
#define map map<int,int>
#define smap map<string,int>
#define set set<int>
typedef long double ld;
typedef long long int ll;
ll max(ll x ,ll y)
{
    return x>y?x:y;
}
int main()
{
    ll a,b;
    cin>>a>>b;
    cout<<max(a+b,max(a-b,a*b))<<endl;
    return 0;
}

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

int main(){
ll test,i,j,xy,count,flag=0,n,o1=0,o2=0,x,y,m,l,z,max1,x1,y1,x2,y2,z1,k,sum,f,r,ans1,min1;

cin>>x>>y>>z>>k;
while(x>=y && k>0){
	y*=2;
	k--;
}
//cout<<x<<" "<<y<<" "<<z<<"\n";
if(x>=y){
	cout<<"No";
	return 0;
}
while(z<=y && k){
	z*=2;
	k--;
}
//cout<<x<<" "<<y<<" "<<z<<"\n";
if(z<=y){
	cout<<"No\n";
	return 0;
}
cout<<"Yes\n";
return 0;
}

Measured memory_bytes: 3632
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <iomanip>
#include <iostream>
#include <limits>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;

template<typename T>
vector<T> make_vec_nd(T init, size_t size) {
    return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, size_t size, Args... rest) {
    auto inner = make_vec_nd(init, rest...);
    return vector<decltype(inner)>(size, inner);
}

int main() {
    ll N;
    cin >> N;
    vector<ll> His;
    for (ll i = 0; i < N; i++) {
        ll Hi;
        cin >> Hi;
        His.push_back(Hi);
    }
    vector<ll> dp(N, numeric_limits<ll>::max());
    for (ll i = 0; i < N; i++) {
        if (i == 0) {
            dp[0] = 0;
            continue;
        }
        dp[i] = dp[i-1] + abs(His[i]-His[i-1]);
        if (i >= 2) {
            dp[i] = min(dp[i], dp[i-2] + abs(His[i]-His[i-2]));
        }
    }
    cout << dp[N-1] << endl;
}


Measured memory_bytes: 1908
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define FAST ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

int32_t main(){
    FAST
    int n;cin>>n;
    if(n%1000==0){
        cout<<0<<"\n";
    }
    else{
        cout<<1000-n%1000<<"\n";
    }
    return 0;
}

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

using namespace  std;

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string d;

    cin >> d;

    if (d <= "2019/04/30") {
        cout << "Heisei" << endl;
    } else {
        cout << "TBD" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
struct Edge{
  double v;
  int d;
};
int main(){
  int n,m,p;
  int i,j,k;
  cin >> n >> m >> p;
  Edge edge[n+1][n+1];
  for(i=0;i<=n;i++){
    for(j=0;j<=n;j++){
      edge[i][j].d=0;
      edge[i][j].v=0;
    }
  }
  for(i=0;i<m;i++){
    cin >> j >> k ;
    cin >> edge[j][k].d >> edge[j][k].v;
    edge[k][j].d=edge[j][k].d;
    edge[k][j].v=edge[j][k].v;
  }
   
  //cout << n << m << p << endl;
   
  double dp[201][2005]={{}};
  //memset(dp,-1,sizeof(dp));
  for(i=0;i<201;i++){
    for(j=0;j<2005;j++){
      dp[i][j]=-1;
    }
  }
  dp[1][0]=0;
  for(i=0;i<p;i++){
    for(j=1;j<=n;j++){
      if(dp[j][i]==-1) continue;
      for(k=1;k<=n;k++){
    if(edge[j][k].d==0) continue;
    dp[j][i+1]=max(dp[j][i+1],dp[j][i]+(edge[j][k].v/edge[j][k].d));
    //cout << i << ":" << j << ":" << k <<"/"<< edge[j][k].d << endl;
    dp[k][i+edge[j][k].d]=max(dp[k][i+edge[j][k].d],dp[j][i]+edge[j][k].v);
      }
    }
  }
  //cout << dp[1][p] << endl;
  printf("%.6lf\n",dp[1][p]);
}

Measured memory_bytes: 5028
a, b, c, d = map(int, input().split())

mod_a, q_a = divmod(a, d)
if (q_a == 0):
  aoki = mod_a
else:
  aoki = mod_a + 1

mod_t, q_t = divmod(c, b)
if (q_t == 0):
  takahashi = mod_t
else:
  takahashi = mod_t + 1

if (takahashi <= aoki):
  print('Yes')
else:
  print('No')

Measured memory_bytes: 61640
def substring(s, t):
    min = 10000    # 変更数の最小
    startIdx = 0   # arraySのstartインデックス
    arrayIdx = 0   # arraySのインデックス
    arrayS = []
    arrayT = []
    
    for item in s:
        arrayS.append(item)

    # Sの文字列-Tの文字列+1回ループ
    loopCnt = len(s) - len(t) + 1
    for i in range(0, loopCnt):
        count = 0       # 変更数

        arrayIdx = startIdx

        for item in t:
            if not item == arrayS[arrayIdx]:
                count += 1
            arrayIdx += 1

        if count < min:
            min = count
        
        startIdx += 1

    print(min)


        

s = input()
t = input()

substring(s, t)

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


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int h = sc.nextInt();
		int w = sc.nextInt();

		FloydWarshall fw = new FloydWarshall(10);

		for (int i = 0; i < 10; i++) {
			for (int j = 0; j < 10; j++) {
				int c = sc.nextInt();

				fw.addEdge(i, j, c);
			}
		}

		int[] cnt = new int[10];
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				int a = sc.nextInt();
				if (a >= 0) {
					cnt[a]++;
				}
			}
		}

		int ans = 0;
		for (int i = 0; i < 10; i++) {
			ans += cnt[i] * fw.getShortestPath(i, 1);
		}

		pr.println(ans);
	}

	private static class FloydWarshall {
		long[][] d;
		int n;
		long[][] result;
		boolean nf; // NEGATIVE CYCLE flag

		final long INF = Long.MAX_VALUE;

		FloydWarshall(int n) {
			this.n = n;
			d = new long[n][n];
			for (int i = 0; i < n; i++) {
				Arrays.fill(d[i], INF);
				d[i][i] = 0;
			}
			nf = false;
		}

		// i, j:0-indexed
		public void addEdge(int i, int j, int c) {
			d[i][j] = c;
		}

		public long getShortestPath(int i, int j) {
			if (nf) {
				return -INF;
			}

			if (result == null) {
				for (int kk = 0; kk < n; kk++) {
					for (int ii = 0; ii < n; ii++) {
						for (int jj = 0; jj < n; jj++) {
//							d[ii][jj] = Math.min(d[ii][jj], d[ii][kk] + d[kk][jj]);
							if (d[ii][kk] != INF && d[kk][jj] != INF && d[ii][jj] > d[ii][kk] + d[kk][jj]) {
								d[ii][jj] = d[ii][kk] + d[kk][jj];
							}
						}
					}
				}

				for (int k = 0; k < n; k++) {
					if (d[k][k] < 0) {
						nf = true;
						return -INF;
					}
				}

				result = d;
			}

			return result[i][j];
		}
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);

		solve();

		pr.close();
		sc.close();
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}


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

int main(void){
    int N;
    cin >> N;
    int C[501],S[501],F[501];

    for(int i = 0;i < N - 1;i++){
        cin >> C[i] >> S[i] >> F[i];
    }


    //calc
    for(int i = 0;i < N;i++){
        int t = 0;
        for(int j = i;j < N - 1;j++){
            if(t < S[j]){
                t = S[j];
            }else if(t % F[j] == 0){

            }else{
                t += F[j] - t % F[j]; 
            }
            t += C[j];//time to move
        }
        cout << t << endl;
    }

    
    return 0;
}

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

int main() {
  string w;
  cin >> w;
  map<char, int> m;
  
  for (int i = 0; i < w.size(); i++) {
    char ch = w.at(i);
    if (m.count(ch)) {
      m.at(ch)++;
    } else {
      m[ch] = 1;
    }
  }
  
  bool b = true;
  for (int i = 0; i < w.size(); i++) {
    char ch = w.at(i);
    int value = m.at(ch);
    if (value % 2) {
      b = false;
      break;
    }
  }
  
  if (b) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define ins insert
#define sz(x) (long long)x.size()
typedef long long ll;
typedef long double ld;
const int N = 1e5 + 5;
const ld pi = 3.141592653;
const ll MOD = 1e9 + 7;
const ll mod = 998244353;
const ll INF = __LONG_LONG_MAX__;

using namespace std;

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

int n, i;
vector<int> a(N), b(N), c(N);
int dp[N][3];

int main()
{
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
        int T = 1;
        //cin>>T;
        while(T--)
        {
                cin>>n;
                for(i = 1; i<=n; i++) cin>>a[i]>>b[i]>>c[i];
                for(i = 0; i<=n; i++) dp[i][0] = dp[i][1] = dp[i][2] = 0;
                dp[1][0] = a[1]; dp[1][1] = b[1]; dp[1][2] = c[1];
                for(i = 2; i<=n; i++){
                        dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a[i];
                        dp[i][1] = max(dp[i - 1][2], dp[i - 1][0]) + b[i];
                        dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + c[i];
                }
                cout<<max({dp[n][0], dp[n][1], dp[n][2]});
        }
        return 0;
}

Measured memory_bytes: 5548
import java.util.*;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);

		String S = in.readLine();
		List<String> splited = split(S);
		List<Integer> result = new ArrayList<>(S.length());
		for (int i = 0; i < splited.size(); ++i) {
			result.addAll(convert(splited.get(i)));
		}
		StringBuilder strBuilder = new StringBuilder();
		strBuilder.append(Integer.toString(result.get(0)));
		for (int i = 1; i < result.size(); ++i) {
			strBuilder.append(" " + Integer.toString(result.get(i)));
		}
		System.out.println(strBuilder.toString());
	}

	static List<Integer> convert(String s) {
		int lCount = 0, rCount = 0;
		// 分割位置を求める
		int splitPos = 0;
		for (int i = 0; i + 1 < s.length(); ++i) {
			if (s.charAt(i) != s.charAt(i + 1)) {
				splitPos = i;
				break;
			}
		}
		int lNum = splitPos + 1;
		int rNum = s.length() - lNum;

		if (lNum % 2 == 0) {
			lCount += lNum / 2;
			rCount += lNum / 2;
		} else {
			lCount += lNum / 2 + 1;
			rCount += lNum - lCount;
		}
		if (rNum % 2 == 0) {
			lCount += rNum / 2;
			rCount += rNum / 2;
		} else {
			lCount += rNum / 2;
			rCount += rNum / 2 + 1;
		}
		List<Integer> result = new ArrayList<>(s.length());
		for (int i = 0; i < splitPos; ++i) {
			result.add(0);
		}
		result.add(lCount);
		result.add(rCount);
		for (int i = splitPos + 2; i < s.length(); ++i) {
			result.add(0);
		}

		return result;
	}

	static List<String> split(String S) {
		Deque<StringBuilder> queue = new ArrayDeque<>();
		queue.addLast(new StringBuilder());
		queue.getLast().append(S.charAt(0));
		char last = S.charAt(0);

		for (int i = 1; i < S.length(); ++i) {
			char c = S.charAt(i);
			if (c == 'R') {
				if (last == c) {
					queue.getLast().append(S.charAt(i));
				} else {
					queue.addLast(new StringBuilder());
					queue.getLast().append(S.charAt(i));
				}
			} else {
				if (last == c) {
					queue.getLast().append(S.charAt(i));
				} else {
					queue.getLast().append(S.charAt(i));
				}
			}
			last = c;
		}
		List<String> r = new ArrayList<>(queue.size());
		while (!queue.isEmpty()) {
			r.add(queue.poll().toString());
		}
		return r;
	}
}

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

int main() {
string s [3] = {"Sunny", "Cloudy", "Rainy"};

string s1 ; cin >> s1 ;
if ( s1[0]=='S') cout << s[1] ; 
else if (s1[0]=='C') cout << s[2] ;
else if (s1[0]=='R') cout << s[0] ;
    return 0;
}

Measured memory_bytes: 256
input_str=input()
# input_str="QWERTYASDFZXCV"
# input_str="ZABCZ"
# input_str="HASFJGHOGAKZZFEGA"
b=0
e=0
length=len(input_str)
for i, s in enumerate(input_str):
	if s=="A":
		b=i
		# print(b)
		break
for i, s in enumerate(input_str[::-1]):
	if s=="Z":
		e=length-i
		# print(e)
		break
print(e-b)


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

ll solve() {
  ll N, P;
  cin >> N >> P;
  if(N == 1) return P;
  ll ans = 1;
  rep(i, 2, sqrt(P)+2) {
    int cnt = 0;
    while(P % i == 0) {
      P /= i;
      cnt++;
      if(cnt == N) {
        ans *= i;
        cnt = 0;
      }
    }
  }
  return ans;
}

int main() {
  cout << solve() << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<array>
using namespace std;
using UL = unsigned;
using LL = long long;
using ULL = unsigned long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)
void Solve() {
	LL t1, t2; cin >> t1 >> t2;
	LL a1, a2; cin >> a1 >> a2;
	LL b1, b2; cin >> b1 >> b2;
	LL a = a1 - b1; LL b = a2 - b2;
	LL d = a * t1 + b * t2;
	if (d == 0) { cout << "infinity" << endl; return; }
	if (double(a) * double(b) > 0.0) { cout << 0 << endl; return; }
	if (double(a) * double(d) > 0.0) { cout << 0 << endl; return; }
	LL df = abs(a * t1);
	d = abs(d);
	LL ans = df / d + (df - 1) / d + 1;
	cout << ans << endl;
}
int main() { Solve(); return 0; }


Measured memory_bytes: 256
A = int(input())
x = list(map(int, input().split()))
listA=[]
count=0
for i in range(A-1):

    if x[i]>=x[i+1]:
        count = count+1
    else:
        listA.append(count)
        count=0
        i=i-1
listA.append(count)
kotae=max(listA)
print(kotae)        


Measured memory_bytes: 14252
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main{
  public static void main(String[] args) throws Exception{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String line = br.readLine();
    int i = 1;
    do {
      System.out.println("Case "+i+": "+line);
      line = br.readLine();
      i++;
    } while (!(line.equals("0")));
  }
}

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

int main() {
  string S;
  cin >> S;
  
  int n = 753;
  int ans = 9999;
  int sa=0;
  for(int i=0; i<S.size()-2; i++){
    char iti = S.at(i); char ni= S.at(i+1); char san= S.at(i+2);
    string s3;
    s3 += iti;
    s3 += ni;
    s3 += san;
    int X = stoi(s3);
    if(X>n)sa=X-n;
    else sa=n-X;
    if(sa<ans)ans=sa;
  }
  cout << ans << endl;
  
}

Measured memory_bytes: 3580
#include<stdio.h>
int main()
{
    int L,R,d,k=1,i=0,n=0;
    scanf("%d%d%d",&L,&R,&d);
    while(1){
        n=d*k;
        k++;
        if(n>=L && n<=R){
            i++;
        }
        if(n>R)break;
    }
    printf("%d\n",i);
    return 0;
}


Measured memory_bytes: 1732
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30);
const int INF = (1LL << 60);
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}

vector<int> divisor(const int n){
  vector<int> ret;
  for(int 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;
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int n;
    cin>>n;
    vector<int> a(n);
    REP(i,n) cin >> a[i];
    vec b(n);
    vec g;
    rep(j,n){
        int i=n-1-j;
        if(a[i]==0&&b[i]%2==1){
            g.pb(i+1);
        }
        else if(a[i]==1&&b[i]%2==0){
            g.pb(i+1);
        }
        else continue;
        vec c=divisor(i+1);
        for(auto &x:c){
            b[x-1]++;
        }
    }

    sort(all(g));

    cout<<g.size()<<endl;
    for(int x:g) cout<<x<<endl;
    
    
}

Measured memory_bytes: 5108
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int mod=1000000007;

vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}
int main() {
  int R,G,B,N;
  cin>>R>>G>>B>>N;
  int cnt=0;
  for(int r=0;r<=N;r++){
    for(int g=0;g<=N-r;g++){
      int Bb=N-R*r-G*g;
      if(Bb%B==0&&Bb/B>=0){cnt++;}
    }
  }
  cout<<cnt<<endl;
  return 0;
}

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

int main()
{
    ll n;
    cin >> n;

    vector<ll> divisors(n+1);
    for(ll i = 0; i < n+1; i++)
    {
        divisors[i] = 1;
    }
    for(ll i = 2; i <= n; i++)
    {
        for(ll j = i; j <= n; j += i)
        {
            divisors[j]++;
        }
    }

    ll answer = 0;
    for(int k = 1; k <= n; k++)
    {
        answer += k * divisors[k];
    }

    cout << answer << endl;

    return 0;
}


Measured memory_bytes: 81380