akhauriyash/Code-Regression huggingface dataset:
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        kk: usize,
        av: [i64; n],
    }
    let _mod = 1000000007;
    let mut ans = 1;
    if kk == n {
        for a in &av {
            ans *= a;
            ans %= _mod;
        }
        if ans < 0 {
            ans += _mod;
        }
    } else {
        let mut bv = vec![];
        let mut cv = vec![];
        for a in &av {
            if *a < 0 { bv.push(a); }
            else    { cv.push(a); }
        }
        bv.sort();
        cv.sort();   
        cv.reverse();
        let mut b = 0;
        let mut c = 0;
        let mut k = kk;
        loop {
            if k > 1 {
                let mut bb = 0;
                if b+1 < bv.len()  { bb = bv[b] * bv[b+1]; }
                let mut cc = 0;
                if c+1 < cv.len()  { cc = cv[c] * cv[c+1]; }
                if bb > cc {
                    ans *= bb%_mod;
                    k -= 2;
                    b += 2;
                } else {
                    ans *= cv[c]%_mod;
                    k -= 1;
                    c += 1;
                }
                ans %= _mod;
                if k == 0 { break; }
            } else if k == 1 {
                if c < cv.len() {
                    ans *= cv[c];
                    ans %= _mod;
                } else if b < bv.len() {
                    ans = 1;
                    for i in 0..kk {
                        ans *= bv[bv.len()-i-1];
                        ans %= _mod;
                    }
                    ans += _mod;
                }
                if ans < 0 { ans += _mod; }
                break;
            }
        }
    }
    println!("{}", ans);
}

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

int main() {
  string A;
  cin>>A;
  if(A=="A") cout<<"T"<<endl;
  else if(A=="T") cout<<"A"<<endl;
  else if(A=="C") cout<<"G"<<endl;
  else if(A=="G") cout<<"C"<<endl;
  

  
}


Measured memory_bytes: 256
kind=int(input())
food=list(map(int,input().split()))
manzoku=list(map(int,input().split()))
manzokuAfter=list(map(int,input().split()))

total=0
for i in range(0,kind):
  total += manzoku[food[i]-1]
  if i!=0 and food[i-1]+1==food[i]:
    total+=manzokuAfter[food[i-1]-1]

print(total)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define int long long
#define lint long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
template <typename T> inline T LB(vector<T>& v, T a) { return *lower_bound(ALL(v),a); }
template <typename T> inline int LBP(vector<T>& v, T a) { return lower_bound(ALL(v),a) - v.begin(); }
template <typename T> inline T UB(vector<T>& v, T a) { return *upper_bound(ALL(v),a); }
template <typename T> inline int UBP(vector<T>& v, T a) { return upper_bound(ALL(v),a) - v.begin(); }
template <typename T1, typename T2> ostream& operator<< (ostream& os, const pair<T1,T2>& p) { os << p.first << " " << p.second; return os; }
template <typename T1, typename T2> istream& operator>> (istream& is, pair<T1,T2>& p) { is >> p.first >> p.second; return is; }
template <typename T> ostream& operator<< (ostream& os, const vector<T>& v) { REP(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
template <typename T> istream& operator>> (istream& is, vector<T>& v) { for(T& in : v) is >> in; return is; }
template <typename T = int> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }
template <typename T, typename V> typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) { t = v; }
template <typename T, typename V> typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) { for(auto &e : t) fill_v(e,v); }
const lint MOD = 1000000007;
const lint INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;

int N, K, Q;
int A[100010];
int p[100010];

void _main() {
    cin >> N >> K >> Q;
    REP(i, Q) {
        cin >> A[i];
        p[A[i] - 1]++;
    }
    REP(i, N) {
        int r = K - Q + p[i];
        cout << (r <= 0 ? "No" : "Yes") << endl;
    }
}

signed main(signed argc, char **argv) {
    if (argc > 1) {
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    }
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

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

int sod(int i){
  int sum = 0;
  while(i>0){
     sum += i%10;
     i /= 10;
  }
  return sum;
}

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

  int co=0;
  for(int n=1; n<=N; n++){
    if(A<=sod(n) && sod(n)<=B){
      co+=n;
    }
  }

  cout << co << endl;

  return 0;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ans=0
for i in range(n):
  if a[i]>=b[i]:
    ans+=b[i]
  elif b[i]>=a[i]+a[i+1]:
    ans+=a[i]+a[i+1]
    a[i+1]=0
  else:
    ans+=b[i]
    a[i+1]-=b[i]-a[i]
print(ans)

Measured memory_bytes: 18476
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <unordered_set>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

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

	int s;
	
	cin >> s;

	std::vector<int> a;
	//unordered_set<int> b;

	a.pb(0);
	a.pb(s);
	
	int i = 1;

	while(true)
	{
		int tmp = -1;
		if (a[i] & 1)
		{
			//a.pb(a[i] * 3 + 1);
			tmp = a[i] * 3 + 1;
		}
		else
		{
			//a.pb(a[i] / 2);
			tmp = a[i] / 2;
		}

		
		if (find(a.begin(), a.end(), tmp) != a.end())
		{
			break;
		}

		a.pb(tmp);
		
		i++;
	}

	cout << i+1 << endl;
	
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        
        double r = sc.nextDouble();
        
        System.out.printf("%.10f %.10f\n ", r*r*Math.PI, 2*r*Math.PI);

    }
}



Measured memory_bytes: 28072
def resolve():
    n = int(input())
    a = list(map(int,input().split()))

    mina = 2*(10**5)
    ans = 0
    for i in range(n):
        mintest = min(a[i], mina)
        if mintest >= a[i]:
            ans += 1
            mina = mintest
    print(ans)
resolve()

Measured memory_bytes: 75600
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
int main()
{
	ll n;
	cin>>n;
	ll a[n][3];
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<3;j++)
		cin>>a[i][j];
	}
	ll dp[n][3];
	memset(dp,0,sizeof dp);
	dp[0][0]=a[0][0],dp[0][1]=a[0][1],dp[0][2]=a[0][2];
	for(int i=1;i<n;i++)
	{
		dp[i][0]=a[i][0]+max(dp[i-1][1],dp[i-1][2]);
		dp[i][1]=a[i][1]+max(dp[i-1][0],dp[i-1][2]);
		dp[i][2]=a[i][2]+max(dp[i-1][0],dp[i-1][1]);
	}
	cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<endl;
}

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

signed main(){
  int N;
  cin>>N;
  vector<int> A(N);
  rep(i,N)cin>>A[i];
  
  int O=0;
  rep(i,N)O+=A[i];
  int P=(O+(N/2))/N;
  int sum=0;
  rep(i,N){
    int cons=0;
    cons=(P-A[i])*(P-A[i]);
    sum+=cons;
  }
  cout<<sum<<endl;
}

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


int main() {
    int n,k;
    cin>>n>>k;
    string s;
    cin>>s;

    s[k-1] = s[k-1]+32;
    cout<<s<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999999
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef vector<llong> LV;

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



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








}


Measured memory_bytes: 256
class UnionFind():
    def __init__(self, n):
        self.parents = list(range(n))
        self.size = [1] * n

    def find(self, x):
        if self.parents[x] == x:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.size[x] < self.size[y]:
                x, y = y, x
            self.parents[y] = x
            self.size[x] += self.size[y]

N, M = map(int, input().split())
ab = [list(map(lambda x: int(x)-1, input().split())) for _ in range(M)]
uf = UnionFind(N)

now = N*(N-1)//2
ans = [now]
for i in range(M-1):
    a = ab[M - i - 1][0]
    b = ab[M - i - 1][1]
    pa = uf.find(a)
    pb = uf.find(b)
    if pa != pb:
        now -= uf.size[pa] * uf.size[pb]
        uf.union(a, b)
    ans.append(now)
[print(a) for a in ans[::-1]]

Measured memory_bytes: 102724
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <map>
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for(int i = (a); i > (b); --i)
#define SZ(a) a.size()
#define ll long long
#define ull unsigned long long
using namespace std;

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

	int N = 0;
	int a[110];
	int A[110];

	cin >> N;
	FOR(i, 0, N)
		cin >> a[i];
	FOR(i, 0, 110)
		A[i] = 0;

	int idx = 0;
	FOR(i, 0, N) {
		if (a[i] == a[i + 1]) {
			A[idx] = 2;
			FOR(j, i+1, N) {
				if (j != N - 1) {
					if (a[j] == a[j + 1])
						++A[idx];
					else {
						++idx;
						i = j;
						break;
					}
				}
				else {
					++idx;
					i = j;
					break;
				}
			}
		}
	}

	//check
	//FOR(i, 0, N)
	//	cout << A[i] << " ";
	//cout << endl;


	int ret = 0;
	FOR(i, 0, N) {
		if (A[i] != 0)
			ret += (int)A[i] / 2;
	}

	cout << ret;
	system("pause");
	return 0;
}

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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  int N, K; scanf("%d %d", &N, &K);
  int ans = 1;
  for (int i = 0; i < N; ++i) {
    if (ans * 2 < ans + K) { ans *= 2; }
    else { ans += K; }
  }
  printf("%d\n", ans);
  return 0;
}


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

int N;
int a[100001];

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

    cin >> N;
    int b = 0;
    int bnum = 0;
    int c = 0;
    int cnum = 0;
    bool check = true;
    for(int i = 0; i < N; ++i){
        cin >> a[i];
        if(bnum == 0 || b == a[i]){
            b = a[i];
            bnum++;
        }
        else if((cnum == 0 && (b == a[i] - 1 || b == a[i] + 1)) || c == a[i]){
            c = a[i];
            cnum++;
        }
        else {
            check = false;
        }
    }
    if(!check){
        cout << "No" << endl;
        return 0;
    }

    if(cnum == 0){
        if(b * 2 <= N || b + 1 == N){
            cout << "Yes" << endl;
        }
        else {
            cout << "No" << endl;
        }
        return 0;
    }

    if(b > c){
        swap(b, c);
        swap(bnum, cnum);
    }

    if(cnum >= 2 && bnum + cnum / 2 >= c && b >= bnum){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }


    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=(0);(i)<(int)(n);++(i))
#define p(x) cout<<(x)<<endl

int main() {
  int x, y, z; cin >> x >> y >> z;
  int i = 0;
  
  while(x >= (i*y + (i+1)*z)) {
    i++;
  }
  
  p(i-1);
}


Measured memory_bytes: 256
'use strict';
const main = input => {
  input = input[0];
  if (input == 'Sunny') console.log('Cloudy');
  if (input == 'Cloudy') console.log('Rainy');
  if (input == 'Rainy') console.log('Sunny');
}
main(require("fs").readFileSync("/dev/stdin", "utf8").split('\n'));

Measured memory_bytes: 21064
#include<bits/stdc++.h>
using namespace std;
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long int
#define ull unsigned long long int  // ranges from (0 - twice of long long int)
#define rep(i,a,n) for (ll i=a;i<n;i++)
#define per(i,a,n) for (ll i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define vll vector<ll>
#define mod 1000000007LL
#define llpair pair<ll,ll>
#define INF 1000000000000000000ll
#define np next_permutation
#define PI acos(-1)
#define deb(x) cout<<#x<<" "<<x<<endl;
#define rotate_left(vec,amt) rotate(vec.begin(),vec.begin()+amt,vec.end());
#define rotate_right(vec,amt) rotate(vec.begin(),vec.begin()+vec.size()-amt,vec.end());

int main() {
  //  auto start = chrono::high_resolution_clock::now();
    fio;
    ll t=1; 
   // cin>>t;
    while(t--)
    {
		ll r; cin>>r;
		double ans= 2 * PI *r;
		cout<<ans<<"\n";
    }

   // auto finish = chrono::high_resolution_clock::now();
   // cerr << "Time elapsed: " << (chrono::duration<long double>(finish-start)).count() << "s\n";
    return 0;
        
}


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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpl;
typedef vector<vll> vvll;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define no cout<<"No"<<endl
#define NO cout<<"NO"<<endl
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

vvll edge(45,vll(2e5, -1));
vll a(2e5);
ll n,k;
vvll s(2e5);

ll jp(ll x){
  if(edge[0][x]!=-1)
    return edge[0][x];

  auto it=upper_bound(ALL(s[a[x]]),x);
  ll next;
  if(it==s[a[x]].end())
    next=s[a[x]][0];
  else
    next=*it;

  next=(next+1)%n;
  if(s[a[x]].size()==1){
    if(x==n-1)
      edge[0][x]=n;
    else
      edge[0][x]=next;
  }
  else if(next<=x)
    edge[0][x]=next;
  else
    edge[0][x]=jp(next);

  return edge[0][x];
}

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

  cin>>n>>k;
  REP(i,n)cin>>a[i];
  REP(i,n)s[a[i]].push_back(i);

  REP(i,n)
    jp(i);
  edge[0][n]=0;

  REP(i,44){
    REP(j,n+1)
      edge[i+1][j]=edge[i][edge[i][j]];
  }

  ll target=k-1;
  ll now=0;
  REP(i,45){
    if((target>>i)&1)
      now=edge[i][now];
  }

  //create ans
  set<ll> se;
  vll ans;
  for(ll i=now; i<n; i++){
    ll p=se.size();
    se.insert(a[i]);

    ll ne=se.size();
    if(p==ne){
      //pop vector
      while(ans.size()!=0){
        ll t=ans.back();
        ans.pop_back();
        se.erase(t);
        if(t==a[i])
          break;
      }
    }
    else
      ans.push_back(a[i]);

  }

  REP(i,ans.size()){
    if(i!=0)
      cout<<" ";
    cout<<ans[i];
  }
  cout<<endl;

}



Measured memory_bytes: 96788
nk = gets.chomp.split
n = nk[0].to_i
k = nk[1].to_i

a = gets.chomp.split
points = []
point = 0
n.times do |i|
    a[i] = a[i].to_i
    point += a[i]
    if i >= k - 1
        points << point
        point -= a[i - k + 1]
    end
end

(n - k).times do |i|
    former = points[i]
    latter = points[i + 1]
    puts former < latter ? "Yes" : "No"
end


Measured memory_bytes: 30920
#include <iostream>
using namespace std;
int main()
{
    // 整数の入力
    // スペース区切りの整数の入力
    string s, t;
    int m;
    cin >> s >> t;
    int x;
    for(int i=0; i<t.size(); i++){
        if(t.at(i)!='a'){
            x = 1;
            break;
        }
        if(i==t.size()-1){
            x = 0;
        }
    }
    int Min = s.size();
    int Max = -1;
    bool flag = true;
    bool Flag = false;
    for(int i=0; i<s.size(); i++){
        flag = true;
        for(int j=0; j<t.size(); j++){
            if(s[i+j]!=t[j] && s[i+j]!='?'){
                flag = false;
            }
        }
        if(flag){
            Flag = true;
            if(Min>i){
                Min = i;
            }
            if(Max<i){
                Max = i;
            }
        }
    }
    if(x){
        m = Max;
    }else{
        m = Min;
    }
    if(Flag){
        string ans;
        for(int i=0; i<s.size(); i++){
            if(m-1<i && i<m+t.size()){
                ans += t[i-m];
            }else if(s[i]=='?'){
                ans += 'a';
            }else{
                ans += s[i];
            }
        }
        cout << ans << endl;
    }else{
        cout << "UNRESTORABLE" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

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


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

int b[200005];
int main(){
    int n;
    cin >> n;
    vector<int> a(n+1);
    rep(i,n){
        cin>>a[i];
    }
    vector<int> ans;
    for(int i = n; i > 0; i--){
        int sum = 0;
        for(int j = i*2; j <= n; j+=i){
            sum ^= b[j];
        }
        b[i] = sum^a[i];
        if(b[i])ans.push_back(i);
    }
    cout << ans.size() << endl;
    for(auto e :ans){
        cout << e << " ";
    }
    cout << endl;
    
    return 0;
}

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
using namespace std;

int main() {
  int k, x;
  cin >> k >> x;

  for (int i = x - k + 1; i <= x + k - 1; i++) {
    if (i != x - k + 1) {
      cout << " ";
    }
    cout << i;
  }
  cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int MAX = 1000000;
const int INF = 1e9;
const double pi=acos(-1);
using namespace std;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main(){
  int n,k;
  cin >> n >> k;
  COMinit();
  vector<ll>vec(n);
  rep(i,n){
    cin >> vec[i];
  }
  sort(vec.begin(),vec.end());
  
  ll M=0;
  ll m=0;
  ll p;
  for(int i=1;i<=n-k+1;i++){
    p = COM(n-i,k-1)*vec[n-i];
    p%=MOD;
    M+=p;
    M%=MOD;
  }
  for(int i=1;i<=n-k+1;i++){
    p = COM(n-i,k-1)*vec[i-1];
    p%=MOD;
    m+=p;
    m%=MOD;
  }
  cout << (M-m+2*MOD)%MOD << endl;
  
  return 0;
}

Measured memory_bytes: 24448
#define _GLIBCXX_DEBUG
#define REP(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define ALL(v) v.begin(), v.end()
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
	int N;
	cin >> N;
	vector<ll> L(N+1);
	L[0] = 2, L[1] = 1;
	FOR(i, 2, N+1) L[i] = L[i-1]+L[i-2];
	cout << L[N] << endl;
}

Measured memory_bytes: 256
from math import gcd

k = int(input())
IJ = []

cnt = 0
for i in range(1, k+1):
    for j in range(1, k+1):
        IJ.append(gcd(i, j))

for ij in IJ:
    for k in range(1, k+1):
        cnt += gcd(ij, k)

print(cnt)


Measured memory_bytes: 9296
#include <bits/stdc++.h>
using namespace std; // 120
int main(){
  vector<int> fac;
  int a,b,k,i=1;
  cin >> a >> b >> k;
  fac.push_back(1);
  while (i <= min(a,b)){
    i++;
    if (a%i==0 && b%i==0){
      fac.push_back(i);
    }
  }
  sort(fac.begin(), fac.end());

  cout << fac[fac.size()-k];
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i, x, n) for (int i = x; i < (int)(n); ++i)
const int N = 1e5, M = 7 + 1e9;
int n, k, a[101], dp[101][N+1];
/*
	CHEAT MODE
*/
int main()
{
	cin >> n >> k;
	f(i, 1, n+1)
		cin >> a[i];
	dp[0][0] = 1;
	f(i, 1, n+1){
		vector<int> sum(k+1);
		f(w, 0, k+1)
			sum[w] = dp[i-1][w];
		f(w, 1, k+1)
			sum[w] = (sum[w] + sum[w-1])%M; // cumulative sum
		f(w, 0,k+1){ //sum[w-a[i] -> w ] 
			dp[i][w] = (sum[w] - (w-a[i]-1 < 0 ? 0 : sum[w-a[i]-1]) + M)%M;//rang
		}
	}
	cout << dp[n][k];
}

Measured memory_bytes: 39676
n = int(input())
a = list(map(int, input().split()))
l = [0] * 9
for i in a:
    if i >= 3200:
        l[8] += 1
    else:
        l[i // 400] += 1
mi = 0
ma = 0
for i in l[:8]:
    if i > 0:
        mi += 1
        ma += 1
if l[8] > 0:
    ma += l[8] 
if sum(l[:8]) == 0:
    print(1, l[8])
    exit()
print(mi, ma)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
const int INF = 1000000001;

int main(){
  char a, b;
  cin >> a >> b;
  if(a<b){
    cout << "<" <<endl; 
  }else if(a == b){
    cout << "=" <<endl;
  }else{
    cout << ">" <<endl;
  }
}

Measured memory_bytes: 256
n = int(input())
t = [int(i) for i in input().split()]
m = int(input())
p = [[int(i) for i in input().split()] for _ in range(m)]

for i in range(m):
  k = t[(p[i][0])-1]
  t[(p[i][0])-1] = p[i][1]
  print(sum(t))
  t[(p[i][0])-1] = k

Measured memory_bytes: 3064
#include <iostream>
#include <array>
#include <vector>
#include <algorithm>
#include <string.h>
#include <set>
#include <math.h>
#include <numeric>
#include <assert.h>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>
#include <queue>
#include <random>
#include <chrono>
#include <limits.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define ld long double
#define endl "\n"
typedef tree<pair<int, int>, null_type, less<pair<int, int> >, rb_tree_tag, tree_order_statistics_node_update> OST;
typedef tree<pair<int, int>, null_type, less_equal<pair<int, int> >, rb_tree_tag, tree_order_statistics_node_update> OST_multiset;
mt19937 rng(chrono::system_clock::now().time_since_epoch().count());
const ll inf = 1e9 + 69;
const ld pi = 3.14159265358979323L;
const ld eps = 1e-15;

void setIn(string s){freopen(s.c_str(), "r", stdin);}
void setOut(string s){freopen(s.c_str(), "w", stdout);}
void unsyncIO(){cin.tie(0) -> sync_with_stdio(0);}
int setIO_count = 0;
void setIO(string s = ""){
	if(!setIO_count){
		unsyncIO();
		setIO_count = 1;
	}
	if(s.size()){ //output only
		setIn(s + ".in");
		setOut(s + ".out");
	}
}

#define gc getchar//_unlocked //can't for window server
#define pc putchar//_unlocked //can't for window server
ll inp(){
	char c = gc(); bool neg = false;
	for(; c < '0'||'9' < c; c = gc())
		if(c == '-') neg=true;
	ll rs = c - '0'; c = gc();
	for(; '0' <= c && c <= '9'; c = gc())
		rs = (rs << 1) + (rs << 3) + (c - '0');
	if(neg) rs = -rs;
	return rs;
}
void pri(ll _n){
	ll N = _n, rev, count = 0;
	bool neg = false;
	if(N < 0){
		N = -N; neg = true;
	}
	rev = N;
	if(N == 0) {pc('0'); return;}
	if(neg) pc('-');
	while(rev % 10 == 0) {count ++; rev /= 10;}
	rev = 0;
	while(N != 0) {rev = (rev << 3) + (rev << 1) + N % 10; N /= 10;}
	while(rev != 0) {pc(rev % 10 + '0'); rev /= 10;}
	while(count --) pc('0');
}

const ll mod = 1e9 + 7;
const int N = 2 * 100 * 1000 + 5;

int main(){
	setIO("");

	int n; cin >> n;
	ll ans = 0ll;
	for(int a = 1; a <= n; a ++){
		ans += (ll)((n - 1) / a);	
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3680
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
struct UnionFind {
  vector<int> par; 

  UnionFind(int N) : par(N) { 
    rep(i,N) par[i] = i;
  }
  int root(int x) { 
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
  }
  void unite(int x, int y) {
    int rx = root(x); 
    int ry = root(y);
    if (rx == ry) return; 
    par[rx] = ry; 
  }
  bool same(int x, int y) {
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
};

int main() {
  int n;
  cin >> n;
  vector<int>x(n),y(n);
  rep(i,n){
    cin>>x.at(i)>>y.at(i);
  }
  int ans=n;
  rep(i,n){
    rep2(j,i+1,n){
      int p=x.at(j)-x.at(i);
      int q=y.at(j)-y.at(i);
      
      int co=0;
  UnionFind tree(n);
  
  rep(k,n){
    rep(l,n){
      if(x.at(k)-x.at(l)==p&&y.at(k)-y.at(l)==q){
        tree.unite(k,l);
      }     
    }
  }
  vector<bool>a(n);
  rep(i,n){
    if(!a.at(tree.root(i))){
      a.at(tree.root(i))=true;
      co++;
    }
  }
      ans=min(ans,co);
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1e17;
const int inf = 1e5;
//typedef long double ld;
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; }
ll gcd(ll a, ll b) { return a ? gcd(b%a, a) : b; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
ll mo = 998244353;
struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};
struct SegmentTree{
  int N;
  vector<int> node;
  public :
    void intit(vector<int>v){
      int sz = v.size();
      N=1;
      while(N<sz) N*=2;
      node.resize(N);
      for(int i=0 ; i<sz ; i++) node[i+N-1] = v[i];
      for(int i=N-2 ; i>=0 ; i--) node[i] = min(node[i*2+1], node[i*2+2]);
    }
    void update(int x, int val){
      x += N-1;
      node[x+N-1] = val;
      while(x>0){
        x = (x-1)/2;
        node[x] = min(node[x*2+1], node[x*2+2]);
      }
    }
    int getmin(int a, int b, int k, int l, int r){
      if(b<=l || r<=a) return inf;
      else if(a<=l && r<=b) return node[k];
      else{
        int vl = getmin(a, b, 2*k+1, l, (l+r)/2);
        int vr = getmin(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
      }
    }
};

int main(){
  int N,K;  cin>>N>>K;
  vector<int> v(K);
  vector<vector<int> > d(K);
  map<int, int> ma;
  rep(i,0,K){
    int k; cin>>k;
    rep(j,0,k){
      int st; cin>>st;
      ma[st]++;
    }
  }
  int cnt=0;
  rep(i,1,N+1){
    if(ma[i]==0) cnt++;
  }
  cout<<cnt<<endl;
  return 0;
}


Measured memory_bytes: 3632
n = gets.to_i
s = 2.times.map {gets.chomp}
m = 1000000007

if s[0][0] == s[1][0]
    ans = 3
    i = 1
    j = true
else
    ans = 6
    i = 2
    j = false
end

while i < n
    if s[0][i] == s[1][i]
        ans = ans * (j ? 2 : 1) % m
        i += 1
        j = true
    else
        ans = ans * (j ? 2 : 3) % m
        i += 2
        j = false
    end
end

puts ans

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

#define SIZE 1000

int main(){
	int i, ii;
	int a[SIZE];
	int b[SIZE];
	for(i=0;i < SIZE;i++){
		a[i] = 0;
	}
	for(i=0;i < SIZE;i++){
		b[i] = 0;
	}
	
	i = 0;
	ii = 0;
	while(1){
		scanf("%d %d", &a[i], &b[i]);
		if( (a[i] == 0) && (b[i] == 0)) break;
		i++;
		ii++;
		if(i > SIZE) break;
	}
	i = 0;
	int j, k, l;
	while(1){
		for(l=0;l<ii;l++){
			for(j=0;j<a[i];j++){
				for(k=0;k<b[i];k++){
					if( j >= 1 && j < a[i] - 1){
						if( k >= 1 && k < b[i] - 1 ){
							printf(".");
						}else{
							printf("#");
						}
					}else{
						printf("#");
					}
				}
				printf("\n");
			}
			i++;
			printf("\n");
		}
		break;
	}
	return 0;
}


Measured memory_bytes: 2024
s = input()
ans = "WA"
if s[0] == "A":
    cnt = 0
    for i in s[2:-1]:
        if i == "C":
            cnt += 1
    if cnt == 1:
        upper_cnt = 0
        for j in s:
            if j.isupper():
                upper_cnt += 1
        if upper_cnt == 2:
            ans = "AC"

print(ans)

Measured memory_bytes: 3064
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>
#include<time.h>
typedef long long int ll;
//#include<bits/stdc++.h>


using namespace std;
 


int main()
{
   
    ll n;
    cin >> n;
    ll p = 100, a = 0;;
    while (p < n) {
        p += p / 100;
        a++;

    }
    cout << a << endl;
    return 0;

}

Measured memory_bytes: 3624
N, K = map(int, input().split())
P = list(map(int, input().split()))
P = list(map(lambda x: (x + 1) / 2, P))

s = sum(P[:K])
ans = [s]
for prev_a, next_a in zip(P, P[K:]):
    s -= prev_a
    s += next_a
    ans.append(s)
print(max(ans))


Measured memory_bytes: 25060
#include<bits/stdc++.h>
#define ll long long 
#define pb push_back
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define MP make_pair
#define F first
#define S second
#define inf 10000000000000
#define vll vector<ll>
using namespace std;
const int N=5005;

void solve()
{
	ll a,b,c;
	cin>>a>>b>>c;
	if(c>a-b)
		cout<<c-a+b;
	else
		cout<<0;
}
 
int main() {
    
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
    ll t=1;
    //cin>>t;
    while(t--)
        solve();
 
    
    return 0;
}

Measured memory_bytes: 256
a=[]
for i in range(3):
    a.append(list(map(int,input().split())))
count = 0
for i in range(2):
    if ((a[i][0]-a[i+1][0]) ==(a[i][1]-a[i+1][1])) and ((a[i][2]-a[i+1][2]) ==(a[i][1]-a[i+1][1])):
        count += 1
if count == 2:
    print('Yes')
else:
    print('No')  

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

#ifdef DEBUG
#define PRINT(x)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#x<<" = "<<(x)<<endl;
#define PRINTA(a,first,last)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<(first)<<", "<<(last)<<")"<<endl;\
    for (int _i=(first);_i<(last);++_i){cout<<#a<<"["<<_i<<"] = "<<(a)[_i]<<endl;}
#define PRINTI(a,i)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<#i<<"] = "<<#a<<"["<<(i)<<"] = "<<(a)[i]<<endl;
#else
#define PRINT(x)
#define PRINTA(a,first,last)
#define PRINTI(a,i)
#endif

#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define MOD 1000000007
//#define MOD 998244353

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}
template <class T, class U> void amin(T& x, U y) {if (x > y) x = y;}

template <class T, class U>
std::ostream& operator<<(std::ostream &os, const std::pair<T, U> &p) {
	os << "(" << p.first << ", " << p.second << ")";
	return os;
}
 
template <class T>
std::ostream& operator<<(std::ostream &os, const std::vector<T> &v) {
    os << "[";
	for (int i = 0; i < v.size(); ++i) {
        if (i) {
            if (i % 5 == 0) {
                os << ",\n ";
            } else {
                os << ", ";
            }
        }
		os << v[i];
	}
	os << "]";
	return os;
}

template <class T>
using vec2 = vector<vector<T>>;

template <class T>
using vec3 = vector<vector<vector<T>>>;

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

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

    int A, B, C, K;
    cin >> A >> B >> C >> K;

    while (K && !(A < B)) {
        B *= 2;
        --K;
    }
    while (K && !(B < C)) {
        C *= 2;
        --K;
    }

    if (A < B && B < C) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }


    return 0;
}


Measured memory_bytes: 3612
#include <iostream>
using namespace std;
int main() {
  int a[3], b[3];
  int cnt[5] = {0};
  for (int i = 0; i < 3; i++) {
    cin >> a[i] >> b[i];
    cnt[a[i]]++;
    cnt[b[i]]++;
  }
  bool flag = true;
  for (int i = 1; i < 5; i++) {
    if (cnt[i] == 3) {
      flag = false;
      break;
    }
  }
  if (flag) {
    cout << "YES\n";
  }
  else {
    cout << "NO\n";
  }
  return 0;
}


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

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

    int n; cin>>n; int p[n];
    for (int i = 0; i < n; i++)cin>>p[i];
    int ans=0;
    for (int i = 0; i < n-2; i++){
        if((p[i]<p[i+1]&&p[i+1]<p[i+2])||(p[i]>p[i+1]&&p[i+1]>p[i+2]))ans++;
    }
    cout<<ans<<'\n';
}

Measured memory_bytes: 256
n=int(input())
A=list(map(int,input().split()))

d={
    2:0,
    4:0,
    1:0
}

for a in A:
    if a%4==0:
        d[4]+=1
    elif a%2==0:
        d[2]+=1
    else:
        d[1]+=1

four=d[4]
odd=d[1]
if d[2]>2:
    four+=1
    odd+=2
else:
    odd+=int((d[2]+2-1)/2)

if odd<=four+1:     # x4x4x4xみたいな感じ
    print("Yes")
else:
    print("No")

Measured memory_bytes: 14252
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=2019;
char s[200005];
ll n;
ll mod1[200005]={0};
int main(void)
{
	scanf("%s",s);
	n=strlen(s);
	ll sum=0,ten=1;
	for(ll i=0;i<n;i++) s[i]-='0';
	for(ll i=n-1;i>=0;i--)
	{
		sum+=ten*s[i];
		ten=(ten*10)%2019;
		sum%=2019;
		mod1[sum]++;
	}
	sum=mod1[0]*(mod1[0]+1)/2;
	for(ll i=1;i<2019;i++)
	{
		sum+=mod1[i]*(mod1[i]-1)/2;
	}
	printf("%lld\n",sum);
}

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

int main() {
  int N;
  cin >> N;
  int A[N][3];
  for(int i=0;i<N;i++){
    cin >> A[i][0] >> A[i][1] >> A[i][2];
  }
  int numb;
  int D;
  for(int k=0;k<N;k++){
    if(A[k][2] > 0) {
      numb++;
      D = k;
    }
  }
  bool ans1 = true;
  if(numb == 1) {
    ans1 = false;
    cout << A[D][0] << endl;
    cout << A[D][1] << endl;
    cout << A[D][2] << endl;
  } 
  bool ans = true;
  for(int i=0;i<=100;i++){
    for(int j=0;j<=100;j++){
      int H = 0;
      ans = true;
      for(int k=0;k<N;k++){
        if(A[k][2] == 0) continue;
        else if(H == 0) {
          H = A[k][2] + abs(i - A[k][0]) + abs(j - A[k][1]);
          continue;
        }
        else if(H != A[k][2] + abs(i - A[k][0]) + abs(j - A[k][1])) {
          ans = false;
          break;
        }
      }
      if(ans == true && ans1 == true) {
        cout << i << endl;
        cout << j << endl;
        cout << H << endl;
      }
    }
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#define MAX_H 505
#define MAX_W 505
using namespace std;

int grid[MAX_H][MAX_W];

typedef struct command {
    int i , j, k, l;
} C;

vector<C> v;

int main() {
    int H, W;
    cin >> H >> W;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) cin >> grid[i][j];
    }
    bool left2right = true;
    int count = 0;
    for (int i = 0; i < H; i++) {
        if (left2right) {
            for (int j = 0; j < W; j++) {
                C com;
                count++;
                if (count == H * W) continue;
                if (grid[i][j] % 2 == 1) {
                    grid[i][j]--;
                    if (j == W - 1) {
                        grid[i + 1][j]++;
                        com.i = i + 1, com.j = j + 1, com.k = i + 2, com.l = j + 1;
                        v.push_back(com);
                    }
                    else {
                        grid[i][j + 1]++;
                        com.i = i + 1, com.j = j + 1, com.k = i + 1, com.l = j + 2;
                        v.push_back(com);
                    }
                }
            }
        }
        else {
            for (int j = W - 1; j >= 0; j--) {
                C com;
                count++;
                if (count == H * W) continue;
                if (grid[i][j] % 2 == 1) {
                    grid[i][j]--;
                    if (j == 0) {
                        grid[i + 1][j]++;
                        com.i = i + 1, com.j = j + 1, com.k = i + 2, com.l = j + 1;
                        v.push_back(com);
                    }
                    else {
                        grid[i][j - 1]++;
                        com.i = i + 1, com.j = j + 1, com.k = i + 1, com.l = j + 2;
                        v.push_back(com);
                    }
                }
            }
        }
        left2right ^= 0;
    }
    cout << v.size() << endl;
    for (int i = 0; i < v.size(); i++) {
        cout << v[i].i << " " << v[i].j << " " << v[i].k << " " << v[i].l << endl;
    }
    /*
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cout << grid[i][j] << " ";
        }
        cout << endl;
    }
    */
    return 0;
}

Measured memory_bytes: 5232
using System;
    class Program
    {
        static void Main(string[] args)
        {
	       var line = System.Console.ReadLine();
            var nums = line.Split(new char[] { ' ' });
            int N = Convert.ToInt32(nums[0]);
            int Sum = Convert.ToInt32(nums[1]);
            int a = 0;
            int b = 0;
            int c = 0;
            bool ok = false;
            for (int i = 0; i <= N; i++)
            {
                for (int j = 0; j <= N - i; j++)
                {
                    a = i;
                    b = j;
                    c = N - a - b;
                    int sum = 10000 * a + 5000 * b + 1000 * c;
                    if (sum == Sum)
                    {
                        ok = true;
                    }
                    if (ok) { break; }
                }
                if (ok) { break; }
            }
            if (!ok) { a = -1;b = -1;c = -1; }
            Console.WriteLine("{0} {1} {2}",a,b,c);
        } 
    }

Measured memory_bytes: 13268
H, W, K = map(int, input().split())
S = [input() for _ in range(H)]

C = [0] * W
for i in range(H):
  for j in range(W):
    if S[i][j] == "#":
      C[j] = 1
#print("C:", C)

U = [[0 for _ in range(W)] for _ in range(H)]
T = []

color = 1
for i in range(W):
  if C[i] == 1:
    T.append(i)
#print("T:", T)

for t in range(len(T)):
  if t == len(T) - 1:
    if t == 0:
      l = 0
    else:
      l = T[t]
    r = W
  else:
    if t == 0:
      l = 0
    else:
      l = T[t]
    r = T[t + 1]
  #print("l, r:", l, r)
  
  flag = 0
  for h in range(H):
    for w in range(l, r):
      if S[h][w] == "#":
        if flag == 0:
          flag = 1
        else:
          color += 1
    for w in range(l, r):
      U[h][w] = color
  color += 1

for h in range(H):
  print(*U[h])

Measured memory_bytes: 47708
#include<bits/stdc++.h>
typedef  long long ll;
using namespace std;
const int maxn = 1e6+5;

int main()
{
    ios_base::sync_with_stdio(false);
    int n, m;
    int a, sum1 = 0, sum = 0;
    string b;
    map<int, int> mp, mp1;
    cin >> n >> m;
    for(int i = 1; i <= m; i++) {
        cin >> a >> b;
        if(b == "WA") mp[a]++;
        else {
            if(!mp1[a]) {
                sum1 += mp[a];
                sum++;
                mp1[a] = 1;
            }
        }
    }
    cout << sum << " " << sum1 << endl;
}


Measured memory_bytes: 9600
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map.Entry;

public class Main {
    public static void main(String[] args) {
        try {
            // 標準入力
            InputStreamReader isr = new InputStreamReader(System.in);
            BufferedReader br = new BufferedReader(isr);
            String w = br.readLine();
            HashMap<String, Integer> map = new HashMap<String, Integer>();
            for (int i = 0; i < w.length(); i++) {
                String tmp = w.substring(i, i + 1);
                if (map.containsKey(tmp)) {
                    int val = map.get(tmp);
                    map.put(tmp, val + 1);
                } else {
                    map.put(tmp, 1);
                }
            }
            boolean flag = true;
            for (Entry<String, Integer> ent : map.entrySet()) {
                int val = ent.getValue();
                if (val % 2 != 0) {
                    flag = false;
                    break;
                }
            }
            if (flag) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
        } catch (IOException e) {
            e.printStackTrace();
           }
    }
}


Measured memory_bytes: 22868
using Yorukatsu026.Questions;
using Yorukatsu026.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace Yorukatsu026.Questions
{
    /// <summary>
    /// ABC121 D復習
    /// </summary>
    public class QuestionD_Review : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var ab = inputStream.ReadLongArray();
            long a = ab[0];
            long b = ab[1];

            var minEven = ((a + 1) / 2) * 2;
            var maxOdd = ((b + 1) / 2) * 2 - 1;

            var evenOddCount = (maxOdd + 1 - minEven) / 2;
            long bit = evenOddCount % 2 == 0 ? 0 : 1;

            if (a != minEven)
            {
                bit ^= a;
            }
            if (b != maxOdd)
            {
                bit ^= b;
            }
            yield return bit;
        }
    }
}


namespace Yorukatsu026
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionD_Review();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace Yorukatsu026.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace Yorukatsu026.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion


Measured memory_bytes: 13396
#include<iostream>
#include<cstring>
#include<cmath>

using namespace std;

int main(){

int n;
  
  cin >> n;
  
  int w[n];
  
  
  for(int i=0;i<n;i++){
   cin >> w[i];
   
  }
  
  int sum[n];
   sum[0]=w[0];
  
  for(int i=1; i<n;i++){
   sum[i]=sum[i-1]+w[i];
  
  }
  
  int res=100000;
  for(int i=0;i<n-1;i++){     
   res=min(res,abs(sum[i]-(sum[n-1]-sum[i])));  
  }
    
  
  cout << res << endl;


}

Measured memory_bytes: 256