akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<ctype.h>
int main()
{
    char a;
    while(a != '\n'){
        scanf("%c", &a);
        if(islower(a)){
            a =toupper(a);
            printf("%c", a);
        }
        else if(isupper(a)){
            a = tolower(a);
            printf("%c", a);
        }
        else {
            printf("%c", a);
        }
    }
    return 0;
}

Measured memory_bytes: 524
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define SIZE 100005

int N,M,K;
int boss[SIZE],height[SIZE],member[SIZE];
int MINUS[SIZE];

int get_boss(int id){
	if(boss[id] == id)return id;
	else{
		return boss[id] = get_boss(boss[id]);
	}
}

int isSame(int x,int y){
	return get_boss(x) == get_boss(y);
}

void unite(int x,int y){
	int boss_x = get_boss(x);
	int boss_y = get_boss(y);

	if(boss_x == boss_y)return;

	if(height[boss_x] > height[boss_y]){

		member[boss_x] += member[boss_y];
		boss[boss_y] = boss_x;


	}else if(height[boss_x] < height[boss_y]){

		member[boss_y] += member[boss_x];
		boss[boss_x] = boss_y;

	}else{ //height[boss_x] == height[boss_y]

		member[boss_x] += member[boss_y];
		boss[boss_y] = boss_x;
		height[x]++;
	}
}

int main(){

	scanf("%d %d %d",&N,&M,&K);

	for(int i = 0; i < N; i++){

		boss[i] = i;
		height[i] = 0;
		member[i] = 1;
		MINUS[i] = 1;
	}

	int A,B;

	for(int i = 0; i < M; i++){

		scanf("%d %d",&A,&B);
		A--;
		B--;

		MINUS[A]++;
		MINUS[B]++;

		unite(A,B);
	}

	for(int i = 0; i < K; i++){

		scanf("%d %d",&A,&B);
		A--;
		B--;

		if(isSame(A,B)){

			MINUS[A]++;
			MINUS[B]++;
		}
	}

	printf("%d",member[get_boss(0)]-MINUS[0]);

	for(int i = 1; i < N; i++){

		printf(" %d",member[get_boss(i)]-MINUS[i]);
	}
	printf("\n");

	return 0;
}


Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
vector<int> lcs(const vector<int>& a, const vector<int>& b) {
  const int n = a.size(), m = b.size();
  vector< vector<int> > X(n+1, vector<int>(m+1));
  vector< vector<int> > Y(n+1, vector<int>(m+1));
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      if (a[i] == b[j]) {
        X[i+1][j+1] = X[i][j] + 1;
        Y[i+1][j+1] = 0;
      } else if (X[i+1][j] < X[i][j+1]) {
        X[i+1][j+1] = X[i][j+1];
        Y[i+1][j+1] = +1;
      } else {
        X[i+1][j+1] = X[i+1][j];
        Y[i+1][j+1] = -1;
      }
    }
  }
  vector<int> c;
  for (int i = n, j = m; i > 0 && j > 0; ) {
    if      (Y[i][j] > 0) --i;
    else if (Y[i][j] < 0) --j;
    else { c.push_back(a[i-1]); --i; --j; }
  }
  reverse(c.begin(), c.end());
  return c;
}
int main(void){
    string S;
    string T;
    cin >> S >> T;
    vector<int> A;
    vector<int> B;
    for (int i=0;i<S.length();i++){
        A.push_back(int(S[i]));
    }
    for (int j=0;j<T.length();j++){
        B.push_back(int(T[j]));
    }
    vector<int> C=lcs(A,B);
    //string ans="";
    for (int k=0;k<C.size();k++){
        cout << char(C[k]);
    }
    cout << endl;
    
}


Measured memory_bytes: 70912
#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>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
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 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 complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
 
void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

int main(){
  string S; cin>>S;
  string T; cin>>T;
  ll count=0;
  rep(i,3){
    if(S[i]==T[i]) count++;
    else continue;
  }
  cout<<count<<endl;
}
  

Measured memory_bytes: 256
# 奇数の時
# a，b，cはkの倍数
# kが偶数
# a, b, cがkの倍数
#　もしくは，全てk/2の倍数

N, K = map(int, input().split())

if K % 2 != 0:
    n = N // K 
    print(n ** 3)

else:
    n = N // K
    half_n = N // (K//2)
    print(n ** 3 + (half_n - n)** 3)

Measured memory_bytes: 2940
use std::io::*;
use std::str::FromStr;
use std::cmp::max;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("faild to read char") as char)
        .take_while(|c| !c.is_whitespace())
        .collect();
    token
        .parse()
        .ok()
        .expect("faild to parse token")
}

fn main(){
    let a: i64 = read();
    let b: i64 = read();
    let c: i64 = read();
    let d: i64 = read();

    println!("{}", max(a * c, max(a * d, max(b * c, b * d))));
}


Measured memory_bytes: 2120
#include<bits/stdc++.h>
using namespace std;
int main(){
int i,j,k,x,n,count = 0;
while(1){
  cin >> n >> x;
  if(n==0&&x==0) break;
  for(i=1;i<=n;i++){
    for(j=i+1;j<=n;j++){
      for(k=j+1;k<=n;k++){
        if(i!=j&&j!=k&&i!=k){
          if(i+j+k==x){
            count++;
          }
        }
      }
    }
  }
  cout << count << endl;
  count = 0;
}
return 0;
}



Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
#define REP(asd, fgh) for(int asd = 0; asd < fgh; asd++)

int n;

class Node{
  public:
  int p;
  int depth;
  int height;
  int sibling;
  int degree;
  string type;
};

vector<Node> ans;
vector< vector<int> > t;

void dfs(int ind, int prev, int depth, int order){
  if(t[ind].size() == 0 && ans[ind].type != "root"){
    cout << " " << ind;
    return;
  }

  if(order == 0){
    cout << " " << ind;
  }
  if(t[ind][0] != -1)
    dfs(t[ind][0], ind, depth+1, order);
  if(order == 1){
    cout << " " << ind;
  }
  if(t[ind][1] != -1)
    dfs(t[ind][1], ind, depth+1, order);
  if(order == 2){
    cout << " " << ind;
  }

  /*
  for(int i = 0; i < t[ind].size(); i++){
    dfs(t[ind][i], ind, depth+1, order);
  }
  */
  return;
}

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

  cin >> n;
  ans = vector<Node>(n);
  t = vector< vector<int> >(n, vector<int>(0));
  int root;
  REP(i, n){
    int id; cin >> id;
    ans[id].type = "internal node";
    REP(j, 2){
      int c; cin >> c;
      t[id].push_back(c);
    }
  }
  //ans[0].p = -1;
  //ans[0].depth = 0;
  vector<bool> used(n, false);
  for(int i = 0; i < n; i++){
    for(int j = 0; j < t[i].size(); j++){
      if(t[i][j] == -1) continue;
      used[ t[i][j] ] = true;
    }
  }
  for(int i = 0; i < n; i++){
    if(used[i] == false){
      root = i;
      break;
    }
  }

  cout << "Preorder" << endl;
  dfs(root, -1, 0, 0);
  cout << endl;
  cout << "Inorder" << endl;
  dfs(root, -1, 0, 1);
  cout << endl;
  cout << "Postorder" << endl;
  dfs(root, -1, 0, 2);
  cout << endl;

  return 0;
}

Measured memory_bytes: 1240
#include <stdio.h>

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

	char A[100 + 1] = "";
	char B[100 + 1] = "";
	int scoreA = 0;
	int scoreB = 0;
	for (int i = 0;  i < n; i++) {
		scanf("%s %s", A, B);
		if (strcmp(A, B) == 0) {
			scoreA++;
			scoreB++;
		}
		else if (strcmp(A, B) < 0) {
			scoreB += 3;
		}
		else {
			scoreA += 3;
		}
	}

	printf("%d %d\n", scoreA, scoreB);

	return 0;
}

Measured memory_bytes: 1764
/*
Cerberus97
Hanit Banga
*/

#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int N = 2e5 + 10;

int a[N], p[N], mx[N];

int solve(int n);

int main() {
	fast_cin();
	int n; cin >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
		p[a[i]] = i;
	}
	int ans = 0;
	for (int i = n; i >= 1; --i) {
		mx[i] = 1;
		if (p[i + 1] > p[i]) {
			mx[i] += mx[i + 1];
		}
		ans = max(ans, mx[i]);
	}
	cout << n - ans << endl;
}

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

using namespace std;

typedef unsigned int UI;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef istringstream ISS;
typedef ostringstream OSS;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )
#define EACH( v, c ) for ( auto &v : c )

#define ITER( c ) __typeof( (c).begin() )
#define IREP( c, it ) for ( ITER(c) it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

class UnionFind
{
private:
	vector<int> ary;
	vector<int> rank;

public:
	UnionFind( int n ) : ary( n ), rank( n, 0 )
	{
		REP( i, 0, n )
		{
			ary[i] = i;
		}

		return;
	}

	int find( int x )
	{
		if ( ary[x] == x )
		{
			return x;
		}
		else
		{
			return ary[x] = find( ary[x] );
		}
	}

	bool same( int x, int y )
	{
		return find( x ) == find( y );
	}

	void unite( int x, int y )
	{
		x = find( x );
		y = find( y );

		if ( x == y )
		{
			return;
		}

		if ( rank[x] < rank[y] )
		{
			ary[x] = y;
		}
		else
		{
			ary[y] = x;

			if ( rank[x] == rank[y] )
			{
				rank[x]++;
			}
		}

		return;
	}
};

struct Edge
{
	int cost, from, to;

	Edge( int c, int f, int t ) : cost( c ), from( f ), to( t )
	{
		return;
	}

	bool operator < ( const Edge &a ) const
	{
		return cost < a.cost;
	}
};

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

	while ( true )
	{
		int n;
		cin >> n;

		if ( !n )
		{
			break;
		}

		int m;
		cin >> m;

		vector< Edge > E;

		for ( int i = 0; i < m; i++ )
		{
			int cost, from, to;
			char dummy;

			cin >> from >> dummy >> to >> dummy >> cost;

			cost = cost / 100 - 1;

			E.PB( Edge( cost, from, to ) );
			E.PB( Edge( cost, to, from ) );
		}

		sort( ALL( E ) );

		int res = 0;
		UnionFind uf( n );

		for ( int i = 0; i < E.size(); i++ )
		{
			if ( uf.same( E[i].from, E[i].to ) )
			{
				continue;
			}

			uf.unite( E[i].from, E[i].to );
			res += E[i].cost;
		}

		cout << res << endl;
	}		

	return 0;
}

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

#define all(v) v.begin(),v.end()

int main(){
  int64_t N;
  cin>>N;
  vector<int64_t> A(N),B(N),C(N);
  for(int64_t &i:A)
    cin>>i;
  for(int64_t &i:B)
    cin>>i;
  for(int64_t &i:C)
    cin>>i;
  sort(all(A));
  sort(all(B));
  sort(all(C));
  int64_t o=0;
  for(int64_t &i:B){
    int64_t l=0,r=N,p;
    while(r-l!=1){
      int64_t j=(l+r)/2;
      if(A.at(j)<i)
        l=j;
      else
        r=j;
    }
    if(A.at(0)>=i)
      r=0;
    if(A.at(N-1)<i)
      r=N;
    p=r;
    l=0;
    r=N;
    while(r-l!=1){
      int64_t j=(l+r)/2;
      if(C.at(j)<=i)
        l=j;
      else
        r=j;
    }
    if(C.at(0)>i)
      r=0;
    if(C.at(N-1)<=i)
      r=N;
    o+=p*(N-r);
  }
  cout<<o<<endl;
}

Measured memory_bytes: 2560
#include <iostream>
#include <queue>

using namespace std;

void solve()
{
	int n;
	while(cin >> n)
	{
		int r;
		cin >> r;
		queue<int> deckA, deckB, deckC;
		for(int i = 0; i < n; ++i)
		{
			deckC.push(i);
		}
		while(r--)
		{
			int c;
			cin >> c;
			if(n % 2)
			{
				for(int i = 0; i < n / 2; ++i)
				{
					deckB.push(deckC.front());
					deckC.pop();
				}
				for(int i = 0; i < n / 2 + 1; ++i)
				{
					deckA.push(deckC.front());
					deckC.pop();
				}
			}
			else
			{
				for(int i = 0; i < n / 2; ++i)
				{
					deckB.push(deckC.front());
					deckC.pop();
				}
				for(int i = 0; i < n / 2; ++i)
				{
					deckA.push(deckC.front());
					deckC.pop();
				}
			}
			while(!deckA.empty())
			{
				for(int i = 0; i < c; ++i)
				{
					if(deckA.empty())
					{
						break;
					}
					deckC.push(deckA.front());
					deckA.pop();
				}
				for(int i = 0; i < c; ++i)
				{
					if(deckB.empty())
					{
						break;
					}
					deckC.push(deckB.front());
					deckB.pop();
				}
			}
		}
		cout << deckC.back() << endl;
	}
}

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

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

int main(){
  int k;
  cin>>k;
  cout << 360/gcd(k,360);
  
  return 0;
}

Measured memory_bytes: 3616
#include <queue>
#include <cstdio>
#include <cstring>

inline int Abs(const int x){return x>=0?x:-x;}

int n,k,c[100005];
int Head[100005],Next[200005],To[200005],En;
struct Rec
{
    int x,v;
    inline bool operator<(const Rec &o)const{return v>o.v;}
};
std::priority_queue<Rec> q;

inline void Add(const int x,const int y){Next[++En]=Head[x],To[Head[x]=En]=y;}

int main()
{
    scanf("%d",&n);
    for(int i=2,x,y;i<=n;++i)scanf("%d%d",&x,&y),Add(x,y),Add(y,x);
    scanf("%d",&k);
    memset(c,-1,sizeof c);
    for(int i=1,x,v;i<=k;++i)scanf("%d%d",&x,&v),c[x]=v,q.push((Rec){x,v});
    while(!q.empty())
    {
        int x=q.top().x,v=q.top().v;
        q.pop();
        for(int i=Head[x],y;i;i=Next[i])
            if(c[y=To[i]]==-1)
            {
                c[y]=v+1,q.push((Rec){y,v+1});
            }
            else if(Abs(c[y]-c[x])!=1)return puts("No"),0;
    }
    puts("Yes");
    for(int i=1;i<=n;++i)printf("%d\n",c[i]);
    return 0;
}

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

const ll INF = 1e18;
const int MX = 2005;

int main() {
  ll x;
  cin >> x;
  ll sum = 100;
  ll ans = 0;
  while(true){
    if(sum >= x) break;
    ans ++;
    sum += sum / 100;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3624
#include<stdio.h>
int main()
{
    int d = 0;
    int s = 0;
    int h = 0,m = 0;
    scanf("%d",&d);
    h = d / 3600;
    m = d % 3600 / 60;
    s = d % 60;
    printf("%d:%d:%d\n",h,m,s);
}



Measured memory_bytes: 2148
#include <bits/stdc++.h>
using namespace std;
vector <int> l;
int N,K,len;

int main(){
    cin>>N>>K;
    for(int i=0;i<N;i++){
        
        cin>>len;
        l.push_back(len);
    }

    sort(l.begin(),l.end(),greater<int>());

    
    int ans=0;
    for(int i=0;i<K;i++)
        ans+=l[i];
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;

int N,K;

int main()
{
  cin >> N >> K;
  string ans = (N >= 2 * K - 1) ? "YES" : "NO";
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
// ABC.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <bitset>
#include <stdlib.h>
using namespace std;
#define rep(i,n) for(int i = 0;i < n;i++)


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

    for (int i = 0;;i++ ) {
        if (i*1000 >= N) {
            cout << i * 1000 - N << endl;
            break;
        }
    }
}

Measured memory_bytes: 3520
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int[] X = new int[N];
		for (int i = 0; i < N; i++) {
			X[i] = sc.nextInt();
		}

		int Xsum = Arrays.stream(X).sum();
		int average = Xsum / X.length;
		if((double)Xsum % X.length != 0.0) {

			int[] sums = new int[2];

			for (int i = 0; i < X.length; i++) {
				sums[0] += (X[i]-average) * (X[i]-average);
			}

			int averagePlusOne = average + 1;
			for (int i = 0; i < X.length; i++) {
				sums[1] += (X[i]-averagePlusOne) * (X[i]-averagePlusOne);
			}

			System.out.println(Arrays.stream(sums).min().getAsInt());

		} else {

			int sum = 0;
			for (int i = 0; i < X.length; i++) {
				sum += (X[i]-average) * (X[i]-average);
			}
			System.out.println(sum);
		}
	}
}

Measured memory_bytes: 26964
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
const int    INF = 100000000;
const double EPS = 1e-10;
const int    MOD = 1000000007;
using namespace std;
typedef pair<int,int> P;

int n;
int a[100000], b[100000];
int x[200000];

int main(){
	cin >> n;
	rep(i,n){
		cin >> a[i] >> b[i];
		a[i]--; b[i]--;
		x[a[i]]++;
		x[b[i]+1]--;
	}
	for(int i = 1; i < n+100; i++) x[i] += x[i-1];
	int ans = 0;
	for(int i = 1; i < n+1; i++){
		if(x[i] >= i) ans = i;
	}
	cout << ans << endl;
}

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

int main(){
  int n;
  double xa,ya,ra,xb,yb,rb,d;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>xa>>ya>>ra>>xb>>yb>>rb;
    d=sqrt( (xb-xa)*(xb-xa)+(yb-ya)*(yb-ya) );
    if(ra-rb>d) cout<<2<<endl;
    else if(rb-ra>d) cout<<-2<<endl;
    else if( ra-rb<=d && ra+rb>=d ) cout<<1<<endl;
    else cout<<0<<endl;
  }
  return 0;
}

Measured memory_bytes: 1232
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
int memo[100100],len[100100],L,n;
int dfs(int x)
{
	if(memo[x]>=0)return memo[x];
	int res=0;
	if(len[x]<len[x-1])res=max(res,dfs(x-1));
	if(len[x]<len[x+1])res=max(res,dfs(x+1));
	res+=L-len[x];
	return memo[x]=res;
}
int main()
{
	memset(memo,-1,sizeof(memo));
	cin >> n >> L;
	for(int i=1;i<=n;i++)
	{
		cin >> len[i];
	}
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		ans=max(ans,dfs(i));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3316
import java.util.Scanner;
public class Main{
    
    public void solve(){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		if(a>=0 && a<86400){
			int h = a / 3600;
			int m = a % 3600 / 60;
			int s = a % 60;
			System.out.println(h+":"+m+":"+s);
		}
    }
    
    public static void main(String[] args){
        Main obj = new Main();
        obj.solve();
    }
}

Measured memory_bytes: 17312
import sys


def input():
    return sys.stdin.readline()[:-1]


N, M = map(int, input().split())

red = [0]*N
red[0] = 1
box = [1]*N
for _ in range(M):
    x, y = map(int, input().split())
    x -= 1
    y -= 1

    if red[x] == 0:
        # 箱Xには赤玉がない場合
        box[x] -= 1
        box[y] += 1
    elif red[x] == 1 and box[x] == 1:
        # 箱Xには赤玉がある可能性があって、全ボール数が1個のみがある場合
        box[x] -= 1
        box[y] += 1
        red[x] -= 1
        red[y] = 1
    elif red[x] == 1 and box[x] >= 2:
        # 箱Xには赤玉がある可能性があって、全ボール数が2個以上ある場合
        box[x] -= 1
        box[y] += 1
        red[y] = 1

print(red.count(1))


Measured memory_bytes: 4596
#include <bits/stdc++.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdlib>
#include <cmath> 
#include <vector> 
#include <queue>
using ll = long long;
using namespace std;
int main() {

    string s;cin>>s;
    bool easy;easy=true;

    for(int i=0;i<3;i++){
        if(s[i]==s[i+1]){
            easy=false;
            break;
        }
    }
    if(easy){
        cout<<"Good"<<endl;
    }else{
        cout<<"Bad"<<endl;
    }
        
  return 0;
}

Measured memory_bytes: 256
#include<iostream>

int main(){
  long int n,M;

  M = 100000;

  std::cin >> n;

  for(int i=0;i<n;i++){
    M = M * 1.05;
    if(M%1000!=0){
      M = M - (M%1000) + 1000;
    }
  }
  std::cout << M << std::endl;
}

Measured memory_bytes: 3060
n, m = map(int, input().split())
a = [[0 for i in range(m)]for j in range(n)]
b = [0 for i in range(m)]

for i in range(n):
    a[i] = list(map(int, input().split()))

for i in range(m):
    b[i] = int(input())

for i in range(n):
    ans = 0
    for j in range(m):
        ans += a[i][j] * b[j]
    print(ans)



Measured memory_bytes: 6020
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scanf("%d", &n)

	res, cnt := 1, 0
	for i := 1; i <= n; i++ {
		t, c := i, 0
		for t % 2 == 0 {
			t /= 2
			c += 1
		}
		if cnt < c {
			res = i
			cnt = c
		}
	}

	fmt.Println(res)
}


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

int main() {
  int N;
  cin >> N;
  
  vector<int> data(N);
  for(int i=0; i<N; i++) cin >> data.at(i);
  
  int count=1;
  for(int i=1; i<N; i++) {
    for(int j=0; j<i; j++) {
      if(data.at(j) > data.at(i)) break;
      else if (j==i-1) ++count;
    }
  }
  cout << count << endl;
}

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

const int maxn = 5e5 + 5;
char str[maxn];
int cnt[maxn][26];
int rt[maxn], lc[maxn << 1], rc[maxn << 1], val[maxn << 1], tot = 0;
int n, q;
inline int newnode(){
	val[++tot] = 0;
	lc[tot] = rc[tot] = 0;
	return tot;
}
inline void pushup(int p){
	val[p] = val[lc[p]] + val[rc[p]];
}
void change(int p, int l, int r, int pos, int v){
	if(l == r){
		val[p] += v;
	}
	else{
		int mid = (l + r) >> 1;
		if(pos <= mid){
			if(!lc[p]) lc[p] = newnode();
			change(lc[p], l, mid, pos, v);
		}
		else{
			if(!rc[p]) rc[p] = newnode();
			change(rc[p], mid+1, r, pos, v);
		}
		pushup(p);
	}
}
int query(int p, int l, int r, int l0, int r0){
	if(!p) return 0;
	if(l > r0 || r < l0) return 0;
	if(l >= l0 && r <= r0) return val[p];
	int mid = (l + r) >> 1;
	return query(lc[p], l, mid, l0, r0) + query(rc[p], mid+1, r, l0, r0);
}
int main(){
	scanf("%d",&n);
	scanf("%s", str+1);
	for(int i=1;i<=n;i++){
		for(int j=0;j<26;j++) cnt[i][j] = cnt[i-1][j];
		cnt[i][str[i] - 'a'] ++;
	}
	scanf("%d",&q);
	for(int i=0;i<26;i++) rt[i] = newnode();
	for(int i=1;i<=q;i++){
		int op, x;
		scanf("%d%d",&op,&x);
		if(op == 1){
			char y;
			y = getchar();
			while(y < 'a' || y > 'z') y = getchar();
			change(rt[str[x] - 'a'], 1, n, x, -1);
			change(rt[y - 'a'], 1, n, x, 1);
			str[x] = y;
		}
		else{
			int y;
			scanf("%d",&y);
			int ret = 0;
			for(int j=0;j<26;j++){
				int tmp = query(rt[j], 1, n, x, y) + cnt[y][j] - cnt[x-1][j];
				if(tmp) ret++;
			}
			printf("%d\n", ret);
		}
	}
	return 0;
}


Measured memory_bytes: 64640
// https://atcoder.jp/contests/abc167/tasks/abc167_c
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, M, X;
    cin >> N >> M >> X;
    vector<int> C(N);
    vector<vector<int>> A(N, vector<int>(M));
    REP(i, N) {
        cin >> C[i];
        REP(j, M) { cin >> A[i][j]; }
    }
    int ans = 1e9;
    REP(i, (1L << N)) {
        vector<int> sum(M);
        int cost = 0;
        REP(j, N) {
            if ((i >> j) & 1) {
                REP(k, M) { sum[k] += A[j][k]; }
                cost += C[j];
            }
        }
        bool flag = true;
        for (auto &x : sum) {
            if (x < X) {
                flag = false;
                break;
            }
        }
        if (flag) {
            ans = min(ans, cost);
        }
    }
    cout << (ans == 1e9 ? -1 : ans) << endl;

    return 0;
}


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

int main(){
    ll N; cin >> N;
    ll atmp;
    vector<ll> a(N);
    rep(i,N){
        cin >> atmp;
        a[i] = atmp - i - 1;
    }
    sort(a.begin(),a.end());
    ll ans = 0;
    rep(i,N) ans += abs(a[i] - a[N/2]);
    cout << ans << endl;
}

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

int main(){
  int n;
  char s;
  cin >> s;
  if (s=='a' || s=='i'|| s=='e'|| s=='o'|| s=='u') cout << "vowel" << endl;
  else cout << "consonant" << endl;
  return 0; 
}


Measured memory_bytes: 256
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
import math
import collections

N, = list(map(int, sys.stdin.readline().rstrip().split()))
As = list(map(int, sys.stdin.readline().rstrip().split()))

Amin = min(As)
Amax = max(As)

if abs(Amax) >= abs(Amin):
    index = [i for i, item in enumerate(As) if item == Amax][0]
    print(2 * N - 1)
    for i in range(len(As)):
        print(index + 1, i + 1)
        As[i] += Amax
    for i in range(1, len(As), 1):
        print(i, i + 1)
        As[i] += As[i - 1]
else:
    index = [i for i, item in enumerate(As) if item == Amin][0]
    print(2 * N - 1)
    for i in range(len(As)):
        print(index + 1, i + 1)
        As[i] += Amin
    for i in range(len(As) - 2, -1, -1):
        print(i + 2, i + 1)
        As[i] += As[i + 1]
# print(As)
exit(0)


Measured memory_bytes: 3444
N, K = map(int, input().split())
a = 0
b = 0
for i in range(1, N+1):
    if i % K == 0:
        a += 1
    elif i % K == K/2:
        b += 1
ans = a * a * a
if K % 2 == 0:
    ans += b * b * b
print(ans)

Measured memory_bytes: 3060
#pragma GCC optimize("Ofast","inline","-ffast-math")
#pragma GCC target("avx,sse2,sse3,sse4,mmx")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/hash_policy.hpp>
#define int long long
using namespace __gnu_pbds;
using namespace std;

int n,m,q,p[100010];
pair<int,pair<int,int> > a[100010];
vector<int> v[100010];

inline int find_set(int x)
{
	return p[x]==x?x:p[x]=find_set(p[x]); 
}

signed main()
{
	ios::sync_with_stdio(false);
	cin>>n>>m>>q;
	for(int i=1;i<=q;i++){
		int x,y,c;
		cin>>x>>y>>c;
		x++;y++;
		a[i]=make_pair(c,make_pair(x,y));
	}
	sort(a+1,a+q+1);
	for(int i=1;i<=n;i++) p[i]=i;
	int e=0;
	bool flag=false;
	for(int i=1;i<=q;i++){
		if(a[i].first==0){
			int rootx=find_set(a[i].second.first),rooty=find_set(a[i].second.second);
			if(rootx==rooty) continue;
			p[rooty]=rootx;
			e++;
		}
		else{
			int rootx=find_set(a[i].second.first),rooty=find_set(a[i].second.second);
			if(rootx==rooty){
				cout<<"No"<<endl;
				return 0;
			}
			flag=true;
		}
	}
	int cnt=0;
	for(int i=1;i<=n;i++) if(find_set(i)==i) cnt++;
	int mx=e+cnt*(cnt-1)/2;
	if(cnt<=2&&flag){
		cout<<"No"<<endl;
		return 0;
	}
	if(flag) e+=cnt;
	else e+=cnt-1;
	if(e>m) cout<<"No"<<endl;
	else if(mx<m) cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 9128
#include <cstdio>
#include <algorithm>

using namespace std;

#define MAX 300000

int w;

int cost(int w) {
	return 1150 + min(max(w - 10, 0), 10) * 125 + min(max(w - 20, 0), 10) * 140
			+ max(w - 30, 0) * 160;
}

int main() {
	while (1) {
		scanf("%d", &w);
		if (w < 0)
			return 0;

		printf("%d\n", 4280 - cost(w));
	}
}

Measured memory_bytes: 0
#pragma GCC optimize(3)
#include<bits/stdc++.h>
#define MOD 998244353
using namespace std;
const int maxn=1e7+5;
int n;
int f[maxn];
int invf[maxn];
int power[maxn];
inline int ksm(int x,int y){
	if(!y) return 1;
	if(y==1) return x;
	int tmp=ksm(x,y/2);
	tmp=(1ll*tmp*tmp)%MOD;
	if(y&1) return (1ll*tmp*x)%MOD;
	else return tmp;
}
inline int C(int x,int y){
	if(x<y) return 0;
	return 1ll*f[x]*invf[y]%MOD*invf[x-y]%MOD;
}
int main(){
	scanf("%d",&n);
	f[0]=invf[0]=1;
	for(int i=1;i<maxn;i++) f[i]=(1ll*f[i-1]*i)%MOD;
	invf[maxn-1]=ksm(f[maxn-1],MOD-2);
	for(int i=maxn-2;i>=1;i--) invf[i]=(1ll*invf[i+1]*(i+1))%MOD;
	power[0]=1;
	for(int i=1;i<maxn;i++) power[i]=(1ll*power[i-1]*2)%MOD;
	int ans=ksm(3,n);
	int res=0;
	for(int i=n/2+1;i<=n;i++) res=(res+2ll*power[n-i]%MOD*C(n,i))%MOD;
	ans=((ans-res)%MOD+MOD)%MOD;
	printf("%d\n",ans);
	return 0;
}

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

using namespace std;

int main(void){
  vector<int> v;
  int p, q, r;
  cin >> p >> q >> r;
  v.push_back(p), v.push_back(q), v.push_back(r);
  sort(v.begin(), v.end());
  cout << v[0] + v[1] << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
int main(){
  ll h,n;cin>> h>>n;
  ll a=0;
  for(int i=0;i<n;i++){
    ll b;cin>>b;
    a+=b;
  }
  if(a>=h){
    cout << "Yes"<<endl;
  }else{
    cout << "No"<<endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<queue>
#include<algorithm>
using namespace std;
int n;
vector<int> g[200005];
long long ans=0,sums=0;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<n;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		if(x>y) swap(x,y);
		g[y].push_back(x);
	}
	for(int i=1;i<=n;i++)
	{
		sums+=i;
		int sz=g[i].size();
		for(int j=0;j<sz;j++)
		{
			int x=g[i][j];
			sums-=x;
		}
		ans+=sums;
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 14764
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    String g[] = new String[4];
    int answer = 0;
    g[0] = s.substring(0,1);
    g[1] = s.substring(1,2);
    g[2] = s.substring(2,3);
    g[3] = s.substring(3,4);
    for(int i =0;i<4;i++){
      if(g[i].equals("+")){
        answer = answer +1;
      }else{
        answer = answer -1;
      }
    }
    System.out.println(answer);
  }
  

  
}

Measured memory_bytes: 22612
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int x = saori.saori_hayami();
		int y = saori.saori_hayami();
		int z = saori.saori_hayami();
		int num = x/(y+z);
		if(num*(y+z)+z <= x){
			System.out.println(num);
		} else {
			System.out.println(num-1);
		}

		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 22612
N, M = list(map(int, input().split()))
sides = []
for i in range(M):
    sides.append(list(map(int, input().split())))

costs = [-(10**20)]*N
costs[0] = 0

epoch = 0
update_number = 1
L = 0

while update_number > 0 and epoch < 2*(N-1):
    update_number = 0
    for side in sides:
        if costs[side[1]-1] < costs[side[0]-1]+side[2]:
            costs[side[1]-1] = costs[side[0]-1]+side[2]
            update_number += 1
    epoch += 1
    if epoch == N-1:
        L = costs[N-1]

if epoch == 2*(N-1) and L != costs[N-1]:
    print('inf')
else:
    print(costs[N-1])

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
#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 ll long long
#define pb(a) push_back(a)

int main(){
  int n;
  cin >> n;
  int ans = 0;
  REP(i, 25){
    REP(j, 15){
      if(4 * i + 7 * j == n) ans++;
    }
  }
  if(ans)cout << "Yes";
  else cout << "No";
}


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

int main(){
 string s;
  
  cin >> s;
  int add = 0;
  
  if(s[0] == 'o') add++;
  if(s[1] == 'o') add++;
  if(s[2] == 'o') add++;

  cout << 700+100*add << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp3
{
    class Program
    {

        public static int[] ReadIntArr()
        {
            return Array.ConvertAll<string, int>(Console.ReadLine().Split(' '), (x) => Convert.ToInt32(x));
        }

        static void Main(string[] args)
        {
            var arr = ReadIntArr();

            if (arr[0] + arr[1] >= arr[2])
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 11220
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
typedef long long ll;

int main(void){
  int i,j;
  //  dic_t dic[200000];
  //  int ii[9];
  //  int ij[9];
  char ans[3];

  //  int ilen[100];
  //  int ia,ib,ic;
  int len,keta;
  int si,ci;
  ans[0] = ' ';
  ans[1] = ' ';
  ans[2] = ' ';
  scanf("%d %d\n",&keta,&len);
  if(len == 0 &&keta ==1){
    printf("0\n");
    return 0;
  }
  for(i=0;i<len;i++){
    scanf("%d %d\n",&si,&ci);
    if(ans[si-1] == '0'+ci){
      ;
    }
    else if(ans[si-1] == ' '){
      ans[si-1]='0'+ci;
    }
    else{
      printf("-1\n");
      return 0;
    }
  }
  if(ans[0]== ' '){
      ans[0]='1';
  }
  for(j=0;j<3;j++){
    if(ans[j]== ' '){
      ans[j]='0';
    }
  }
  if(ans[0]== '0' && keta ==1){
    printf("0\n");
    return 0;
  }
  if(ans[0]== '0'){
    printf("-1\n");
    return 0;
  }
  for(j=0;j<keta;j++){
    printf("%c",ans[j]);
  }
  printf("\n");
  return 0;


}


Measured memory_bytes: 128
#include <bits/stdc++.h>
int sum(int a){
  return a/100000 + (a/10000)%10 + (a/1000)%10
    + (a/100)%10 + (a/10)%10 + a%10;
}
int main(void)
{
  int a, min;
  std::cin >> a;
  min = a;
  for(int i = 1; i <= a / 2; i++) min = std::min(sum(i) + sum(a - i), min);
  std::cout << min << std::endl;
  return 0;
}


Measured memory_bytes: 256
a, b, c = gets.split(" ").map(&:to_i)
k = gets.to_i

# c > b > a を作る
k.times do
  if a >= b
    b *= 2
  elsif b >= c
    c *= 2
  end
end

if c > b && b > a
  puts "Yes"
else
  puts "No"
end

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

int main() {
    string s;
    cin >> s;
    int l = s.size();
    rep(i,l) cout << "x";
    cout << endl;
}

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


int main(void) {
  int a, b, c;
  cin >> a >> b >> c;

  if (a <= c && c <= b) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3632
#include <algorithm>
#include <bitset>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

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

    vector<bool> done(n, false);
    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> q;
    q.push(make_pair(0, 0));
    int ans = 0;
    while (!q.empty()) {
        int d = q.top().first;
        int v = q.top().second;
        q.pop();
        if (done[v]) {
            continue;
        }
        done[v] = true;
        ans += d;
        for (int i = 0; i < n; i++) {
            if (edges[v][i] < 0) {
                continue;
            }
            q.push(make_pair(edges[v][i], i));
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1372
#include <iostream>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <list>
#include <math.h>
#include <map>
using namespace std;
#define REP(i, k, n) for(int i = k;i < n; i++)
#define rep(i, n) REP(i,0,n)
#define ll long long int
int dx[4] = {0,-1,1,0};
int dy[4] = {-1,0,0,1};
#define eps 10e-6
#define mod 1000000007
int cnt[51][26];

ll x[100001];
ll y[100001];
int main(void){
	int n, m;
	cin >> n >> m;
	ll xsum = 0;
	rep(i,n){
		cin >> x[i];
		xsum -= (x[i]*(n-i-1));
		xsum += (x[i]*(i));
	}
	xsum %= mod;
	ll ysum = 0;
	rep(i,m){
		cin >> y[i];
		ysum -= (y[i]*(m-i-1));
		ysum += (y[i]*(i));
	}
	ysum %= mod;
	cout << xsum * ysum %mod << endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

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

int main() {
  int n;
  string s;
  cin >> n;
  cin >> s;
  if (n % 2 != 0) {
    cout << "No" << endl;
    return 0;
  }
  int half = n / 2;
  rep(i, half) {
    if (s[i] != s[i + half]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

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

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout<<setprecision(10)<<fixed;
	char n,m;
	cin>>n>>m;
	int n1=n-'0';
	int m1=m-'0';
	int t1=min(n1,m1);
	int t2=max(n1,m1);
	if(t1!=n1)
		n=m;
	string s;
	for(int i=0;i<t2;i++)
		s+=n;
	cout<<s<<endl;
	return 0;
}



Measured memory_bytes: 256
package main

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

func main() {
	sc := NewScanner()
	N := sc.NextInt()
	A := sc.NextIntArray()
	count := 0
	for i := 0; i < N-1; i++ {
		if A[i] == A[i+1] {
			count += 1
			i++
		}
	}
	fmt.Println(count)

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
#include <iostream>
using namespace std;
long long n, i, j, k, ans;
int main() {
	cin>>n;
	for(i=1; i*i<=n; i++) {
		if(n%i==0) {
			for(j=n/i, k=0; j; j/=10, k++);
			ans = k;
		}
	}
	cout<<ans;
	return 0;
}

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

int main(){
    long long n,a,b;cin>>n>>a>>b;
    if ((b - a) % 2 == 0){
        cout << (b - a) / 2 << endl;
    } else {
        long long val_1;
        long long delta_a = a - 1 + 1;
        if (delta_a == b - 1){
            val_1 = delta_a;
        } else {
            val_1 = delta_a + ((b - a - 1) / 2);
        }
        long long val_2;
        long long delta_b = n - b + 1;
        if (delta_b == n - a){
            val_2 = delta_b;
        } else {
            val_2 = delta_b + ((b - a - 1) / 2);
        }

        cout << min(val_1, val_2) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

#define dump(x) cerr << #x << "=" << x << endl
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())

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

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

  cout << min(B / A, C) << endl;

  return 0;
}

Measured memory_bytes: 3636
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>
#include <atcoder/dsu>

using namespace std;
using namespace atcoder;

#define ll long long
#define ld long double

int main(void){
	int N, M; cin >> N >> M;
	dsu uf(N);
	while (M--){
		int a, b;
		cin >> a >> b;
		--a, --b;
		uf.merge(a, b); 
	}
	auto tmp = uf.groups();
	int ans = tmp.size() - 1;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 8856
n = int(input())
h = list(map(int, input().split()))

dp = [0] * len(h)
dp[0] = 0
dp[1] = abs(h[0]-h[1])

for i in range(2, len(dp)):
    dp[i] = min(abs(h[i]-h[i-1])+dp[i-1], abs(h[i]-h[i-2])+dp[i-2])
print(dp[-1])



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

int main_()
{
    int A, B;
    cin >> A >> B;
    int count = 0;
    for (int i = A; i <= B; ++i)
    {
        auto str = to_string(i);
        if (str[0] == str[4] && str[1] == str[3])
        {
            count++;
        }
    }
    cout << count << endl;
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import static java.lang.System.out;

public class Main{
    static MyReader in = new MyReader();

    public static void main(String[] args){
        char[] s = in.s().toCharArray();
        out.println(s[2] == s[3] && s[4] == s[5] ? "Yes" : "No");
    }

    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }

        String s(){
            try{return readLine();}catch(IOException e){return "";}
        }

        String[] ss(){
            return s().split(" ");
        }

        int i(){
            return Integer.parseInt(s());
        }

        int[] ii(){
            String[] ss = ss();
            int[] ii = new int[ss.length];
            for(int j = 0; j < ss.length; j++) ii[j] = Integer.parseInt(ss[j]);
            return ii;
        }

        ArrayList<Integer> li(){
            String[] ss = ss();
            ArrayList<Integer> li = new ArrayList<>();
            for(int j = 0; j < ss.length; j++) li.add(Integer.parseInt(ss[j]));
            return li;
        }

        long l(){
            return Long.parseLong(s());
        }

        long[] ll(){
            String[] ss = ss();
            long[] ll = new long[ss.length];
            for(int j = 0; j < ss.length; j++) ll[j] = Long.parseLong(ss[j]);
            return ll;
        }
    }
}


Measured memory_bytes: 22740
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
/* 大文字を小文字に変換 tolower*/
/* 小文字を大文字に変換 toupper*/
 
int main () {
	string s;
	cin >> s;
	rep(i,s.size()){
		if(s[i] == ',') s[i] = ' ';
		cout << s[i];
	}
cout << endl;
}


Measured memory_bytes: 256
//El Lool
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <fstream>
#include <cctype>
#include <string>
#include <string.h>
#include <vector>
#include <sstream>
#include <queue>
#include <map>
#include <set>
#include <stack>
using namespace std;
#define all(v) ((v).begin()),((v).end())
#define sz(v) ((int)((v).size()))
void fast()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
int main()
{
	fast();
	long long a, b, c, d, n,ans=0;
	cin >> a >> b >> c >> d >> n;
		if (d / 8.0 < double(a)&&d / 4.0 < b&&d / 2.0 < double(c)&&n >= 2)
		{
			if (n % 2 == 0)
			{
				
				ans += (d*(n / 2));
				n = 0;
			}
			else
			{
				ans += (d*((n - 1) / 2));
				n = 1;
			}
			
		}
		if (c / 2.0 < double(b)&&c / 4.0 < double(a)&&n>=1)
		{
			
			ans += (c*n);
			n = 0;
		}
		if (b / 2.0<a)
		{
			ans += ((2*n) * b);
			n = 0;
		}
		if (n)
		{
			ans += ((4 * n) * a);
		}
	
	cout << ans;
	return 0;

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)) {
			
			int x = sc.nextInt();
			int n = sc.nextInt();
			
			int[] pArray = new int[100+2];
			
			for(int i = 0 ; i <= 101 ; i++ ) {
				pArray[i] = (int)Math.abs(x - i);
			}
						
			for(int i = 0 ; i < n ; i++ ) {
				int index = sc.nextInt();
				pArray[index] = Integer.MAX_VALUE;
			}
			
			int ans = 0;
			int minDiff = pArray[0];
			
			for(int i = 1 ; i <= 101 ; i++ ) {
				if ( pArray[i] < minDiff) {
					ans = i;
					minDiff = pArray[i];
				}
			}
			
			System.out.println(ans);
				
		}
	}

}

Measured memory_bytes: 35740