akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,(n))
using namespace std;

const int MAX_N = 1e5+1;
vector<int> graph[MAX_N], ans;
bool visited[MAX_N];

void dfs(int x) {
    visited[x] = true;
    ans.push_back(x);
    for (int i : graph[x]) {
        if (!visited[i]) {
            dfs(i);
            break;
        }
    }
}

int main() {
    int N, M, a, b;
    cin >> N >> M;
    rep(i, M) {
        cin >> a >> b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    dfs(1);
    reverse(ans.begin(), ans.end());
    ans.pop_back();
    dfs(1);

    cout << ans.size() << endl;
    for (int i: ans) {
        cout << i << " ";
    }
    //cout << endl;
}

Measured memory_bytes: 9720
#include <iostream>
#include <vector>
#include <map>
#include <functional>

int main() {
  int n;
  std::cin >> n;
  std::map<int, int,std::greater<int>> map;
  for (int i = 0; i < (1 << n); ++i) {
    int s;
    std::cin >> s;
    ++map[s];
  }

  std::vector<int> tree(n + 1), temp(n + 1);
  tree[n] = 1;
  for (auto& e : map) {
    for (int i = n; i >= 0; --i) {
      while (tree[i] > 0 && e.second > 0) {
        --e.second;
        --tree[i];
        for (int j = 0; j < i; ++j) {
          ++temp[j];
        }
      }
    }
    if (e.second > 0) {
      std::cout << "No" << std::endl;
      return 0;
    }
    for (int i = 0; i <= n; ++i) {
      tree[i] += temp[i];
    }
    temp.assign(n + 1, 0);
  }
  std::cout << "Yes" << std::endl;

  return 0;
}


Measured memory_bytes: 12544
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;*/
#include<algorithm>
#include <bits/stdc++.h>
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<ctype.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define S second
#define F first
#define vi vector<ll>
#define pii pair<ll,ll>
#define bc __builtin_popcountll
#define vvi vector<vi> 
#define vpii vector<pair<ll,ll>>
#define mll unordered_map<ll,ll>
#define INF LONG_LONG_MAX
#define NINF LONG_LONG_MIN
#define fo(i,a,b) for(i=a;i<=b;i++)
#define f(i,n) for(ll i=0;i<n;i++)
#define f1(i,n) for(ll i=1;i<=n;i++)
#define fb(i,n) for(ll i=n-1;i>=0;i--)
#define fb1(i,n) for(ll i=n;i>0;i--)
#define endd cout<<'\n';
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define fr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define clr(x) memset(x, -1.00, sizeof(x))
#define sortall(x) sort(all(x))
#define all(x) x.begin(), x.end()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define CASES  ll t;cin>>t;while(t--)
typedef long long ll;
typedef unsigned long long ull;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
//*X.find_by_order()-->returns an iterator to the k-th largest element (counting from zero)
//X.order_of_key()-->the number of items in a set that are strictly smaller than our item.
struct cmp
{
	bool operator() (ll a,ll b){
		return (a>b);
	}
};
ll ceil(const ll &a, const ll &b)
{
    if(a%b == 0)
        return a/b;
    return a/b +1;
}
ll mod=1000000007;
const ll N=3005;
ll dp[N][N][2];
ll a[N];
ll go(ll i,ll j,ll k)
{
    if(i>j)
        return 0;
    if(dp[i][j][k]!=-1)
        return dp[i][j][k];
    ll res;
    if(k==0)
    {
        res=max(a[i]+go(i+1,j,1),a[j]+go(i,j-1,1));
    }
    else
    {
        res=min(-a[i]+go(i+1,j,0),-a[j]+go(i,j-1,0));
    }
    return dp[i][j][k]=res;
}
int main()
{
fast;
    ll n;
    cin>>n;
    f(i,n)
        cin>>a[i];
    clr(dp);
    cout<<go(0,n-1,0);   
    return 0;
}


Measured memory_bytes: 144840
#include <iostream>
#include <cstring>
#include <cstdio>


using namespace std;
char grid[1001][1001];
unsigned long long dp[1001][1001];


int main()
{
    memset(grid, '#', sizeof(grid));
    memset(dp, 0, sizeof(dp));

    int H, W;
    cin >> H >> W;

    for (int h = 1; h <= H; h++) {
        for (int w = 1; w <= W; w++) {
            char ch = getchar();
            if (ch == '\n')
                ch = getchar();
            grid[h][w] = ch;
        }
    }

    dp[0][1] = 1;
    for (int h = 1; h <= H; h++) {
        for (int w = 1; w <= W; w++) {
            if (grid[h][w] == '#')
                continue;
            dp[h][w] = (dp[h - 1][w] + dp[h][w - 1]) % (1000000000 + 7);
        }
    }

    cout << dp[H][W] << endl;
}


Measured memory_bytes: 9088
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <utility>
#include <tuple>
#include <random>
#include <map>
using namespace std;

const double pi = acos(-1);
#define nyan cout << "(=^•ω•^=)" << endl;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define loop while(true)
#define YN(f) f?cout<<"YES"<<endl:cout<<"NO"<<endl;
#define yn(f) f?cout<<"Yes"<<endl:cout<<"No"<<endl;

int n;
int a[200000];
int b[200000];
int sum[2];
int more[200000];
int num_more;
int les;
int ans;

signed main(){
	cin>>n;
	rep(i,n){
		cin>>a[i];
		sum[0]+=a[i];
	}
	rep(i,n){
		cin>>b[i];
		sum[1]+=b[i];
	}
	if(sum[0]<sum[1]){
		cout<<-1<<endl;
		return 0;
	}
	rep(i,n){
		if(a[i]>=b[i]){
			more[num_more]=a[i]-b[i];
			num_more++;
		}
		else{
			les+=b[i]-a[i];
			ans++;
		}
	}
	if(les==0){
		cout<<0<<endl;
		return 0;
	}
	sort(more,more+num_more);
	reverse(more,more+num_more);
	for(int i=0;i<num_more;i++){
		les-=more[i];
		if(les<=0){
			ans+=i+1;
			break;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3456
#include <iostream>
#include<string>
#include<algorithm>
using namespace std;



int main() {
	int N;
	cin >> N;
	int long long power = 1;
	for (int i = 1; i <= N; i++) {
		power = power * i % 1000000007;
	}
	cout << power;
	return 0;
}

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

long long h, w, a, b;
vector<string> ans;

bool solve();

int main() {
  cin >> h >> w >> a >> b;
  if(solve()) {
    for(int i = 0; i < h; ++i) cout << ans[i] << endl;
  }
  else
    cout << "No" << endl;
  return 0;
}

bool solve() {
  ans.resize(h);
  string t;
  for(int i = 0; i < w; ++i) {
    if(i < a)
      t += '0';
    else
      t += '1';
  }
  for(int i = 0; i < h; ++i) {
    for(int j = 0; j < w; ++j) {
      if(i < b)
        ans[i] += t[j];
      else
        ans[i] += '1' - (t[j] - '0');
    }
  }
  return 1;
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
const int maxN = 25;

vector<pair<int, int> > g[maxN];

vector<int> vv;

int beginNode = 1;
int nNode = 1;

void brute(int u, int curSum) {
    if(u == nNode)
        vv.push_back(curSum);

    for(auto v : g[u]) {
        brute(v.first, curSum + v.second);
    }
}

pair<int, int> label[55];

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

    int l;  cin >> l;
    l--;

    vector<array<int, 3> > edg;

    int N = 0;

    if(l == 1) {
        cout << "2 2\n";
        cout << "1 2 0\n";
        cout << "1 2 1\n";
        return 0;
    }

    for(int i = 0; i < 20; i++)
        if(l & (1 << i))
            N = i;

    for(int i = N - 1; i >= 0; i--) {
        nNode++;
        edg.push_back({nNode - 1, nNode, 1 << i});
        label[i] = {nNode - 1, nNode};
    }

    int sum = (1 << N);
    for(int i = N - 1; i >= 0; i--) {
        if(l & (1 << i)) {
            edg.push_back({1, label[i].second, sum});
            sum += (1 << i);
        }
    }

    edg.push_back({1, nNode, l});

    for(int i = 1; i + 1 <= nNode; i++)
    edg.push_back({i, i + 1, 0});

    assert(nNode <= 20);
    assert((int)edg.size() <= 60);

    cout << nNode << ' ' << (int)edg.size() << '\n';
    for(auto curEdg : edg) {
        for(auto x : curEdg)
            cout << x << ' ';
        cout << '\n';
//
//        g[curEdg[0]].emplace_back(curEdg[1], curEdg[2]);
    }

//    int L = l + 1;
//    brute(1, 0);
//
//    if((int)vv.size() != L) {
//        cerr << "cac\n";
//        return 0;
//    }
//
//
//    cerr << "SIZE " << (int)vv.size() << ' ' << L << '\n';
//
//    sort(vv.begin(), vv.end());
//
//    for(int i = 0; i < (int)vv.size(); i++) {
//        if(vv[i] != i)
//            return cerr << "an cuc roi\n", 0;
//
//        //cerr << vv[i] << '\n';
//    }

    return 0;
}


Measured memory_bytes: 3648
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
const int Dx[8] = {0,1,1,1,0,-1,-1,-1}, Dy[8] = {-1,-1,0,1,1,1,0,-1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
int a, b, c, x, y;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >>a>>b>>c>>x>>y;
    if(a+b<=2*c){
        cout<<a*x+b*y<<"\n";
        return 0;
    }
    else{
        int ans;
        if(x>y){
            ans=2*c*y+a*(x-y);
        }
        else{
            ans=2*c*x+b*(y-x);
        }
        ans=min(ans,2*c*max(x,y));
        cout <<ans<< "\n";
    return 0;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include<stdio.h>
#include<algorithm>
#define PI 3.14159265
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define SZ(x) ((int)(x).size())

using namespace std;

int main() {
	int n,ans;
	ll a[10000];
	cin >> n;
	ans = 0;
	REP(i, n) {
		cin >> a[i];
		while(a[i] % 2 == 0){
			a[i] = a[i] / 2;
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
n=int(input())
B = list(map(int,input().split()))
A = []
for i in range(n-1):
  if i == 0:
    A.append(B[i])
    A.append(B[i])
  else:
    if B[i] <= A[i]:
      A[i] = B[i]
      A.append(B[i])
    else:
      A.append(B[i])

print(sum(A))

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

int main(){
  long long int   N, K;
  string S;
  cin >> N >> K;
  vector<long long int> P(N);
  for(long long int i = 0; i < N; i++) cin >> P[i];
  
  sort(P.begin(),P.end());
  long long int ans = 0;
  for(long long int i = 0; i < K; i++) ans += P[i];
  cout << ans << endl;
}


Measured memory_bytes: 3616
s=input()
if len(s)==2:
  if s[0]==s[1]:
    print(1,2)
    exit()
for i in range(len(s)-2):
  if s[i]==s[i+1] or s[i]==s[i+2] or s[i+1]==s[i+2]:
    print(i+1,i+3)
    exit()
print(-1,-1)

Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <ctime>
#include <algorithm>
#include <cstdlib>
#include <fstream>
#include <set>
#include <queue>

using namespace std;

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

	int a, b;
	cin >> a >> b;
	map<int, int> cost;
	if (a == 1 && b == 1) {
		cout << "Draw" << endl;
		return 0;
	}
	if (a == 1) {
		cout << "Alice" << endl;
		return 0;
	}
	if (b == 1) {
		cout << "Bob" << endl;
		return 0;
	}
	if (a == b) cout << "Draw" << endl;
	if (a > b) cout << "Alice" << endl;
	if (a < b) cout << "Bob" << endl;

	return 0;
}

Measured memory_bytes: 256
def main():
  n = int(input())
  d = list(map(int,input().split()))
  ans = 0 
  d.sort()# distructive sort of list d
  if d[n//2 -1] != d[n//2]:
    ans = d[n//2] -d[n//2 -1] 
  print(ans)
main()


Measured memory_bytes: 52776
int main(void)
{
	int n, temp;
	int sum = 0;

	scanf("%d", &n);
	temp = n;
	for (int i = 0; i < 10; i++) {
		sum += temp % 10;
		temp /= 10;
	}
	if (n % sum == 0) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define maxn 100005
#define ll long long
#define mod 1000000007
using namespace std;

typedef pair<ll, ll> P;

int n;
int f[maxn];
ll cnt[maxn];
vector<int> v[maxn];

int getf(int x)
{
    return (f[x] == x) ? x : f[x] = getf(f[x]);
}

void unite(int x, int y)
{
    x = getf(x);
    y = getf(y);
    if (x != y)
        f[y] = x;
}

map<int, bool> mp;

int main()
{
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        int x, y;
        scanf("%d%d", &x, &y);
        v[x].push_back(y);
    }
    for (int i = 1; i < maxn; i++)
        f[i] = i;
    for (int i = 1; i < maxn; i++)
    {
        for (int j = 0; j + 1 < v[i].size(); j++)
            unite(v[i][j], v[i][j + 1]);
    }
    for (int i = 1; i < maxn; i++)
    {
        cnt[getf(i)]++;
    }

    ll ans = 0;
    for (int i = 1; i < maxn; i++)
    {
        mp.clear();
        for (int j = 0; j < v[i].size(); j++)
        {
            if (mp[getf(v[i][j])])
                continue;
            mp[getf(v[i][j])] = 1;
            ans += cnt[getf(v[i][j])];
        }
    }
    printf("%lld", ans - n);

    return 0;
}

Measured memory_bytes: 5376
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};

int n;ll a[200010];
ll dp[200010][4][2];

void solve(){
  cin >> n;
  rep(i,n){
    cin >> a[i];
  }
  rep(i,n+1){
    rep(j,4){
      rep(flag,2){
        dp[i][j][flag]=-INF;
      }
    }
  }
  dp[0][0][0]=0;
  rep(i,n){
    rep(j,3){
      dp[i+1][j][1]=max(dp[i+1][j][1],dp[i][j][0]+a[i]);
      if(j<2)dp[i+1][j+1][0]=max(dp[i+1][j+1][0],dp[i][j][0]);
      dp[i+1][j][0]=max(dp[i+1][j][0],dp[i][j][1]);
    }
  }
  // rep(i,n+1){
  //   rep(j,3){
  //     rep(flag,2){
  //       cout << i << " " << j << " " << flag << " " << dp[i][j][flag] << endl;
  //     }
  //   }
  // }
  if(n%2) cout << max(dp[n][1][0],dp[n][2][1]) << endl;
  else cout << max(dp[n][0][0],dp[n][1][1]) << endl;
}

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

Measured memory_bytes: 17716
#include <iostream>
using namespace std;
typedef long long LL;

int main()
{
	LL k,a,b;
	while(cin>>k>>a>>b){
		//1次达标情况 
		if(a>=k)
			cout<<1<<endl;		
		//不可能达标情况 
		else if(a<=b){
			cout<<-1<<endl;
		}
		//一般情况 
		else{
			LL n,m;
			n=k/(a-b);
			for(int i=a;i>=0;i--){
				if((a-b)*(n-i)+a>=k){
					m=2*(n-i)+1;
					break;
				}			
			}
			cout<<m<<endl;
		}		
	}
	return 0;
}

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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
// static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

int main(void) {
    vector<vector<int>> c(3, vector<int>(3, 0));

    for(int i=0;i<3;i++) {
        for(int j=0;j<3;j++) {
            cin >> c.at(i).at(j);
        }
    }

    if(c.at(2).at(0)-c.at(1).at(0)==c.at(2).at(1)-c.at(1).at(1)&&c.at(2).at(1)-c.at(1).at(1)==c.at(2).at(2)-c.at(1).at(2)) {
        ;
    }
    else {
        cout << "No" << endl;
        return 0;
    }
    if(c.at(1).at(0)-c.at(0).at(0)==c.at(1).at(1)-c.at(0).at(1)&&c.at(1).at(1)-c.at(0).at(1)==c.at(1).at(2)-c.at(0).at(2)) {
        ;
    }
    else {
        cout << "No" << endl;
        return 0;
    }
    if(c.at(0).at(0)-c.at(0).at(1)==c.at(1).at(0)-c.at(1).at(1)&&c.at(1).at(0)-c.at(1).at(1)==c.at(2).at(0)-c.at(2).at(1)) {
        ;
    }
    else {
        cout << "No" << endl;
        return 0;
    }
    if(c.at(0).at(1)-c.at(0).at(2)==c.at(1).at(1)-c.at(1).at(2)&&c.at(1).at(1)-c.at(1).at(2)==c.at(2).at(1)-c.at(2).at(2)) {
        ;
    }
    else {
        cout << "No" << endl;
        return 0;
    }
    
    cout << "Yes" << endl;
    return 0;
}


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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int N; cin >> N;
	vll arr (N);
	F0R(i, N) cin >> arr[i];
	sort(arr.begin(), arr.end());
	ll total = 0;
	F0R(i, N-1) total += arr[i];
	int x = N - 2;
	while (x >= 0) {
		if (2 * total < arr[x+1]) break;
		total -= arr[x--];
	}
	print(N - x - 1);
}

Measured memory_bytes: 1024
test=list(map(int, input().split()))
 
def iroha():
    if test==[5,5,7]:
        print("YES")
    elif test==[5,7,5]:
        print("YES")
    elif test==[7,5,5]:
        print("YES")
    else:
        print("NO")
 

iroha()

Measured memory_bytes: 2940
S=input()

def solve():
  temp=0
  if S[0]!='A':
    print('WA')
    return
  if not 'a'<=S[1]<='z':
    print('WA')
    return
  for i in range(2,len(S)-1):
    if S[i]=='C':
      temp+=1
      if temp>1:
        print('WA')
        return
  if temp==0:
    print('WA')
    return
    
  if not 'a'<=S[len(S)-1]<='z':
    print('WA')
    return
  
  print('AC')

solve()

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

a, b, k = map(int, input().split())

if b-a < 2*k:
    for i in range(a, b+1):
        print(i)
else:
    for i in range(a, a+k):
        print(i)
    for i in range(b-k+1, b+1):
        print(i)


Measured memory_bytes: 3060
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <string>
#include <cstring>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <ctime>
#include <vector>
#include <fstream>
#include <list>
#include <iomanip>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define ms(s) memset(s, 0, sizeof(s))
const int INF = 1e9;
inline int read(){
	int X = 0,w = 0 ;
	char ch = 0;
	while(!isdigit(ch)) {w |= ch == '-';ch = getchar();}
	while(isdigit(ch)) X = (X<<3) + (X<<1) + (ch ^ 48),ch = getchar();
	return w ? -X : X;
}

vector<int> edg[10005];
bool vis[100005];
void dfs(int x)
{
	if(vis[x])
		return;
	vis[x]=true;
	for(int i=0;i<edg[x].size();i++)
	{
		dfs(edg[x][i]);
	}
}
int main() 
{
	for(int i=0;i<3;i++)
	{
		int x,y;
		cin>>x>>y;
		edg[x].push_back(y);
		edg[y].push_back(x);
	}
	dfs(1);
	for(int i=1;i<=4;i++)
	{
		if(!vis[i])
		{
			cout<<"NO";
			return 0;
		}
	}
	int cnt=0;
	for(int i=1;i<=4;i++)
	{
		if(edg[i].size()%2)
		{
			cnt++;
		}
	}
	if(cnt==0 or cnt==2)
	{
		cout<<"YES";
	}
	else
	{
		cout<<"NO";
	}
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<cstring>
using namespace std;
int tx,ty,ax[4005],ay[4005],dp[4005][16005];
void dfsx(int s,int n){
	if(dp[s][n+8000])
		return;
	if(s<tx){
		dfsx(s+1,n+ax[s]);
		dfsx(s+1,n-ax[s]);
	}
	dp[s][n+8000]=1;
}
void dfsy(int s,int n){
	if(dp[s][n+8000])
		return;
	if(s<ty){
		dfsy(s+1,n+ay[s]);
		dfsy(s+1,n-ay[s]);
	}
	dp[s][n+8000]=1;
}
int main(){
	string s;
	int x,y,n,fx=1;
	cin>>s>>x>>y;
	n=s.size();
	for(int i=0;i<n;i++){
		if(s[i]=='F'){
			if(fx)
				ax[tx]++;
			else
				ay[ty]++;
		}
		else{
			if(fx){
				fx=0;
				tx++;
			}
			else{
				fx=1;
				ty++;
			}
		}
	}
	if(s[n-1]=='F'){
		if(fx)
			tx++;
		else
			ty++;
	}
	dfsx(1,ax[0]);
	int bx=dp[tx][x+8000];
	memset(dp,0,sizeof(dp));
	dfsy(0,0);
	int by=dp[ty][y+8000];
	if(bx&&by)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

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

typedef long long ll;
typedef vector< int > vi;
typedef vector< ll > vl;

int N;
vi T, A;

void init(){
    cin >> N;
    T = vi( N );
    A = vi( N );
    for( int i = 0; i < N; ++i )
        cin >> T[ i ] >> A[ i ];
}

void solve(){
    ll a = 1, b = 1;
    for( int i = 0; i < N; ++i ){
        ll u = max( ( a + T[ i ] - 1 ) / T[ i ], ( b + A[ i ] - 1 ) / A[ i ] );
        a = u * T[ i ], b = u * A[ i ];
    }
    cout << a + b << endl;
}

signed main(){
    ios::sync_with_stdio( 0 );
    init();
    solve();
    return 0;
}


Measured memory_bytes: 256
import math
a, b, h, m = map(int, input().split())

rad1 = math.pi*2*(h/12 + m/720 - m/60)
rad2 = math.pi*2*(1-h/12 - m/720 + m/60)
kaku = min(abs((30*h+0.5*m)-60*m), abs(360-(30*h+0.5*m)+60*m))
if kaku == 180:
    print(a+b)
elif kaku == 0:
    print(abs(a-b))
else:
    rad = min(rad1, rad2)
    print(math.sqrt(a**2 + b**2 - 2*a*b*math.cos(rad)))

Measured memory_bytes: 9592
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
const long long INF = 1e16;
typedef long long ll;

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

  vector <string> S(N);
  for (int i = 0; i < N; i++){
    vector <char> s(10);
    for (int j = 0; j < 10; j++){
      cin >> s[j];
    }
    sort(s.begin(), s.end());

    for (int j = 0; j < 10; j++){
      S[i] += s[j];
    }
  }
  sort(S.begin(), S.end());

  ll ans = 0; ll cnt = 1;
  for (int i = 0; i < N - 1; i++){
    if (S[i] == S[i + 1]){
      cnt++;
    }else{
      ans += cnt * (cnt - 1) / 2;
      cnt = 1;
    }
  }
  ans += cnt * (cnt - 1) / 2;

  cout << ans << endl;

  return 0;
}


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

int n, m, sum;
string ans = "Yes";

int main() {
  cin >> n >> m;
  vector<int> a(n);
  rep (i, n) {
    cin >> a.at(i);
  }
  sum = 0;
  rep (i, n) {
    sum += a.at(i);
  }
  sort(a.begin(), a.end());
  if (a.at(n - m) * 4 * m < sum) ans = "No";
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
S = input()

flag = 1
c_count = 0
ans = 'AC'
if S[0] != 'A':
  ans = 'WA'
for i in range(1,len(S)):
  if (i == 1 or i == len(S)-1) and S[i].islower() == False:
    ans = 'WA'
  elif 2 <= i <= len(S)-2:
      if S[i] == 'C':
        c_count += 1
if c_count != 1:
  ans = 'WA'
print(ans)

Measured memory_bytes: 9128
// 最大値を求める
// 逐次最小を保存しておいて計算量を減らす
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int R[n];
    for(int i = 0; i < n; i++){
        cin >> R[i];
    }
    int ma = INT_MIN;
    int mi = R[0];
    for(int i = 1; i < n; i++){
        ma = max(ma, R[i]-mi);
        mi = min(mi,R[i]);
    }
    cout << ma << endl;

}


Measured memory_bytes: 3876
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
using namespace std;

int main(){
    string S;
    cin >> S;
    int N = S.size();
    int ans0 = 0, ans1 = 0;
    for(int i=0; i<N; i++){
        if(i % 2 == 0 && S[i] == '0')
            ans0++;
        if(i % 2 == 1 && S[i] == '1')
            ans0++;
    }
    for(int i=0; i<N; i++){
        if(i % 2 == 0 && S[i] == '1')
            ans1++;
        if(i % 2 == 1 && S[i] == '0')
            ans1++;
    }
    cout << min(ans0, ans1) << endl;
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#include <array>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;

void Solve(){
    UL ans = 0;
    UL a; cin >> a;
    ans = 1;
    while(ans <= a) ans *= 2;
    cout << ans / 2 << endl;
}

int main(){
    Solve();
    return 0;
}



Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define puts(i) cout<<i<<endl
#define pi 3.14159265358979
using ll = long long;
using P = pair<int,int>;

ll divisor=998244353;
int main(){
	string s;
	int k;
	cin>>k>>s;
	if((int)s.size()>k){
		string str=s.substr(0,k);
		str = str+"...";
      	puts(str);
	}else{
		puts(s);
	}
}


Measured memory_bytes: 3632
/*
 * ID: ALDS1_1_B
 * Problem: Greatest Common Number
 */

#include <stdio.h>

void swap(int *a, int *b)
{
    int t;
    t = *a;
    *a = *b;
    *b = t;
}

int main(void)
{
    int x, y;

    scanf("%d %d", &x, &y);

    while (x >= 1) {
        if (y > x)
            swap(&x, &y);
        x %= y;

        //printf("%d %d\n", x, y);
    }
    printf("%d\n", y);

    return 0;
}



Measured memory_bytes: 2104
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <math.h>
#include <stdlib.h>
#include <algorithm>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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

//INT_MAX	2,147,483,647 = 2*1.0e9

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

  int a = N.length();
  int n_int = stoi(N);

  int ans = 0;

  switch (a){
    case 1: ans = n_int - 0; break;
    case 2: ans = 9; break;
    case 3: ans = 9 + n_int - 99; break;
    case 4: ans = 9 + 900; break;
    case 5: ans = 9 + 900 + n_int - 9999; break;
    case 6: ans = 9 + 900 + 90000;
    default: break;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 384
import { getMaxListeners } from 'cluster';

namespace sample {
  class Scanner {
    private buffer = '';
    private stdinQueue: any = [];

    constructor() {
      process.stdin.resume();
      process.stdin.setEncoding('utf8');
      process.stdin.on(
        'data',
        (chunk): void => {
          this.buffer += chunk;
          while (this.stdinQueue.length > 0) {
            const i = this.buffer.indexOf('\n');
            if (i < 0) {
              break;
            }
            let line = this.buffer.substr(0, i);
            if (line.endsWith('\r')) {
              line = line.slice(0, -1);
            }
            this.buffer = this.buffer.substr(i + 1);
            this.stdinQueue.shift()(line);
          }
        },
      );
    }
    public getLine(): Promise<string> {
      return new Promise((resolve, reject) => {
        const i = this.buffer.indexOf('\n');
        if (i >= 0 && this.stdinQueue.length == 0) {
          let line = this.buffer.substr(0, i);
          if (line.endsWith('\r')) {
            line = line.slice(0, -1);
          }
          this.buffer = this.buffer.substr(i + 1);
          resolve(line);
        } else {
          this.stdinQueue.push(resolve);
        }
      });
    }

    public close(): void {
      process.stdin.pause();
    }
  }

  async function slove() {
    const sc = new Scanner();
    const [A, B, C] = (await sc.getLine()).split(' ').map((x) => +x);
    const K = +(await sc.getLine());
    let maxNum = Math.max(A, B, C);
    let ans = A + B + C - maxNum;
    for (let i = 0; i < K; i++) {
      maxNum *= 2;
    }
    ans += maxNum;
    console.log(ans);
    sc.close();
  }

  slove();
}


Measured memory_bytes: 7500
n = int(input())
a_list = list(map(int, input().split()))

a_list_min = sorted(a_list)
ai = a_list_min[-1]

mid_ai = ai // 2

for i in range(n):
    if a_list_min[i] >= mid_ai:
        if i == 0:
            aj = a_list_min[i]
        elif i == n-1:
            aj = a_list_min[i-1]
        else:
            if a_list_min[i] - mid_ai > mid_ai - a_list_min[i-1]:
                aj = a_list_min[i-1]
            else:
                aj = a_list_min[i]
        break
print(ai, aj)
    

Measured memory_bytes: 19916
while True:
    try:
        n = int(input())
    except:
        break
    x = 0
    for a in range(0, 10):
        for b in range(0, 10):
            for c in range(0, 10):
                for d in range(0, 10):
                    x += (a + b + c + d == n)
    print(x)



Measured memory_bytes: 5592
#include<iostream>
#include<algorithm>
#include<stdio.h>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	if(b==100)b++;
	if(a==0)cout<<b<<endl;
	else if(a==1)cout<<b*100<<endl;
	else cout<<b*10000<<endl;
}


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

using namespace std;

int main()
{
    string str;
    cin >> str;
    
    int a_count = 0;
    int b_count = 0;
    int c_count = 0;
    
    for(int i=0; i<3; ++i){
         if(str.at(i) == 'a') ++a_count;
         else if(str.at(i)=='b') ++b_count;
         else if(str.at(i)=='c') ++c_count;
         else continue;
    }
    
    if(a_count==1 && b_count==1 && c_count==1) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000007
int mat[1002][1002];
int d[1002][1002];
bool vis[1002][1002];
bool reach[1002][1002];
int n, m, a, b, x, y;
void solve(int pp, int qq, int dx[], int dy[], int ddx[], int ddy[]) {
    
    priority_queue<pair<int, pair<int, int>>, vector<pair<int, pair<int, int>>>, greater<pair<int, pair<int, int>>>> q;
	 
	d[pp][qq] = 0;
    q.push({0, {pp, qq}});
    
    while(!q.empty()) {
    	int row = q.top().second.first;
    	int col = q.top().second.second;
    	q.pop();
    	
    	if(vis[row][col]) continue;
    	vis[row][col] = true;
    	
    	for(int i = 0; i < 4; i++) {
    		if(row + ddx[i] < 0 || row + ddx[i] >= n) continue;
    		if(col + ddy[i] < 0 || col + ddy[i] >= m) continue;
    		if(mat[row + ddx[i]][col + ddy[i]] == 0) continue;
    		
    		if(d[row][col] < d[row + ddx[i]][col + ddy[i]]) {
    			d[row + ddx[i]][col + ddy[i]] = d[row][col];
    			q.push({d[row][col], {row + ddx[i], col + ddy[i]}});
			}
		}
		for(int i = 0; i < 20; i++) {
    		if(row + dx[i] < 0 || row + dx[i] >= n) continue;
    		if(col + dy[i] < 0 || col + dy[i] >= m) continue;
    		if(mat[row + dx[i]][col + dy[i]] == 0) continue;
    		
    		if(d[row][col] + 1 < d[row + dx[i]][col + dy[i]]) {
    			d[row + dx[i]][col + dy[i]] = d[row][col] + 1;
    			q.push({d[row][col] + 1, {row + dx[i], col + dy[i]}});
			}
		}
	}
		 
}
signed main() {
	//freopen("in.txt", "r",stdin);
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);

	int dx[20] = {-2,-2,-2,-2,-2,-1,-1, 0,0,1, 1,2,2,2,2,2,-1,-1,1,1};
	int dy[20] = {-2,-1, 0, 1, 2,-2, 2,-2,2,-2,2,-2,-1,0,1,2,-1,1,-1,1};
	int ddx[4] = {1,-1,0,0};
	int ddy[4] = {0,0,1,-1};
	cin >> n >> m >> a >> b >> x >> y;
	--a, --b, --x, --y;
	string s;
	for(int i = 0; i < n; i++) {
	    cin >> s;
	    for(int j = 0; j < m; j++) {
	        mat[i][j] = (s[j] == '.');
	    }
	}
	for(int i = 0; i < n; i++) {
	    for(int j = 0; j < m; j++) {
	        d[i][j] = inf;
	        vis[i][j] = false;
	    }
	}
	solve(a, b, dx, dy, ddx, ddy);
	
	cout << (d[x][y] > 9999999 ? -1 : d[x][y]);
}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    int x, y;
    cin >> x >> y;
    if((x < 0) && (y < 0)){
        if(x <= y){
            cout << y - x << endl;
            return 0;
        }
        cout << 2 + (-y) - (-x) << endl;
        return 0;
    }
    if((x >= 0) && (y >= 0)){
        if(y >= x){
            cout << y - x << endl;
            return 0;
        }
        if(y == 0) y++;
        cout << 2 + x - y << endl;
        return 0;
    }
    if((x < 0) && (y >= 0)){
        if(-x <= y){
            cout << 1 + y - (-x) << endl;
            return 0;
        }
        if(y == 0) y++;
        cout << 1 + (-x) - y << endl;
        return 0;
    }
    if((x >= 0) && (y < 0)){
        if(-x <= y){
            cout << 1 + y - (-x) << endl;
            return 0;
        }
        cout << 1 + (-y) - x << endl;
        return 0;
    }
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	int memo[60];
	REP(i, 60)
		memo[i] = 999;
	int mi=0;
	int count = 0;
	REP(i, 60){
		REP(j, a){
			memo[mi] = min(count, memo[mi]);
			mi++;
			if (mi >= 60){
				mi %= 60;
				count++;
			}
		}
			memo[mi] = min(count, memo[mi]);
		REP(j, b){
			mi++;
			if (mi >= 60){
				mi %= 60;
				count++;
			}
			//memo[mi] = min(i, memo[mi]);
		}
		if (mi == 0)break;
	}
	if (memo[c] != 999)
		cout << 60 * memo[c] + c << endl;
	else
		cout << -1 << endl;
}

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

def f(n):
  s=1
  t=0
  while s <= n:
    if n%s==0:
      t+=1
    s+=1
  return (t==8 and n%2==1)

S=1
T=0
while S<=n:
  T=T + (1 if f(S) else 0)
  S+=1
print(T)
    

Measured memory_bytes: 3060
import sys

A, B, K = [int(num) for num in input().split()]

if A + B <= K:
    A = 0
    B = 0
    print(A, B)
    sys.exit(0)

if A > K:
    A = A - K
    print(A, B)
    sys.exit(0)
else:
    K = K - A
    A = 0

if B > K:
    B = B - K
    print(A, B)
    sys.exit(0)
else:
    B = 0
    print(A, B)


Measured memory_bytes: 3060
#include <stdio.h>
void swap(long long int &a, long long int &b) {
	long long int temp = a;
	a = b;
	b = temp;
	return ;
}
long long int min(long long int a,long long int b) {return a > b ? b : a;}
int main() {
	long long int n, a, b, ta, tb, lans = 0, rans = 0;
	scanf("%lld%lld%lld", &n, &a, &b);
	if (a > b) swap(a, b);
	if ((a - b) & 1) {
		ta = a;
		tb = b;
		lans += ta - 1;
		tb -= ta - 1;
		ta = 1;
		lans++;
		tb--;
		lans += (tb - ta) >> 1;
		ta = a;
		tb = b;
		rans += n - tb;
		ta += n - tb;
		tb = n;
		ta++;
		rans++;
		rans += (tb - ta) >> 1;
		printf("%lld\n", min(lans, rans));
	}
	else printf("%lld\n", (b - a) >> 1);
}


Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main(void) {
  int N;
  bool P=true, W=true, G=true, Y=true;
  char *S;
  cin >> N;
  S = (char *)malloc(sizeof(char) * N);

  for(int i=0;i < N;i++) {
    cin >> S[i];
  }
  /*
  for(int i=0;i < N;i++) {
    if (P && S[i] == 'P') {
      P = false;
    } else if (W && S[i] == 'W') {
      W = false;
    } else if (G && S[i] == 'G') {
      G = false;
    } else if (Y && S[i] == 'Y') {
      Y = false;
    }
  }

  if (P || W || G || Y) {
    cout << "Three" << endl;
  } else {
    cout << "Four" << endl;
  }
  */

  for(int i=0;i < N;i++) {
    if (Y && S[i] == 'Y') {
      Y = false;
    }
  }

  if (Y) {
    cout << "Three" << endl;
  } else {
    cout << "Four" << endl;
  }

  return 0;
}


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

int mod = 1e9 + 7;

long long modpow(long long x, long long y){
    if (y == 0) return 1;
    if (y % 2) return x * modpow(x, y - 1) % mod;
    long long res = modpow(x, y / 2);
    return res * res % mod;
}

int main(){
    vector<long long> fac(1e5 + 1, 1);
    for (int i = 2; i < 1e5 + 1; i++) fac[i] = fac[i - 1] * i % mod;
    vector<long long> inv(1e5 + 1, 1);
    for (int i = 2; i < 1e5 + 1; i++) inv[i] = modpow(fac[i], mod - 2);
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(), a.end());
    long long ans = 0;
    for (int i = 0; i < n; i++){
        long long minus = 0;
        if (n - i >= k) minus = (fac[n - i - 1] * inv[k - 1] % mod) * inv[n - i - k] % mod;
        long long plus = 0;
        if (i + 1 >= k) plus = ((fac[i]) * inv[k - 1] % mod) * inv[i - k + 1] % mod;
        ans += ((mod + plus - minus) % mod) * (mod + a[i]) % mod;
        ans %= mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 2176
using System;

namespace _20200322
{
    class Program
    {
        static void Main()
        {
            var input = Console.ReadLine().Split(' ');
            var n = int.Parse(input[0]);
            var m = int.Parse(input[1]);
            Console.WriteLine(n * (n - 1) / 2 + m * (m - 1) / 2);
        }
    }
}


Measured memory_bytes: 13140
n=int(input())
v=list(map(int,input().split()))
plus=0
x=0
for i in range(n):
    plus+=v[i]
    if plus>=sum(v)/2:
        x=i
        break
ans=min(abs(sum(v[:x+1])-sum(v[x+1:])),abs(sum(v[:x])-sum(v[x:])))
print(ans)

Measured memory_bytes: 3064
//#include<map>
//#include<queue>
//#include<cmath>
#include<cstdio>
#include<string>
#include<cstring>
#include<cstdlib>
#include<iostream>
//#include<algorithm>
using namespace std;
#define N 100010
#define int long long
#define debug cout<<__LINE__<<" "<<__FUNCTION__<<"\n"
int n,k;
string s;
signed main(){
// 	freopen(".in","r",stdin);
// 	freopen(".out","w",stdout);
	cin>>s>>k;
	n=s.length();
	if(n==1){
		cout<<(k>>1)<<"\n";
		return 0;
	}
	int ans=0,res=1;
	for(int i=1;i<n;i++){
		if(s[i]==s[i-1]){++res;}
		else{
			ans+=(res>>1);
			res=1;
		}
	}
	ans+=(res>>1);
	ans*=k;
	int l=0,r=n-1;
	if(s[0]==s[n-1]){
		while(l<=n-1&&s[l]==s[n-1]) ++l;
		--l;
		while(r>=0&&s[r]==s[0]) --r;
		++r;
//		cout<<l<<" "<<r<<"\n";
		if(r==0||l==n-1){
			cout<<((n*k)>>1)<<"\n";
			return 0;
		}
		ans-=(k-1)*(((l+1)>>1)+((n-r)>>1));
		l+=n;
//		len=l-r+1;
		ans+=(k-1)*((l-r+1)>>1);
//		cout<<l<<" "<<r<<" "<<((l-r+1)>>1)<<"\n";
	}
	
	cout<<ans<<"\n";
//	fclose(stdin);
//	fclose(stdout);
    return 0;
}


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

object Helpers {
  def readIntLine = readLine.split(" ").map(_.toInt)
  def readInts(n: Int) = Array.fill(n)(readInt)
  def readLines(n: Int) = Array.fill(n)(readLine)

  def splitDigits(i: Int): Seq[Int] = i.toString.map(_.asDigit)

  def log[A](x: A): A = {println(x); x}

  implicit class IntImplicits(val i: Int) {
    def isEven = i % 2 == 0
    def isOdd = !isEven

    def ** (exp: Int): Int = scala.math.pow(i, exp).intValue
  }

  implicit class LongImplicits(val i: Long) {
    def isEven = i % 2 == 0
    def isOdd = !isEven

    def ** (exp: Long): Long = scala.math.pow(i, exp).longValue
  }

  def mycomb[T](n: Int, l: List[T]): List[List[T]] =
    n match {
      case 0 => List(List())
      case _ => for(el <- l;
                sl <- mycomb(n-1, l dropWhile { _ != el } ))
                yield el :: sl
  }
  
  def comb[T](n: Int, l: List[T]): List[List[T]] = mycomb(n, l.distinct)
}

object Main extends App {
  import Helpers._

  val Array(n, k) = readIntLine
  val ds = readLine.split(" ")

  val u = n to 100000000
  val x = u.dropWhile(_.toString.split("").exists(ds.contains))

  println(x.head)
}



Measured memory_bytes: 55480
n,m=map(int,input().split())
l=[[0,0] for i in range(n)]
for i in range(m):
    p,s=input().split()
    p=int(p)
    if s=="AC":
        if l[p-1][0]!=1:
            l[p-1][0]=1
    else:
        if l[p-1][0]!=1:
            l[p-1][1]+=1
ac=0
wa=0
for i in range(len(l)):
    ac+=l[i][0]
    if l[i][0]!=0:
        wa+=l[i][1]
print(ac,wa)

Measured memory_bytes: 17712
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;

struct s {
	int to, c;
	s(){}
	s(int to_, int c_) {
		to = to_;
		c = c_;
	}
	bool operator<(const s & obj) const {
		if(this->c == obj.c) {
			return this->to < obj.to;
		}
		return this->c > obj.c;
	}
	bool operator==(const s & obj) const {
		return this->to == obj.to && this->c == obj.c;
	}
};

int n, m;
vector<vector
 > edge;
bool visited[210];

void mk_zero_edge(int cur, int cnt, int src) {
	if(!cnt) {
		if(cur != src)
			edge[src-n].push_back(s(cur, 0));
		return;
	}

	for(int i = 0; i < edge[cur].size(); i++) {
		mk_zero_edge(edge[cur][i].to, cnt-1, src);
	}
}

int main() {
	while(cin >> n >> m, n || m) {
		edge.clear();
		edge.resize(n*2);
		for(int i = 0; i < 210; i++) visited[i] = false;

		for(int i = 0; i < m; i++) {
			int a, b, c;
			cin >> a >> b >> c;
			a--; b--;
			edge[a].push_back(s(b, c));
			edge[b].push_back(s(a, c));
			edge[a+n].push_back(s(b+n, c));
			edge[b+n].push_back(s(a+n, c));
		}
		for(int i = 0; i < n; i++) {
			mk_zero_edge(i+n, 2, i+n);
		}

		for(int i = 0; i < edge.size(); i++) {
			sort(edge[i].begin(), edge[i].end());
			edge[i].erase(unique(edge[i].begin(), edge[i].end()), edge[i].end());
		}

		priority_queue
 q;
		q.push(s(0,0));
		int res = -1;
		while(!q.empty()) {
			s cur = q.top(); q.pop();
			if(cur.to == n-1 || cur.to == n*2-1) {
				res = cur.c;
				break;
			}
			visited[cur.to] = true;
			for(int i = 0; i < edge[cur.to].size(); i++) {
				if(!visited[edge[cur.to][i].to]) {
					q.push(s(edge[cur.to][i].to, cur.c + edge[cur.to][i].c));
				}
			}
		}

		cout << res << endl;
	}
}

Measured memory_bytes: 1244
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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 INF = 1e9;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s, t;
	cin >> s >> t;
	ll n = s.size();
	vector<set<int>> v(26);
	rep(i,n){
		int id = s[i] - 'a';
		v[id].insert(i+1);
	}
	rep(i,26){
		v[i].insert(INF);
	}
	ll cur = 0, loop = 0;
	rep(i,t.size()){
		int id = t[i] - 'a';
		auto p = v[id].lower_bound(cur+1);
		if(*p == INF){
			++loop;
			cur = 0;
			p = v[id].lower_bound(0);
		}
		if(*p == INF){
			cout << -1 << endl;
			return 0;
		}
		cur = *p;
	}
	ll ans = loop * n + cur;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5200
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll INF=1e18;

struct UnionFind {
  vector<int> d;
  UnionFind(int n): d(n,-1) {}//-1で初期化
  int root(int x) {
    if (d[x] < 0) return x;//rootを負にする（構成node数x(-1))
    //root以外は親の番号
    return d[x] = root(d[x]);
    //return(root(d[x]))とするとメモできないが上の書き方だとメモができる
  }
  bool unite(int x, int y) {
    x = root(x); y = root(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x,y);
    //swapすることで小さい方を大きい方につけられ計算量減らせる
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return root(x) == root(y);}
  //同じグループ化
  int size(int x) { return -d[root(x)];}
  //グループのnode数
    int group_num(int n){
        set<int> s;
        for(int i = 0; i < n; ++i){
            s.insert(root(i));
        }
        return int(s.size());}
};



int main() {
  ll n,m;
  cin>>n>>m;
  UnionFind uf(n);
  vector<ll> g(n);
  rep(i,m){
    ll a1,b1;
    cin>>a1>>b1;
    a1--;b1--;
    uf.unite(a1,b1);
  }
  ll now=uf.group_num(n);
  cout<<now-1;
}


Measured memory_bytes: 8188
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools


sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]


def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    N, i = LI()
    print(N-i + 1)

main()


Measured memory_bytes: 67052
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <ccomplex>
#include <unordered_map>
#include <cstring>
#include <iostream>
#include <numeric>

using namespace std;
#define MAX 1000000000

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

    cout << A*B / 2 << "\n";

    return 0;
}

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

int main()
{
	char a[15];
	int count = 0,count_ = 0;

		cin >> a;

	for(int i = 0; i < 15; i++ )
	{
		if( a[i] == 'o' ){
			count++;
		}else if( a[i] == 'x' ){
			count_++;
		}else{
			break;
		}
	}
	if( count_ > 7){
		cout << "NO" << endl;
	}else{
		cout<< "YES" << endl;
	}
	return 0;
}


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

public class Main {

	public static void main(String[] args) {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		String buffer;

		int count = 0;
		int m = 0;
		int n = 0;
		int l = 0;
		int[][] matrix1 = null;
		int[][] matrix2 = null;
		try {
			while ((buffer = reader.readLine())  != null) {
				String[] input = buffer.split(" ");

				if (count == 0) {
					n = Integer.valueOf(input[0]);
					m = Integer.valueOf(input[1]);
					l = Integer.valueOf(input[2]);
					matrix1 = new int[n][m];
					matrix2 = new int[m][l];
				}
				else if (count <= n) {
					for (int i = 0; i < m; i++) {
						matrix1[count - 1][i] = Integer.valueOf(input[i]);
					}
				}
				else if (count <= n + m) {
					for (int i = 0; i < l; i++) {
						matrix2[count - 1 - n][i] = Integer.valueOf(input[i]);
					}
				}
				if (count == n + m) {
					for (int h = 0; h < n; h++) {
						for (int w = 0; w < l; w++) {
							long calc = 0;
							for (int i = 0; i < m; i++) {
								calc += matrix1[h][i] * matrix2[i][w];
							}
							System.out.print(calc);
							if (w != l - 1) {
								System.out.print(" ");
							}
							else {
								System.out.println();
							}
						}
					}
					//output
					reader.close();
					return;
				}

				count++;
			}
		} catch (Exception ex) {
			ex.printStackTrace();
		}
	}
}



Measured memory_bytes: 37864